Fix FS#10331 and get mpegplayer working again.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21293 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Steve Bavin 2009-06-15 15:46:09 +00:00
parent 3391bf3543
commit 77f6f4caad
4 changed files with 39 additions and 35 deletions

View file

@ -245,20 +245,6 @@ static int32_t *resample_buf;
#define RESAMPLE_BUF_LEFT_CHANNEL 0
#define RESAMPLE_BUF_RIGHT_CHANNEL (sample_buf_count/2 * RESAMPLE_RATIO)
#if 0
/* Clip sample to arbitrary limits where range > 0 and min + range = max */
static inline long clip_sample(int32_t sample, int32_t min, int32_t range)
{
if ((uint32_t)(sample - min) > (uint32_t)range)
{
int32_t c = min;
if (sample > min)
c += range;
sample = c;
}
return sample;
}
#endif
/* Clip sample to signed 16 bit range */
static inline int32_t clip_sample_16(int32_t sample)
@ -282,14 +268,14 @@ void sound_set_pitch(int permille)
void tdspeed_setup(struct dsp_config *dspc)
{
dspc->tdspeed_active = false;
if (dspc == &AUDIO_DSP)
{
dspc->tdspeed_active = false;
if (!dspc->tdspeed_enabled)
return;
if (dspc->tdspeed_percent == 0)
dspc->tdspeed_percent = 100;
if (!tdspeed_init(
if (!tdspeed_config(
dspc->codec_frequency == 0 ? NATIVE_FREQUENCY : dspc->codec_frequency,
dspc->stereo_mode != STEREO_MONO,
dspc->tdspeed_percent))
@ -1277,19 +1263,7 @@ 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)
{
if(!dsp->tdspeed_active)
{
sample_buf = small_sample_buf;
resample_buf = small_resample_buf;
sample_buf_count = SMALL_SAMPLE_BUF_COUNT;
}
else
{
sample_buf = big_sample_buf;
sample_buf_count = big_sample_buf_count;
resample_buf = big_resample_buf;
}
if(dsp->tdspeed_active)
if (dsp->tdspeed_active)
count = tdspeed_est_output_size();
if (dsp->resample)
{
@ -1324,7 +1298,7 @@ int dsp_input_count(struct dsp_config *dsp, int count)
dsp->data.resample_data.delta) >> 16);
}
if(dsp->tdspeed_active)
if (dsp->tdspeed_active)
count = tdspeed_est_input_size(count);
return count;
@ -1464,6 +1438,19 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value)
return 0;
}
if (!dsp->tdspeed_active)
{
sample_buf = small_sample_buf;
resample_buf = small_resample_buf;
sample_buf_count = SMALL_SAMPLE_BUF_COUNT;
}
else
{
sample_buf = big_sample_buf;
sample_buf_count = big_sample_buf_count;
resample_buf = big_resample_buf;
}
return 1;
}

View file

@ -336,6 +336,9 @@ static void init(void)
scrobbler_init();
cuesheet_init();
#if CONFIG_CODEC == SWCODEC
tdspeed_init();
#endif /* CONFIG_CODEC == SWCODEC */
audio_init();
button_clear_queue(); /* Empty the keyboard buffer */
@ -549,6 +552,9 @@ static void init(void)
filetype_init();
scrobbler_init();
cuesheet_init();
#if CONFIG_CODEC == SWCODEC
tdspeed_init();
#endif /* CONFIG_CODEC == SWCODEC */
#if CONFIG_CODEC != SWCODEC
/* No buffer allocation (see buffer.c) may take place after the call to

View file

@ -54,11 +54,8 @@ static struct tdspeed_state_s tdspeed_state;
static int32_t *overlap_buffer[2] = { NULL, NULL };
static int32_t *outbuf[2] = { NULL, NULL };
bool tdspeed_init(int samplerate, bool stereo, int factor)
void tdspeed_init()
{
struct tdspeed_state_s *st = &tdspeed_state;
int src_frame_sz;
/* Allocate buffers */
if (overlap_buffer[0] == NULL)
overlap_buffer[0] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t));
@ -68,6 +65,19 @@ bool tdspeed_init(int samplerate, bool stereo, int factor)
outbuf[0] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t));
if (outbuf[1] == NULL)
outbuf[1] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t));
}
bool tdspeed_config(int samplerate, bool stereo, int factor)
{
struct tdspeed_state_s *st = &tdspeed_state;
int src_frame_sz;
/* Check buffers were allocated ok */
if (overlap_buffer[0] == NULL || overlap_buffer[1] == NULL)
return false;
if (outbuf[0] == NULL || outbuf[1] == NULL)
return false;
/* Check parameters */
if (factor == 100)

View file

@ -25,7 +25,8 @@
#define TDSPEED_OUTBUFSIZE 4096
bool tdspeed_init(int samplerate, bool stereo, int factor);
void tdspeed_init();
bool tdspeed_config(int samplerate, bool stereo, int factor);
long tdspeed_est_output_size(void);
long tdspeed_est_input_size(long size);
int tdspeed_doit(int32_t *src[], int count);