diff --git a/apps/SOURCES b/apps/SOURCES index c93c5bcc1f..e27e15d749 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -10,6 +10,7 @@ filetypes.c language.c main.c menu.c +menus/menu_common.c menus/display_menu.c menus/theme_menu.c #if CONFIG_CODEC == SWCODEC diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c index 1dbb5541c5..2337b32e6d 100644 --- a/apps/menus/eq_menu.c +++ b/apps/menus/eq_menu.c @@ -46,6 +46,7 @@ #include "keyboard.h" #include "gui/scrollbar.h" #include "eq_menu.h" +#include "menu_common.h" /* * Utility functions @@ -615,8 +616,7 @@ MENUITEM_FUNCTION(eq_save, 0, ID2P(LANG_EQUALIZER_SAVE), MENUITEM_FUNCTION(eq_browse, 0, ID2P(LANG_EQUALIZER_BROWSE), (int(*)(void))eq_browse_presets, NULL, NULL, Icon_NOICON); -int soundmenu_callback(int action,const struct menu_item_ex *this_item); -MAKE_MENU(equalizer_menu, ID2P(LANG_EQUALIZER), soundmenu_callback, Icon_EQ, +MAKE_MENU(equalizer_menu, ID2P(LANG_EQUALIZER), lowlatency_callback, Icon_EQ, &eq_enable, &eq_graphical, &eq_precut, &gain_menu, &advanced_eq_menu_, &eq_save, &eq_browse); diff --git a/apps/menus/menu_common.c b/apps/menus/menu_common.c new file mode 100644 index 0000000000..2f3844c1ea --- /dev/null +++ b/apps/menus/menu_common.c @@ -0,0 +1,47 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Dan Everton + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include +#include +#include "config.h" +#include "action.h" +#include "menu.h" +#include "menu_common.h" +#if CONFIG_CODEC == SWCODEC +#include "pcmbuf.h" +#endif + +#if CONFIG_CODEC == SWCODEC +/* Use this callback if your menu adjusts DSP settings. */ +int lowlatency_callback(int action, const struct menu_item_ex *this_item) +{ + (void)this_item; + switch (action) + { + case ACTION_ENTER_MENUITEM: /* on entering an item */ + pcmbuf_set_low_latency(true); + break; + case ACTION_EXIT_MENUITEM: /* on exit */ + pcmbuf_set_low_latency(false); + break; + } + return action; +} +#endif + diff --git a/apps/menus/menu_common.h b/apps/menus/menu_common.h new file mode 100644 index 0000000000..1f835ce72c --- /dev/null +++ b/apps/menus/menu_common.h @@ -0,0 +1,30 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Dan Everton + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef _MENU_COMMON_H +#define _MENU_COMMON_H + +#include "menu.h" +#include "config.h" + +#if CONFIG_CODEC == SWCODEC +int lowlatency_callback(int action, const struct menu_item_ex *this_item); +#endif + +#endif /* _MENU_COMMON_H */ + diff --git a/apps/menus/sound_menu.c b/apps/menus/sound_menu.c index 127b01d342..315fef81b3 100644 --- a/apps/menus/sound_menu.c +++ b/apps/menus/sound_menu.c @@ -32,60 +32,64 @@ #include "pcmbuf.h" #endif #include "exported_menus.h" +#include "menu_common.h" /***********************************/ /* SOUND MENU */ -#if CONFIG_CODEC == SWCODEC -/* This callback is also used in the eq menu to toggle low latency mode. - So, remember this if the callback is used for anything other than the togging */ -int soundmenu_callback(int action, const struct menu_item_ex *this_item) -{ - (void)this_item; - switch (action) - { - case ACTION_ENTER_MENUITEM: /* on entering an item */ - pcmbuf_set_low_latency(true); - break; - case ACTION_EXIT_MENUITEM: /* on exit */ - pcmbuf_set_low_latency(false); - break; - } - return action; -} +MENUITEM_SETTING(volume, &global_settings.volume, NULL); +MENUITEM_SETTING(bass, &global_settings.bass, +#ifdef HAVE_SW_TONE_CONTROLS + lowlatency_callback #else -#define soundmenu_callback NULL + NULL #endif - -MENUITEM_SETTING(volume, &global_settings.volume, soundmenu_callback); -MENUITEM_SETTING(bass, &global_settings.bass, soundmenu_callback); +); #ifdef HAVE_WM8758 -MENUITEM_SETTING(bass_cutoff, &global_settings.bass_cutoff, soundmenu_callback); +MENUITEM_SETTING(bass_cutoff, &global_settings.bass_cutoff, NULL); #endif -MENUITEM_SETTING(treble, &global_settings.treble, soundmenu_callback); +MENUITEM_SETTING(treble, &global_settings.treble, +#ifdef HAVE_SW_TONE_CONTROLS + lowlatency_callback +#else + NULL +#endif +); #ifdef HAVE_WM8758 -MENUITEM_SETTING(treble_cutoff, &global_settings.treble_cutoff, soundmenu_callback); +MENUITEM_SETTING(treble_cutoff, &global_settings.treble_cutoff, NULL); #endif -MENUITEM_SETTING(balance, &global_settings.balance, soundmenu_callback); -MENUITEM_SETTING(channel_config, &global_settings.channel_config, soundmenu_callback); -MENUITEM_SETTING(stereo_width, &global_settings.stereo_width, soundmenu_callback); +MENUITEM_SETTING(balance, &global_settings.balance, NULL); +MENUITEM_SETTING(channel_config, &global_settings.channel_config, +#if CONFIG_CODEC == SWCODEC + lowlatency_callback +#else + NULL +#endif +); +MENUITEM_SETTING(stereo_width, &global_settings.stereo_width, +#if CONFIG_CODEC == SWCODEC + lowlatency_callback +#else + NULL +#endif +); #if CONFIG_CODEC == SWCODEC /* Crossfeed Submenu */ - MENUITEM_SETTING(crossfeed, &global_settings.crossfeed, soundmenu_callback); + MENUITEM_SETTING(crossfeed, &global_settings.crossfeed, lowlatency_callback); MENUITEM_SETTING(crossfeed_direct_gain, - &global_settings.crossfeed_direct_gain, soundmenu_callback); + &global_settings.crossfeed_direct_gain, lowlatency_callback); MENUITEM_SETTING(crossfeed_cross_gain, - &global_settings.crossfeed_cross_gain, soundmenu_callback); + &global_settings.crossfeed_cross_gain, lowlatency_callback); MENUITEM_SETTING(crossfeed_hf_attenuation, - &global_settings.crossfeed_hf_attenuation, soundmenu_callback); + &global_settings.crossfeed_hf_attenuation, lowlatency_callback); MENUITEM_SETTING(crossfeed_hf_cutoff, - &global_settings.crossfeed_hf_cutoff, soundmenu_callback); + &global_settings.crossfeed_hf_cutoff, lowlatency_callback); MAKE_MENU(crossfeed_menu,ID2P(LANG_CROSSFEED), NULL, Icon_NOICON, &crossfeed, &crossfeed_direct_gain, &crossfeed_cross_gain, &crossfeed_hf_attenuation, &crossfeed_hf_cutoff); MENUITEM_SETTING(dithering_enabled, - &global_settings.dithering_enabled, soundmenu_callback); + &global_settings.dithering_enabled, lowlatency_callback); #endif #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)