diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2009-01-05 10:31:19 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2009-01-05 10:31:19 +0000 |
commit | 2054627caa7f71c564ce35b4525b6281fcd2cc39 (patch) | |
tree | 2b0aa3b9b8888c4746b75d4750d90f79552159ee /apps/plugins/test_codec.c | |
parent | 45aa9a22f9a3e08505cc2f2999459d249356ed9c (diff) | |
download | rockbox-2054627caa7f71c564ce35b4525b6281fcd2cc39.tar.gz rockbox-2054627caa7f71c564ce35b4525b6281fcd2cc39.zip |
Have the codec thread do callbacks instead of messing with the stack which is much simpler and safer. Remove threads array from plugin API since it now serves no purpose. Up minimum API version and sort.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19684 a1c6a512-1295-4272-9138-f99709370657
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 |