diff options
-rw-r--r-- | apps/plugins/test_codec.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index 4bde1ba39d..5c9820109f 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c | |||
@@ -135,6 +135,7 @@ static uint32_t crc32; | |||
135 | 135 | ||
136 | static volatile unsigned int elapsed; | 136 | static volatile unsigned int elapsed; |
137 | static volatile bool codec_playing; | 137 | static volatile bool codec_playing; |
138 | static volatile enum codec_command_action codec_action; | ||
138 | static volatile long endtick; | 139 | static volatile long endtick; |
139 | static volatile long rebuffertick; | 140 | static volatile long rebuffertick; |
140 | struct wavinfo_t wavinfo; | 141 | struct wavinfo_t wavinfo; |
@@ -504,7 +505,7 @@ static void seek_complete(void) | |||
504 | static enum codec_command_action get_command(intptr_t *param) | 505 | static enum codec_command_action get_command(intptr_t *param) |
505 | { | 506 | { |
506 | rb->yield(); | 507 | rb->yield(); |
507 | return CODEC_ACTION_NULL; /* just continue processing */ | 508 | return codec_action; |
508 | (void)param; | 509 | (void)param; |
509 | } | 510 | } |
510 | 511 | ||
@@ -718,13 +719,19 @@ static enum plugin_status test_track(const char* filename) | |||
718 | starttick = *rb->current_tick; | 719 | starttick = *rb->current_tick; |
719 | 720 | ||
720 | codec_playing = true; | 721 | codec_playing = true; |
722 | codec_action = CODEC_ACTION_NULL; | ||
721 | 723 | ||
722 | rb->codec_thread_do_callback(codec_thread, NULL); | 724 | rb->codec_thread_do_callback(codec_thread, NULL); |
723 | 725 | ||
724 | /* Wait for codec thread to die */ | 726 | /* Wait for codec thread to die */ |
725 | while (codec_playing) | 727 | while (codec_playing) |
726 | { | 728 | { |
727 | rb->sleep(HZ); | 729 | if (rb->button_get_w_tmo(HZ) == TESTCODEC_EXITBUTTON) |
730 | { | ||
731 | codec_action = CODEC_ACTION_HALT; | ||
732 | break; | ||
733 | } | ||
734 | |||
728 | rb->snprintf(str,sizeof(str),"%d of %d",elapsed,(int)track.id3.length); | 735 | rb->snprintf(str,sizeof(str),"%d of %d",elapsed,(int)track.id3.length); |
729 | log_text(str,false); | 736 | log_text(str,false); |
730 | } | 737 | } |
@@ -734,8 +741,12 @@ static enum plugin_status test_track(const char* filename) | |||
734 | rb->codec_thread_do_callback(NULL, NULL); | 741 | rb->codec_thread_do_callback(NULL, NULL); |
735 | rb->backlight_on(); | 742 | rb->backlight_on(); |
736 | log_text(str,true); | 743 | log_text(str,true); |
737 | 744 | ||
738 | if (checksum) | 745 | if (codec_action == CODEC_ACTION_HALT) |
746 | { | ||
747 | /* User aborted test */ | ||
748 | } | ||
749 | else if (checksum) | ||
739 | { | 750 | { |
740 | rb->snprintf(str, sizeof(str), "CRC32 - %08x", (unsigned)crc32); | 751 | rb->snprintf(str, sizeof(str), "CRC32 - %08x", (unsigned)crc32); |
741 | log_text(str,true); | 752 | log_text(str,true); |
@@ -940,6 +951,10 @@ menu: | |||
940 | if (!(info.attribute & ATTR_DIRECTORY)) { | 951 | if (!(info.attribute & ATTR_DIRECTORY)) { |
941 | rb->snprintf(filename,sizeof(filename),"%s%s",dirpath,entry->d_name); | 952 | rb->snprintf(filename,sizeof(filename),"%s%s",dirpath,entry->d_name); |
942 | test_track(filename); | 953 | test_track(filename); |
954 | |||
955 | if (codec_action == CODEC_ACTION_HALT) | ||
956 | break; | ||
957 | |||
943 | log_text("", true); | 958 | log_text("", true); |
944 | } | 959 | } |
945 | 960 | ||
@@ -958,7 +973,9 @@ menu: | |||
958 | close_wav(); | 973 | close_wav(); |
959 | log_text("Wrote /test.wav",true); | 974 | log_text("Wrote /test.wav",true); |
960 | } | 975 | } |
961 | while (rb->button_get(true) != TESTCODEC_EXITBUTTON); | 976 | |
977 | while (codec_action != CODEC_ACTION_HALT && | ||
978 | rb->button_get(true) != TESTCODEC_EXITBUTTON); | ||
962 | } | 979 | } |
963 | 980 | ||
964 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 981 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |