src/modules/module-tunnel-sink-new.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
New commits: commit 3fd2004603b1df207e21fde846c0ea0bd4f96aa2 Author: Alexander Couzens <lyn...@fe80.eu> Date: Mon Sep 16 13:06:27 2013 +0200 tunnel-sink-new: Fix a possible crash When the creation of u->thread fails, then pa_thread_mq_done() in pa__done() will crash, because pa_thread_mq_init() was never called. Allocating the thread_mq object separately, instead of embedding it in the userdata struct, allows pa__done() to call pa_thread_mq_done() only when necessary. diff --git a/src/modules/module-tunnel-sink-new.c b/src/modules/module-tunnel-sink-new.c index e0dbe91..ee05d18 100644 --- a/src/modules/module-tunnel-sink-new.c +++ b/src/modules/module-tunnel-sink-new.c @@ -71,7 +71,7 @@ struct userdata { pa_module *module; pa_sink *sink; pa_thread *thread; - pa_thread_mq thread_mq; + pa_thread_mq *thread_mq; pa_mainloop *thread_mainloop; pa_mainloop_api *thread_mainloop_api; @@ -126,7 +126,7 @@ static void thread_func(void *userdata) { pa_assert(u); pa_log_debug("Thread starting up"); - pa_thread_mq_install(&u->thread_mq); + pa_thread_mq_install(u->thread_mq); proplist = tunnel_new_proplist(u); u->context = pa_context_new_with_proplist(u->thread_mainloop_api, @@ -203,8 +203,8 @@ static void thread_func(void *userdata) { } } fail: - pa_asyncmsgq_post(u->thread_mq.outq, PA_MSGOBJECT(u->module->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL, NULL); - pa_asyncmsgq_wait_for(u->thread_mq.inq, PA_MESSAGE_SHUTDOWN); + pa_asyncmsgq_post(u->thread_mq->outq, PA_MSGOBJECT(u->module->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL, NULL); + pa_asyncmsgq_wait_for(u->thread_mq->inq, PA_MESSAGE_SHUTDOWN); finish: if (u->stream) { @@ -453,7 +453,8 @@ int pa__init(pa_module *m) { u->remote_sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL)); - pa_thread_mq_init_thread_mainloop(&u->thread_mq, m->core->mainloop, u->thread_mainloop_api); + u->thread_mq = pa_xnew0(pa_thread_mq, 1); + pa_thread_mq_init_thread_mainloop(u->thread_mq, m->core->mainloop, u->thread_mainloop_api); /* Create sink */ pa_sink_new_data_init(&sink_data); @@ -491,7 +492,7 @@ int pa__init(pa_module *m) { u->sink->update_requested_latency = sink_update_requested_latency_cb; /* set thread message queue */ - pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq); + pa_sink_set_asyncmsgq(u->sink, u->thread_mq->inq); if (!(u->thread = pa_thread_new("tunnel-sink", thread_func, u))) { pa_log("Failed to create thread."); @@ -528,11 +529,14 @@ void pa__done(pa_module *m) { pa_sink_unlink(u->sink); if (u->thread) { - pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL); + pa_asyncmsgq_send(u->thread_mq->inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL); pa_thread_free(u->thread); } - pa_thread_mq_done(&u->thread_mq); + if (u->thread_mq) { + pa_thread_mq_done(u->thread_mq); + pa_xfree(u->thread_mq); + } if (u->thread_mainloop) pa_mainloop_free(u->thread_mainloop); commit 0c3f3934f59e001dc64d29dd226fe9ceac74337a Author: Alexander Couzens <lyn...@fe80.eu> Date: Mon Sep 16 13:06:34 2013 +0200 tunnel-sink-new: remove switch-default from state change callbacks Using default sections for switch(state) in state change callbacks will prevent useful compiler warnings for non-handled cases diff --git a/src/modules/module-tunnel-sink-new.c b/src/modules/module-tunnel-sink-new.c index cd7c39c..e0dbe91 100644 --- a/src/modules/module-tunnel-sink-new.c +++ b/src/modules/module-tunnel-sink-new.c @@ -245,7 +245,8 @@ static void stream_state_cb(pa_stream *stream, void *userdata) { sink_update_requested_latency_cb(u->sink); else stream_changed_buffer_attr_cb(stream, userdata); - default: + case PA_STREAM_CREATING: + case PA_STREAM_UNCONNECTED: break; } } @@ -333,8 +334,6 @@ static void context_state_cb(pa_context *c, void *userdata) { u->connected = false; u->thread_mainloop_api->quit(u->thread_mainloop_api, TUNNEL_THREAD_FAILED_MAINLOOP); break; - default: - break; } } _______________________________________________ pulseaudio-commits mailing list pulseaudio-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/pulseaudio-commits