1
0
Fork 0
forked from len0rd/rockbox

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 playback.c
codecs.c codecs.c
dsp.c dsp.c
#ifdef HAVE_PITCHSCREEN
tdspeed.c tdspeed.c
#endif
#ifdef HAVE_RECORDING #ifdef HAVE_RECORDING
enc_config.c enc_config.c
recorder/pcm_record.c recorder/pcm_record.c

View file

@ -348,13 +348,13 @@ static char* create_bookmark()
snprintf(global_bookmark, sizeof(global_bookmark), snprintf(global_bookmark, sizeof(global_bookmark),
/* new optional bookmark token descriptors should be inserted /* new optional bookmark token descriptors should be inserted
just before the "%s;%s" in this line... */ 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", ">%d;%d;%ld;%d;%ld;%d;%d;%ld;%ld;%s;%s",
#else #else
">%d;%d;%ld;%d;%ld;%d;%d;%s;%s", ">%d;%d;%ld;%d;%ld;%d;%d;%s;%s",
#endif #endif
/* ... their flags should go here ... */ /* ... their flags should go here ... */
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHSCREEN)
BM_PITCH | BM_SPEED, BM_PITCH | BM_SPEED,
#else #else
0, 0,
@ -366,7 +366,7 @@ static char* create_bookmark()
global_settings.repeat_mode, global_settings.repeat_mode,
global_settings.playlist_shuffle, global_settings.playlist_shuffle,
/* ...and their values should go here */ /* ...and their values should go here */
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHSCREEN)
(long)sound_get_pitch(), (long)sound_get_pitch(),
(long)dsp_get_timestretch(), (long)dsp_get_timestretch(),
#endif #endif
@ -913,7 +913,7 @@ static void say_bookmark(const char* bookmark,
/* ------------------------------------------------------------------------*/ /* ------------------------------------------------------------------------*/
static bool play_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 */ /* preset pitch and speed to 100% in case bookmark doesn't have info */
bm.pitch = sound_get_pitch(); bm.pitch = sound_get_pitch();
bm.speed = dsp_get_timestretch(); 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.repeat_mode = bm.repeat_mode;
global_settings.playlist_shuffle = bm.shuffle; global_settings.playlist_shuffle = bm.shuffle;
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC && defined(HAVE_PITCHSCREEN)
sound_set_pitch(bm.pitch); sound_set_pitch(bm.pitch);
dsp_set_timestretch(bm.speed); dsp_set_timestretch(bm.speed);
#endif #endif

View file

@ -216,7 +216,9 @@ static int treble; /* A/V */
#endif #endif
/* Settings applicable to audio codec only */ /* Settings applicable to audio codec only */
#ifdef HAVE_PITCHSCREEN
static int32_t pitch_ratio = PITCH_SPEED_100; static int32_t pitch_ratio = PITCH_SPEED_100;
#endif
static int channels_mode; static int channels_mode;
long dsp_sw_gain; long dsp_sw_gain;
long dsp_sw_cross; long dsp_sw_cross;
@ -240,12 +242,14 @@ static bool crossfeed_enabled;
#define RESAMPLE_RATIO 4 /* Enough for 11,025 Hz -> 44,100 Hz */ #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_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 small_resample_buf[SMALL_SAMPLE_BUF_COUNT * RESAMPLE_RATIO] IBSS_ATTR;
static int32_t *big_sample_buf = NULL; static int32_t *big_sample_buf = NULL;
static int32_t *big_resample_buf = NULL; static int32_t *big_resample_buf = NULL;
static int big_sample_buf_count = -1; /* -1=unknown, 0=not available */ static int big_sample_buf_count = -1; /* -1=unknown, 0=not available */
#endif
static int sample_buf_count; static int sample_buf_count;
static int32_t *sample_buf; static int32_t *sample_buf;
@ -274,6 +278,7 @@ static inline int32_t clip_sample_16(int32_t sample)
return sample; return sample;
} }
#ifdef HAVE_PITCHSCREEN
int32_t sound_get_pitch(void) int32_t sound_get_pitch(void)
{ {
return pitch_ratio; return pitch_ratio;
@ -347,6 +352,7 @@ bool dsp_timestretch_available()
{ {
return (global_settings.timestretch_enabled && big_sample_buf_count > 0); return (global_settings.timestretch_enabled && big_sample_buf_count > 0);
} }
#endif
/* Convert count samples to the internal format, if needed. Updates src /* 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 * 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); dsp->input_samples(samples, src, tmp);
#ifdef HAVE_PITCHSCREEN
if (dsp->tdspeed_active) if (dsp->tdspeed_active)
samples = tdspeed_doit(tmp, samples); samples = tdspeed_doit(tmp, samples);
#endif
int chunk_offset = 0; int chunk_offset = 0;
while (samples > 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 */ /* dsp_input_size MUST be called afterwards */
int dsp_output_count(struct dsp_config *dsp, int count) int dsp_output_count(struct dsp_config *dsp, int count)
{ {
#ifdef HAVE_PITCHSCREEN
if (dsp->tdspeed_active) if (dsp->tdspeed_active)
count = tdspeed_est_output_size(); count = tdspeed_est_output_size();
#endif
if (dsp->resample) if (dsp->resample)
{ {
count = (int)(((unsigned long)count * NATIVE_FREQUENCY 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); dsp->data.resample_data.delta) >> 16);
} }
#ifdef HAVE_PITCHSCREEN
if (dsp->tdspeed_active) if (dsp->tdspeed_active)
count = tdspeed_est_input_size(count); count = tdspeed_est_input_size(count);
#endif
return count; 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 if we're called from the main audio thread. Voice UI thread should
not need this feature. not need this feature.
*/ */
#ifdef HAVE_PITCHSCREEN
if (dsp == &AUDIO_DSP) if (dsp == &AUDIO_DSP)
dsp->frequency = pitch_ratio * dsp->codec_frequency / PITCH_SPEED_100; dsp->frequency = pitch_ratio * dsp->codec_frequency / PITCH_SPEED_100;
else else
#endif
dsp->frequency = dsp->codec_frequency; dsp->frequency = dsp->codec_frequency;
resampler_new_delta(dsp); resampler_new_delta(dsp);
#ifdef HAVE_PITCHSCREEN
tdspeed_setup(dsp); tdspeed_setup(dsp);
#endif
break; break;
case DSP_SET_SAMPLE_DEPTH: 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->stereo_mode = value;
dsp->data.num_channels = value == STEREO_MONO ? 1 : 2; dsp->data.num_channels = value == STEREO_MONO ? 1 : 2;
dsp_update_functions(dsp); dsp_update_functions(dsp);
#ifdef HAVE_PITCHSCREEN
tdspeed_setup(dsp); tdspeed_setup(dsp);
#endif
break; break;
case DSP_RESET: case DSP_RESET:
@ -1434,7 +1452,9 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value)
dsp_update_functions(dsp); dsp_update_functions(dsp);
resampler_new_delta(dsp); resampler_new_delta(dsp);
#ifdef HAVE_PITCHSCREEN
tdspeed_setup(dsp); tdspeed_setup(dsp);
#endif
if (dsp == &AUDIO_DSP) if (dsp == &AUDIO_DSP)
release_gain = UNITY; release_gain = UNITY;
break; break;
@ -1444,7 +1464,9 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value)
sizeof (dsp->data.resample_data)); sizeof (dsp->data.resample_data));
resampler_new_delta(dsp); resampler_new_delta(dsp);
dither_init(dsp); dither_init(dsp);
#ifdef HAVE_PITCHSCREEN
tdspeed_setup(dsp); tdspeed_setup(dsp);
#endif
if (dsp == &AUDIO_DSP) if (dsp == &AUDIO_DSP)
release_gain = UNITY; release_gain = UNITY;
break; break;

