src/audio/mixer.c
/* Mix n 16 bit PCM source streams to one sink stream */
Mix n 16 bit PCM source streams to one sink stream
Mix n 16 bit PCM source streams to one sink stream
static void mix_n_s16(struct comp_dev *dev, struct audio_stream *sink,
		      const struct audio_stream **sources, uint32_t num_sources,
		      uint32_t frames)
{
	int16_t *src;
	int16_t *dest;
	int32_t val;
	int i;
	int j;
	int channel;
	uint32_t frag = 0;
	for (i = 0; i < frames; i++) {
		for (channel = 0; channel < sink->channels; channel++) {
			val = 0;
			for (j = 0; j < num_sources; j++) {
				src = audio_stream_read_frag_s16(sources[j],
								 frag);
				val += *src;
			}
			dest = audio_stream_write_frag_s16(sink, frag);
			*dest = sat_int16(val);
			frag++;
		}
	}
}
static void mix_n_s16 ( struct comp_dev * dev , struct audio_stream * sink , const struct audio_stream * * sources , uint32_t num_sources , uint32_t frames ) { int16_t * src ; int16_t * dest ; int32_t val ; int i ; int j ; int channel ; uint32_t frag = 0 ; for ( i = 0 ; i < frames ; i ++ ) { for ( channel = 0 ; channel < sink -> channels ; channel ++ ) { val = 0 ; for ( j = 0 ; j < num_sources ; j ++ ) { src = audio_stream_read_frag_s16 ( sources [ j ] , frag ) ; val += * src ; } dest = audio_stream_write_frag_s16 ( sink , frag ) ; * dest = sat_int16 ( val ) ; frag ++ ; } } }
Mix n 16 bit PCM source streams to one sink stream
Mix n 16 bit PCM source streams to one sink stream
/* Saturate to 16 bits */