usbaudio: send through dsp (new)

Does not seem to affect UI usability, but allowable DSP loads will vary
based on device and playback sample rate.

To-Do (someday):
- Add dedicated DSP channel
- How to apply DSP settings to above new channel? (UI)
- How to lock out timestretch from being enabled?

Change-Id: Ia24d1055340354e2c32e6008e7e2b03a8e88867d
This commit is contained in:
Dana Conrad 2025-11-02 00:02:02 +00:00
parent 7c4293af64
commit c533222851
12 changed files with 94 additions and 31 deletions

View file

@ -249,7 +249,7 @@ static void codec_pcmbuf_insert_callback(
}
else
{
dsp_process(ci.dsp, &src, &dst);
dsp_process(ci.dsp, &src, &dst, true);
if (dst.remcount > 0)
{

View file

@ -751,7 +751,7 @@ struct plugin_api {
unsigned int setting, intptr_t value);
struct dsp_config * (*dsp_get_config)(unsigned int dsp_id);
void (*dsp_process)(struct dsp_config *dsp, struct dsp_buffer *src,
struct dsp_buffer *dst);
struct dsp_buffer *dst, bool thread_yield);
enum channel_status (*mixer_channel_status)(enum pcm_mixer_channel channel);
const void * (*mixer_channel_get_buffer)(enum pcm_mixer_channel channel,

View file

@ -444,7 +444,7 @@ static inline void synthbuf(void)
dst.remcount = 0;
dst.bufcount = available;
dst.p16out = (int16_t *)outptr;
rb->dsp_process(dsp, &src, &dst);
rb->dsp_process(dsp, &src, &dst, true);
if (dst.remcount > 0)
{
outptr += dst.remcount;

View file

@ -665,7 +665,7 @@ static void audio_thread(void)
}
dst.bufcount = size / (2 * sizeof (int16_t));
rb->dsp_process(td.dsp, &td.src, &dst);
rb->dsp_process(td.dsp, &td.src, &dst, true);
if (dst.remcount > 0)
{

View file

@ -230,7 +230,7 @@ static int process_dsp(const void *ch1, const void *ch2, int count)
while (1)
{
int old_remcount = dst.remcount;
rb->dsp_process(ci.dsp, &src, &dst);
rb->dsp_process(ci.dsp, &src, &dst, true);
if (dst.bufcount <= 0 ||
(src.remcount <= 0 && dst.remcount <= old_remcount))

View file

@ -33,11 +33,14 @@ struct dsp_loop_context
#endif
};
static inline void dsp_process_start(struct dsp_loop_context *ctx)
static inline void dsp_process_start(struct dsp_loop_context *ctx, bool thread_yield)
{
/* At least perform one yield before starting */
ctx->last_yield = current_tick;
yield();
if (thread_yield)
{
yield();
}
#if defined(CPU_COLDFIRE)
/* set emac unit for dsp processing, and save old macsr, we're running in
codec thread context at this point, so can't clobber it */
@ -46,14 +49,17 @@ static inline void dsp_process_start(struct dsp_loop_context *ctx)
#endif
}
static inline void dsp_process_loop(struct dsp_loop_context *ctx)
static inline void dsp_process_loop(struct dsp_loop_context *ctx, bool thread_yield)
{
/* Yield at least once each tick */
long tick = current_tick;
if (TIME_AFTER(tick, ctx->last_yield))
{
ctx->last_yield = tick;
yield();
if (thread_yield)
{
yield();
}
}
}
@ -66,12 +72,12 @@ static inline void dsp_process_end(struct dsp_loop_context *ctx)
(void)ctx;
}
#define DSP_PROCESS_START() \
#define DSP_PROCESS_START(yield) \
struct dsp_loop_context __ctx; \
dsp_process_start(&__ctx)
dsp_process_start(&__ctx, yield)
#define DSP_PROCESS_LOOP() \
dsp_process_loop(&__ctx)
#define DSP_PROCESS_LOOP(yield) \
dsp_process_loop(&__ctx, yield)
#define DSP_PROCESS_END() \
dsp_process_end(&__ctx)

View file

@ -511,7 +511,7 @@ static enum voice_state voice_buffer_insert(struct voice_thread_data *td)
dst.bufcount = VOICE_PCM_FRAME_COUNT;
td->dst = &dst;
dsp_process(td->dsp, &td->src, &dst);
dsp_process(td->dsp, &td->src, &dst, true);
td->dst = NULL;
voice_buf_commit(dst.remcount);