* snd_pcm_drop causing lockup with DMix
@ 2010-02-28 15:37 John Lindgren
2010-02-28 16:22 ` Jaroslav Kysela
0 siblings, 1 reply; 10+ messages in thread
From: John Lindgren @ 2010-02-28 15:37 UTC (permalink / raw)
To: alsa-devel
Hi,
A couple of weeks ago I reported a rather serious bug #4914 that can
cause a multi-threaded using ALSA to lock up so that it can only be
ended with SIGKILL.
I maintain the ALSA output part of Audacious, and I need to be able to
play audio in one thread of the program and then signal that thread to
stop from another. The way to do this in ALSA, if I understand
correctly, is to interrupt the thread that is sending audio with a call
to snd_pcm_drop. But using DMix makes the first thread hang up in a
snd_pcm_wait call with a timeout of -1.
Is anyone working on this bug? Is there any more help I can provide?
John Lindgren
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: snd_pcm_drop causing lockup with DMix
2010-02-28 15:37 snd_pcm_drop causing lockup with DMix John Lindgren
@ 2010-02-28 16:22 ` Jaroslav Kysela
2010-02-28 17:15 ` John Lindgren
0 siblings, 1 reply; 10+ messages in thread
From: Jaroslav Kysela @ 2010-02-28 16:22 UTC (permalink / raw)
To: John Lindgren; +Cc: alsa-devel
On Sun, 28 Feb 2010, John Lindgren wrote:
> Hi,
>
> A couple of weeks ago I reported a rather serious bug #4914 that can
> cause a multi-threaded using ALSA to lock up so that it can only be
> ended with SIGKILL.
>
> I maintain the ALSA output part of Audacious, and I need to be able to
> play audio in one thread of the program and then signal that thread to
> stop from another. The way to do this in ALSA, if I understand
> correctly, is to interrupt the thread that is sending audio with a call
> to snd_pcm_drop. But using DMix makes the first thread hang up in a
> snd_pcm_wait call with a timeout of -1.
>
> Is anyone working on this bug? Is there any more help I can provide?
Could you try this patch?
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
index d9e596e..8c7ca06 100644
--- a/src/pcm/pcm_direct.c
+++ b/src/pcm/pcm_direct.c
@@ -1274,6 +1274,7 @@ int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix)
snd_timer_params_set_ticks(params, 1);
if (dmix->tread) {
filter = (1<<SND_TIMER_EVENT_TICK) |
+ (1<<SND_TIMER_EVENT_STOP) |
dmix->timer_event_suspend |
dmix->timer_event_resume;
snd_timer_params_set_filter(params, filter);
Jaroslav
-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: snd_pcm_drop causing lockup with DMix
2010-02-28 16:22 ` Jaroslav Kysela
@ 2010-02-28 17:15 ` John Lindgren
2010-03-01 6:53 ` Jaroslav Kysela
0 siblings, 1 reply; 10+ messages in thread
From: John Lindgren @ 2010-02-28 17:15 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: alsa-devel
Unfortunately, it doesn't make a difference.
On Sun, 2010-02-28 at 17:22 +0100, Jaroslav Kysela wrote:
> Could you try this patch?
>
> diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
> index d9e596e..8c7ca06 100644
> --- a/src/pcm/pcm_direct.c
> +++ b/src/pcm/pcm_direct.c
> @@ -1274,6 +1274,7 @@ int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix)
> snd_timer_params_set_ticks(params, 1);
> if (dmix->tread) {
> filter = (1<<SND_TIMER_EVENT_TICK) |
> + (1<<SND_TIMER_EVENT_STOP) |
> dmix->timer_event_suspend |
> dmix->timer_event_resume;
> snd_timer_params_set_filter(params, filter);
>
> Jaroslav
>
> -----
> Jaroslav Kysela <perex@perex.cz>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: snd_pcm_drop causing lockup with DMix
2010-02-28 17:15 ` John Lindgren
@ 2010-03-01 6:53 ` Jaroslav Kysela
2010-03-01 23:52 ` John Lindgren
0 siblings, 1 reply; 10+ messages in thread
From: Jaroslav Kysela @ 2010-03-01 6:53 UTC (permalink / raw)
To: John Lindgren; +Cc: ALSA development
On Sun, 28 Feb 2010, John Lindgren wrote:
> Unfortunately, it doesn't make a difference.
And this one?
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
index d9e596e..ae32fab 100644
--- a/src/pcm/pcm_direct.c
+++ b/src/pcm/pcm_direct.c
@@ -540,7 +540,6 @@ void snd_pcm_direct_clear_timer_queue(snd_pcm_direct_t *dmix)
int snd_pcm_direct_timer_stop(snd_pcm_direct_t *dmix)
{
snd_timer_stop(dmix->timer);
- snd_pcm_direct_clear_timer_queue(dmix);
return 0;
}
@@ -1274,6 +1273,7 @@ int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix)
snd_timer_params_set_ticks(params, 1);
if (dmix->tread) {
filter = (1<<SND_TIMER_EVENT_TICK) |
+ (1<<SND_TIMER_EVENT_STOP) |
dmix->timer_event_suspend |
dmix->timer_event_resume;
snd_timer_params_set_filter(params, filter);
-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: snd_pcm_drop causing lockup with DMix
2010-03-01 6:53 ` Jaroslav Kysela
@ 2010-03-01 23:52 ` John Lindgren
2010-03-02 13:25 ` Jaroslav Kysela
0 siblings, 1 reply; 10+ messages in thread
From: John Lindgren @ 2010-03-01 23:52 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: ALSA development
Still no difference.
I also noticed that with or without the patch, Audacious will
occasionally not hang up, and instead the snd_pcm_writei call that is
interrupted will return -EBADFD. I haven't seen the test case do the
same.
On Mon, 2010-03-01 at 07:53 +0100, Jaroslav Kysela wrote:
> And this one?
>
> diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
> index d9e596e..ae32fab 100644
> --- a/src/pcm/pcm_direct.c
> +++ b/src/pcm/pcm_direct.c
> @@ -540,7 +540,6 @@ void snd_pcm_direct_clear_timer_queue(snd_pcm_direct_t *dmix)
> int snd_pcm_direct_timer_stop(snd_pcm_direct_t *dmix)
> {
> snd_timer_stop(dmix->timer);
> - snd_pcm_direct_clear_timer_queue(dmix);
> return 0;
> }
>
> @@ -1274,6 +1273,7 @@ int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix)
> snd_timer_params_set_ticks(params, 1);
> if (dmix->tread) {
> filter = (1<<SND_TIMER_EVENT_TICK) |
> + (1<<SND_TIMER_EVENT_STOP) |
> dmix->timer_event_suspend |
> dmix->timer_event_resume;
> snd_timer_params_set_filter(params, filter);
>
> -----
> Jaroslav Kysela <perex@perex.cz>
> Linux Kernel Sound Maintainer
> ALSA Project, Red Hat, Inc.
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: snd_pcm_drop causing lockup with DMix
2010-03-01 23:52 ` John Lindgren
@ 2010-03-02 13:25 ` Jaroslav Kysela
2010-03-03 0:24 ` John Lindgren
0 siblings, 1 reply; 10+ messages in thread
From: Jaroslav Kysela @ 2010-03-02 13:25 UTC (permalink / raw)
To: John Lindgren; +Cc: ALSA development
On Mon, 1 Mar 2010, John Lindgren wrote:
> Still no difference.
>
> I also noticed that with or without the patch, Audacious will
> occasionally not hang up, and instead the snd_pcm_writei call that is
> interrupted will return -EBADFD. I haven't seen the test case do the
> same.
Could you provide a simple C program to test this issue? You may modify
alsa-lib/src/test/pcm_min.c for example.
Thanks,
Jaroslav
-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: snd_pcm_drop causing lockup with DMix
2010-03-02 13:25 ` Jaroslav Kysela
@ 2010-03-03 0:24 ` John Lindgren
2010-03-03 10:01 ` Jaroslav Kysela
0 siblings, 1 reply; 10+ messages in thread
From: John Lindgren @ 2010-03-03 0:24 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: ALSA development
On Tue, 2010-03-02 at 14:25 +0100, Jaroslav Kysela wrote:
> Could you provide a simple C program to test this issue? You may modify
> alsa-lib/src/test/pcm_min.c for example.
There is already one attached to the bug report page:
https://bugtrack.alsa-project.org/alsa-bug/bug_view_advanced_page.php?bug_id=4914
Thanks for investigating this.
John Lindgren
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: snd_pcm_drop causing lockup with DMix
2010-03-03 0:24 ` John Lindgren
@ 2010-03-03 10:01 ` Jaroslav Kysela
2010-03-03 12:28 ` John Lindgren
0 siblings, 1 reply; 10+ messages in thread
From: Jaroslav Kysela @ 2010-03-03 10:01 UTC (permalink / raw)
To: John Lindgren; +Cc: ALSA development
On Tue, 2 Mar 2010, John Lindgren wrote:
> On Tue, 2010-03-02 at 14:25 +0100, Jaroslav Kysela wrote:
>> Could you provide a simple C program to test this issue? You may modify
>> alsa-lib/src/test/pcm_min.c for example.
>
> There is already one attached to the bug report page:
>
> https://bugtrack.alsa-project.org/alsa-bug/bug_view_advanced_page.php?bug_id=4914
>
> Thanks for investigating this.
This commit should solve this issue:
http://git.alsa-project.org/?p=alsa-lib.git;a=commitdiff;h=b9dbee694a94a724670b36f4df1aeceb0dd4a261
Jaroslav
-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: snd_pcm_drop causing lockup with DMix
2010-03-03 10:01 ` Jaroslav Kysela
@ 2010-03-03 12:28 ` John Lindgren
2010-03-03 12:59 ` Jaroslav Kysela
0 siblings, 1 reply; 10+ messages in thread
From: John Lindgren @ 2010-03-03 12:28 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: ALSA development
Confirmed, that fixes the hangup. A minor issue remains that
snd_pcm_writei still always returns -EIO or -EBADFD in this situation.
John Lindgren
On Wed, 2010-03-03 at 11:01 +0100, Jaroslav Kysela wrote:
> This commit should solve this issue:
>
> http://git.alsa-project.org/?p=alsa-lib.git;a=commitdiff;h=b9dbee694a94a724670b36f4df1aeceb0dd4a261
>
> Jaroslav
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: snd_pcm_drop causing lockup with DMix
2010-03-03 12:28 ` John Lindgren
@ 2010-03-03 12:59 ` Jaroslav Kysela
0 siblings, 0 replies; 10+ messages in thread
From: Jaroslav Kysela @ 2010-03-03 12:59 UTC (permalink / raw)
To: John Lindgren; +Cc: ALSA development
On Wed, 3 Mar 2010, John Lindgren wrote:
> Confirmed, that fixes the hangup. A minor issue remains that
> snd_pcm_writei still always returns -EIO or -EBADFD in this situation.
I don't see a problem here. If transfer is stopped, the pcm handle is
not initialized for I/O transactions, thus upper layers return these
errors.
Your application should check snd_pcm_state() in case of error and look if
stream is inactive (back in SND_PCM_STATE_SETUP), because your application
invoked the drop() call.
Jaroslav
-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-03-03 12:59 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-28 15:37 snd_pcm_drop causing lockup with DMix John Lindgren
2010-02-28 16:22 ` Jaroslav Kysela
2010-02-28 17:15 ` John Lindgren
2010-03-01 6:53 ` Jaroslav Kysela
2010-03-01 23:52 ` John Lindgren
2010-03-02 13:25 ` Jaroslav Kysela
2010-03-03 0:24 ` John Lindgren
2010-03-03 10:01 ` Jaroslav Kysela
2010-03-03 12:28 ` John Lindgren
2010-03-03 12:59 ` Jaroslav Kysela
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).