* [PATCH] plug: Move fast_ops copy after slave configuration.
@ 2011-12-11 19:42 Reilly Grant
2011-12-12 0:18 ` Raymond Yau
0 siblings, 1 reply; 4+ messages in thread
From: Reilly Grant @ 2011-12-11 19:42 UTC (permalink / raw)
To: patch, alsa-devel
[-- Attachment #1.1: Type: text/plain, Size: 1572 bytes --]
The plug plugin copies the fast_ops structure and fast_op_arg from its
slave PCM on initialization and after inserting a new plugin. This works
unless the slave PCM is also an instance of the plug plugin because plug
can change its fast_ops structure during _snd_pcm_hw_params.
Instead of copying fast_ops in snd_pcm_plug_insert_plugins wait until
the end of snd_pcm_plug_hw_params when the slave has been fully
initialized.
This fixes a crash when two instances of plug are instantiated back to
back and the format conversion plugin inserted by the second is skipped
by the first because the fast_ops pointer is not properly updated. This
is the case for applications requesting plug:default on Intel HDA chips.
---
src/pcm/pcm_plug.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c
index e9d2923..72456d5 100644
--- a/src/pcm/pcm_plug.c
+++ b/src/pcm/pcm_plug.c
@@ -659,8 +659,6 @@ static int snd_pcm_plug_insert_plugins(snd_pcm_t *pcm,
}
if (err) {
plug->gen.slave = new;
- pcm->fast_ops = new->fast_ops;
- pcm->fast_op_arg = new->fast_op_arg;
}
k++;
}
@@ -1049,6 +1047,9 @@ static int snd_pcm_plug_hw_params(snd_pcm_t *pcm,
snd_pcm_hw_params_t *params)
}
snd_pcm_unlink_hw_ptr(pcm, plug->req_slave);
snd_pcm_unlink_appl_ptr(pcm, plug->req_slave);
+
+ pcm->fast_ops = slave->fast_ops;
+ pcm->fast_op_arg = slave->fast_op_arg;
snd_pcm_link_hw_ptr(pcm, slave);
snd_pcm_link_appl_ptr(pcm, slave);
return 0;
--
1.7.3.4
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 900 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] plug: Move fast_ops copy after slave configuration.
2011-12-11 19:42 [PATCH] plug: Move fast_ops copy after slave configuration Reilly Grant
@ 2011-12-12 0:18 ` Raymond Yau
2011-12-12 17:00 ` Reilly Grant
0 siblings, 1 reply; 4+ messages in thread
From: Raymond Yau @ 2011-12-12 0:18 UTC (permalink / raw)
To: alsa-devel
2011/12/12 Reilly Grant <reillyeon@qotw.net>:
>
> This fixes a crash when two instances of plug are instantiated back to
> back and the format conversion plugin inserted by the second is skipped
> by the first because the fast_ops pointer is not properly updated. This
> is the case for applications requesting plug:default on Intel HDA chips.
The card 's "default" device of snd-hda-intel should be "plug:dmix"
you don't need to use "plug:default"
http://git.alsa-project.org/?p=alsa-lib.git;a=blob_plain;f=src/conf/cards/HDA-Intel.conf
# default with dmix+softvol & dsnoop
HDA-Intel.pcm.default {
@args [ CARD ]
@args.CARD {
type string
}
type asym
playback.pcm {
type plug
slave.pcm {
type softvol
slave.pcm {
@func concat
strings [ "dmix:" $CARD ]
}
control {
name "PCM Playback Volume"
card $CARD
}
}
}
capture.pcm {
type plug
slave.pcm {
type softvol
slave.pcm {
@func concat
strings [ "dsnoop:" $CARD ]
}
control {
name "Digital Capture Volume"
card $CARD
}
min_dB -30.0
max_dB 30.0
resolution 121
}
# to avoid possible phase inversions with digital mics
route_policy copy
}
hint.device 0
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] plug: Move fast_ops copy after slave configuration.
@ 2011-12-06 2:05 Reilly Grant
0 siblings, 0 replies; 4+ messages in thread
From: Reilly Grant @ 2011-12-06 2:05 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1.1: Type: text/plain, Size: 1493 bytes --]
The plug plugin copies the fast_ops structure and fast_op_arg from its
slave PCM on initialization and after inserting a new plugin. This works
unless the slave PCM is also an instance of the plug plugin because plug
can change its fast_ops structure during _snd_pcm_hw_params.
Instead of copying fast_ops in snd_pcm_plug_insert_plugins wait until
the end of snd_pcm_plug_hw_params when the slave has been fully
initialized.
This fixes a crash when two instances of plug are instantiated back to
back and the format conversion plugin inserted by the second is skipped
by the first because the fast_ops pointer is not properly updated.
---
src/pcm/pcm_plug.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c
index e9d2923..72456d5 100644
--- a/src/pcm/pcm_plug.c
+++ b/src/pcm/pcm_plug.c
@@ -659,8 +659,6 @@ static int snd_pcm_plug_insert_plugins(snd_pcm_t *pcm,
}
if (err) {
plug->gen.slave = new;
- pcm->fast_ops = new->fast_ops;
- pcm->fast_op_arg = new->fast_op_arg;
}
k++;
}
@@ -1049,6 +1047,9 @@ static int snd_pcm_plug_hw_params(snd_pcm_t *pcm,
snd_pcm_hw_params_t *params)
}
snd_pcm_unlink_hw_ptr(pcm, plug->req_slave);
snd_pcm_unlink_appl_ptr(pcm, plug->req_slave);
+
+ pcm->fast_ops = slave->fast_ops;
+ pcm->fast_op_arg = slave->fast_op_arg;
snd_pcm_link_hw_ptr(pcm, slave);
snd_pcm_link_appl_ptr(pcm, slave);
return 0;
--
1.7.3.4
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 900 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-12-12 17:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-11 19:42 [PATCH] plug: Move fast_ops copy after slave configuration Reilly Grant
2011-12-12 0:18 ` Raymond Yau
2011-12-12 17:00 ` Reilly Grant
-- strict thread matches above, loose matches on Subject: below --
2011-12-06 2:05 Reilly Grant
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).