From 0569fae8ec2b7138d512aac01f2bfd09c89fdde8 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Thu, 12 Apr 2007 17:58:42 +0000 Subject: Fix metronome plugin crashing on SWCODEC targets and fixed a division by zero as well when tapping in the beat. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13129 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/metronome.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c index 3361ce32bc..712731462a 100644 --- a/apps/plugins/metronome.c +++ b/apps/plugins/metronome.c @@ -706,6 +706,9 @@ static signed short sound[] = { }; int tock; +#if CONFIG_CODEC == SWCODEC +bool need_to_play = false; +#endif short sndbuf[sizeof(sound)*2]; @@ -829,7 +832,12 @@ void timer_callback(void) if(minitick >= period){ minitick = 0; if(!sound_active && !sound_paused && !tap_count) { +#if CONFIG_CODEC == SWCODEC + /* On SWCODEC we can't call play_tock() directly from an ISR. */ + need_to_play = true; +#else play_tock(); +#endif rb->reset_poweroff_timer(); } } @@ -855,7 +863,7 @@ void cleanup(void *parameter) void tap(void) { - if (tap_count == 0) { + if (tap_count == 0 || tap_time < tap_count) { tap_time = 0; } else { @@ -918,9 +926,19 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){ while (true){ reset_tap = true; + +#if CONFIG_CODEC == SWCODEC + button = pluginlib_getaction(rb,1,plugin_contexts,PLA_ARRAY_COUNT); + if (need_to_play) + { + need_to_play = false; + play_tock(); + } +#else button = pluginlib_getaction(rb,TIMEOUT_BLOCK, plugin_contexts,PLA_ARRAY_COUNT); - +#endif + switch (button) { case METRONOME_QUIT: -- cgit v1.2.3