View file

@ -120,7 +120,7 @@ char* get_dir(char* buf, int buf_size, const char* path, int level)
return buf; return buf;
} }
#if (CONFIG_CODEC != MAS3507D) #if (CONFIG_CODEC != MAS3507D) && defined (HAVE_PITCHSCREEN)
/* A helper to determine the enum value for pitch/speed. /* A helper to determine the enum value for pitch/speed.
When there are two choices (i.e. boolean), return 1 if the value is 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) */ #endif /* (CONFIG_CODEC == SWCODEC) */
#if (CONFIG_CODEC != MAS3507D) #if (CONFIG_CODEC != MAS3507D) && defined (HAVE_PITCHSCREEN)
case SKIN_TOKEN_SOUND_PITCH: case SKIN_TOKEN_SOUND_PITCH:
{ {
int32_t pitch = sound_get_pitch(); int32_t pitch = sound_get_pitch();
@ -1156,7 +1156,7 @@ const char *get_token_value(struct gui_wps *gwps,
} }
#endif #endif
#if CONFIG_CODEC == SWCODEC #if (CONFIG_CODEC == SWCODEC) && defined (HAVE_PITCHSCREEN)
case SKIN_TOKEN_SOUND_SPEED: case SKIN_TOKEN_SOUND_SPEED:
{ {
int32_t pitch = sound_get_pitch(); int32_t pitch = sound_get_pitch();

View file

@ -399,7 +399,7 @@ static void init(void)
#endif /* CONFIG_CODEC != SWCODEC */ #endif /* CONFIG_CODEC != SWCODEC */
scrobbler_init(); scrobbler_init();
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC && defined (HAVE_PITCHSCREEN)
tdspeed_init(); tdspeed_init();
#endif /* CONFIG_CODEC == SWCODEC */ #endif /* CONFIG_CODEC == SWCODEC */
@ -663,7 +663,7 @@ static void init(void)
tree_mem_init(); tree_mem_init();
filetype_init(); filetype_init();
scrobbler_init(); scrobbler_init();
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC && defined (HAVE_PITCHSCREEN)
tdspeed_init(); tdspeed_init();
#endif /* CONFIG_CODEC == SWCODEC */ #endif /* CONFIG_CODEC == SWCODEC */
theme_init_buffer(); 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, &crossfeed_direct_gain, &crossfeed_cross_gain,
&crossfeed_hf_attenuation, &crossfeed_hf_cutoff); &crossfeed_hf_attenuation, &crossfeed_hf_cutoff);
#ifdef HAVE_PIUTCHSCREEN
static int timestretch_callback(int action,const struct menu_item_ex *this_item) static int timestretch_callback(int action,const struct menu_item_ex *this_item)
{ {
switch (action) switch (action)
@ -118,6 +119,8 @@ static int timestretch_callback(int action,const struct menu_item_ex *this_item)
} }
MENUITEM_SETTING(timestretch_enabled, MENUITEM_SETTING(timestretch_enabled,
&global_settings.timestretch_enabled, timestretch_callback); &global_settings.timestretch_enabled, timestretch_callback);
#endif
MENUITEM_SETTING(dithering_enabled, MENUITEM_SETTING(dithering_enabled,
&global_settings.dithering_enabled, lowlatency_callback); &global_settings.dithering_enabled, lowlatency_callback);
@ -178,7 +181,9 @@ MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, Icon_Audio,
#endif #endif
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
,&crossfeed_menu, &equalizer_menu, &dithering_enabled ,&crossfeed_menu, &equalizer_menu, &dithering_enabled
#ifdef HAVE_PITCHSCREEN
,&timestretch_enabled ,&timestretch_enabled
#endif
,&compressor_menu ,&compressor_menu
#endif #endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) #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) #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
mpeg_get_last_header, mpeg_get_last_header,
#endif #endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \ #if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
(CONFIG_CODEC == SWCODEC) (CONFIG_CODEC == SWCODEC)) && defined (HAVE_PITCHSCREEN)
sound_set_pitch, sound_set_pitch,
#endif #endif

