/* skips backwards or forward in the current cuesheet * the return value indicates whether we're still in a cusheet after skipping * it also returns false if we weren't in a cuesheet. * direction should be 1 or -1. */ bool curr_cuesheet_skip(struct cuesheet *cue, int direction, unsigned long curr_pos) { int track = cue_find_current_track(cue, curr_pos); if (direction >= 0 && track == cue->track_count - 1) { /* we want to get out of the cuesheet */ return false; } else { if (!(direction <= 0 && track == 0)) { /* If skipping forward, skip to next cuesheet segment. If skipping backward before DEFAULT_SKIP_TRESH milliseconds have elapsed, skip to previous cuesheet segment. If skipping backward after DEFAULT_SKIP_TRESH seconds have elapsed, skip to the start of the current cuesheet segment */ if (direction == 1 || ((curr_pos - cue->tracks[track].offset) < DEFAULT_SKIP_TRESH)) { track += direction; } } seek(cue->tracks[track].offset); return true; } }
bool cuesheet_subtrack_changed(struct mp3entry *id3) { struct cuesheet *cue = id3->cuesheet; if (cue && (id3->elapsed < cue->curr_track->offset || (cue->curr_track_idx < cue->track_count - 1 && id3->elapsed >= (cue->curr_track+1)->offset))) { cue_find_current_track(cue, id3->elapsed); return true; } return false; }
void browse_cuesheet(struct cuesheet *cue) { struct gui_synclist lists; int action; bool done = false; int sel; char title[MAX_PATH]; char cuepath[MAX_PATH]; struct mp3entry *id3 = audio_current_track(); snprintf(title, MAX_PATH, "%s: %s", cue->performer, cue->title); gui_synclist_init(&lists, list_get_name_cb, cue, false, 2, NULL); gui_synclist_set_nb_items(&lists, 2*cue->track_count); gui_synclist_set_title(&lists, title, 0); if (id3) { gui_synclist_select_item(&lists, 2*cue_find_current_track(cue, id3->elapsed)); } while (!done) { gui_synclist_draw(&lists); action = get_action(CONTEXT_LIST,TIMEOUT_BLOCK); if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD)) continue; switch (action) { case ACTION_STD_OK: id3 = audio_current_track(); if (id3 && *id3->path && strcmp(id3->path, "No file!")) { look_for_cuesheet_file(id3->path, cuepath); if (id3->cuesheet && !strcmp(cue->path, cuepath)) { sel = gui_synclist_get_sel_pos(&lists); seek(cue->tracks[sel/2].offset); } } break; case ACTION_STD_CANCEL: done = true; } } }
/* skips backwards or forward in the current cuesheet * the return value indicates whether we're still in a cusheet after skipping * it also returns false if we weren't in a cuesheet. * direction should be 1 or -1. */ bool curr_cuesheet_skip(struct cuesheet *cue, int direction, unsigned long curr_pos) { int track = cue_find_current_track(cue, curr_pos); if (direction >= 0 && track == cue->track_count - 1) { /* we want to get out of the cuesheet */ return false; } else { if (!(direction <= 0 && track == 0)) track += direction; seek(cue->tracks[track].offset); return true; } }