diff options
Diffstat (limited to 'apps/plugins/metronome.c')
-rw-r--r-- | apps/plugins/metronome.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c index b38f0bbf2c..37a7329b22 100644 --- a/apps/plugins/metronome.c +++ b/apps/plugins/metronome.c | |||
@@ -20,9 +20,8 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "lib/pluginlib_actions.h" | 22 | #include "lib/pluginlib_actions.h" |
23 | #include "lib/pluginlib_exit.h" | ||
24 | |||
25 | 23 | ||
24 | PLUGIN_HEADER | ||
26 | 25 | ||
27 | #if CONFIG_CODEC != SWCODEC | 26 | #if CONFIG_CODEC != SWCODEC |
28 | /* tick sound from a metronome */ | 27 | /* tick sound from a metronome */ |
@@ -847,14 +846,13 @@ void timer_callback(void) | |||
847 | } | 846 | } |
848 | } | 847 | } |
849 | 848 | ||
850 | void cleanup(void) | 849 | void cleanup(void *parameter) |
851 | { | 850 | { |
851 | (void)parameter; | ||
852 | |||
852 | rb->timer_unregister(); | 853 | rb->timer_unregister(); |
853 | MET_PLAY_STOP; /* stop audio ISR */ | 854 | MET_PLAY_STOP; /* stop audio ISR */ |
854 | rb->led(0); | 855 | rb->led(0); |
855 | #if CONFIG_CODEC == SWCODEC | ||
856 | rb->pcm_set_frequency(HW_SAMPR_DEFAULT); | ||
857 | #endif | ||
858 | } | 856 | } |
859 | 857 | ||
860 | void tap(void) | 858 | void tap(void) |
@@ -887,9 +885,9 @@ enum plugin_status plugin_start(const void* parameter) | |||
887 | { | 885 | { |
888 | int button; | 886 | int button; |
889 | static int last_button = BUTTON_NONE; | 887 | static int last_button = BUTTON_NONE; |
888 | enum plugin_status status; | ||
890 | 889 | ||
891 | (void)parameter; | 890 | (void)parameter; |
892 | atexit(cleanup); | ||
893 | 891 | ||
894 | if (MET_IS_PLAYING) | 892 | if (MET_IS_PLAYING) |
895 | MET_PLAY_STOP; /* stop audio IS */ | 893 | MET_PLAY_STOP; /* stop audio IS */ |
@@ -929,7 +927,9 @@ enum plugin_status plugin_start(const void* parameter) | |||
929 | 927 | ||
930 | case METRONOME_QUIT: | 928 | case METRONOME_QUIT: |
931 | /* get out of here */ | 929 | /* get out of here */ |
932 | return PLUGIN_OK; | 930 | cleanup(NULL); |
931 | status = PLUGIN_OK; | ||
932 | goto metronome_exit; | ||
933 | 933 | ||
934 | case METRONOME_PAUSE: | 934 | case METRONOME_PAUSE: |
935 | if(!sound_paused) | 935 | if(!sound_paused) |
@@ -981,7 +981,12 @@ enum plugin_status plugin_start(const void* parameter) | |||
981 | #endif | 981 | #endif |
982 | 982 | ||
983 | default: | 983 | default: |
984 | exit_on_usb(button); | 984 | if (rb->default_event_handler_ex(button, cleanup, NULL) |
985 | == SYS_USB_CONNECTED) | ||
986 | { | ||
987 | status = PLUGIN_USB_CONNECTED; | ||
988 | goto metronome_exit; | ||
989 | } | ||
985 | reset_tap = false; | 990 | reset_tap = false; |
986 | break; | 991 | break; |
987 | 992 | ||
@@ -993,5 +998,11 @@ enum plugin_status plugin_start(const void* parameter) | |||
993 | } | 998 | } |
994 | rb->yield(); | 999 | rb->yield(); |
995 | } | 1000 | } |
1001 | |||
1002 | metronome_exit: | ||
1003 | #if CONFIG_CODEC == SWCODEC | ||
1004 | rb->pcm_set_frequency(HW_SAMPR_DEFAULT); | ||
1005 | #endif | ||
1006 | return status; | ||
996 | } | 1007 | } |
997 | 1008 | ||