From 700cd06c538638d3aa72b56408f2f7cbd3e38902 Mon Sep 17 00:00:00 2001 Message-Id: <700cd06c538638d3aa72b56408f2f7cbd3e38902.1369841886.git.minovotn@redhat.com> In-Reply-To: <9db4fbc10d733a88102ef99acaf6eb5d54153495.1369841886.git.minovotn@redhat.com> References: <9db4fbc10d733a88102ef99acaf6eb5d54153495.1369841886.git.minovotn@redhat.com> From: Marc-Andr Lureau Date: Wed, 29 May 2013 14:39:30 +0200 Subject: [PATCH 13/14] audio/spice: add support for volume control MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Marc-André Lureau Message-id: <1369838371-26570-3-git-send-email-marcandre.lureau@redhat.com> Patchwork-id: 51684 O-Subject: [RHEL-6.5 qemu-kvm PATCHv3 12/13] audio/spice: add support for volume control Bugzilla: 884253 RH-Acked-by: Hans de Goede RH-Acked-by: Gerd Hoffmann RH-Acked-by: Paolo Bonzini From: Marc-André Lureau Use Spice server volume control API when available. Signed-off-by: Marc-Andr? Lureau Signed-off-by: malc (cherry picked from commit a70c99c6140bd4b0d0bc3ddc7c5fc09a773921c6) --- audio/spiceaudio.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) Signed-off-by: Michal Novotny --- audio/spiceaudio.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index a5c0d6b..cb3f128 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -202,7 +202,26 @@ static int line_out_ctl (HWVoiceOut *hw, int cmd, ...) } spice_server_playback_stop (&out->sin); break; + case VOICE_VOLUME: + { +#if ((SPICE_INTERFACE_PLAYBACK_MAJOR >= 1) && (SPICE_INTERFACE_PLAYBACK_MINOR >= 2)) + SWVoiceOut *sw; + va_list ap; + uint16_t vol[2]; + + va_start (ap, cmd); + sw = va_arg (ap, SWVoiceOut *); + va_end (ap); + + vol[0] = sw->vol.l / ((1ULL << 16) + 1); + vol[1] = sw->vol.r / ((1ULL << 16) + 1); + spice_server_playback_set_volume (&out->sin, 2, vol); + spice_server_playback_set_mute (&out->sin, sw->vol.mute); +#endif + break; + } } + return 0; } @@ -304,7 +323,26 @@ static int line_in_ctl (HWVoiceIn *hw, int cmd, ...) in->active = 0; spice_server_record_stop (&in->sin); break; + case VOICE_VOLUME: + { +#if ((SPICE_INTERFACE_RECORD_MAJOR >= 2) && (SPICE_INTERFACE_RECORD_MINOR >= 2)) + SWVoiceIn *sw; + va_list ap; + uint16_t vol[2]; + + va_start (ap, cmd); + sw = va_arg (ap, SWVoiceIn *); + va_end (ap); + + vol[0] = sw->vol.l / ((1ULL << 16) + 1); + vol[1] = sw->vol.r / ((1ULL << 16) + 1); + spice_server_record_set_volume (&in->sin, 2, vol); + spice_server_record_set_mute (&in->sin, sw->vol.mute); +#endif + break; + } } + return 0; } @@ -337,6 +375,9 @@ struct audio_driver spice_audio_driver = { .max_voices_in = 1, .voice_size_out = sizeof (SpiceVoiceOut), .voice_size_in = sizeof (SpiceVoiceIn), +#if ((SPICE_INTERFACE_PLAYBACK_MAJOR >= 1) && (SPICE_INTERFACE_PLAYBACK_MINOR >= 2)) + .ctl_caps = VOICE_VOLUME_CAP +#endif }; void qemu_spice_audio_init (void) -- 1.7.11.7