summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/wma.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-07-14 07:59:39 -0400
committerMichael Sevakis <jethead71@rockbox.org>2014-03-10 04:12:30 +0100
commit31b712286721dd606940c7b557d03e3f714b9604 (patch)
tree8c4a4cc32e9000ea721ebb23aa3c0129ca97bf53 /lib/rbcodec/codecs/wma.c
parentdda54b85daa83b7803b4fb189ab45859f96ff3f9 (diff)
downloadrockbox-31b712286721dd606940c7b557d03e3f714b9604.zip
rockbox-31b712286721dd606940c7b557d03e3f714b9604.tar.gz
rockbox-31b712286721dd606940c7b557d03e3f714b9604.tar.bz2
rockbox-31b712286721dd606940c7b557d03e3f714b9604.tar.xz
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>
Diffstat (limited to 'lib/rbcodec/codecs/wma.c')
-rwxr-xr-xlib/rbcodec/codecs/wma.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/rbcodec/codecs/wma.c b/lib/rbcodec/codecs/wma.c
index 9039f81..9a5e0c7 100755
--- a/lib/rbcodec/codecs/wma.c
+++ b/lib/rbcodec/codecs/wma.c
@@ -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(&param);
+ if (action == CODEC_ACTION_NULL)
+ action = ci->get_command(&param);
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;