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 Nov 6, 2023
1 parent 2e438d9 commit 67bb33b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 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
37 changes: 34 additions & 3 deletions src/audio/rtnr/rtnr_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,56 @@
//

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

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 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 67bb33b

Please sign in to comment.