diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2007-04-12 17:58:42 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2007-04-12 17:58:42 +0000 |
commit | 0569fae8ec2b7138d512aac01f2bfd09c89fdde8 (patch) | |
tree | 9f96ea66e3ff37824994f4e8571a3ca7688355cc /apps/plugins/metronome.c | |
parent | dbcd32181325c06d87056e82cbe2a0659063c93c (diff) |
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
Diffstat (limited to 'apps/plugins/metronome.c')
-rw-r--r-- | apps/plugins/metronome.c | 22 |
1 files changed, 20 insertions, 2 deletions
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: |