summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/speex.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/speex.c')
-rw-r--r--lib/rbcodec/codecs/speex.c60
1 files changed, 37 insertions, 23 deletions
diff --git a/lib/rbcodec/codecs/speex.c b/lib/rbcodec/codecs/speex.c
index ac3bc963b1..a073151ee2 100644
--- a/lib/rbcodec/codecs/speex.c
+++ b/lib/rbcodec/codecs/speex.c
@@ -381,7 +381,6 @@ enum codec_status codec_run(void)
381 int error = CODEC_ERROR; 381 int error = CODEC_ERROR;
382 382
383 SpeexBits bits; 383 SpeexBits bits;
384 int eof = 0;
385 spx_ogg_sync_state oy; 384 spx_ogg_sync_state oy;
386 spx_ogg_page og; 385 spx_ogg_page og;
387 spx_ogg_packet op; 386 spx_ogg_packet op;
@@ -403,9 +402,10 @@ enum codec_status codec_run(void)
403 int packet_count = 0; 402 int packet_count = 0;
404 int lookahead; 403 int lookahead;
405 int headerssize = 0; 404 int headerssize = 0;
406 unsigned long strtoffset = ci->id3->offset; 405 unsigned long strtoffset;
407 void *st = NULL; 406 void *st = NULL;
408 int j = 0; 407 int j = 0;
408 enum codec_command_action action;
409 intptr_t param; 409 intptr_t param;
410 410
411 memset(&bits, 0, sizeof(bits)); 411 memset(&bits, 0, sizeof(bits));
@@ -416,6 +416,10 @@ enum codec_status codec_run(void)
416 goto exit; 416 goto exit;
417 } 417 }
418 418
419 action = CODEC_ACTION_NULL;
420 param = ci->id3->elapsed;
421 strtoffset = ci->id3->offset;
422
419 ci->seek_buffer(0); 423 ci->seek_buffer(0);
420 ci->set_elapsed(0); 424 ci->set_elapsed(0);
421 425
@@ -425,29 +429,39 @@ enum codec_status codec_run(void)
425 429
426 codec_set_replaygain(ci->id3); 430 codec_set_replaygain(ci->id3);
427 431
428 eof = 0; 432 if (!strtoffset && param) {
429 while (!eof) { 433 action = CODEC_ACTION_SEEK_TIME;
430 enum codec_command_action action = ci->get_command(&param); 434 }
431 435
432 if (action == CODEC_ACTION_HALT) 436 goto next_page;
433 break; 437
434 438 while (1) {
435 /*seek (seeks to the page before the position) */ 439 if (action == CODEC_ACTION_NULL)
436 if (action == CODEC_ACTION_SEEK_TIME) { 440 action = ci->get_command(&param);
437 if(samplerate!=0&&packet_count>1){ 441
438 LOGF("Speex seek page:%lld,%lld,%ld,%lld,%d\n", 442 if (action != CODEC_ACTION_NULL) {
439 ((spx_int64_t)param/1000) * 443 if (action == CODEC_ACTION_HALT)
440 (spx_int64_t)samplerate, 444 break;
441 page_granule, (long)param, 445
442 (page_granule/samplerate)*1000, samplerate); 446 /*seek (seeks to the page before the position) */
443 447 if (action == CODEC_ACTION_SEEK_TIME) {
444 speex_seek_page_granule(((spx_int64_t)param/1000) * 448 if(samplerate!=0&&packet_count>1){
445 (spx_int64_t)samplerate, 449 LOGF("Speex seek page:%lld,%lld,%ld,%lld,%d\n",
446 page_granule, &oy, headerssize); 450 ((spx_int64_t)param/1000) *
451 (spx_int64_t)samplerate,
452 page_granule, (long)param,
453 (page_granule/samplerate)*1000, samplerate);
454
455 speex_seek_page_granule(((spx_int64_t)param/1000) *
456 (spx_int64_t)samplerate,
457 page_granule, &oy, headerssize);
458 }
459
460 ci->set_elapsed(param);
461 ci->seek_complete();
447 } 462 }
448 463
449 ci->set_elapsed(param); 464 action = CODEC_ACTION_NULL;
450 ci->seek_complete();
451 } 465 }
452 466
453next_page: 467next_page: