From patchwork Tue Mar 21 12:58:18 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: 9636559 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 9C51A60216 for ; Tue, 21 Mar 2017 12:58:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9377E20952 for ; Tue, 21 Mar 2017 12:58:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8668F27CF3; Tue, 21 Mar 2017 12:58:34 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM, 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 99F1520952 for ; Tue, 21 Mar 2017 12:58:33 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id AA0C6267299; Tue, 21 Mar 2017 13:58:31 +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 EAD2F267299; Tue, 21 Mar 2017 13:58:29 +0100 (CET) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by alsa0.perex.cz (Postfix) with ESMTP id A75FE267296; Tue, 21 Mar 2017 13:58:26 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id u132so2765386wmg.1; Tue, 21 Mar 2017 05:58:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=aSiKwv0GEg0FZCtOsZwN0x4OVgV9qYiY8crrsuBbwn4=; b=r1Lc0h2dI5aAROLnLcAgQsMINC5GfHHEnBTexCEN8Nh1NDx0B9IfI/YQCEg7N5xQDK eUs+s0VMYovyH/7HiB8RKWFmRdHjFmxfBj5vyq9hU933C4XYlBGomCRmU+vjPb3bE1AT RWBjYwgMgLq2WLnlT+Hhtds2sVdXJI97cXvhtVaUCl+PKWlAz7AszaKkqrY86vnkiLK/ ag56MuRVFC7+JYgMUbqxgzSRFpo85OY9Ssl3L96iVT6HiuSsZxixNXNIOIqhlZnHaMlx Iaf6Ipzo8W1az/5t5cIeHUagEfqGDDX3sbhA3kYzv61gtbFJFx1kfFEp6r/euzGEF9Oh qZHg== 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=aSiKwv0GEg0FZCtOsZwN0x4OVgV9qYiY8crrsuBbwn4=; b=JczFZQabaDr4teQjwMdn8pfVlflMGAsW0elNhoJDItroVmLkdFs7GSmAiOt8+OTWlZ okDzf1agoYDazKv8caRJdPiWfOaVxe8mBKerpDF7fdQaTiqQbXHtxIlTcGNNTRqBZwFc n5AuhE4J9VqTiYRhYyy2eVoY6HalI/UsxXiLjoKxmh0EdllleFLOQXxh2BRvEZDaN8Mh qFHb/0R5xi9tGewAyWSYkB2r9wR5Az7GKFp+6eO5d31FbbE5GbGFdYfme0Dr/dlJvGK9 A8gpPjyTawrZd3c3OcAvAOcb/MrGi48ivL9UVYywdEjgvIJAuwRaBv8ShRGPvA0lXvJS i8aA== X-Gm-Message-State: AFeK/H3JbPrSsCX1REAob/4biv8lDiIl9Dn9CaoK7KcwSMpCXKZe31Xtk9TRKvCHTgSsHg== X-Received: by 10.28.197.133 with SMTP id v127mr2525458wmf.120.1490101105786; Tue, 21 Mar 2017 05:58:25 -0700 (PDT) Received: from msutar-VirtualBox.inp.mentorg.com ([139.181.35.34]) by smtp.gmail.com with ESMTPSA id s18sm17585045wmb.18.2017.03.21.05.58.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Mar 2017 05:58:25 -0700 (PDT) From: sutar.mounesh@gmail.com To: patch@alsa-project.org Date: Tue, 21 Mar 2017 18:28:18 +0530 Message-Id: <1490101098-24998-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 v5 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..c4375ec 100644 --- a/src/pcm/pcm_plug.c +++ b/src/pcm/pcm_plug.c @@ -50,7 +50,7 @@ typedef struct { snd_pcm_format_t sformat; int schannels; int srate; - const snd_config_t *rate_converter; + snd_config_t *rate_converter; enum snd_pcm_plug_route_policy route_policy; snd_pcm_route_ttable_entry_t *ttable; int ttable_ok; @@ -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(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,6 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp, plug->sformat = sformat; plug->schannels = schannels; plug->srate = srate; - plug->rate_converter = rate_converter; plug->gen.slave = plug->req_slave = slave; plug->gen.close_slave = close_slave; plug->route_policy = route_policy; @@ -1125,6 +1128,15 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp, pcm->ops = &snd_pcm_plug_ops; pcm->fast_ops = slave->fast_ops; pcm->fast_op_arg = slave->fast_op_arg; + if (rate_converter) { + err = snd_config_copy(&plug->rate_converter, + (snd_config_t *)rate_converter); + if (err < 0) { + snd_pcm_free(pcm); + free(plug); + return err; + } + } pcm->private_data = plug; pcm->poll_fd = slave->poll_fd; pcm->poll_events = slave->poll_events;