* [PATCH v3 6/6] pcm:plug: save converter config
@ 2017-03-03 9:58 sutar.mounesh
2017-03-09 10:21 ` Sutar, Mounesh
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: sutar.mounesh @ 2017-03-03 9:58 UTC (permalink / raw)
To: patch; +Cc: Mounesh Sutar, alsa-devel, Andreas Pape, mounesh_sutar
From: Andreas Pape <apape@de.adit-jv.com>
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 <apape@de.adit-jv.com>
Signed-off-by: Mounesh Sutar <sutar.mounesh@gmail.com>
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;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 6/6] pcm:plug: save converter config
2017-03-03 9:58 [PATCH v3 6/6] pcm:plug: save converter config sutar.mounesh
@ 2017-03-09 10:21 ` Sutar, Mounesh
2017-03-17 6:19 ` Sutar, Mounesh
2017-03-18 2:28 ` Takashi Sakamoto
2 siblings, 0 replies; 4+ messages in thread
From: Sutar, Mounesh @ 2017-03-09 10:21 UTC (permalink / raw)
To: patch; +Cc: sutar.mounesh, alsa-devel, Andreas Pape
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 <Mounesh_Sutar@mentor.com>; Andreas Pape <apape@de.adit-jv.com>; Mounesh Sutar <sutar.mounesh@gmail.com>
Subject: [PATCH v3 6/6] pcm:plug: save converter config
From: Andreas Pape <apape@de.adit-jv.com>
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 <apape@de.adit-jv.com>
Signed-off-by: Mounesh Sutar <sutar.mounesh@gmail.com>
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;
}
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 6/6] pcm:plug: save converter config
2017-03-03 9:58 [PATCH v3 6/6] pcm:plug: save converter config sutar.mounesh
2017-03-09 10:21 ` Sutar, Mounesh
@ 2017-03-17 6:19 ` Sutar, Mounesh
2017-03-18 2:28 ` Takashi Sakamoto
2 siblings, 0 replies; 4+ messages in thread
From: Sutar, Mounesh @ 2017-03-17 6:19 UTC (permalink / raw)
To: patch; +Cc: sutar.mounesh, alsa-devel, Andreas Pape
ping
-----Original Message-----
From: Sutar, Mounesh
Sent: 09 March 2017 15:51
To: patch@alsa-project.org
Cc: alsa-devel@alsa-project.org; Andreas Pape <apape@de.adit-jv.com>; 'sutar.mounesh@gmail.com' <sutar.mounesh@gmail.com>
Subject: RE: [PATCH v3 6/6] pcm:plug: save converter config
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 <Mounesh_Sutar@mentor.com>; Andreas Pape <apape@de.adit-jv.com>; Mounesh Sutar <sutar.mounesh@gmail.com>
Subject: [PATCH v3 6/6] pcm:plug: save converter config
From: Andreas Pape <apape@de.adit-jv.com>
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 <apape@de.adit-jv.com>
Signed-off-by: Mounesh Sutar <sutar.mounesh@gmail.com>
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;
}
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 6/6] pcm:plug: save converter config
2017-03-03 9:58 [PATCH v3 6/6] pcm:plug: save converter config sutar.mounesh
2017-03-09 10:21 ` Sutar, Mounesh
2017-03-17 6:19 ` Sutar, Mounesh
@ 2017-03-18 2:28 ` Takashi Sakamoto
2 siblings, 0 replies; 4+ messages in thread
From: Takashi Sakamoto @ 2017-03-18 2:28 UTC (permalink / raw)
To: sutar.mounesh, patch; +Cc: alsa-devel, Andreas Pape, mounesh_sutar
Hi,
On Mar 3 2017 18:58, sutar.mounesh@gmail.com wrote:
> From: Andreas Pape <apape@de.adit-jv.com>
>
> 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 <apape@de.adit-jv.com>
> Signed-off-by: Mounesh Sutar <sutar.mounesh@gmail.com>
I agree with your idea to fix this issue. However...
> 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;
> + }
> + }
> +
The 'rate_converter' member is not referred in a call of following
snd_pcm_new(), thus the copy operation can be postponed enough later
than the call. This dedicates code simplicity, I think.
> 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;
> }
Thanks
Takashi Sakamoto
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-18 2:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 9:58 [PATCH v3 6/6] pcm:plug: save converter config sutar.mounesh
2017-03-09 10:21 ` Sutar, Mounesh
2017-03-17 6:19 ` Sutar, Mounesh
2017-03-18 2:28 ` Takashi Sakamoto
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.