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