View file

@ -678,8 +678,8 @@ struct plugin_api {
#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC) #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
unsigned long (*mpeg_get_last_header)(void); unsigned long (*mpeg_get_last_header)(void);
#endif #endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \ #if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
(CONFIG_CODEC == SWCODEC) (CONFIG_CODEC == SWCODEC)) && defined (HAVE_PITCHSCREEN)
void (*sound_set_pitch)(int32_t pitch); void (*sound_set_pitch)(int32_t pitch);
#endif #endif

View file

@ -483,7 +483,9 @@ static void audio_thread(void)
td.dsp = (struct dsp_config *)rb->dsp_configure(NULL, DSP_MYDSP, td.dsp = (struct dsp_config *)rb->dsp_configure(NULL, DSP_MYDSP,
CODEC_IDX_AUDIO); CODEC_IDX_AUDIO);
#ifdef HAVE_PITCHSCREEN
rb->sound_set_pitch(PITCH_SPEED_100); rb->sound_set_pitch(PITCH_SPEED_100);
#endif
rb->dsp_configure(td.dsp, DSP_RESET, 0); rb->dsp_configure(td.dsp, DSP_RESET, 0);
rb->dsp_configure(td.dsp, DSP_SET_SAMPLE_DEPTH, MAD_F_FRACBITS); 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); dsp_dither_enable(global_settings.dithering_enabled);
#ifdef HAVE_PITCHSCREEN
dsp_timestretch_enable(global_settings.timestretch_enabled); dsp_timestretch_enable(global_settings.timestretch_enabled);
#endif
dsp_set_compressor(global_settings.compressor_threshold, dsp_set_compressor(global_settings.compressor_threshold,
global_settings.compressor_makeup_gain, global_settings.compressor_makeup_gain,
global_settings.compressor_ratio, global_settings.compressor_ratio,

View file

@ -364,7 +364,9 @@ struct user_settings
int keyclick; /* keyclick volume */ int keyclick; /* keyclick volume */
int keyclick_repeats; /* keyclick on repeats */ int keyclick_repeats; /* keyclick on repeats */
bool dithering_enabled; bool dithering_enabled;
#ifdef HAVE_PITCHSCREEN
bool timestretch_enabled; bool timestretch_enabled;
#endif
#endif /* CONFIG_CODEC == SWCODEC */ #endif /* CONFIG_CODEC == SWCODEC */
#ifdef HAVE_RECORDING #ifdef HAVE_RECORDING

View file

@ -1371,9 +1371,11 @@ const struct settings_list settings[] = {
OFFON_SETTING(F_SOUNDSETTING, dithering_enabled, LANG_DITHERING, false, OFFON_SETTING(F_SOUNDSETTING, dithering_enabled, LANG_DITHERING, false,
"dithering enabled", dsp_dither_enable), "dithering enabled", dsp_dither_enable),
#ifdef HAVE_PITCHSCREEN
/* timestretch */ /* timestretch */
OFFON_SETTING(F_SOUNDSETTING, timestretch_enabled, LANG_TIMESTRETCH, false, OFFON_SETTING(F_SOUNDSETTING, timestretch_enabled, LANG_TIMESTRETCH, false,
"timestretch enabled", dsp_timestretch_enable), "timestretch enabled", dsp_timestretch_enable),
#endif
/* compressor */ /* compressor */
INT_SETTING_NOWRAP(F_SOUNDSETTING, compressor_threshold, INT_SETTING_NOWRAP(F_SOUNDSETTING, compressor_threshold,