summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/SOURCES1
-rw-r--r--apps/plugins/mpegplayer/audio_thread.c56
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c8
-rw-r--r--apps/plugins/test_codec.c51
4 files changed, 63 insertions, 53 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index db690a6..e5f026c 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -33,6 +33,7 @@ flipit.c
shopper.c
resistor.c
+test_codec.c
#ifdef USB_ENABLE_HID
remote_control.c
diff --git a/apps/plugins/mpegplayer/audio_thread.c b/apps/plugins/mpegplayer/audio_thread.c
index f976fd6..b06727f 100644
--- a/apps/plugins/mpegplayer/audio_thread.c
+++ b/apps/plugins/mpegplayer/audio_thread.c
@@ -36,6 +36,7 @@ struct audio_thread_data
unsigned samplerate; /* Current stream sample rate */
int nchannels; /* Number of audio channels */
struct dsp_config *dsp; /* The DSP we're using */
+ struct dsp_buffer src; /* Current audio data for DSP processing */
};
/* The audio thread is stolen from the core codec thread */
@@ -479,12 +480,13 @@ static void audio_thread(void)
/* We need this here to init the EMAC for Coldfire targets */
init_mad();
- td.dsp = (struct dsp_config *)rb->dsp_configure(NULL, DSP_MYDSP,
- CODEC_IDX_AUDIO);
+ td.dsp = rb->dsp_get_config(CODEC_IDX_AUDIO);
#ifdef HAVE_PITCHSCREEN
rb->sound_set_pitch(PITCH_SPEED_100);
+ rb->dsp_set_timestretch(PITCH_SPEED_100);
#endif
rb->dsp_configure(td.dsp, DSP_RESET, 0);
+ rb->dsp_configure(td.dsp, DSP_FLUSH, 0);
rb->dsp_configure(td.dsp, DSP_SET_SAMPLE_DEPTH, MAD_F_FRACBITS);
goto message_wait;
@@ -631,43 +633,53 @@ static void audio_thread(void)
STEREO_MONO : STEREO_NONINTERLEAVED);
}
+ td.src.remcount = synth.pcm.length;
+ td.src.pin[0] = synth.pcm.samples[0];
+ td.src.pin[1] = synth.pcm.samples[1];
+ td.src.proc_mask = 0;
+
td.state = TSTATE_RENDER_WAIT;
/* Add a frame of audio to the pcm buffer. Maximum is 1152 samples. */
render_wait:
- if (synth.pcm.length > 0)
+ rb->yield();
+
+ while (1)
{
- const char *src[2] =
- { (char *)synth.pcm.samples[0], (char *)synth.pcm.samples[1] };
- int out_count = (synth.pcm.length * CLOCK_RATE
- + (td.samplerate - 1)) / td.samplerate;
- unsigned char *out_buf;
- ssize_t size = out_count*4;
+ struct dsp_buffer dst;
+ dst.remcount = 0;
+ dst.bufcount = MAX(td.src.remcount, 1024);
+
+ ssize_t size = dst.bufcount * 2 * sizeof(int16_t);
/* Wait for required amount of free buffer space */
- while ((out_buf = pcm_output_get_buffer(&size)) == NULL)
+ while ((dst.p16out = pcm_output_get_buffer(&size)) == NULL)
{
/* Wait one frame */
- int timeout = out_count*HZ / td.samplerate;
+ int timeout = dst.bufcount*HZ / td.samplerate;
str_get_msg_w_tmo(&audio_str, &td.ev, MAX(timeout, 1));
if (td.ev.id != SYS_TIMEOUT)
goto message_process;
}
- out_count = rb->dsp_process(td.dsp, out_buf, src, synth.pcm.length);
+ dst.bufcount = size / (2 * sizeof (int16_t));
+ rb->dsp_process(td.dsp, &td.src, &dst);
- if (out_count <= 0)
- break;
-
- /* Make this data available to DMA */
- pcm_output_commit_data(out_count*4, audio_queue.curr->time);
+ if (dst.remcount > 0)
+ {
+ /* Make this data available to DMA */
+ pcm_output_commit_data(dst.remcount * 2 * sizeof(int16_t),
+ audio_queue.curr->time);
- /* As long as we're on this timestamp, the time is just
- incremented by the number of samples */
- audio_queue.curr->time += out_count;
+ /* As long as we're on this timestamp, the time is just
+ incremented by the number of samples */
+ audio_queue.curr->time += dst.remcount;
+ }
+ else if (td.src.remcount <= 0)
+ {
+ break;
+ }
}
-
- rb->yield();
} /* end decoding loop */
}
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index 1c3f3c0..7f92fb7 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -457,13 +457,13 @@ static void sync_audio_setting(int setting, bool global)
break;
case MPEG_AUDIO_CROSSFEED:
- rb->dsp_set_crossfeed((global || settings.crossfeed) ?
- rb->global_settings->crossfeed : false);
+ rb->dsp_crossfeed_enable((global || settings.crossfeed) ?
+ rb->global_settings->crossfeed : false);
break;
case MPEG_AUDIO_EQUALIZER:
- rb->dsp_set_eq((global || settings.equalizer) ?
- rb->global_settings->eq_enabled : false);
+ rb->dsp_eq_enable((global || settings.equalizer) ?
+ rb->global_settings->eq_enabled : false);
break;
case MPEG_AUDIO_DITHERING:
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c
index dafcf35..920be54 100644
--- a/apps/plugins/test_codec.c
+++ b/apps/plugins/test_codec.c
@@ -164,6 +164,7 @@ static inline void int2le16(unsigned char* buf, int16_t x)
static unsigned char *wavbuffer;
static unsigned char *dspbuffer;
+static int dspbuffer_count;
void init_wav(char* filename)
{
@@ -215,34 +216,31 @@ static void* codec_get_buffer(size_t *size)
static int process_dsp(const void *ch1, const void *ch2, int count)
{
- const char *src[2] = { ch1, ch2 };
- int written_count = 0;
- char *dest = dspbuffer;
-
- while (count > 0)
+ struct dsp_buffer src;
+ src.remcount = count;
+ src.pin[0] = ch1;
+ src.pin[1] = ch2;
+ src.proc_mask = 0;
+
+ struct dsp_buffer dst;
+ dst.remcount = 0;
+ dst.p16out = (int16_t *)dspbuffer;
+ dst.bufcount = dspbuffer_count;
+
+ while (1)
{
- int out_count = rb->dsp_output_count(ci.dsp, count);
-
- int inp_count = rb->dsp_input_count(ci.dsp, out_count);
-
- if (inp_count <= 0)
- break;
-
- if (inp_count > count)
- inp_count = count;
-
- out_count = rb->dsp_process(ci.dsp, dest, src, inp_count);
+ int old_remcount = dst.remcount;
+ rb->dsp_process(ci.dsp, &src, &dst);
- if (out_count <= 0)
+ if (dst.bufcount <= 0 ||
+ (src.remcount <= 0 && dst.remcount <= old_remcount))
+ {
+ /* Dest is full or no input left and DSP purged */
break;
-
- written_count += out_count;
- dest += out_count * 4;
-
- count -= inp_count;
+ }
}
- return written_count;
+ return dst.remcount;
}
/* Null output */
@@ -502,7 +500,6 @@ static void configure(int setting, intptr_t value)
rb->dsp_configure(ci.dsp, setting, value);
switch(setting)
{
- case DSP_SWITCH_FREQUENCY:
case DSP_SET_FREQUENCY:
DEBUGF("samplerate=%d\n",(int)value);
wavinfo.samplerate = use_dsp ? NATIVE_FREQUENCY : (int)value;
@@ -525,9 +522,7 @@ static void init_ci(void)
{
/* --- Our "fake" implementations of the codec API functions. --- */
- ci.dsp = (struct dsp_config *)rb->dsp_configure(NULL, DSP_MYDSP,
- CODEC_IDX_AUDIO);
-
+ ci.dsp = rb->dsp_get_config(CODEC_IDX_AUDIO);
ci.codec_get_buffer = codec_get_buffer;
if (wavinfo.fd >= 0 || checksum) {
@@ -849,6 +844,8 @@ enum plugin_status plugin_start(const void* parameter)
wavbuffer = rb->plugin_get_buffer(&buffer_size);
dspbuffer = wavbuffer + buffer_size / 2;
+ dspbuffer_count = (buffer_size - (dspbuffer - wavbuffer)) /
+ (2 * sizeof (int16_t));
codec_mallocbuf = rb->plugin_get_audio_buffer(&audiosize);
/* Align codec_mallocbuf to pointer size, tlsf wants that */