summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/wma.c
diff options
context:
space:
mode:
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;