From 00e076795f2d6dfa0c078ff5d5ee5d77190cb4b9 Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Wed, 5 Jan 2011 01:05:47 +0100 Subject: audio: split sample conversion and volume mixing Refactor the volume mixing, so it can be reused for capturing devices. Additionally, it removes superfluous multiplications with the nominal volume within the hardware voice code path. Signed-off-by: Michael Walle Signed-off-by: malc --- audio/mixeng.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'audio/mixeng.c') diff --git a/audio/mixeng.c b/audio/mixeng.c index 9f1d93fcfc..4a9e8ebe2a 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -333,3 +333,28 @@ void mixeng_clear (struct st_sample *buf, int len) { memset (buf, 0, len * sizeof (struct st_sample)); } + +void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *vol) +{ +#ifdef CONFIG_MIXEMU + if (vol->mute) { + mixeng_clear (buf, len); + return; + } + + while (len--) { +#ifdef FLOAT_MIXENG + buf->l = buf->l * vol->l; + buf->r = buf->r * vol->r; +#else + buf->l = (buf->l * vol->l) >> 32; + buf->r = (buf->r * vol->r) >> 32; +#endif + buf += 1; + } +#else + (void) buf; + (void) len; + (void) vol; +#endif +} -- cgit v1.2.1