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.tar.gz
rockbox-31b712286721dd606940c7b557d03e3f714b9604.zip
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 9039f81429..9a5e0c71fa 100755
--- a/lib/rbcodec/codecs/wma.c
+++ b/lib/rbcodec/codecs/wma.c
@@ -52,13 +52,16 @@ enum codec_status codec_run(void)
52 int audiobufsize; 52 int audiobufsize;
53 int packetlength = 0; 53 int packetlength = 0;
54 int errcount = 0; 54 int errcount = 0;
55 enum codec_command_action action;
55 intptr_t param; 56 intptr_t param;
56 57
57 /* Remember the resume position - when the codec is opened, the 58 /* Remember the resume position - when the codec is opened, the
58 playback engine will reset it. */ 59 playback engine will reset it. */
60 elapsedtime = ci->id3->elapsed;
59 resume_offset = ci->id3->offset; 61 resume_offset = ci->id3->offset;
60 62
61restart_track: 63restart_track:
64 action = CODEC_ACTION_NULL;
62 65
63 /* Proper reset of the decoder context. */ 66 /* Proper reset of the decoder context. */
64 memset(&wmadec, 0, sizeof(wmadec)); 67 memset(&wmadec, 0, sizeof(wmadec));
@@ -78,13 +81,20 @@ restart_track:
78 return CODEC_ERROR; 81 return CODEC_ERROR;
79 } 82 }
80 83
81 if (resume_offset > ci->id3->first_frame_offset) 84 if (resume_offset > ci->id3->first_frame_offset || elapsedtime)
82 { 85 {
83 /* Get start of current packet */ 86 if (resume_offset) {
84 int packet_offset = (resume_offset - ci->id3->first_frame_offset) 87 /* Get start of current packet */
85 % wfx.packet_size; 88 int packet_offset = (resume_offset -
86 ci->seek_buffer(resume_offset - packet_offset); 89 MIN(resume_offset, ci->id3->first_frame_offset))
87 elapsedtime = asf_get_timestamp(&i); 90 % wfx.packet_size;
91 ci->seek_buffer(resume_offset - packet_offset);
92 elapsedtime = asf_get_timestamp(&i);
93 }
94 else {
95 param = elapsedtime;
96 action = CODEC_ACTION_SEEK_TIME;
97 }
88 } 98 }
89 else 99 else
90 { 100 {
@@ -104,7 +114,8 @@ restart_track:
104 /* The main decoding loop */ 114 /* The main decoding loop */
105 while (res >= 0) 115 while (res >= 0)
106 { 116 {
107 enum codec_command_action action = ci->get_command(&param); 117 if (action == CODEC_ACTION_NULL)
118 action = ci->get_command(&param);
108 119
109 if (action != CODEC_ACTION_NULL) { 120 if (action != CODEC_ACTION_NULL) {
110 121
@@ -126,6 +137,7 @@ restart_track:
126 if (param == 0) { 137 if (param == 0) {
127 ci->set_elapsed(0); 138 ci->set_elapsed(0);
128 ci->seek_complete(); 139 ci->seek_complete();
140 elapsedtime = 0;
129 goto restart_track; /* Pretend you never saw this... */ 141 goto restart_track; /* Pretend you never saw this... */
130 } 142 }
131 143
@@ -140,6 +152,8 @@ restart_track:
140 ci->set_elapsed(elapsedtime); 152 ci->set_elapsed(elapsedtime);
141 ci->seek_complete(); 153 ci->seek_complete();
142 } 154 }
155
156 action = CODEC_ACTION_NULL;
143 } 157 }
144 158
145 errcount = 0; 159 errcount = 0;