diff options
Diffstat (limited to 'apps/playback.c')
-rw-r--r-- | apps/playback.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/apps/playback.c b/apps/playback.c index cee89d3bbb..7bd3f252ae 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -210,6 +210,9 @@ static struct mp3entry *thistrack_id3, /* the currently playing track */ | |||
210 | * next track otherwise */ | 210 | * next track otherwise */ |
211 | static struct mp3entry unbuffered_id3; /* the id3 for the first unbuffered track */ | 211 | static struct mp3entry unbuffered_id3; /* the id3 for the first unbuffered track */ |
212 | 212 | ||
213 | /* for cuesheet support */ | ||
214 | static struct cuesheet *curr_cue = NULL; | ||
215 | |||
213 | /* Track info structure about songs in the file buffer (A/C-) */ | 216 | /* Track info structure about songs in the file buffer (A/C-) */ |
214 | struct track_info { | 217 | struct track_info { |
215 | int audio_hid; /* The ID for the track's buffer handle */ | 218 | int audio_hid; /* The ID for the track's buffer handle */ |
@@ -218,6 +221,7 @@ struct track_info { | |||
218 | #ifdef HAVE_ALBUMART | 221 | #ifdef HAVE_ALBUMART |
219 | int aa_hid; /* The ID for the track's album art handle */ | 222 | int aa_hid; /* The ID for the track's album art handle */ |
220 | #endif | 223 | #endif |
224 | int cuesheet_hid; /* The ID for the track's parsed cueesheet handle */ | ||
221 | 225 | ||
222 | size_t filesize; /* File total length */ | 226 | size_t filesize; /* File total length */ |
223 | 227 | ||
@@ -384,6 +388,13 @@ static bool clear_track_info(struct track_info *track) | |||
384 | } | 388 | } |
385 | #endif | 389 | #endif |
386 | 390 | ||
391 | if (track->cuesheet_hid >= 0) { | ||
392 | if (bufclose(track->cuesheet_hid)) | ||
393 | track->cuesheet_hid = -1; | ||
394 | else | ||
395 | return false; | ||
396 | } | ||
397 | |||
387 | track->filesize = 0; | 398 | track->filesize = 0; |
388 | track->taginfo_ready = false; | 399 | track->taginfo_ready = false; |
389 | 400 | ||
@@ -566,6 +577,12 @@ struct mp3entry* audio_current_track(void) | |||
566 | if (cur_idx == track_ridx && *thistrack_id3->path) | 577 | if (cur_idx == track_ridx && *thistrack_id3->path) |
567 | { | 578 | { |
568 | /* The usual case */ | 579 | /* The usual case */ |
580 | if (tracks[cur_idx].cuesheet_hid >= 0) | ||
581 | { | ||
582 | bufread(tracks[cur_idx].cuesheet_hid, sizeof(struct cuesheet), curr_cue); | ||
583 | thistrack_id3->cuesheet = curr_cue; | ||
584 | cue_spoof_id3(thistrack_id3->cuesheet, thistrack_id3); | ||
585 | } | ||
569 | return thistrack_id3; | 586 | return thistrack_id3; |
570 | } | 587 | } |
571 | else if (automatic_skip && offset == -1 && *othertrack_id3->path) | 588 | else if (automatic_skip && offset == -1 && *othertrack_id3->path) |
@@ -574,6 +591,12 @@ struct mp3entry* audio_current_track(void) | |||
574 | but the audio being played is still the same (now previous) track. | 591 | but the audio being played is still the same (now previous) track. |
575 | othertrack_id3.elapsed is being updated in an ISR by | 592 | othertrack_id3.elapsed is being updated in an ISR by |
576 | codec_pcmbuf_position_callback */ | 593 | codec_pcmbuf_position_callback */ |
594 | if (tracks[cur_idx].cuesheet_hid >= 0) | ||
595 | { | ||
596 | bufread(tracks[cur_idx].cuesheet_hid, sizeof(struct cuesheet), curr_cue); | ||
597 | othertrack_id3->cuesheet = curr_cue; | ||
598 | cue_spoof_id3(othertrack_id3->cuesheet, othertrack_id3); | ||
599 | } | ||
577 | return othertrack_id3; | 600 | return othertrack_id3; |
578 | } | 601 | } |
579 | 602 | ||
@@ -1826,7 +1849,21 @@ static void audio_finish_load_track(void) | |||
1826 | 1849 | ||
1827 | return; | 1850 | return; |
1828 | } | 1851 | } |
1852 | /* Try to load a cuesheet for the track */ | ||
1853 | if (curr_cue) | ||
1854 | { | ||
1855 | char cuepath[MAX_PATH]; | ||
1829 | 1856 | ||
1857 | struct cuesheet temp_cue; | ||
1858 | |||
1859 | if (look_for_cuesheet_file(track_id3->path, cuepath) && | ||
1860 | parse_cuesheet(cuepath, &temp_cue)) | ||
1861 | { | ||
1862 | strcpy(temp_cue.audio_filename, track_id3->path); | ||
1863 | tracks[track_widx].cuesheet_hid = | ||
1864 | bufalloc(&temp_cue, sizeof(struct cuesheet), TYPE_CUESHEET); | ||
1865 | } | ||
1866 | } | ||
1830 | #ifdef HAVE_ALBUMART | 1867 | #ifdef HAVE_ALBUMART |
1831 | if (tracks[track_widx].aa_hid < 0 && gui_sync_wps_uses_albumart()) | 1868 | if (tracks[track_widx].aa_hid < 0 && gui_sync_wps_uses_albumart()) |
1832 | { | 1869 | { |
@@ -2602,6 +2639,10 @@ void audio_init(void) | |||
2602 | thistrack_id3 = &mp3entry_buf[0]; | 2639 | thistrack_id3 = &mp3entry_buf[0]; |
2603 | othertrack_id3 = &mp3entry_buf[1]; | 2640 | othertrack_id3 = &mp3entry_buf[1]; |
2604 | 2641 | ||
2642 | /* cuesheet support */ | ||
2643 | if (global_settings.cuesheet) | ||
2644 | curr_cue = (struct cuesheet*)buffer_alloc(sizeof(struct cuesheet)); | ||
2645 | |||
2605 | /* initialize the buffer */ | 2646 | /* initialize the buffer */ |
2606 | filebuf = audiobuf; | 2647 | filebuf = audiobuf; |
2607 | 2648 | ||
@@ -2648,6 +2689,7 @@ void audio_init(void) | |||
2648 | #ifdef HAVE_ALBUMART | 2689 | #ifdef HAVE_ALBUMART |
2649 | tracks[i].aa_hid = -1; | 2690 | tracks[i].aa_hid = -1; |
2650 | #endif | 2691 | #endif |
2692 | tracks[i].cuesheet_hid = -1; | ||
2651 | } | 2693 | } |
2652 | 2694 | ||
2653 | add_event(BUFFER_EVENT_REBUFFER, false, buffering_handle_rebuffer_callback); | 2695 | add_event(BUFFER_EVENT_REBUFFER, false, buffering_handle_rebuffer_callback); |