summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-06-06 06:28:40 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-06-06 06:28:40 +0000
commitb8d98fcc1991a60ec1cde475b68fcda67153528b (patch)
treea9e33268e8b289983ee753961894d0608351dc5f /apps
parentb807cb0808b2c045e0fdcd332c711a713eb25032 (diff)
downloadrockbox-b8d98fcc1991a60ec1cde475b68fcda67153528b.tar.gz
rockbox-b8d98fcc1991a60ec1cde475b68fcda67153528b.tar.bz2
rockbox-b8d98fcc1991a60ec1cde475b68fcda67153528b.zip
Change cuesheet handling so the id3 info is not spoofed anymore. If something wants the subtracks info it is easy to get to. This makes next track display in the skins show the next subtrack if we are in a cuesheet
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26611 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/cuesheet.c51
-rw-r--r--apps/cuesheet.h6
-rw-r--r--apps/gui/skin_engine/skin_tokens.c7
-rw-r--r--apps/gui/wps.c1
-rw-r--r--apps/mpeg.c1
-rw-r--r--apps/playback.c2
6 files changed, 41 insertions, 27 deletions
diff --git a/apps/cuesheet.c b/apps/cuesheet.c
index c75ea65334..cadb2ab8f6 100644
--- a/apps/cuesheet.c
+++ b/apps/cuesheet.c
@@ -346,29 +346,39 @@ bool curr_cuesheet_skip(struct cuesheet *cue, int direction, unsigned long curr_
}
}
-
-void cue_spoof_id3(struct cuesheet *cue, struct mp3entry *id3)
+const char *get_cuesheetid3_token(struct wps_token *token, struct mp3entry *id3,
+ int offset_tracks, char *buf, int buf_size)
{
+ struct cuesheet *cue = id3?id3->cuesheet:NULL;
if (!cue || !cue->curr_track)
- return;
-
+ return NULL;
+
struct cue_track_info *track = cue->curr_track;
-
- id3->title = *track->title ? track->title : NULL;
- id3->artist = *track->performer ? track->performer : NULL;
- id3->composer = *track->songwriter ? track->songwriter : NULL;
- id3->album = *cue->title ? cue->title : NULL;
-
- /* if the album artist is the same as the track artist, we hide it. */
- if (strcmp(cue->performer, track->performer))
- id3->albumartist = *cue->performer ? cue->performer : NULL;
- else
- id3->albumartist = NULL;
-
- int i = cue->curr_track_idx;
- id3->tracknum = i+1;
- if (id3->track_string)
- snprintf(id3->track_string, 10, "%d/%d", i+1, cue->track_count);
+ if (offset_tracks)
+ {
+ if (cue->curr_track_idx+offset_tracks < cue->track_count)
+ track+=offset_tracks;
+ else
+ return NULL;
+ }
+ switch (token->type)
+ {
+ case WPS_TOKEN_METADATA_ARTIST:
+ return *track->performer ? track->performer : NULL;
+ case WPS_TOKEN_METADATA_COMPOSER:
+ return *track->songwriter ? track->songwriter : NULL;
+ case WPS_TOKEN_METADATA_ALBUM:
+ return *cue->title ? cue->title : NULL;
+ case WPS_TOKEN_METADATA_ALBUM_ARTIST:
+ return *cue->performer ? cue->performer : NULL;
+ case WPS_TOKEN_METADATA_TRACK_TITLE:
+ return *track->title ? track->title : NULL;
+ case WPS_TOKEN_METADATA_TRACK_NUMBER:
+ snprintf(buf, buf_size, "%d/%d",
+ cue->curr_track_idx+offset_tracks+1, cue->track_count);
+ return buf;
+ }
+ return NULL;
}
#ifdef HAVE_LCD_BITMAP
@@ -402,7 +412,6 @@ bool cuesheet_subtrack_changed(struct mp3entry *id3)
&& id3->elapsed >= (cue->curr_track+1)->offset)))
{
cue_find_current_track(cue, id3->elapsed);
- cue_spoof_id3(cue, id3);
return true;
}
return false;
diff --git a/apps/cuesheet.h b/apps/cuesheet.h
index 8e9266416d..451fff5dbe 100644
--- a/apps/cuesheet.h
+++ b/apps/cuesheet.h
@@ -26,6 +26,7 @@
#include "screens.h"
#include "file.h"
#include "metadata.h"
+#include "skin_engine/skin_tokens.h"
#define MAX_NAME 80 /* Max length of information strings */
#define MAX_TRACKS 99 /* Max number of tracks in a cuesheet */
@@ -69,8 +70,9 @@ bool display_cuesheet_content(char* filename);
/* finds the index of the current track played within a cuesheet */
int cue_find_current_track(struct cuesheet *cue, unsigned long curpos);
-/* update the id3 info to that of the currently playing track in the cuesheet */
-void cue_spoof_id3(struct cuesheet *cue, struct mp3entry *id3);
+/* Get the id3 fields from the cuesheet */
+const char *get_cuesheetid3_token(struct wps_token *token, struct mp3entry *id3,
+ int offset_tracks, char *buf, int buf_size);
/* skip to next track in the cuesheet towards "direction" (which is 1 or -1) */
bool curr_cuesheet_skip(struct cuesheet *cue, int direction, unsigned long curr_pos);
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index 7997290119..39bf0d497e 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -34,6 +34,7 @@
#include "powermgmt.h"
#include "sound.h"
#include "debug.h"
+#include "cuesheet.h"
#ifdef HAVE_LCD_CHARCELLS
#include "hwcompat.h"
#endif
@@ -513,6 +514,12 @@ const char *get_token_value(struct gui_wps *gwps,
*intval = -1;
}
+ if (state->id3 && state->id3->cuesheet)
+ {
+ out_text = get_cuesheetid3_token(token, state->id3, token->next?1:0, buf, buf_size);
+ if (out_text)
+ return out_text;
+ }
out_text = get_id3_token(token, id3, buf, buf_size, limit, intval);
if (out_text)
return out_text;
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 090276d3fe..7b84782477 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -1230,7 +1230,6 @@ static void track_changed_callback(void *param)
if (wps_state.id3->cuesheet)
{
cue_find_current_track(wps_state.id3->cuesheet, wps_state.id3->elapsed);
- cue_spoof_id3(wps_state.id3->cuesheet, wps_state.id3);
}
wps_sync_data.do_full_update = true;
}
diff --git a/apps/mpeg.c b/apps/mpeg.c
index c6090f863b..1ba491ce89 100644
--- a/apps/mpeg.c
+++ b/apps/mpeg.c
@@ -2079,7 +2079,6 @@ struct mp3entry* audio_current_track(void)
parse_cuesheet(cuepath, curr_cuesheet))
{
id3->cuesheet = curr_cuesheet;
- cue_spoof_id3(curr_cuesheet, id3);
}
}
return id3;
diff --git a/apps/playback.c b/apps/playback.c
index 0be45b035a..6be869f83a 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -524,7 +524,6 @@ struct mp3entry* audio_current_track(void)
{
bufread(tracks[cur_idx].cuesheet_hid, sizeof(struct cuesheet), curr_cue);
thistrack_id3->cuesheet = curr_cue;
- cue_spoof_id3(thistrack_id3->cuesheet, thistrack_id3);
}
return thistrack_id3;
}
@@ -538,7 +537,6 @@ struct mp3entry* audio_current_track(void)
{
bufread(tracks[cur_idx].cuesheet_hid, sizeof(struct cuesheet), curr_cue);
othertrack_id3->cuesheet = curr_cue;
- cue_spoof_id3(othertrack_id3->cuesheet, othertrack_id3);
}
return othertrack_id3;
}