Skip to content

Commit 1bd1654

Browse files
committed
Audio: RTNR stub: Add audio_stream_copy() to stub functions
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>
1 parent 804ae06 commit 1bd1654

3 files changed

Lines changed: 43 additions & 8 deletions

File tree

src/audio/rtnr/rtnr.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,7 @@ static int rtnr_set_config(struct processing_module *mod, uint32_t param_id,
684684
#endif
685685
}
686686

687-
static void rtnr_copy_from_sof_stream(struct audio_stream_rtnr *dst,
688-
struct audio_stream *src)
687+
void rtnr_copy_from_sof_stream(struct audio_stream_rtnr *dst, struct audio_stream *src)
689688
{
690689

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

700-
static void rtnr_copy_to_sof_stream(struct audio_stream *dst,
701-
struct audio_stream_rtnr *src)
699+
void rtnr_copy_to_sof_stream(struct audio_stream *dst, struct audio_stream_rtnr *src)
702700
{
703701
audio_stream_set_size(dst, src->size);
704702
audio_stream_set_avail(dst, src->avail);

src/audio/rtnr/rtnr_stub.c

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,58 @@
66
//
77

88
#include <sof/audio/rtnr/rtklib/include/RTK_MA_API.h>
9+
#include <sof/audio/audio_stream.h>
910
#include <rtos/alloc.h>
1011

12+
#define RTNR_STUB_CONTEXT_SIZE 42 /* Just some random size to allocate */
13+
1114
void RTKMA_API_S16_Default(void *Context, struct audio_stream_rtnr **sources,
1215
struct audio_stream_rtnr *sink, int frames,
1316
_Bool ref_active, int in_idx, int ref_idx,
1417
int ref_32bits, int ref_shift)
15-
{}
18+
{
19+
struct audio_stream sof_source;
20+
struct audio_stream sof_sink;
21+
22+
rtnr_copy_to_sof_stream(&sof_source, sources[0]);
23+
rtnr_copy_to_sof_stream(&sof_sink, sink);
24+
audio_stream_copy(&sof_source, 0, &sof_sink, 0,
25+
frames * audio_stream_get_channels(&sof_sink));
26+
rtnr_copy_from_sof_stream(sources[0], &sof_source);
27+
rtnr_copy_from_sof_stream(sink, &sof_sink);
28+
}
1629

1730
void RTKMA_API_S24_Default(void *Context, struct audio_stream_rtnr **sources,
1831
struct audio_stream_rtnr *sink, int frames,
1932
_Bool ref_active, int in_idx, int ref_idx,
2033
int ref_32bits, int ref_shift)
21-
{}
34+
{
35+
struct audio_stream sof_source;
36+
struct audio_stream sof_sink;
37+
38+
rtnr_copy_to_sof_stream(&sof_source, sources[0]);
39+
rtnr_copy_to_sof_stream(&sof_sink, sink);
40+
audio_stream_copy(&sof_source, 0, &sof_sink, 0,
41+
frames * audio_stream_get_channels(&sof_sink));
42+
rtnr_copy_from_sof_stream(sources[0], &sof_source);
43+
rtnr_copy_from_sof_stream(sink, &sof_sink);
44+
}
2245

2346
void RTKMA_API_S32_Default(void *Context, struct audio_stream_rtnr **sources,
2447
struct audio_stream_rtnr *sink, int frames,
2548
_Bool ref_active, int in_idx, int ref_idx,
2649
int ref_32bits, int ref_shift)
27-
{}
50+
{
51+
struct audio_stream sof_source;
52+
struct audio_stream sof_sink;
53+
54+
rtnr_copy_to_sof_stream(&sof_source, sources[0]);
55+
rtnr_copy_to_sof_stream(&sof_sink, sink);
56+
audio_stream_copy(&sof_source, 0, &sof_sink, 0,
57+
frames * audio_stream_get_channels(&sof_sink));
58+
rtnr_copy_from_sof_stream(sources[0], &sof_source);
59+
rtnr_copy_from_sof_stream(sink, &sof_sink);
60+
}
2861

2962
void RTKMA_API_First_Copy(void *Context, int SampleRate, int MicCh)
3063
{}
@@ -40,7 +73,7 @@ void *RTKMA_API_Context_Create(int sample_rate)
4073
/* Allocate something, to avoid return NULL and cause error
4174
* in check of success of this.
4275
*/
43-
return rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, 42);
76+
return rzalloc(SOF_MEM_ZONE_RUNTIME, 0, SOF_MEM_CAPS_RAM, RTNR_STUB_CONTEXT_SIZE);
4477
}
4578

4679
void RTKMA_API_Context_Free(void *Context)

src/include/sof/audio/rtnr/rtnr.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,8 @@ void rtnr_printf(int a, int b, int c, int d, int e);
8282
void *rtk_rballoc(unsigned int flags, unsigned int caps, unsigned int bytes);
8383
void rtk_rfree(void *ptr);
8484

85+
/* For stub processing functions */
86+
void rtnr_copy_from_sof_stream(struct audio_stream_rtnr *dst, struct audio_stream *src);
87+
void rtnr_copy_to_sof_stream(struct audio_stream *dst, struct audio_stream_rtnr *src);
88+
8589
#endif /* __SOF_AUDIO_RTNR_RTNR_H__ */

0 commit comments

Comments
 (0)