Fix FS#8977. The issue was caused by multiple successive calls to audio_load_track() happening before the corresponding calls to audio_finish_load_track(), resulting in disappearing tracks. I added the track_load_started boolean flag as a means to prevent audio_load_track() from doing anything if a call to audio_finish_load_track is pending.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17891 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
58335f8724
commit
f69982bb0b
1 changed files with 22 additions and 0 deletions
|
@ -264,6 +264,12 @@ static bool skipped_during_pause = false; /* Do we need to clear the PCM buffer
|
|||
static bool start_play_g = false; /* Used by audio_load_track to notify
|
||||
audio_finish_load_track about start_play */
|
||||
|
||||
/* True when a track load is in progress, i.e. audio_load_track() has returned
|
||||
* but audio_finish_load_track() hasn't been called yet. Used to avoid allowing
|
||||
* audio_load_track() to get called twice in a row, which would cause problems.
|
||||
*/
|
||||
static bool track_load_started = false;
|
||||
|
||||
/* Set to true if the codec thread should send an audio stop request
|
||||
* (typically because the end of the playlist has been reached).
|
||||
*/
|
||||
|
@ -1610,6 +1616,14 @@ static bool audio_load_track(size_t offset, bool start_play)
|
|||
const char *trackname;
|
||||
int fd = -1;
|
||||
|
||||
if (track_load_started) {
|
||||
/* There is already a track load in progress, so track_widx hasn't been
|
||||
incremented yet. Loading another track would overwrite the one that
|
||||
hasn't finished loading. */
|
||||
logf("audio_load_track(): a track load is already in progress");
|
||||
return false;
|
||||
}
|
||||
|
||||
start_play_g = start_play; /* will be read by audio_finish_load_track */
|
||||
|
||||
/* Stop buffer filling if there is no free track entries.
|
||||
|
@ -1693,6 +1707,7 @@ static bool audio_load_track(size_t offset, bool start_play)
|
|||
}
|
||||
|
||||
close(fd);
|
||||
track_load_started = true; /* Remember that we've started loading a track */
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1724,6 +1739,8 @@ static void audio_finish_load_track(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
track_load_started = false;
|
||||
|
||||
if (tracks[track_widx].id3_hid < 0) {
|
||||
logf("no metatdata");
|
||||
return;
|
||||
|
@ -1901,6 +1918,9 @@ static void audio_rebuffer(void)
|
|||
track_widx = track_ridx;
|
||||
audio_clear_track_entries();
|
||||
|
||||
/* Reset a possibly interrupted track load */
|
||||
track_load_started = false;
|
||||
|
||||
/* Fill the buffer */
|
||||
last_peek_offset = -1;
|
||||
ci.curpos = 0;
|
||||
|
@ -2121,6 +2141,7 @@ static void audio_stop_playback(void)
|
|||
paused = false;
|
||||
audio_stop_codec_flush();
|
||||
playing = false;
|
||||
track_load_started = false;
|
||||
|
||||
filling = STATE_IDLE;
|
||||
|
||||
|
@ -2149,6 +2170,7 @@ static void audio_play_start(size_t offset)
|
|||
track_changed = true;
|
||||
|
||||
playing = true;
|
||||
track_load_started = false;
|
||||
|
||||
ci.new_track = 0;
|
||||
ci.seek_time = 0;
|
||||
|
|
Loading…
Reference in a new issue