qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/2] Introduce AUD_set_volume v2


From: Jan Kiszka
Subject: [Qemu-devel] [PATCH 1/2] Introduce AUD_set_volume v2
Date: Fri, 02 May 2008 21:04:44 +0200
User-agent: Thunderbird 2.0.0.12 (X11/20080226)

This is second revision to improve the volume control abilities of QEMU
is based on Andrzej's patch, ie. works per-voice.

In addition, this patch corrects the nominal_volume initialization and
enables volume control by default (the user searching for this feature
will thank us ;) ). For now the NOVOL infrastructure is left in place
although I think it is useless. If we can agree on removing it, I would
immediately post an according patch.

Unless I oversaw some path, input volume control should not yet work, we
still have to apply the per-voice level before delivering the data.

Signed-off-by: Jan Kiszka <address@hidden>
---
 audio/audio.c  |   22 ++++++++++++++++++++--
 audio/audio.h  |    3 +++
 audio/mixeng.c |    2 +-
 3 files changed, 24 insertions(+), 3 deletions(-)

Index: b/audio/audio.c
===================================================================
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -117,8 +117,8 @@ volume_t nominal_volume = {
     1.0,
     1.0
 #else
-    UINT_MAX,
-    UINT_MAX
+    1ULL << 32,
+    1ULL << 32
 #endif
 };
 
@@ -1955,3 +1955,21 @@ void AUD_del_capture (CaptureVoiceOut *c
         }
     }
 }
+
+void AUD_set_volume_out (SWVoiceOut *sw, int mute, uint8_t lvol, uint8_t rvol)
+{
+    if (sw) {
+        sw->vol.mute = mute;
+        sw->vol.l = nominal_volume.l * lvol / 255;
+        sw->vol.r = nominal_volume.r * rvol / 255;
+    }
+}
+
+void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol)
+{
+    if (sw) {
+        sw->vol.mute = mute;
+        sw->vol.l = nominal_volume.l * lvol / 255;
+        sw->vol.r = nominal_volume.r * rvol / 255;
+    }
+}
Index: b/audio/audio.h
===================================================================
--- a/audio/audio.h
+++ b/audio/audio.h
@@ -124,6 +124,9 @@ int  AUD_is_active_out (SWVoiceOut *sw);
 void     AUD_init_time_stamp_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
 uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
 
+void AUD_set_volume_out (SWVoiceOut *sw, int mute, uint8_t lvol, uint8_t rvol);
+void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol);
+
 SWVoiceIn *AUD_open_in (
     QEMUSoundCard *card,
     SWVoiceIn *sw,
Index: b/audio/mixeng.c
===================================================================
--- a/audio/mixeng.c
+++ b/audio/mixeng.c
@@ -28,7 +28,7 @@
 #define AUDIO_CAP "mixeng"
 #include "audio_int.h"
 
-#define NOVOL
+//#define NOVOL
 
 /* 8 bit */
 #define ENDIAN_CONVERSION natural




reply via email to

[Prev in Thread] Current Thread [Next in Thread]