From patchwork Tue Apr 17 12:32:40 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: 153181 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 96E67B705E for ; Tue, 17 Apr 2012 23:47:53 +1000 (EST) Received: from localhost ([::1]:36821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SK8l5-0000N3-Hr for incoming@patchwork.ozlabs.org; Tue, 17 Apr 2012 09:47:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SK7bC-0002Uu-38 for qemu-devel@nongnu.org; Tue, 17 Apr 2012 08:33:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SK7bA-0008OH-9o for qemu-devel@nongnu.org; Tue, 17 Apr 2012 08:33:33 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:47043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SK7bA-0008AG-1L for qemu-devel@nongnu.org; Tue, 17 Apr 2012 08:33:32 -0400 Received: by mail-pb0-f45.google.com with SMTP id uo5so8847635pbc.4 for ; Tue, 17 Apr 2012 05:33:31 -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=hGSLhLTVN5E4d2yhEDPOdPQawlTc8XpcfDUxkUYG3fY=; b=o+lD79DFuDPXMIXLUibJYjL/maYF7AEgHsh0HuFeBk5v1FeQW2BcGkTTSI6DnZXE4m RpT5F5+XQ1te1f/528SafYBQwhdh6D7q5F0XL/vVtewtHJMsycD0tP9/e9RdyTo9oJm4 kv/12Hh7fKSilHM52ECUiRDAM7ddGyxjRfpQAkXcSkIdxUu+Bl/bcZ5LhQxc5t21kzXs Hh4PIy7U3tiGB/xzrpZ4Qhwnsp9ZVwm0g97maZHawM9xAWYiFU4S/C2QNCFkYap7MI0H 8K6+yFlF4gLDfZ3rXpQgVzAXR6+aLKMeCujXXZcjwrQO4pcTFkqrC/ZAK6dtUStx6YeB t4XA== Received: by 10.68.222.38 with SMTP id qj6mr9483389pbc.69.1334666011181; Tue, 17 Apr 2012 05:33:31 -0700 (PDT) Received: from localhost (140.pool85-58-59.dynamic.orange.es. [85.58.59.140]) by mx.google.com with ESMTPS id qo2sm16089536pbb.15.2012.04.17.05.33.28 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Apr 2012 05:33:30 -0700 (PDT) From: "=?UTF-8?q?Marc-Andr=C3=A9=20Lureau?=" To: qemu-devel@nongnu.org Date: Tue, 17 Apr 2012 14:32:40 +0200 Message-Id: <1334665964-3075-7-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1334665964-3075-1-git-send-email-marcandre.lureau@redhat.com> References: <1334665964-3075-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: 209.85.160.45 Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , dlaor@redhat.com, kraxel@redhat.com, areis@redhat.com Subject: [Qemu-devel] [PATCH 06/10] 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 file changed, 41 insertions(+) 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)