diff options
author | Michael Walle <michael@walle.cc> | 2011-01-05 01:05:47 +0100 |
---|---|---|
committer | malc <av1474@comtv.ru> | 2011-01-12 18:36:22 +0300 |
commit | 00e076795f2d6dfa0c078ff5d5ee5d77190cb4b9 (patch) | |
tree | 125088eea53cc55083a5b69e927937b89db22645 /audio/mixeng.c | |
parent | 0f136d9e060ad879d0b840274ddfd1955e24fc10 (diff) | |
download | qemu-00e076795f2d6dfa0c078ff5d5ee5d77190cb4b9.tar.gz qemu-00e076795f2d6dfa0c078ff5d5ee5d77190cb4b9.tar.bz2 qemu-00e076795f2d6dfa0c078ff5d5ee5d77190cb4b9.zip |
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 <michael@walle.cc>
Signed-off-by: malc <av1474@comtv.ru>
Diffstat (limited to 'audio/mixeng.c')
-rw-r--r-- | audio/mixeng.c | 25 |
1 files changed, 25 insertions, 0 deletions
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 +} |