From patchwork Fri Mar 3 09:58:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sutar.mounesh@gmail.com X-Patchwork-Id: 9602457 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 C5CB160453 for ; Fri, 3 Mar 2017 09:58:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B783122B1F for ; Fri, 3 Mar 2017 09:58:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABBE5285EB; Fri, 3 Mar 2017 09:58:53 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no 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 A918222B1F for ; Fri, 3 Mar 2017 09:58:52 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B6185266927; Fri, 3 Mar 2017 10:58:47 +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 E6503266927; Fri, 3 Mar 2017 10:58:45 +0100 (CET) Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by alsa0.perex.cz (Postfix) with ESMTP id ADB0C2668C0; Fri, 3 Mar 2017 10:58:40 +0100 (CET) Received: by mail-pf0-f194.google.com with SMTP id x66so9463508pfb.1; Fri, 03 Mar 2017 01:58:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=C1j0Ig/lwP33elKS9ER1DWPNXAWbMwqSBuCnRNkFDsI=; b=vSD8lR/sLIlhz6BMguWgllctSGHaW2OGWwiHzvnzsuFvXSLmi3rHeX2M/vmLbUrB7y tvjpC/2GtjxlbQJtanbRP5WgeVmZ48OsT/uRZGbV2d2Q+5BZZ6fK5xXBXQffqA+zUDX6 aBdw12/a/jzaceAwyYLOYB3IRYih+Ds/ZPdSMQ2UoUwf1Vr3ek4hw93+7SaRgF/xlnHM zD3Xaw4pKqfHonh2RBnToZF1pACWIaW1Cqc8taEKFWcUHHnEU0X/HamZ+JHndjLDi5gg XGrQufRqaZkGHvVIhOMQOcsg0bcQcjt4lqxhEC9h3lnCTrbXz0UuHy4RocdgFha85MZH h2JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=C1j0Ig/lwP33elKS9ER1DWPNXAWbMwqSBuCnRNkFDsI=; b=mID+Krgf8xWsGtxjo6HeJWI7F7+lSLoU5aDUv50L1V2zs78LpQSPa8bWqxacIgACta kECAWAqjLImLGg2Xr8zPdg2+fUS5s+2aLjkzh2jm45ugf9uk/wHUcK5i+Orw17L42AtA HKFTamgAnaTQIUPdPjORpLs76NUnK4uN/WZaMXES+toFxGNVX8b2L89aM3qogj9DyN03 NluTlGh80S1+17MqTaJlsD0J1mtVzIZynyCu1w0lGd8E//zbxO+CtvYeEAeWZv+0nNgv PuylIdMYVYKbbc0cEplaCXyF3noDtIHgji56XwchS6N7UEk4KJFlsWk1+MxJkTB6V8NQ 2rkw== X-Gm-Message-State: AMke39nu32rgEpOUKdbrrowBsrZCP7j3T7Acdaovv6QacGBXbxQvFrnFhb2PhrNCH5+1/g== X-Received: by 10.99.167.9 with SMTP id d9mr2324670pgf.19.1488535118803; Fri, 03 Mar 2017 01:58:38 -0800 (PST) Received: from msutar-VirtualBox.inp.mentorg.com ([139.181.35.34]) by smtp.gmail.com with ESMTPSA id c22sm22451910pgn.43.2017.03.03.01.58.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 01:58:38 -0800 (PST) From: sutar.mounesh@gmail.com To: patch@alsa-project.org Date: Fri, 3 Mar 2017 15:28:29 +0530 Message-Id: <1488535109-11572-1-git-send-email-sutar.mounesh@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: Mounesh Sutar , alsa-devel@alsa-project.org, Andreas Pape , mounesh_sutar@mentor.com Subject: [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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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, 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; }