From patchwork Thu Mar 9 10:21:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sutar, Mounesh" X-Patchwork-Id: 9612963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A1B60604D9 for ; Thu, 9 Mar 2017 10:21:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DC0F284D3 for ; Thu, 9 Mar 2017 10:21:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F5D4285E8; Thu, 9 Mar 2017 10:21:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F28A284D3 for ; Thu, 9 Mar 2017 10:21:34 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id EF5832671DF; Thu, 9 Mar 2017 11:21:30 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id E2B202671DF; Thu, 9 Mar 2017 11:21:28 +0100 (CET) Received: from relay1.mentorg.com (relay1.mentorg.com [192.94.38.131]) by alsa0.perex.cz (Postfix) with ESMTP id 1B6E52671D3; Thu, 9 Mar 2017 11:21:23 +0100 (CET) Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-03.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1clvCD-0006cH-51 from Mounesh_Sutar@mentor.com ; Thu, 09 Mar 2017 02:21:21 -0800 Received: from SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) by SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Thu, 9 Mar 2017 10:21:18 +0000 Received: from SVR-IES-MBX-04.mgc.mentorg.com ([fe80::9dd6:2f1c:ad6:d35f]) by SVR-IES-MBX-04.mgc.mentorg.com ([fe80::9dd6:2f1c:ad6:d35f%22]) with mapi id 15.00.1210.000; Thu, 9 Mar 2017 10:21:18 +0000 From: "Sutar, Mounesh" To: "patch@alsa-project.org" Thread-Topic: [PATCH v3 6/6] pcm:plug: save converter config Thread-Index: AQHSlATTN0MU1EwSVkyHyrFmXjb8K6GMVYRQ Date: Thu, 9 Mar 2017 10:21:18 +0000 Message-ID: <4f438adcb1cc4665832b336ff9eed86b@SVR-IES-MBX-04.mgc.mentorg.com> References: <1488535109-11572-1-git-send-email-sutar.mounesh@gmail.com> In-Reply-To: <1488535109-11572-1-git-send-email-sutar.mounesh@gmail.com> Accept-Language: en-US, en-IE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [137.202.0.87] MIME-Version: 1.0 Cc: "sutar.mounesh@gmail.com" , "alsa-devel@alsa-project.org" , Andreas Pape Subject: Re: [alsa-devel] [PATCH v3 6/6] pcm:plug: save converter config X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP ping -----Original Message----- From: sutar.mounesh@gmail.com [mailto:sutar.mounesh@gmail.com] Sent: 03 March 2017 15:28 To: patch@alsa-project.org Cc: alsa-devel@alsa-project.org; Sutar, Mounesh ; Andreas Pape ; Mounesh Sutar Subject: [PATCH v3 6/6] pcm:plug: save converter config From: Andreas Pape Passed config is freed after call to open, thus it is invalid when trying to extract the converter name. So config entry is saved for later usage. Signed-off-by: Andreas Pape Signed-off-by: Mounesh Sutar plug->sformat = sformat; plug->schannels = schannels; plug->srate = srate; - plug->rate_converter = rate_converter; + if (rate_converter) { + if ((err = snd_config_copy((snd_config_t**)&plug->rate_converter, + (snd_config_t *)rate_converter)) < 0) { + free(plug); + return err; + } + } + plug->gen.slave = plug->req_slave = slave; plug->gen.close_slave = close_slave; plug->route_policy = route_policy; @@ -1119,6 +1130,10 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp, err = snd_pcm_new(&pcm, SND_PCM_TYPE_PLUG, name, slave->stream, slave->mode); if (err < 0) { + if (plug->rate_converter) { + snd_config_delete((snd_config_t*)plug->rate_converter); + plug->rate_converter = NULL; + } free(plug); return err; } --- 2.7.4 diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c index 266707b..c643278 100644 --- a/src/pcm/pcm_plug.c +++ b/src/pcm/pcm_plug.c @@ -64,6 +64,10 @@ static int snd_pcm_plug_close(snd_pcm_t *pcm) snd_pcm_plug_t *plug = pcm->private_data; int err, result = 0; free(plug->ttable); + if (plug->rate_converter) { + snd_config_delete((snd_config_t*)plug->rate_converter); + plug->rate_converter = NULL; + } assert(plug->gen.slave == plug->req_slave); if (plug->gen.close_slave) { snd_pcm_unlink_hw_ptr(pcm, plug->req_slave); @@ -1108,7 +1112,14 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp,