peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0502-audio-don-t-apply-volume-effect-if-backend-has-VOICE.patch

56753f
From eaa3b2d4cc2ac17b2aaf0d6387d3991b9d08c56e Mon Sep 17 00:00:00 2001
56753f
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@gmail.com>
56753f
Date: Tue, 17 Apr 2012 14:32:36 +0200
56753f
Subject: [PATCH 502/509] audio: don't apply volume effect if backend has
56753f
 VOICE_VOLUME_CAP
56753f
56753f
If the audio backend is capable of volume control, don't apply
56753f
software volume (mixeng_volume ()), but instead, rely on backend
56753f
volume control. This will allow guest to have full range volume
56753f
control.
56753f
56753f
Signed-off-by: Marc-Andr? Lureau <marcandre.lureau@redhat.com>
56753f
Signed-off-by: malc <av1474@comtv.ru>
56753f
---
56753f
 audio/audio.c          |    9 +++++++--
56753f
 audio/audio_int.h      |    5 +++++
56753f
 audio/audio_template.h |    2 ++
56753f
 3 files changed, 14 insertions(+), 2 deletions(-)
56753f
56753f
diff --git a/audio/audio.c b/audio/audio.c
56753f
index 2ae9b2f..0fe95a7 100644
56753f
--- a/audio/audio.c
56753f
+++ b/audio/audio.c
56753f
@@ -954,7 +954,9 @@ int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size)
56753f
         total += isamp;
56753f
     }
56753f
 
56753f
-    mixeng_volume (sw->buf, ret, &sw->vol);
56753f
+    if (!(hw->ctl_caps & VOICE_VOLUME_CAP)) {
56753f
+        mixeng_volume (sw->buf, ret, &sw->vol);
56753f
+    }
56753f
 
56753f
     sw->clip (buf, sw->buf, ret);
56753f
     sw->total_hw_samples_acquired += total;
56753f
@@ -1038,7 +1040,10 @@ int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int size)
56753f
     swlim = audio_MIN (swlim, samples);
56753f
     if (swlim) {
56753f
         sw->conv (sw->buf, buf, swlim);
56753f
-        mixeng_volume (sw->buf, swlim, &sw->vol);
56753f
+
56753f
+        if (!(sw->hw->ctl_caps & VOICE_VOLUME_CAP)) {
56753f
+            mixeng_volume (sw->buf, swlim, &sw->vol);
56753f
+        }
56753f
     }
56753f
 
56753f
     while (swlim) {
56753f
diff --git a/audio/audio_int.h b/audio/audio_int.h
56753f
index 117f95e..b9b0676 100644
56753f
--- a/audio/audio_int.h
56753f
+++ b/audio/audio_int.h
56753f
@@ -82,6 +82,7 @@ typedef struct HWVoiceOut {
56753f
     int samples;
56753f
     QLIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head;
56753f
     QLIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head;
56753f
+    int ctl_caps;
56753f
     struct audio_pcm_ops *pcm_ops;
56753f
     QLIST_ENTRY (HWVoiceOut) entries;
56753f
 } HWVoiceOut;
56753f
@@ -101,6 +102,7 @@ typedef struct HWVoiceIn {
56753f
 
56753f
     int samples;
56753f
     QLIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head;
56753f
+    int ctl_caps;
56753f
     struct audio_pcm_ops *pcm_ops;
56753f
     QLIST_ENTRY (HWVoiceIn) entries;
56753f
 } HWVoiceIn;
56753f
@@ -150,6 +152,7 @@ struct audio_driver {
56753f
     int max_voices_in;
56753f
     int voice_size_out;
56753f
     int voice_size_in;
56753f
+    int ctl_caps;
56753f
 };
56753f
 
56753f
 struct audio_pcm_ops {
56753f
@@ -233,6 +236,8 @@ void audio_run (const char *msg);
56753f
 #define VOICE_DISABLE 2
56753f
 #define VOICE_VOLUME 3
56753f
 
56753f
+#define VOICE_VOLUME_CAP (1 << VOICE_VOLUME)
56753f
+
56753f
 static inline int audio_ring_dist (int dst, int src, int len)
56753f
 {
56753f
     return (dst >= src) ? (dst - src) : (len - src + dst);
56753f
diff --git a/audio/audio_template.h b/audio/audio_template.h
56753f
index e62a713..519432a 100644
56753f
--- a/audio/audio_template.h
56753f
+++ b/audio/audio_template.h
56753f
@@ -263,6 +263,8 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as)
56753f
     }
56753f
 
56753f
     hw->pcm_ops = drv->pcm_ops;
56753f
+    hw->ctl_caps = drv->ctl_caps;
56753f
+
56753f
     QLIST_INIT (&hw->sw_head);
56753f
 #ifdef DAC
56753f
     QLIST_INIT (&hw->cap_head);
56753f
-- 
56753f
1.7.10
56753f