diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/test_codec.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index 855503a0ec..4bde1ba39d 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c | |||
@@ -127,7 +127,6 @@ struct test_track_info { | |||
127 | }; | 127 | }; |
128 | 128 | ||
129 | static struct test_track_info track; | 129 | static struct test_track_info track; |
130 | static bool taginfo_ready = true; | ||
131 | 130 | ||
132 | static bool use_dsp; | 131 | static bool use_dsp; |
133 | 132 | ||
@@ -433,6 +432,7 @@ static void pcmbuf_insert_wav_checksum(const void *ch1, const void *ch2, int cou | |||
433 | static void set_elapsed(unsigned long value) | 432 | static void set_elapsed(unsigned long value) |
434 | { | 433 | { |
435 | elapsed = value; | 434 | elapsed = value; |
435 | ci.id3->elapsed = value; | ||
436 | } | 436 | } |
437 | 437 | ||
438 | 438 | ||
@@ -482,6 +482,7 @@ static void* request_buffer(size_t *realsize, size_t reqsize) | |||
482 | static void advance_buffer(size_t amount) | 482 | static void advance_buffer(size_t amount) |
483 | { | 483 | { |
484 | ci.curpos += amount; | 484 | ci.curpos += amount; |
485 | ci.id3->offset = ci.curpos; | ||
485 | } | 486 | } |
486 | 487 | ||
487 | 488 | ||
@@ -499,20 +500,17 @@ static void seek_complete(void) | |||
499 | /* Do nothing */ | 500 | /* Do nothing */ |
500 | } | 501 | } |
501 | 502 | ||
502 | /* Request file change from file buffer. Returns true is next | 503 | /* Codec calls this to know what it should do next. */ |
503 | track is available and changed. If return value is false, | 504 | static enum codec_command_action get_command(intptr_t *param) |
504 | codec should exit immediately with PLUGIN_OK status. */ | ||
505 | static bool request_next_track(void) | ||
506 | { | 505 | { |
507 | /* We are only decoding a single track */ | 506 | rb->yield(); |
508 | return false; | 507 | return CODEC_ACTION_NULL; /* just continue processing */ |
508 | (void)param; | ||
509 | } | 509 | } |
510 | 510 | ||
511 | |||
512 | static void set_offset(size_t value) | 511 | static void set_offset(size_t value) |
513 | { | 512 | { |
514 | /* ??? */ | 513 | ci.id3->offset = value; |
515 | (void)value; | ||
516 | } | 514 | } |
517 | 515 | ||
518 | 516 | ||
@@ -546,6 +544,9 @@ static void init_ci(void) | |||
546 | { | 544 | { |
547 | /* --- Our "fake" implementations of the codec API functions. --- */ | 545 | /* --- Our "fake" implementations of the codec API functions. --- */ |
548 | 546 | ||
547 | ci.dsp = (struct dsp_config *)rb->dsp_configure(NULL, DSP_MYDSP, | ||
548 | CODEC_IDX_AUDIO); | ||
549 | |||
549 | ci.codec_get_buffer = codec_get_buffer; | 550 | ci.codec_get_buffer = codec_get_buffer; |
550 | 551 | ||
551 | if (wavinfo.fd >= 0 || checksum) { | 552 | if (wavinfo.fd >= 0 || checksum) { |
@@ -560,11 +561,9 @@ static void init_ci(void) | |||
560 | ci.advance_buffer = advance_buffer; | 561 | ci.advance_buffer = advance_buffer; |
561 | ci.seek_buffer = seek_buffer; | 562 | ci.seek_buffer = seek_buffer; |
562 | ci.seek_complete = seek_complete; | 563 | ci.seek_complete = seek_complete; |
563 | ci.request_next_track = request_next_track; | ||
564 | ci.set_offset = set_offset; | 564 | ci.set_offset = set_offset; |
565 | ci.configure = configure; | 565 | ci.configure = configure; |
566 | ci.dsp = (struct dsp_config *)rb->dsp_configure(NULL, DSP_MYDSP, | 566 | ci.get_command = get_command; |
567 | CODEC_IDX_AUDIO); | ||
568 | 567 | ||
569 | /* --- "Core" functions --- */ | 568 | /* --- "Core" functions --- */ |
570 | 569 | ||
@@ -620,20 +619,22 @@ static void init_ci(void) | |||
620 | static void codec_thread(void) | 619 | static void codec_thread(void) |
621 | { | 620 | { |
622 | const char* codecname; | 621 | const char* codecname; |
623 | void *handle; | 622 | int res; |
624 | int res = CODEC_ERROR; | ||
625 | 623 | ||
626 | codecname = rb->get_codec_filename(track.id3.codectype); | 624 | codecname = rb->get_codec_filename(track.id3.codectype); |
627 | 625 | ||
628 | /* Load the codec and start decoding. */ | 626 | /* Load the codec */ |
629 | handle = rb->codec_load_file(codecname,&ci); | 627 | res = rb->codec_load_file(codecname, &ci); |
630 | 628 | ||
631 | if (handle != NULL) | 629 | if (res >= 0) |
632 | { | 630 | { |
633 | res = rb->codec_begin(handle); | 631 | /* Decode the file */ |
634 | rb->codec_close(handle); | 632 | res = rb->codec_run_proc(); |
635 | } | 633 | } |
636 | 634 | ||
635 | /* Clean up */ | ||
636 | rb->codec_close(); | ||
637 | |||
637 | /* Signal to the main thread that we are done */ | 638 | /* Signal to the main thread that we are done */ |
638 | endtick = *rb->current_tick - rebuffertick; | 639 | endtick = *rb->current_tick - rebuffertick; |
639 | codec_playing = false; | 640 | codec_playing = false; |
@@ -705,11 +706,7 @@ static enum plugin_status test_track(const char* filename) | |||
705 | /* Prepare the codec struct for playing the whole file */ | 706 | /* Prepare the codec struct for playing the whole file */ |
706 | ci.filesize = track.filesize; | 707 | ci.filesize = track.filesize; |
707 | ci.id3 = &track.id3; | 708 | ci.id3 = &track.id3; |
708 | ci.taginfo_ready = &taginfo_ready; | ||
709 | ci.curpos = 0; | 709 | ci.curpos = 0; |
710 | ci.stop_codec = false; | ||
711 | ci.new_track = 0; | ||
712 | ci.seek_time = 0; | ||
713 | 710 | ||
714 | if (use_dsp) | 711 | if (use_dsp) |
715 | rb->dsp_configure(ci.dsp, DSP_RESET, 0); | 712 | rb->dsp_configure(ci.dsp, DSP_RESET, 0); |