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
This commit is contained in:
Frank Gevaerts 2010-09-17 20:28:47 +00:00
parent bd43690170
commit f366090562
12 changed files with 51 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -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
,&timestretch_enabled
#endif
,&compressor_menu
#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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,

View File

@ -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

View File

@ -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,