diff options
Diffstat (limited to 'apps/codecs/aiff.c')
-rw-r--r-- | apps/codecs/aiff.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/apps/codecs/aiff.c b/apps/codecs/aiff.c index 62d79ac340..4e16788e06 100644 --- a/apps/codecs/aiff.c +++ b/apps/codecs/aiff.c | |||
@@ -100,6 +100,9 @@ next_track: | |||
100 | 100 | ||
101 | codec_set_replaygain(ci->id3); | 101 | codec_set_replaygain(ci->id3); |
102 | 102 | ||
103 | /* Need to save offset for later use (cleared indirectly by advance_buffer) */ | ||
104 | bytesdone = ci->id3->offset; | ||
105 | |||
103 | /* assume the AIFF header is less than 1024 bytes */ | 106 | /* assume the AIFF header is less than 1024 bytes */ |
104 | buf = ci->request_buffer(&n, 1024); | 107 | buf = ci->request_buffer(&n, 1024); |
105 | if (n < 54) { | 108 | if (n < 54) { |
@@ -279,9 +282,26 @@ next_track: | |||
279 | firstblockposn = 1024 - n; | 282 | firstblockposn = 1024 - n; |
280 | ci->advance_buffer(firstblockposn); | 283 | ci->advance_buffer(firstblockposn); |
281 | 284 | ||
285 | /* make sure we're at the correct offset */ | ||
286 | if (bytesdone > (uint32_t) firstblockposn) { | ||
287 | /* Round down to previous block */ | ||
288 | struct pcm_pos *newpos = codec->get_seek_pos(bytesdone - firstblockposn, | ||
289 | PCM_SEEK_POS, NULL); | ||
290 | |||
291 | if (newpos->pos > format.numbytes) | ||
292 | goto done; | ||
293 | if (ci->seek_buffer(firstblockposn + newpos->pos)) | ||
294 | { | ||
295 | bytesdone = newpos->pos; | ||
296 | decodedsamples = newpos->samples; | ||
297 | } | ||
298 | ci->seek_complete(); | ||
299 | } else { | ||
300 | /* already where we need to be */ | ||
301 | bytesdone = 0; | ||
302 | } | ||
303 | |||
282 | /* The main decoder loop */ | 304 | /* The main decoder loop */ |
283 | bytesdone = 0; | ||
284 | ci->set_elapsed(0); | ||
285 | endofstream = 0; | 305 | endofstream = 0; |
286 | 306 | ||
287 | while (!endofstream) { | 307 | while (!endofstream) { |
@@ -290,8 +310,8 @@ next_track: | |||
290 | break; | 310 | break; |
291 | 311 | ||
292 | if (ci->seek_time) { | 312 | if (ci->seek_time) { |
293 | /* 2nd args(read_buffer) is unnecessary in the format which AIFF supports. */ | 313 | /* 3rd args(read_buffer) is unnecessary in the format which AIFF supports. */ |
294 | struct pcm_pos *newpos = codec->get_seek_pos(ci->seek_time, NULL); | 314 | struct pcm_pos *newpos = codec->get_seek_pos(ci->seek_time, PCM_SEEK_TIME, NULL); |
295 | 315 | ||
296 | if (newpos->pos > format.numbytes) | 316 | if (newpos->pos > format.numbytes) |
297 | break; | 317 | break; |