From patchwork Mon Mar 12 18:50:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 146205 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 A4338B6FB6 for ; Tue, 13 Mar 2012 05:51:07 +1100 (EST) Received: from localhost ([::1]:40553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7AKn-0007OF-Ha for incoming@patchwork.ozlabs.org; Mon, 12 Mar 2012 14:51:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7AKS-00076O-JR for qemu-devel@nongnu.org; Mon, 12 Mar 2012 14:50:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7AKN-0008MF-SS for qemu-devel@nongnu.org; Mon, 12 Mar 2012 14:50:44 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:58705) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7AKN-0008IV-Ip for qemu-devel@nongnu.org; Mon, 12 Mar 2012 14:50:39 -0400 Received: by mail-ee0-f45.google.com with SMTP id t10so1686104eei.4 for ; Mon, 12 Mar 2012 11:50:38 -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; bh=bmIqgM9uuTTm4EJkZJmAPLxU1bJh7QrR3qiSMIG5008=; b=ECsGzKtZiKPaP/C0VgtDeWIITV/kMUDQoVPb1asBc2YnvNPpTAjoOtDloAdspiFoz4 zb81klhb0EhU84+11mEgCRgCHZ8wDXsBNPf4xGpx4tX5nHlCe8bdeYZbOLTUA9SxbzQc 3EX9jc+xkvxBm7EtqIK6a1nMhnrPXhmYWQoTBGro5QgsmTtAzBkdp+SVPW3EeUXlyATK e48VdtjdZjSj9kuRInqp9PVc1Wj1LALAjNb0QRrFakrC801VOkPPBvBqQLH1Yr2kyqSx 4iaWpzH1laU53Wq0YNSPt6uqfprFTwT8uVXp2jYV2fToW9J7BRV8IabNQ7RMhvGtnuKJ vIkQ== Received: by 10.213.26.15 with SMTP id b15mr1052364ebc.167.1331578238608; Mon, 12 Mar 2012 11:50:38 -0700 (PDT) Received: from localhost (133.pool85-58-35.dynamic.orange.es. [85.58.35.133]) by mx.google.com with ESMTPS id y11sm52782608eem.3.2012.03.12.11.50.35 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Mar 2012 11:50:36 -0700 (PDT) From: "=?UTF-8?q?Marc-Andr=C3=A9=20Lureau?=" To: qemu-devel@nongnu.org Date: Mon, 12 Mar 2012 19:50:02 +0100 Message-Id: <1331578211-18232-3-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1331578211-18232-1-git-send-email-marcandre.lureau@redhat.com> References: <1331578211-18232-1-git-send-email-marcandre.lureau@redhat.com> 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 02/11] audio: don't apply volume effect if backend has VOICE_VOLUME_CAP 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 If the audio backend is capable of volume control, don't apply software volume (mixeng_volume ()), but instead, rely on backend volume control. This will allow guest to have full range volume control. --- audio/audio.c | 9 +++++++-- audio/audio_int.h | 5 +++++ audio/audio_template.h | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index d76c342..bd9237e 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -957,7 +957,9 @@ int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size) total += isamp; } - mixeng_volume (sw->buf, ret, &sw->vol); + if (!(hw->ctl_caps & VOICE_VOLUME_CAP)) { + mixeng_volume (sw->buf, ret, &sw->vol); + } sw->clip (buf, sw->buf, ret); sw->total_hw_samples_acquired += total; @@ -1041,7 +1043,10 @@ int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int size) swlim = audio_MIN (swlim, samples); if (swlim) { sw->conv (sw->buf, buf, swlim); - mixeng_volume (sw->buf, swlim, &sw->vol); + + if (!(sw->hw->ctl_caps & VOICE_VOLUME_CAP)) { + mixeng_volume (sw->buf, swlim, &sw->vol); + } } while (swlim) { diff --git a/audio/audio_int.h b/audio/audio_int.h index 117f95e..b9b0676 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -82,6 +82,7 @@ typedef struct HWVoiceOut { int samples; QLIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head; QLIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head; + int ctl_caps; struct audio_pcm_ops *pcm_ops; QLIST_ENTRY (HWVoiceOut) entries; } HWVoiceOut; @@ -101,6 +102,7 @@ typedef struct HWVoiceIn { int samples; QLIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head; + int ctl_caps; struct audio_pcm_ops *pcm_ops; QLIST_ENTRY (HWVoiceIn) entries; } HWVoiceIn; @@ -150,6 +152,7 @@ struct audio_driver { int max_voices_in; int voice_size_out; int voice_size_in; + int ctl_caps; }; struct audio_pcm_ops { @@ -233,6 +236,8 @@ void audio_run (const char *msg); #define VOICE_DISABLE 2 #define VOICE_VOLUME 3 +#define VOICE_VOLUME_CAP (1 << VOICE_VOLUME) + static inline int audio_ring_dist (int dst, int src, int len) { return (dst >= src) ? (dst - src) : (len - src + dst); diff --git a/audio/audio_template.h b/audio/audio_template.h index e62a713..519432a 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -263,6 +263,8 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as) } hw->pcm_ops = drv->pcm_ops; + hw->ctl_caps = drv->ctl_caps; + QLIST_INIT (&hw->sw_head); #ifdef DAC QLIST_INIT (&hw->cap_head);