From: Takashi Iwai Subject: Re: [PATCH 6/6] pcm:plug: save converter config Date: Fri, 17 Feb 2017 18:44:30 +0100 Message-ID: References: <1487315882-9160-1-git-send-email-sutar.mounesh@gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id C9BAA2671DB for ; Fri, 17 Feb 2017 18:44:32 +0100 (CET) In-Reply-To: <1487315882-9160-1-git-send-email-sutar.mounesh@gmail.com> 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 To: sutar.mounesh@gmail.com Cc: alsa-devel@alsa-project.org, Andreas Pape , mounesh_sutar@mentor.com List-Id: alsa-devel@alsa-project.org On Fri, 17 Feb 2017 08:18:02 +0100, sutar.mounesh@gmail.com wrote: > > 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..6d0c03d 100644 > --- a/src/pcm/pcm_plug.c > +++ b/src/pcm/pcm_plug.c > @@ -64,6 +64,8 @@ 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); > assert(plug->gen.slave == plug->req_slave); > if (plug->gen.close_slave) { > snd_pcm_unlink_hw_ptr(pcm, plug->req_slave); > @@ -1108,7 +1110,15 @@ 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; > + } > + else > + snd_config_delete((snd_config_t*)plug->rate_converter); Why do we need to delete plug->rate_converter here...? It's nowhere assigned after the patch? thanks, Takashi