From f366090562dcdc1c4c0efbd87476ef6c068b7db5 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Fri, 17 Sep 2010 20:28:47 +0000 Subject: Make disabling HAVE_PITCHSCREEN actually work without breaking the build git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28102 a1c6a512-1295-4272-9138-f99709370657 --- apps/SOURCES | 2 ++ apps/bookmark.c | 10 +++++----- apps/dsp.c | 22 ++++++++++++++++++++++ apps/gui/skin_engine/skin_tokens.c | 6 +++--- apps/main.c | 4 ++-- apps/menus/sound_menu.c | 5 +++++ apps/plugin.c | 4 ++-- apps/plugin.h | 4 ++-- apps/plugins/mpegplayer/audio_thread.c | 2 ++ apps/settings.c | 2 ++ apps/settings.h | 2 ++ apps/settings_list.c | 2 ++ 12 files changed, 51 insertions(+), 14 deletions(-) diff --git a/apps/SOURCES b/apps/SOURCES index 2a13b6245d..ad1003bb0d 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -157,7 +157,9 @@ codec_thread.c playback.c codecs.c dsp.c +#ifdef HAVE_PITCHSCREEN tdspeed.c +#endif #ifdef HAVE_RECORDING enc_config.c recorder/pcm_record.c diff --git a/apps/bookmark.c b/apps/bookmark.c index dc6a09de10..efc43c6270 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c @@ -348,13 +348,13 @@ static char* create_bookmark() snprintf(global_bookmark, sizeof(global_bookmark), /* new optional bookmark token descriptors should be inserted just before the "%s;%s" in this line... */ -#if CONFIG_CODEC == SWCODEC +#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHSCREEN) ">%d;%d;%ld;%d;%ld;%d;%d;%ld;%ld;%s;%s", #else ">%d;%d;%ld;%d;%ld;%d;%d;%s;%s", #endif /* ... their flags should go here ... */ -#if CONFIG_CODEC == SWCODEC +#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHSCREEN) BM_PITCH | BM_SPEED, #else 0, @@ -366,7 +366,7 @@ static char* create_bookmark() global_settings.repeat_mode, global_settings.playlist_shuffle, /* ...and their values should go here */ -#if CONFIG_CODEC == SWCODEC +#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHSCREEN) (long)sound_get_pitch(), (long)dsp_get_timestretch(), #endif @@ -913,7 +913,7 @@ static void say_bookmark(const char* bookmark, /* ------------------------------------------------------------------------*/ static bool play_bookmark(const char* bookmark) { -#if CONFIG_CODEC == SWCODEC +#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHSCREEN) /* preset pitch and speed to 100% in case bookmark doesn't have info */ bm.pitch = sound_get_pitch(); bm.speed = dsp_get_timestretch(); @@ -923,7 +923,7 @@ static bool play_bookmark(const char* bookmark) { global_settings.repeat_mode = bm.repeat_mode; global_settings.playlist_shuffle = bm.shuffle; -#if CONFIG_CODEC == SWCODEC +#if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHSCREEN) sound_set_pitch(bm.pitch); dsp_set_timestretch(bm.speed); #endif diff --git a/apps/dsp.c b/apps/dsp.c index 7292328212..33a54008e2 100644 --- a/apps/dsp.c +++ b/apps/dsp.c @@ -216,7 +216,9 @@ static int treble; /* A/V */ #endif /* Settings applicable to audio codec only */ +#ifdef HAVE_PITCHSCREEN static int32_t pitch_ratio = PITCH_SPEED_100; +#endif static int channels_mode; long dsp_sw_gain; long dsp_sw_cross; @@ -240,12 +242,14 @@ static bool crossfeed_enabled; #define RESAMPLE_RATIO 4 /* Enough for 11,025 Hz -> 44,100 Hz */ +#ifdef HAVE_PITCHSCREEN static int32_t small_sample_buf[SMALL_SAMPLE_BUF_COUNT] IBSS_ATTR; static int32_t small_resample_buf[SMALL_SAMPLE_BUF_COUNT * RESAMPLE_RATIO] IBSS_ATTR; static int32_t *big_sample_buf = NULL; static int32_t *big_resample_buf = NULL; static int big_sample_buf_count = -1; /* -1=unknown, 0=not available */ +#endif static int sample_buf_count; static int32_t *sample_buf; @@ -274,6 +278,7 @@ static inline int32_t clip_sample_16(int32_t sample) return sample; } +#ifdef HAVE_PITCHSCREEN int32_t sound_get_pitch(void) { return pitch_ratio; @@ -347,6 +352,7 @@ bool dsp_timestretch_available() { return (global_settings.timestretch_enabled && big_sample_buf_count > 0); } +#endif /* Convert count samples to the internal format, if needed. Updates src * to point past the samples "consumed" and dst is set to point to the @@ -1225,8 +1231,10 @@ int dsp_process(struct dsp_config *dsp, char *dst, const char *src[], int count) dsp->input_samples(samples, src, tmp); +#ifdef HAVE_PITCHSCREEN if (dsp->tdspeed_active) samples = tdspeed_doit(tmp, samples); +#endif int chunk_offset = 0; while (samples > 0) @@ -1294,8 +1302,10 @@ int dsp_process(struct dsp_config *dsp, char *dst, const char *src[], int count) /* dsp_input_size MUST be called afterwards */ int dsp_output_count(struct dsp_config *dsp, int count) { +#ifdef HAVE_PITCHSCREEN if (dsp->tdspeed_active) count = tdspeed_est_output_size(); +#endif if (dsp->resample) { count = (int)(((unsigned long)count * NATIVE_FREQUENCY @@ -1329,8 +1339,10 @@ int dsp_input_count(struct dsp_config *dsp, int count) dsp->data.resample_data.delta) >> 16); } +#ifdef HAVE_PITCHSCREEN if (dsp->tdspeed_active) count = tdspeed_est_input_size(count); +#endif return count; } @@ -1373,13 +1385,17 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value) if we're called from the main audio thread. Voice UI thread should not need this feature. */ +#ifdef HAVE_PITCHSCREEN if (dsp == &AUDIO_DSP) dsp->frequency = pitch_ratio * dsp->codec_frequency / PITCH_SPEED_100; else +#endif dsp->frequency = dsp->codec_frequency; resampler_new_delta(dsp); +#ifdef HAVE_PITCHSCREEN tdspeed_setup(dsp); +#endif break; case DSP_SET_SAMPLE_DEPTH: @@ -1409,7 +1425,9 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value) dsp->stereo_mode = value; dsp->data.num_channels = value == STEREO_MONO ? 1 : 2; dsp_update_functions(dsp); +#ifdef HAVE_PITCHSCREEN tdspeed_setup(dsp); +#endif break; case DSP_RESET: @@ -1434,7 +1452,9 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value) dsp_update_functions(dsp); resampler_new_delta(dsp); +#ifdef HAVE_PITCHSCREEN tdspeed_setup(dsp); +#endif if (dsp == &AUDIO_DSP) release_gain = UNITY; break; @@ -1444,7 +1464,9 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value) sizeof (dsp->data.resample_data)); resampler_new_delta(dsp); dither_init(dsp); +#ifdef HAVE_PITCHSCREEN tdspeed_setup(dsp); +#endif if (dsp == &AUDIO_DSP) release_gain = UNITY; break; diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index bf024c7e2e..1bfc861624 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -120,7 +120,7 @@ char* get_dir(char* buf, int buf_size, const char* path, int level) return buf; } -#if (CONFIG_CODEC != MAS3507D) +#if (CONFIG_CODEC != MAS3507D) && defined (HAVE_PITCHSCREEN) /* A helper to determine the enum value for pitch/speed. When there are two choices (i.e. boolean), return 1 if the value is @@ -1141,7 +1141,7 @@ const char *get_token_value(struct gui_wps *gwps, } #endif /* (CONFIG_CODEC == SWCODEC) */ -#if (CONFIG_CODEC != MAS3507D) +#if (CONFIG_CODEC != MAS3507D) && defined (HAVE_PITCHSCREEN) case SKIN_TOKEN_SOUND_PITCH: { int32_t pitch = sound_get_pitch(); @@ -1156,7 +1156,7 @@ const char *get_token_value(struct gui_wps *gwps, } #endif -#if CONFIG_CODEC == SWCODEC +#if (CONFIG_CODEC == SWCODEC) && defined (HAVE_PITCHSCREEN) case SKIN_TOKEN_SOUND_SPEED: { int32_t pitch = sound_get_pitch(); diff --git a/apps/main.c b/apps/main.c index b86b083e44..949790b05f 100644 --- a/apps/main.c +++ b/apps/main.c @@ -399,7 +399,7 @@ static void init(void) #endif /* CONFIG_CODEC != SWCODEC */ scrobbler_init(); -#if CONFIG_CODEC == SWCODEC +#if CONFIG_CODEC == SWCODEC && defined (HAVE_PITCHSCREEN) tdspeed_init(); #endif /* CONFIG_CODEC == SWCODEC */ @@ -663,7 +663,7 @@ static void init(void) tree_mem_init(); filetype_init(); scrobbler_init(); -#if CONFIG_CODEC == SWCODEC +#if CONFIG_CODEC == SWCODEC && defined (HAVE_PITCHSCREEN) tdspeed_init(); #endif /* CONFIG_CODEC == SWCODEC */ theme_init_buffer(); diff --git a/apps/menus/sound_menu.c b/apps/menus/sound_menu.c index e9715534c9..9fc10f88b8 100644 --- a/apps/menus/sound_menu.c +++ b/apps/menus/sound_menu.c @@ -104,6 +104,7 @@ MENUITEM_SETTING(depth_3d, &global_settings.depth_3d, NULL); &crossfeed, &crossfeed_direct_gain, &crossfeed_cross_gain, &crossfeed_hf_attenuation, &crossfeed_hf_cutoff); +#ifdef HAVE_PIUTCHSCREEN static int timestretch_callback(int action,const struct menu_item_ex *this_item) { switch (action) @@ -118,6 +119,8 @@ static int timestretch_callback(int action,const struct menu_item_ex *this_item) } MENUITEM_SETTING(timestretch_enabled, &global_settings.timestretch_enabled, timestretch_callback); +#endif + MENUITEM_SETTING(dithering_enabled, &global_settings.dithering_enabled, lowlatency_callback); @@ -178,7 +181,9 @@ MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, Icon_Audio, #endif #if CONFIG_CODEC == SWCODEC ,&crossfeed_menu, &equalizer_menu, &dithering_enabled +#ifdef HAVE_PITCHSCREEN ,×tretch_enabled +#endif ,&compressor_menu #endif #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) diff --git a/apps/plugin.c b/apps/plugin.c index 9b490d0fa9..193d02e034 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -544,8 +544,8 @@ static const struct plugin_api rockbox_api = { #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC) mpeg_get_last_header, #endif -#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \ - (CONFIG_CODEC == SWCODEC) +#if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \ + (CONFIG_CODEC == SWCODEC)) && defined (HAVE_PITCHSCREEN) sound_set_pitch, #endif diff --git a/apps/plugin.h b/apps/plugin.h index 499e1d657d..0b3a5b566f 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -678,8 +678,8 @@ struct plugin_api { #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC) unsigned long (*mpeg_get_last_header)(void); #endif -#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \ - (CONFIG_CODEC == SWCODEC) +#if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \ + (CONFIG_CODEC == SWCODEC)) && defined (HAVE_PITCHSCREEN) void (*sound_set_pitch)(int32_t pitch); #endif diff --git a/apps/plugins/mpegplayer/audio_thread.c b/apps/plugins/mpegplayer/audio_thread.c index 106eac7f9e..9e3968007f 100644 --- a/apps/plugins/mpegplayer/audio_thread.c +++ b/apps/plugins/mpegplayer/audio_thread.c @@ -483,7 +483,9 @@ static void audio_thread(void) td.dsp = (struct dsp_config *)rb->dsp_configure(NULL, DSP_MYDSP, CODEC_IDX_AUDIO); +#ifdef HAVE_PITCHSCREEN rb->sound_set_pitch(PITCH_SPEED_100); +#endif rb->dsp_configure(td.dsp, DSP_RESET, 0); rb->dsp_configure(td.dsp, DSP_SET_SAMPLE_DEPTH, MAD_F_FRACBITS); diff --git a/apps/settings.c b/apps/settings.c index 3b12274eae..7b0707b2f1 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -992,7 +992,9 @@ void settings_apply(bool read_disk) } dsp_dither_enable(global_settings.dithering_enabled); +#ifdef HAVE_PITCHSCREEN dsp_timestretch_enable(global_settings.timestretch_enabled); +#endif dsp_set_compressor(global_settings.compressor_threshold, global_settings.compressor_makeup_gain, global_settings.compressor_ratio, diff --git a/apps/settings.h b/apps/settings.h index 24ff9ef62a..443369b77e 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -364,7 +364,9 @@ struct user_settings int keyclick; /* keyclick volume */ int keyclick_repeats; /* keyclick on repeats */ bool dithering_enabled; +#ifdef HAVE_PITCHSCREEN bool timestretch_enabled; +#endif #endif /* CONFIG_CODEC == SWCODEC */ #ifdef HAVE_RECORDING diff --git a/apps/settings_list.c b/apps/settings_list.c index 07450661c2..a8c3c36651 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -1371,9 +1371,11 @@ const struct settings_list settings[] = { OFFON_SETTING(F_SOUNDSETTING, dithering_enabled, LANG_DITHERING, false, "dithering enabled", dsp_dither_enable), +#ifdef HAVE_PITCHSCREEN /* timestretch */ OFFON_SETTING(F_SOUNDSETTING, timestretch_enabled, LANG_TIMESTRETCH, false, "timestretch enabled", dsp_timestretch_enable), +#endif /* compressor */ INT_SETTING_NOWRAP(F_SOUNDSETTING, compressor_threshold, -- cgit v1.2.3