From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Js0Zk-0002Fs-9b for qemu-devel@nongnu.org; Fri, 02 May 2008 15:05:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Js0Zi-0002FY-P5 for qemu-devel@nongnu.org; Fri, 02 May 2008 15:05:43 -0400 Received: from [199.232.76.173] (port=57325 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Js0Zi-0002FV-Kf for qemu-devel@nongnu.org; Fri, 02 May 2008 15:05:42 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Js0Zi-0002az-1b for qemu-devel@nongnu.org; Fri, 02 May 2008 15:05:42 -0400 Message-ID: <481B65CC.7080801@web.de> Date: Fri, 02 May 2008 21:04:44 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Sender: jan.kiszka@web.de Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 1/2] Introduce AUD_set_volume v2 Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- audio/audio.c | 22 ++++++++++++++++++++-- audio/audio.h | 3 +++ audio/mixeng.c | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) Index: b/audio/audio.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- a/audio/audio.c +++ b/audio/audio.c @@ -117,8 +117,8 @@ volume_t nominal_volume =3D { 1.0, 1.0 #else - UINT_MAX, - UINT_MAX + 1ULL << 32, + 1ULL << 32 #endif }; =20 @@ -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 =3D mute; + sw->vol.l =3D nominal_volume.l * lvol / 255; + sw->vol.r =3D nominal_volume.r * rvol / 255; + } +} + +void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t r= vol) +{ + if (sw) { + sw->vol.mute =3D mute; + sw->vol.l =3D nominal_volume.l * lvol / 255; + sw->vol.r =3D nominal_volume.r * rvol / 255; + } +} Index: b/audio/audio.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 *t= s); =20 +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 r= vol); + SWVoiceIn *AUD_open_in ( QEMUSoundCard *card, SWVoiceIn *sw, Index: b/audio/mixeng.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -28,7 +28,7 @@ #define AUDIO_CAP "mixeng" #include "audio_int.h" =20 -#define NOVOL +//#define NOVOL =20 /* 8 bit */ #define ENDIAN_CONVERSION natural