From patchwork Tue Mar 13 15:20:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 146437 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E03FCB6F62 for ; Wed, 14 Mar 2012 03:03:26 +1100 (EST) Received: from localhost ([::1]:42120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7TYj-000434-5d for incoming@patchwork.ozlabs.org; Tue, 13 Mar 2012 11:22:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7TXy-00027S-4I for qemu-devel@nongnu.org; Tue, 13 Mar 2012 11:22:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7TXZ-0003FG-Ar for qemu-devel@nongnu.org; Tue, 13 Mar 2012 11:21:57 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:38634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7TXZ-00039n-1m for qemu-devel@nongnu.org; Tue, 13 Mar 2012 11:21:33 -0400 Received: by mail-ee0-f45.google.com with SMTP id t10so359321eei.4 for ; Tue, 13 Mar 2012 08:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=2tK6piEtmwaZhA0cDodp6PZO5SIVZ2nXknjKBEdZVvo=; b=shyVnKKFdWTWnJhJ7gS/KC/HqdszzNMFDmNlZq5hS2XxHxiPwcGZoy/UjJt+eYby41 91UzIn9I0bFphYM312NzKgKTGskaT6OAC5AQpR5r13l3OfRZdfDscjapvv+dvzt3eiG0 RNRmTL5IRDQbf5lwINSmmwAtzjWwAhdEyDIMX9cgeA0YXM+Hsde3Wq7XcndV1XIliTO6 UrFIZzGaeu8dmKq9k4hzay/X5oZnRiSMnPCEakyIcCdBonUkC3I8WMXTwSQhRQCVFVHL jBRnSRloxf0pQYhxD9uqJs2IhK/Fwr733ggI0W9S79Xte6zCTfEjTft4bfLSEKye1NTO dR+g== Received: by 10.14.133.198 with SMTP id q46mr2497323eei.64.1331652092204; Tue, 13 Mar 2012 08:21:32 -0700 (PDT) Received: from localhost (254.pool85-58-48.dynamic.orange.es. [85.58.48.254]) by mx.google.com with ESMTPS id o49sm2949781eeb.7.2012.03.13.08.21.27 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Mar 2012 08:21:31 -0700 (PDT) From: "=?UTF-8?q?Marc-Andr=C3=A9=20Lureau?=" To: qemu-devel@nongnu.org Date: Tue, 13 Mar 2012 16:20:54 +0100 Message-Id: <1331652059-10090-7-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1331652059-10090-1-git-send-email-marcandre.lureau@redhat.com> References: <1331652059-10090-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.83.45 Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , dnb@redhat.com, dlaor@redhat.com, kraxel@redhat.com Subject: [Qemu-devel] [PATCH v4 06/11] audio/spice: add support for volume control X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use Spice server volume control API when available. Signed-off-by: Marc-André Lureau --- audio/spiceaudio.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index f972110..6f15591 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)