From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS6130 216.105.38.0/24 X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS,T_DKIM_INVALID shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 30FA91F424 for ; Fri, 27 Apr 2018 17:50:56 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1fC7WD-0006yW-Dx; Fri, 27 Apr 2018 17:50:49 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fC7WC-0006yP-Fu for sox-devel@lists.sourceforge.net; Fri, 27 Apr 2018 17:50:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EffDunr2iCoEHtSf99Tka5taQ5u2VhvuVdb861ertQ8=; b=ZEusKAa0nm93R9363dBDDK31IK DMo72/vajmoWkY7OGQ5MX053u9BDjRFAx+Of2lz/1d7fqBKH6AWTpKLNpb/SayiFp1yfNpCDRBtF7 bLUdLWjEfXPPHKTl3yAHawzCSie4g+KzQKBZl/KjH4k4nF4tpLpYXEIJ/MOcvygY1F+4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version: Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=EffDunr2iCoEHtSf99Tka5taQ5u2VhvuVdb861ertQ8=; b=H5hI2A7cejMITGAcKjIBPu8NG6 lbFHMdKO339CVAO5HyHxEDkTVFu0mCDtcpgR17w/8fNVzoKgMC6fKYZKsc7XfdWhMVuQg+GFYj1o8 X3XXAE0Zf5FUJftC0qVJttNzJFjY3K+d2nR4XqoMJL9NW9GTXWS2nZrMs4TtICRVd/7E=; Received: from unicorn.mansr.com ([81.2.72.234]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1fC7WA-00EIud-J4 for sox-devel@lists.sourceforge.net; Fri, 27 Apr 2018 17:50:48 +0000 Received: by unicorn.mansr.com (Postfix, from userid 51770) id 1FFD716402; Fri, 27 Apr 2018 18:50:36 +0100 (BST) From: Mans Rullgard To: sox-devel@lists.sourceforge.net Date: Fri, 27 Apr 2018 18:50:26 +0100 Message-Id: <20180427175026.3481-1-mans@mansr.com> X-Mailer: git-send-email 2.17.0 X-Headers-End: 1fC7WA-00EIud-J4 Subject: [PATCH] oss: prefer stereo mode X-BeenThere: sox-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sox-devel@lists.sourceforge.net MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: sox-devel-bounces@lists.sourceforge.net Some OSS drivers treat mono data as stereo without any indication. To get correct playabck on such devices, attempt stereo first and fall back to mono only if this fails. --- src/oss.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/oss.c b/src/oss.c index 9b13dc2f9a1a..9c6682f1d478 100644 --- a/src/oss.c +++ b/src/oss.c @@ -63,7 +63,7 @@ typedef struct /* common r/w initialization code */ static int ossinit(sox_format_t* ft) { - int sampletype, samplesize, dsp_stereo; + int sampletype, samplesize; int tmp, rc; char const* szDevname; priv_t* pPriv = (priv_t*)ft->priv; @@ -153,7 +153,7 @@ static int ossinit(sox_format_t* ft) lsx_report("Forcing to signed linear word"); } - if (ft->signal.channels > 2) ft->signal.channels = 2; + ft->signal.channels = 2; if (ioctl(pPriv->device, (size_t) SNDCTL_DSP_RESET, 0) < 0) { @@ -213,21 +213,13 @@ static int ossinit(sox_format_t* ft) return (SOX_EOF); } - if (ft->signal.channels == 2) - dsp_stereo = 1; - else - dsp_stereo = 0; - - tmp = dsp_stereo; - if (ioctl(pPriv->device, SNDCTL_DSP_STEREO, &tmp) < 0) + tmp = 1; + if (ioctl(pPriv->device, SNDCTL_DSP_STEREO, &tmp) < 0 || tmp != 1) { - lsx_warn("Couldn't set to %s", dsp_stereo? "stereo":"mono"); - dsp_stereo = 0; + lsx_warn("Couldn't set to stereo"); + ft->signal.channels = 1; } - if (tmp != dsp_stereo) - ft->signal.channels = tmp + 1; - tmp = ft->signal.rate; if (ioctl(pPriv->device, SNDCTL_DSP_SPEED, &tmp) < 0 || (int)ft->signal.rate != tmp) { -- 2.17.0 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ SoX-devel mailing list SoX-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sox-devel