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) | |
download | rockbox-0569fae8ec2b7138d512aac01f2bfd09c89fdde8.tar.gz rockbox-0569fae8ec2b7138d512aac01f2bfd09c89fdde8.zip |
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[] = { | |||
706 | }; | 706 | }; |
707 | 707 | ||
708 | int tock; | 708 | int tock; |
709 | #if CONFIG_CODEC == SWCODEC | ||
710 | bool need_to_play = false; | ||
711 | #endif | ||
709 | 712 | ||
710 | short sndbuf[sizeof(sound)*2]; | 713 | short sndbuf[sizeof(sound)*2]; |
711 | 714 | ||
@@ -829,7 +832,12 @@ void timer_callback(void) | |||
829 | if(minitick >= period){ | 832 | if(minitick >= period){ |
830 | minitick = 0; | 833 | minitick = 0; |
831 | if(!sound_active && !sound_paused && !tap_count) { | 834 | if(!sound_active && !sound_paused && !tap_count) { |
835 | #if CONFIG_CODEC == SWCODEC | ||
836 | /* On SWCODEC we can't call play_tock() directly from an ISR. */ | ||
837 | need_to_play = true; | ||
838 | #else | ||
832 | play_tock(); | 839 | play_tock(); |
840 | #endif | ||
833 | rb->reset_poweroff_timer(); | 841 | rb->reset_poweroff_timer(); |
834 | } | 842 | } |
835 | } | 843 | } |
@@ -855,7 +863,7 @@ void cleanup(void *parameter) | |||
855 | 863 | ||
856 | void tap(void) | 864 | void tap(void) |
857 | { | 865 | { |
858 | if (tap_count == 0) { | 866 | if (tap_count == 0 || tap_time < tap_count) { |
859 | tap_time = 0; | 867 | tap_time = 0; |
860 | } | 868 | } |
861 | else { | 869 | else { |
@@ -918,9 +926,19 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){ | |||
918 | while (true){ | 926 | while (true){ |
919 | reset_tap = true; | 927 | reset_tap = true; |
920 | 928 | ||
929 | |||
930 | #if CONFIG_CODEC == SWCODEC | ||
931 | button = pluginlib_getaction(rb,1,plugin_contexts,PLA_ARRAY_COUNT); | ||
932 | if (need_to_play) | ||
933 | { | ||
934 | need_to_play = false; | ||
935 | play_tock(); | ||
936 | } | ||
937 | #else | ||
921 | button = pluginlib_getaction(rb,TIMEOUT_BLOCK, | 938 | button = pluginlib_getaction(rb,TIMEOUT_BLOCK, |
922 | plugin_contexts,PLA_ARRAY_COUNT); | 939 | plugin_contexts,PLA_ARRAY_COUNT); |
923 | 940 | #endif | |
941 | |||
924 | switch (button) { | 942 | switch (button) { |
925 | 943 | ||
926 | case METRONOME_QUIT: | 944 | case METRONOME_QUIT: |