I'll just resend my patch after having discussed it on LAC with Lennart.
Compared to the previous patch this patch also adds a comment Lennart
wanted, and also does the same change for jack sources.

// David
>From 0dddabf79b51600db45b5205e85b4589a56825df Mon Sep 17 00:00:00 2001
From: David Henningsson <di...@ubuntu.com>
Date: Mon, 3 May 2010 11:41:47 +0200
Subject: [PATCH] Prevent crash on jack server shutdown

---
 src/modules/jack/module-jack-sink.c   |    7 ++++---
 src/modules/jack/module-jack-source.c |    6 +++---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/modules/jack/module-jack-sink.c b/src/modules/jack/module-jack-sink.c
index 9f3e071..b58777a 100644
--- a/src/modules/jack/module-jack-sink.c
+++ b/src/modules/jack/module-jack-sink.c
@@ -147,6 +147,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
                 pa_sample_spec ss;
 
                 /* Humm, we're not RUNNING, hence let's write some silence */
+                /* This can happen if we're paused, or during shutdown (when we're unlinked but jack is still running). */
 
                 ss = u->sink->sample_spec;
                 ss.channels = 1;
@@ -475,12 +476,12 @@ void pa__done(pa_module*m) {
     if (!(u = m->userdata))
         return;
 
-    if (u->client)
-        jack_client_close(u->client);
-
     if (u->sink)
         pa_sink_unlink(u->sink);
 
+    if (u->client)
+        jack_client_close(u->client);
+
     if (u->thread) {
         pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
         pa_thread_free(u->thread);
diff --git a/src/modules/jack/module-jack-source.c b/src/modules/jack/module-jack-source.c
index 6c68527..bca9a14 100644
--- a/src/modules/jack/module-jack-source.c
+++ b/src/modules/jack/module-jack-source.c
@@ -425,12 +425,12 @@ void pa__done(pa_module*m) {
     if (!(u = m->userdata))
         return;
 
-    if (u->client)
-        jack_client_close(u->client);
-
     if (u->source)
         pa_source_unlink(u->source);
 
+    if (u->client)
+        jack_client_close(u->client);
+
     if (u->thread) {
         pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
         pa_thread_free(u->thread);
-- 
1.6.3.3
_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss

Reply via email to