diff options
Diffstat (limited to 'apps/plugins/test_codec.c')
-rw-r--r-- | apps/plugins/test_codec.c | 60 |
1 files changed, 4 insertions, 56 deletions
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index 17effd8dfd..20a1febd4f 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c | |||
@@ -513,9 +513,6 @@ static void codec_thread(void) | |||
513 | codec_playing = false; | 513 | codec_playing = false; |
514 | } | 514 | } |
515 | 515 | ||
516 | static uintptr_t* codec_stack; | ||
517 | static size_t codec_stack_size; | ||
518 | |||
519 | static enum plugin_status test_track(const char* filename) | 516 | static enum plugin_status test_track(const char* filename) |
520 | { | 517 | { |
521 | size_t n; | 518 | size_t n; |
@@ -525,7 +522,6 @@ static enum plugin_status test_track(const char* filename) | |||
525 | long ticks; | 522 | long ticks; |
526 | unsigned long speed; | 523 | unsigned long speed; |
527 | unsigned long duration; | 524 | unsigned long duration; |
528 | unsigned int codecthread_id; | ||
529 | const char* ch; | 525 | const char* ch; |
530 | 526 | ||
531 | /* Display filename (excluding any path)*/ | 527 | /* Display filename (excluding any path)*/ |
@@ -588,13 +584,7 @@ static enum plugin_status test_track(const char* filename) | |||
588 | 584 | ||
589 | codec_playing = true; | 585 | codec_playing = true; |
590 | 586 | ||
591 | if ((codecthread_id = rb->create_thread(codec_thread, | 587 | rb->codec_thread_do_callback(codec_thread, NULL); |
592 | codec_stack, codec_stack_size, 0, "testcodec" | ||
593 | IF_PRIO(,PRIORITY_PLAYBACK) IF_COP(, CPU))) == 0) | ||
594 | { | ||
595 | log_text("Cannot create codec thread!",true); | ||
596 | goto exit; | ||
597 | } | ||
598 | 588 | ||
599 | /* Wait for codec thread to die */ | 589 | /* Wait for codec thread to die */ |
600 | while (codec_playing) | 590 | while (codec_playing) |
@@ -606,7 +596,7 @@ static enum plugin_status test_track(const char* filename) | |||
606 | ticks = endtick - starttick; | 596 | ticks = endtick - starttick; |
607 | 597 | ||
608 | /* Be sure it is done */ | 598 | /* Be sure it is done */ |
609 | rb->thread_wait(codecthread_id); | 599 | rb->codec_thread_do_callback(NULL, NULL); |
610 | 600 | ||
611 | log_text(str,true); | 601 | log_text(str,true); |
612 | 602 | ||
@@ -656,11 +646,9 @@ exit: | |||
656 | /* plugin entry point */ | 646 | /* plugin entry point */ |
657 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 647 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) |
658 | { | 648 | { |
659 | uintptr_t* codec_stack_copy; | ||
660 | int result, selection = 0; | 649 | int result, selection = 0; |
661 | enum plugin_status res = PLUGIN_OK; | 650 | enum plugin_status res = PLUGIN_OK; |
662 | int scandir; | 651 | int scandir; |
663 | int i; | ||
664 | struct dirent *entry; | 652 | struct dirent *entry; |
665 | DIR* dir; | 653 | DIR* dir; |
666 | char* ch; | 654 | char* ch; |
@@ -676,43 +664,8 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
676 | } | 664 | } |
677 | 665 | ||
678 | codec_mallocbuf = rb->plugin_get_audio_buffer(&audiosize); | 666 | codec_mallocbuf = rb->plugin_get_audio_buffer(&audiosize); |
679 | 667 | audiobuf = SKIPBYTES(codec_mallocbuf, CODEC_SIZE); | |
680 | #ifdef SIMULATOR | 668 | audiosize -= CODEC_SIZE; |
681 | /* The simulator thread implementation doesn't have stack buffers */ | ||
682 | (void)i; | ||
683 | codec_stack_size = 0; | ||
684 | #else | ||
685 | /* Borrow the codec thread's stack (in IRAM on most targets) */ | ||
686 | codec_stack = NULL; | ||
687 | for (i = 0; i < MAXTHREADS; i++) | ||
688 | { | ||
689 | if (rb->strcmp(rb->threads[i].name,"codec")==0) | ||
690 | { | ||
691 | /* Wait to ensure the codec thread has blocked */ | ||
692 | while (rb->threads[i].state!=STATE_BLOCKED) | ||
693 | rb->yield(); | ||
694 | |||
695 | codec_stack = rb->threads[i].stack; | ||
696 | codec_stack_size = rb->threads[i].stack_size; | ||
697 | break; | ||
698 | } | ||
699 | } | ||
700 | |||
701 | if (codec_stack == NULL) | ||
702 | { | ||
703 | rb->splash(HZ*2, "No codec thread!"); | ||
704 | return PLUGIN_ERROR; | ||
705 | } | ||
706 | #endif | ||
707 | |||
708 | codec_stack_copy = codec_mallocbuf + CODEC_SIZE; | ||
709 | audiobuf = SKIPBYTES(codec_stack_copy, codec_stack_size); | ||
710 | audiosize -= CODEC_SIZE + codec_stack_size; | ||
711 | |||
712 | #ifndef SIMULATOR | ||
713 | /* Backup the codec thread's stack */ | ||
714 | rb->memcpy(codec_stack_copy,codec_stack,codec_stack_size); | ||
715 | #endif | ||
716 | 669 | ||
717 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 670 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
718 | rb->cpu_boost(true); | 671 | rb->cpu_boost(true); |
@@ -803,11 +756,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
803 | exit: | 756 | exit: |
804 | log_close(); | 757 | log_close(); |
805 | 758 | ||
806 | #ifndef SIMULATOR | ||
807 | /* Restore the codec thread's stack */ | ||
808 | rb->memcpy(codec_stack, codec_stack_copy, codec_stack_size); | ||
809 | #endif | ||
810 | |||
811 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 759 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
812 | rb->cpu_boost(false); | 760 | rb->cpu_boost(false); |
813 | #endif | 761 | #endif |