diff options
-rw-r--r-- | apps/playback.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/apps/playback.c b/apps/playback.c index 8cd25cca2a..10908821e9 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -560,6 +560,7 @@ struct mp3entry* audio_current_track(void) | |||
560 | struct playlist_track_info trackinfo; | 560 | struct playlist_track_info trackinfo; |
561 | int cur_idx; | 561 | int cur_idx; |
562 | int offset = ci.new_track + wps_offset; | 562 | int offset = ci.new_track + wps_offset; |
563 | struct mp3entry *write_id3; | ||
563 | 564 | ||
564 | cur_idx = (track_ridx + offset) & MAX_TRACK_MASK; | 565 | cur_idx = (track_ridx + offset) & MAX_TRACK_MASK; |
565 | 566 | ||
@@ -576,18 +577,36 @@ struct mp3entry* audio_current_track(void) | |||
576 | codec_pcmbuf_position_callback */ | 577 | codec_pcmbuf_position_callback */ |
577 | return othertrack_id3; | 578 | return othertrack_id3; |
578 | } | 579 | } |
579 | else if (tracks[cur_idx].id3_hid >= 0) | 580 | |
581 | if (offset != 0) | ||
582 | { | ||
583 | /* Codec may be using thistrack_id3, so it must not be overwritten. | ||
584 | If this is a manual skip, othertrack_id3 will become | ||
585 | thistrack_id3 in audio_check_new_track(). | ||
586 | FIXME: If this is an automatic skip, it probably means multiple | ||
587 | short tracks fit in the PCM buffer. Overwriting othertrack_id3 | ||
588 | can lead to an incorrect value later. | ||
589 | Note that othertrack_id3 may also be used for next track. | ||
590 | */ | ||
591 | write_id3 = othertrack_id3; | ||
592 | } | ||
593 | else | ||
594 | { | ||
595 | write_id3 = thistrack_id3; | ||
596 | } | ||
597 | |||
598 | if (tracks[cur_idx].id3_hid >= 0) | ||
580 | { | 599 | { |
581 | /* The current track's info has been buffered but not read yet, so get it */ | 600 | /* The current track's info has been buffered but not read yet, so get it */ |
582 | if (bufread(tracks[cur_idx].id3_hid, sizeof(struct mp3entry), thistrack_id3) | 601 | if (bufread(tracks[cur_idx].id3_hid, sizeof(struct mp3entry), write_id3) |
583 | == sizeof(struct mp3entry)) | 602 | == sizeof(struct mp3entry)) |
584 | return thistrack_id3; | 603 | return write_id3; |
585 | } | 604 | } |
586 | 605 | ||
587 | /* We didn't find the ID3 metadata, so we fill temp_id3 with the little info | 606 | /* We didn't find the ID3 metadata, so we fill temp_id3 with the little info |
588 | we have and return that. */ | 607 | we have and return that. */ |
589 | 608 | ||
590 | memset(thistrack_id3, 0, sizeof(struct mp3entry)); | 609 | memset(write_id3, 0, sizeof(struct mp3entry)); |
591 | 610 | ||
592 | playlist_get_track_info(NULL, playlist_next(0)+wps_offset, &trackinfo); | 611 | playlist_get_track_info(NULL, playlist_next(0)+wps_offset, &trackinfo); |
593 | filename = trackinfo.filename; | 612 | filename = trackinfo.filename; |
@@ -595,18 +614,18 @@ struct mp3entry* audio_current_track(void) | |||
595 | filename = "No file!"; | 614 | filename = "No file!"; |
596 | 615 | ||
597 | #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) | 616 | #if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE) |
598 | if (tagcache_fill_tags(thistrack_id3, filename)) | 617 | if (tagcache_fill_tags(write_id3, filename)) |
599 | return thistrack_id3; | 618 | return write_id3; |
600 | #endif | 619 | #endif |
601 | 620 | ||
602 | strncpy(thistrack_id3->path, filename, sizeof(thistrack_id3->path)-1); | 621 | strncpy(write_id3->path, filename, sizeof(write_id3->path)-1); |
603 | thistrack_id3->title = strrchr(thistrack_id3->path, '/'); | 622 | write_id3->title = strrchr(write_id3->path, '/'); |
604 | if (!thistrack_id3->title) | 623 | if (!write_id3->title) |
605 | thistrack_id3->title = &thistrack_id3->path[0]; | 624 | write_id3->title = &write_id3->path[0]; |
606 | else | 625 | else |
607 | thistrack_id3->title++; | 626 | write_id3->title++; |
608 | 627 | ||
609 | return thistrack_id3; | 628 | return write_id3; |
610 | } | 629 | } |
611 | 630 | ||
612 | struct mp3entry* audio_next_track(void) | 631 | struct mp3entry* audio_next_track(void) |