Skip to contentSkip to conversation

Introduce AUD_set_volume v2

PATCH New Jan Kiszka 1 participant 1 message May 2, 2008

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/2 Introduce AUD_set_volume v2

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.

---
 audio/audio.c  |   22 ++++++++++++++++++++--
 audio/audio.h  |    3 +++
 audio/mixeng.c |    2 +-
 3 files changed, 24 insertions(+), 3 deletions(-)
audio/audio.c +20 -2
Index: 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;
+    }
+}
audio/audio.h +3 -0
Index: 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,
audio/mixeng.c +1 -1
Index: 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