Skip to content

Commit

Permalink
Audio: RTNR stub: Add audio_stream_copy() to stub functions
Browse files Browse the repository at this point in the history
This change avoids with stub library version annoying playback
sound from non-updated sink buffer when the processing ALSA
switch control is enabled. The audio is passed through from
source to sink.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
  • Loading branch information
singalsu committed Jan 12, 2024
1 parent 804ae06 commit 1bd1654
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/audio/rtnr/rtnr.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,7 @@ static int rtnr_set_config(struct processing_module *mod, uint32_t param_id,
#endif
}

static void rtnr_copy_from_sof_stream(struct audio_stream_rtnr *dst,
struct audio_stream *src)
void rtnr_copy_from_sof_stream(struct audio_stream_rtnr *dst, struct audio_stream *src)
{

dst->size = audio_stream_get_size(src);
Expand All @@ -697,8 +696,7 @@ static void rtnr_copy_from_sof_stream(struct audio_stream_rtnr *dst,
dst->end_addr = audio_stream_get_end_addr(src);
}

static void rtnr_copy_to_sof_stream(struct audio_stream *dst,
struct audio_stream_rtnr *src)
void rtnr_copy_to_sof_stream(struct audio_stream *dst, struct audio_stream_rtnr *src)
{
audio_stream_set_size(dst, src->size);
audio_stream_set_avail(dst, src->avail);
Expand Down
41 changes: 37 additions & 4 deletions src/audio/rtnr/rtnr_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,58 @@
//

#include <sof/audio/rtnr/rtklib/include/RTK_MA_API.h>
#include <sof/audio/audio_stream.h>
#include <rtos/alloc.h>

#define RTNR_STUB_CONTEXT_SIZE 42 /* Just some random size to allocate */

void RTKMA_API_S16_Default(void *Context, struct audio_stream_rtnr **sources,
struct audio_stream_rtnr *sink, int frames,
_Bool ref_active, int in_idx, int ref_idx,
int ref_32bits, int ref_shift)
{}
{
struct audio_stream sof_source;
struct audio_stream sof_sink;

rtnr_copy_to_sof_stream(&sof_source, sources[0]);
rtnr_copy_to_sof_stream(&sof_sink, sink);
audio_stream_copy(&sof_source, 0, &sof_sink, 0,
frames * audio_stream_get_channels(&sof_sink));
rtnr_copy_from_sof_stream(sources[0], &sof_source);
rtnr_copy_from_sof_stream(sink, &sof_sink);
}

void RTKMA_API_S24_Default(void *Context, struct audio_stream_rtnr **sources,
struct audio_stream_rtnr *sink, int frames,
_Bool ref_active, int in_idx, int ref_idx,
int ref_32bits, int ref_shift)
{}
{
struct audio_stream sof_source;
struct audio_stream sof_sink;

rtnr_copy_to_sof_stream(&sof_source, sources[0]);
rtnr_copy_to_sof_stream(&sof_sink, sink);
audio_stream_copy(&sof_source, 0, &sof_sink, 0,
frames * audio_stream_get_channels(&sof_sink));
rtnr_copy_from_sof_stream(sources[0], &sof_source);
rtnr_copy_from_sof_stream(sink, &sof_sink);
}

void RTKMA_API_S32_Default(void *Context, struct audio_stream_rtnr **sources,
struct audio_stream_rtnr *sink, int frames,
_Bool ref_active, int in_idx, int ref_idx,
int ref_32bits, int ref_shift)
{}
{
struct audio_stream sof_source;
struct audio_stream sof_sink;

rtnr_copy_to_sof_stream(&sof_source, sources[0]);
rtnr_copy_to_sof_stream(&sof_sink, sink);
audio_stream_copy(&sof_source, 0, &sof_sink, 0,
frames * audio_stream_get_channels(&sof_sink));
rtnr_copy_from_sof_stream(sources[0], &sof_source);
rtnr_copy_from_sof_stream(sink, &sof_sink);
}

void RTKMA_API_First_Copy(void *Context, int SampleRate, int MicCh)
{}
Expand All @@ -40,7 +73,7 @@ void *RTKMA_API_Context_Create(int sample_rate)
/* Allocate something, to avoid return NULL and cause error
* in check of success of this.
*/
return rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, 42);
return rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, RTNR_STUB_CONTEXT_SIZE);
}

void RTKMA_API_Context_Free(void *Context)
Expand Down
4 changes: 4 additions & 0 deletions src/include/sof/audio/rtnr/rtnr.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ void rtnr_printf(int a, int b, int c, int d, int e);
void *rtk_rballoc(unsigned int flags, unsigned int caps, unsigned int bytes);
void rtk_rfree(void *ptr);

/* For stub processing functions */
void rtnr_copy_from_sof_stream(struct audio_stream_rtnr *dst, struct audio_stream *src);
void rtnr_copy_to_sof_stream(struct audio_stream *dst, struct audio_stream_rtnr *src);

#endif /* __SOF_AUDIO_RTNR_RTNR_H__ */

0 comments on commit 1bd1654

Please sign in to comment.