playback: Fix track resume from file offset
Resuming a track with "Resume Playback" or a bookmark is supposed
to pass both the file offset and elapsed time to the codec. Since
commit dfff938dff
the offset has been getting zeroed because the
buffer handle wasn't open at the time of the buf_filesize() call,
causing it to return a negative error code.
Having a valid offset improves resume accuracy with some codecs,
like VBR MP3.
Change-Id: I8af7f001644f1ee1bd27ca3049a4cff2d2274149
This commit is contained in:
parent
0d30356734
commit
26ffcd8f9f
1 changed files with 13 additions and 12 deletions
|
@ -2097,23 +2097,11 @@ static int audio_finish_load_track(struct track_info *infop)
|
|||
/** Finally, load the audio **/
|
||||
off_t file_offset = 0;
|
||||
|
||||
if (track_id3->elapsed > track_id3->length)
|
||||
track_id3->elapsed = 0;
|
||||
|
||||
if ((off_t)track_id3->offset >= buf_filesize(infop->audio_hid))
|
||||
track_id3->offset = 0;
|
||||
|
||||
logf("%s: set offset for %s to %lu\n", __func__,
|
||||
track_id3->title, track_id3->offset);
|
||||
|
||||
/* Adjust for resume rewind so we know what to buffer - starting the codec
|
||||
calls it again, so we don't save it (and they shouldn't accumulate) */
|
||||
unsigned long elapsed, offset;
|
||||
resume_rewind_adjust_progress(track_id3, &elapsed, &offset);
|
||||
|
||||
logf("%s: Set resume for %s to %lu %lu", __func__,
|
||||
track_id3->title, elapsed, offset);
|
||||
|
||||
enum data_type audiotype = rbcodec_format_is_atomic(track_id3->codectype) ?
|
||||
TYPE_ATOMIC_AUDIO : TYPE_PACKET_AUDIO;
|
||||
|
||||
|
@ -2145,6 +2133,19 @@ static int audio_finish_load_track(struct track_info *infop)
|
|||
if (hid >= 0)
|
||||
{
|
||||
infop->audio_hid = hid;
|
||||
|
||||
/*
|
||||
* Fix up elapsed time and offset if past the end
|
||||
*/
|
||||
if (track_id3->elapsed > track_id3->length)
|
||||
track_id3->elapsed = 0;
|
||||
|
||||
if ((off_t)track_id3->offset >= buf_filesize(infop->audio_hid))
|
||||
track_id3->offset = 0;
|
||||
|
||||
logf("%s: set resume for %s to %lu %lX", __func__,
|
||||
track_id3->title, track_id3->elapsed, track_id3->offset);
|
||||
|
||||
if (infop->self_hid == cur_info.self_hid)
|
||||
{
|
||||
/* This is the current track to decode - should be started now */
|
||||
|
|
Loading…
Reference in a new issue