From patchwork Fri Oct 18 07:41:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11197657 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A505217E1 for ; Fri, 18 Oct 2019 07:49:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 856F921897 for ; Fri, 18 Oct 2019 07:49:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 856F921897 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLN0f-0005qg-T8 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Oct 2019 03:49:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59215) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLMtX-0006Gs-Rt for qemu-devel@nongnu.org; Fri, 18 Oct 2019 03:41:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLMtV-00073m-Bu for qemu-devel@nongnu.org; Fri, 18 Oct 2019 03:41:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38174) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iLMtV-00072R-2E for qemu-devel@nongnu.org; Fri, 18 Oct 2019 03:41:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E1A45302C096; Fri, 18 Oct 2019 07:41:51 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-43.ams2.redhat.com [10.36.116.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DFA15C1B2; Fri, 18 Oct 2019 07:41:51 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9556D31EC0; Fri, 18 Oct 2019 09:41:44 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 13/13] paaudio: fix channel order for usb-audio 5.1 and 7.1 streams Date: Fri, 18 Oct 2019 09:41:44 +0200 Message-Id: <20191018074144.24071-14-kraxel@redhat.com> In-Reply-To: <20191018074144.24071-1-kraxel@redhat.com> References: <20191018074144.24071-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 18 Oct 2019 07:41:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?b?S8WRdsOhZ8OzQHJlZGhhdC5jb20sID0/VVRGLTg/cT9ab2x0PUMz?= =?unknown-8bit?b?PUExbj89IDxEaXJ0WS5pQ0UuaHVAZ21haWwuY29tPiwgR2VyZCBIb2Zm?= =?unknown-8bit?b?bWFubiA8a3JheGVsQHJlZGhhdC5jb20+LCBNYXJrdXMgQXJtYnJ1c3Rl?= =?unknown-8bit?b?ciA8YXJtYnJ1QHJlZGhhdC5jb20+?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Kővágó, Zoltán Signed-off-by: Kővágó, Zoltán Message-id: 2900e462d27bd73277ae083d037c32b1b4451ee2.1570996490.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann --- audio/paaudio.c | 50 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 292c8c9ff4c0..df541a72d3a9 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -339,17 +339,59 @@ static pa_stream *qpa_simple_new ( pa_stream_direction_t dir, const char *dev, const pa_sample_spec *ss, - const pa_channel_map *map, const pa_buffer_attr *attr, int *rerror) { int r; - pa_stream *stream; + pa_stream *stream = NULL; pa_stream_flags_t flags; + pa_channel_map map; pa_threaded_mainloop_lock(c->mainloop); - stream = pa_stream_new(c->context, name, ss, map); + pa_channel_map_init(&map); + map.channels = ss->channels; + + /* + * TODO: This currently expects the only frontend supporting more than 2 + * channels is the usb-audio. We will need some means to set channel + * order when a new frontend gains multi-channel support. + */ + switch (ss->channels) { + case 1: + map.map[0] = PA_CHANNEL_POSITION_MONO; + break; + + case 2: + map.map[0] = PA_CHANNEL_POSITION_LEFT; + map.map[1] = PA_CHANNEL_POSITION_RIGHT; + break; + + case 6: + map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; + map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT; + map.map[2] = PA_CHANNEL_POSITION_CENTER; + map.map[3] = PA_CHANNEL_POSITION_LFE; + map.map[4] = PA_CHANNEL_POSITION_REAR_LEFT; + map.map[5] = PA_CHANNEL_POSITION_REAR_RIGHT; + break; + + case 8: + map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; + map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT; + map.map[2] = PA_CHANNEL_POSITION_CENTER; + map.map[3] = PA_CHANNEL_POSITION_LFE; + map.map[4] = PA_CHANNEL_POSITION_REAR_LEFT; + map.map[5] = PA_CHANNEL_POSITION_REAR_RIGHT; + map.map[6] = PA_CHANNEL_POSITION_SIDE_LEFT; + map.map[7] = PA_CHANNEL_POSITION_SIDE_RIGHT; + + default: + dolog("Internal error: unsupported channel count %d\n", ss->channels); + goto fail; + } + + stream = pa_stream_new(c->context, name, ss, &map); if (!stream) { goto fail; } @@ -422,7 +464,6 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as, PA_STREAM_PLAYBACK, ppdo->has_name ? ppdo->name : NULL, &ss, - NULL, /* channel map */ &ba, /* buffering attributes */ &error ); @@ -471,7 +512,6 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) PA_STREAM_RECORD, ppdo->has_name ? ppdo->name : NULL, &ss, - NULL, /* channel map */ &ba, /* buffering attributes */ &error );