From 6469926b889f1533134233c63c894ac471f2f53c Mon Sep 17 00:00:00 2001 From: Michael Giacomelli Date: Tue, 11 Aug 2009 02:05:38 +0000 Subject: FS#10506. Don't compile various crossfade only functions in pcmbuf.c on low memory targets (mainly AMS) to save memory. Some crossfade related items remain in the code, but they're not worth cluttering the code with ifdefs over. Also, introduce HAVE_CROSSFADE define for neatness. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22248 a1c6a512-1295-4272-9138-f99709370657 --- apps/menus/playback_menu.c | 4 ++-- apps/pcmbuf.c | 13 ++++++++++++- apps/settings_list.c | 2 +- firmware/export/config.h | 5 +++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/apps/menus/playback_menu.c b/apps/menus/playback_menu.c index e6298b95bb..d7f9aeef56 100644 --- a/apps/menus/playback_menu.c +++ b/apps/menus/playback_menu.c @@ -102,7 +102,7 @@ MENUITEM_SETTING(crossfade_fade_out_duration, &global_settings.crossfade_fade_out_duration, setcrossfadeonexit_callback); MENUITEM_SETTING(crossfade_fade_out_mixmode, &global_settings.crossfade_fade_out_mixmode,NULL); -#if MEMORYSIZE > 2 +#ifdef HAVE_CROSSFADE MAKE_MENU(crossfade_settings_menu,ID2P(LANG_CROSSFADE),0, Icon_NOICON, &crossfade, &crossfade_fade_in_delay, &crossfade_fade_in_duration, &crossfade_fade_out_delay, &crossfade_fade_out_duration, @@ -187,7 +187,7 @@ MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0, #endif &fade_on_stop, &party_mode, -#if CONFIG_CODEC == SWCODEC && MEMORYSIZE > 2 +#if CONFIG_CODEC == SWCODEC && defined(HAVE_CROSSFADE) &crossfade_settings_menu, &replaygain_settings_menu, &beep, #endif diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index b8d8a0c8d0..e23f6d0fb6 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c @@ -91,11 +91,13 @@ static bool crossfade_init IDATA_ATTR; /* Track the current location for processing crossfade */ static struct pcmbufdesc *crossfade_chunk IDATA_ATTR; +#ifdef HAVE_CROSSFADE static size_t crossfade_sample IDATA_ATTR; /* Counters for fading in new data */ static size_t crossfade_fade_in_total IDATA_ATTR; static size_t crossfade_fade_in_rem IDATA_ATTR; +#endif static struct pcmbufdesc *pcmbuf_read IDATA_ATTR; static struct pcmbufdesc *pcmbuf_read_end IDATA_ATTR; @@ -543,6 +545,11 @@ static bool pcmbuf_flush_fillpos(void) return false; } +/** + * Low memory targets don't have crossfade, so don't compile crossfade + * specific code in order to save some memory. */ + +#ifdef HAVE_CROSSFADE /** * Completely process the crossfade fade out effect with current pcm buffer. */ @@ -824,6 +831,7 @@ fade_done: } } +#endif static bool prepare_insert(size_t length) { @@ -862,8 +870,10 @@ static bool prepare_insert(size_t length) void* pcmbuf_request_buffer(int *count) { +#ifdef HAVE_CROSSFADE if (crossfade_init) crossfade_start(); +#endif if (crossfade_active) { *count = MIN(*count, PCMBUF_MIX_CHUNK/4); @@ -929,7 +939,7 @@ bool pcmbuf_is_crossfade_active(void) void pcmbuf_write_complete(int count) { size_t length = (size_t)(unsigned int)count << 2; - +#ifdef HAVE_CROSSFADE if (crossfade_active) { flush_crossfade(fadebuf, length); @@ -937,6 +947,7 @@ void pcmbuf_write_complete(int count) crossfade_active = false; } else +#endif { audiobuffer_fillpos += length; diff --git a/apps/settings_list.c b/apps/settings_list.c index 71fbecc621..c03731f2b7 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -1129,7 +1129,7 @@ const struct settings_list settings[] = { NULL, 4, ID2P(LANG_OFF), ID2P(LANG_WEAK), ID2P(LANG_MODERATE), ID2P(LANG_STRONG)), -#if MEMORYSIZE > 2 +#ifdef HAVE_CROSSFADE /* crossfade */ CHOICE_SETTING(F_SOUNDSETTING, crossfade, LANG_CROSSFADE_ENABLE, 0, "crossfade", diff --git a/firmware/export/config.h b/firmware/export/config.h index 0082f3ab31..8871abcb88 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -139,6 +139,11 @@ * for example in hardware, but not controllable*/ #define BACKLIGHT_FADING_TARGET 0x8 +/*include support for crossfading - requires significant PCM buffer space*/ +#if MEMORYSIZE > 2 +#define HAVE_CROSSFADE +#endif + /* CONFIG_CHARGING */ /* Generic types */ -- cgit v1.2.3