From 5663e1cd0afc62e212c43c8fb374c791d554fb1b Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Fri, 8 Jul 2011 22:31:15 +0000 Subject: Have mpegplayer use the mixer (the playback channel, since it's mutually exclusive to audio playback) so the clicks and skip beep can be used according to user settings. Introduce some system sound functions to make easier playing event sounds from various places and convert files calling 'beep_play' to use 'system_sound_play' and 'keyclick_click'. Event sound could be become themeable. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30130 a1c6a512-1295-4272-9138-f99709370657 --- apps/misc.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'apps/misc.c') diff --git a/apps/misc.c b/apps/misc.c index dfee05fb5a..1800342a50 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -1037,3 +1037,51 @@ enum current_activity get_current_activity(void) return current_activity[current_activity_top?current_activity_top-1:0]; } +#if CONFIG_CODEC == SWCODEC +/* Play a standard sound */ +void system_sound_play(enum system_sound sound) +{ + static const struct beep_params + { + int *setting; + unsigned short frequency; + unsigned short duration; + unsigned short amplitude; + } beep_params[] = + { + [SOUND_KEYCLICK] = + { &global_settings.keyclick, + 4000, KEYCLICK_DURATION, 2500 }, + [SOUND_TRACK_SKIP] = + { &global_settings.beep, + 2000, 100, 2500 }, + [SOUND_TRACK_NO_MORE] = + { &global_settings.beep, + 1000, 100, 1500 }, + }; + + const struct beep_params *params = &beep_params[sound]; + + if (*params->setting) + { + beep_play(params->frequency, params->duration, + params->amplitude * *params->setting); + } +} + +/* Produce keyclick based upon button and global settings */ +void keyclick_click(int button) +{ + /* Settings filters */ + if (global_settings.keyclick && + (global_settings.keyclick_repeats || !(button & BUTTON_REPEAT))) + { + /* Button filters */ + if (button != BUTTON_NONE && !(button & BUTTON_REL) + && !(button & (SYS_EVENT|BUTTON_MULTIMEDIA)) ) + { + system_sound_play(SOUND_KEYCLICK); + } + } +} +#endif /* CONFIG_CODEC == SWCODEC */ -- cgit v1.2.3