1
0
Fork 0
forked from len0rd/rockbox

more cuesheet cleanup. pass the cuesheet into cue functions so they dont have to call audio_current_track()

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22020 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2009-07-24 01:13:30 +00:00
parent bd9156a4ad
commit eb0061411d
4 changed files with 14 additions and 14 deletions

View file

@ -317,12 +317,11 @@ bool display_cuesheet_content(char* filename)
* it also returns false if we weren't in a cuesheet. * it also returns false if we weren't in a cuesheet.
* direction should be 1 or -1. * direction should be 1 or -1.
*/ */
bool curr_cuesheet_skip(int direction, unsigned long curr_pos) bool curr_cuesheet_skip(struct cuesheet *cue, int direction, unsigned long curr_pos)
{ {
struct cuesheet *curr_cue = audio_current_track()->cuesheet; int track = cue_find_current_track(cue, curr_pos);
int track = cue_find_current_track(curr_cue, curr_pos);
if (direction >= 0 && track == curr_cue->track_count - 1) if (direction >= 0 && track == cue->track_count - 1)
{ {
/* we want to get out of the cuesheet */ /* we want to get out of the cuesheet */
return false; return false;
@ -332,7 +331,7 @@ bool curr_cuesheet_skip(int direction, unsigned long curr_pos)
if (!(direction <= 0 && track == 0)) if (!(direction <= 0 && track == 0))
track += direction; track += direction;
seek(curr_cue->tracks[track].offset); seek(cue->tracks[track].offset);
return true; return true;
} }
@ -372,15 +371,15 @@ static inline void draw_veritcal_line_mark(struct screen * screen,
/* draw the cuesheet markers for a track of length "tracklen", /* draw the cuesheet markers for a track of length "tracklen",
between (x1,y) and (x2,y) */ between (x1,y) and (x2,y) */
void cue_draw_markers(struct screen *screen, unsigned long tracklen, void cue_draw_markers(struct screen *screen, struct cuesheet *cue,
unsigned long tracklen,
int x1, int x2, int y, int h) int x1, int x2, int y, int h)
{ {
struct cuesheet *curr_cue = audio_current_track()->cuesheet;
int i,xi; int i,xi;
int w = x2 - x1; int w = x2 - x1;
for (i=1; i < curr_cue->track_count; i++) for (i=1; i < cue->track_count; i++)
{ {
xi = x1 + (w * curr_cue->tracks[i].offset)/tracklen; xi = x1 + (w * cue->tracks[i].offset)/tracklen;
draw_veritcal_line_mark(screen, xi, y, h); draw_veritcal_line_mark(screen, xi, y, h);
} }
} }

View file

@ -73,11 +73,12 @@ int cue_find_current_track(struct cuesheet *cue, unsigned long curpos);
void cue_spoof_id3(struct cuesheet *cue, struct mp3entry *id3); void cue_spoof_id3(struct cuesheet *cue, struct mp3entry *id3);
/* skip to next track in the cuesheet towards "direction" (which is 1 or -1) */ /* skip to next track in the cuesheet towards "direction" (which is 1 or -1) */
bool curr_cuesheet_skip(int direction, unsigned long curr_pos); bool curr_cuesheet_skip(struct cuesheet *cue, int direction, unsigned long curr_pos);
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
/* draw track markers on the progressbar */ /* draw track markers on the progressbar */
void cue_draw_markers(struct screen *screen, unsigned long tracklen, void cue_draw_markers(struct screen *screen, struct cuesheet *cue,
unsigned long tracklen,
int x1, int x2, int y, int h); int x1, int x2, int y, int h);
#endif #endif

View file

@ -412,7 +412,7 @@ static void draw_progressbar(struct gui_wps *gwps,
#endif #endif
if (state->id3->cuesheet) if (state->id3->cuesheet)
cue_draw_markers(display, state->id3->length, cue_draw_markers(display, state->id3->cuesheet, state->id3->length,
pb->x, pb->x + pb->width, y+1, pb->height-2); pb->x, pb->x + pb->width, y+1, pb->height-2);
} }

View file

@ -151,7 +151,7 @@ static void prev_track(unsigned long skip_thresh)
{ {
if (wps_state.id3->cuesheet) if (wps_state.id3->cuesheet)
{ {
curr_cuesheet_skip(-1, wps_state.id3->elapsed); curr_cuesheet_skip(wps_state.id3->cuesheet, -1, wps_state.id3->elapsed);
return; return;
} }
@ -176,7 +176,7 @@ static void next_track(void)
/* take care of if we're playing a cuesheet */ /* take care of if we're playing a cuesheet */
if (wps_state.id3->cuesheet) if (wps_state.id3->cuesheet)
{ {
if (curr_cuesheet_skip(1, wps_state.id3->elapsed)) if (curr_cuesheet_skip(wps_state.id3->cuesheet, 1, wps_state.id3->elapsed))
{ {
/* if the result was false, then we really want /* if the result was false, then we really want
to skip to the next track */ to skip to the next track */