From patchwork Thu Mar 22 15:21:30 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: 148267 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 9E551B6F6E for ; Fri, 23 Mar 2012 02:22:16 +1100 (EST) Received: from localhost ([::1]:41215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAjq9-0006n0-Tt for incoming@patchwork.ozlabs.org; Thu, 22 Mar 2012 11:22:13 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAjpq-0006R8-2p for qemu-devel@nongnu.org; Thu, 22 Mar 2012 11:22:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SAjpn-0002HP-Gp for qemu-devel@nongnu.org; Thu, 22 Mar 2012 11:21:53 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:53761) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAjpn-0002Fl-85 for qemu-devel@nongnu.org; Thu, 22 Mar 2012 11:21:51 -0400 Received: by mail-we0-f173.google.com with SMTP id p12so2237834wer.4 for ; Thu, 22 Mar 2012 08:21:50 -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=dK+ww/asP2mQPoMM1FnIXCThALhOcyHQop2oI01Txx0=; b=0vy8R2zSZrliJlwtgbBLSULJezazXJNEBfnWURnIlSr7HxMptjTGR/dOLitYjVpael hqvEf84LWFZuOC+yQu8bcAiEe98TVUdJtSBHzfinen8pEQlYIma6H27ie5H8rB07lYsT WA4eHnjPvOSlsC2z/Tj6K8lsqywUW6uE2PX16owBwz65LxCKul8shQ+Kk47twAmU9abg gAJ2EXPXy5X4lMAkQVOtemR8J1yeXWe6YudowVXLmnj2aHyUU3uAQ14cM2ClRON+kbVZ P8GYUqqKCNh2x+VnHGKc083HjwKMm8pAWlxyP8k1HvXGopnwWN3PJBl0JpneP0btJfpo mmcw== Received: by 10.216.135.199 with SMTP id u49mr5116068wei.7.1332429710262; Thu, 22 Mar 2012 08:21:50 -0700 (PDT) Received: from localhost (49.pool85-58-61.dynamic.orange.es. [85.58.61.49]) by mx.google.com with ESMTPS id ff9sm5962035wib.2.2012.03.22.08.21.47 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Mar 2012 08:21:49 -0700 (PDT) From: "=?UTF-8?q?Marc-Andr=C3=A9=20Lureau?=" To: qemu-devel@nongnu.org Date: Thu, 22 Mar 2012 16:21:30 +0100 Message-Id: <1332429698-10395-3-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1332429698-10395-1-git-send-email-marcandre.lureau@redhat.com> References: <1332429698-10395-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.82.173 Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [Qemu-devel] [PATCH 02/10] 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. Signed-off-by: Marc-André Lureau --- 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);