forked from len0rd/rockbox
Implement time-based resume and playback start.
This complements offset-based resume and playback start funcionality. The implementation is global on both HWCODEC and SWCODEC. Basically, if either the specified elapsed or offset are non-zero, it indicates a mid-track resume. To resume by time only, set elapsed to nonzero and offset to zero. To resume by offset only, set offset to nonzero and elapsed to zero. Which one the codec uses and which has priority is up to the codec; however, using an elapsed time covers more cases: * Codecs not able to use an offset such as VGM or other atomic formats * Starting playback at a nonzero elapsed time from a source that contains no offset, such as a cuesheet The change re-versions pretty much everything from tagcache to nvram. Change-Id: Ic7aebb24e99a03ae99585c5e236eba960d163f38 Reviewed-on: http://gerrit.rockbox.org/516 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested: Michael Sevakis <jethead71@rockbox.org>
This commit is contained in:
parent
dda54b85da
commit
31b7122867
65 changed files with 724 additions and 297 deletions
|
|
@ -52,13 +52,16 @@ enum codec_status codec_run(void)
|
|||
int audiobufsize;
|
||||
int packetlength = 0;
|
||||
int errcount = 0;
|
||||
enum codec_command_action action;
|
||||
intptr_t param;
|
||||
|
||||
/* Remember the resume position - when the codec is opened, the
|
||||
playback engine will reset it. */
|
||||
elapsedtime = ci->id3->elapsed;
|
||||
resume_offset = ci->id3->offset;
|
||||
|
||||
restart_track:
|
||||
action = CODEC_ACTION_NULL;
|
||||
|
||||
/* Proper reset of the decoder context. */
|
||||
memset(&wmadec, 0, sizeof(wmadec));
|
||||
|
|
@ -78,13 +81,20 @@ restart_track:
|
|||
return CODEC_ERROR;
|
||||
}
|
||||
|
||||
if (resume_offset > ci->id3->first_frame_offset)
|
||||
if (resume_offset > ci->id3->first_frame_offset || elapsedtime)
|
||||
{
|
||||
/* Get start of current packet */
|
||||
int packet_offset = (resume_offset - ci->id3->first_frame_offset)
|
||||
% wfx.packet_size;
|
||||
ci->seek_buffer(resume_offset - packet_offset);
|
||||
elapsedtime = asf_get_timestamp(&i);
|
||||
if (resume_offset) {
|
||||
/* Get start of current packet */
|
||||
int packet_offset = (resume_offset -
|
||||
MIN(resume_offset, ci->id3->first_frame_offset))
|
||||
% wfx.packet_size;
|
||||
ci->seek_buffer(resume_offset - packet_offset);
|
||||
elapsedtime = asf_get_timestamp(&i);
|
||||
}
|
||||
else {
|
||||
param = elapsedtime;
|
||||
action = CODEC_ACTION_SEEK_TIME;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -104,7 +114,8 @@ restart_track:
|
|||
/* The main decoding loop */
|
||||
while (res >= 0)
|
||||
{
|
||||
enum codec_command_action action = ci->get_command(¶m);
|
||||
if (action == CODEC_ACTION_NULL)
|
||||
action = ci->get_command(¶m);
|
||||
|
||||
if (action != CODEC_ACTION_NULL) {
|
||||
|
||||
|
|
@ -126,6 +137,7 @@ restart_track:
|
|||
if (param == 0) {
|
||||
ci->set_elapsed(0);
|
||||
ci->seek_complete();
|
||||
elapsedtime = 0;
|
||||
goto restart_track; /* Pretend you never saw this... */
|
||||
}
|
||||
|
||||
|
|
@ -140,6 +152,8 @@ restart_track:
|
|||
ci->set_elapsed(elapsedtime);
|
||||
ci->seek_complete();
|
||||
}
|
||||
|
||||
action = CODEC_ACTION_NULL;
|
||||
}
|
||||
|
||||
errcount = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue