module-loopback: check validity of source-output/sink-input properly 72/254872/1 accepted/tizen/unified/20210311.151507 submit/tizen/20210310.092407
authorSeungbae Shin <seungbae.shin@samsung.com>
Wed, 10 Mar 2021 02:54:02 +0000 (11:54 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Wed, 10 Mar 2021 07:31:48 +0000 (16:31 +0900)
When the bt a2dp-source linked to the combined sink is disconnected,
a crash occurs due to an attempt to access the opposite pair that has already been released.

[Version] 13.0-28
[Issue Type] Bug fix

Change-Id: I57d05f8d8b9ffff354857b2b7cfeb4b8cbd6877b

packaging/pulseaudio.spec
src/modules/module-loopback.c

index 457dda6..3bb8673 100644 (file)
@@ -3,7 +3,7 @@
 Name:             pulseaudio
 Summary:          Improved Linux sound server
 Version:          13.0
-Release:          27
+Release:          28
 Group:            Multimedia/Audio
 License:          LGPL-2.1
 URL:              http://pulseaudio.org
index a287619..3f16cef 100644 (file)
@@ -463,7 +463,12 @@ static void enable_adjust_timer(struct userdata *u, bool enable) {
 
 /* Called from main context */
 static void update_adjust_timer(struct userdata *u) {
+#ifdef __TIZEN__
+    if ((u->sink_input && u->sink_input->state == PA_SINK_INPUT_CORKED) ||
+        (u->source_output && u->source_output->state == PA_SOURCE_OUTPUT_CORKED))
+#else
     if (u->sink_input->state == PA_SINK_INPUT_CORKED || u->source_output->state == PA_SOURCE_OUTPUT_CORKED)
+#endif
         enable_adjust_timer(u, false);
     else
         enable_adjust_timer(u, true);
@@ -738,6 +743,13 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) {
     pa_assert_ctl_context();
     pa_assert_se(u = o->userdata);
 
+#ifdef __TIZEN__
+    if (!u->sink_input) {
+        pa_log_warn("sink_input is already null now, do nothing");
+        return;
+    }
+#endif
+
     input_description = pa_sprintf_malloc("Loopback of %s",
                                           pa_strnull(pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION)));
     pa_sink_input_set_property(u->sink_input, PA_PROP_MEDIA_NAME, input_description);
@@ -799,15 +811,25 @@ static void source_output_suspend_cb(pa_source_output *o, pa_source_state_t old_
     /* If the source has been suspended, we need to handle this like
      * a source change when the source is resumed */
     if (suspended) {
+#ifdef __TIZEN__
+        if (u->sink_input && u->sink_input->sink)
+#else
         if (u->sink_input->sink)
+#endif
             pa_asyncmsgq_send(u->sink_input->sink->asyncmsgq, PA_MSGOBJECT(u->sink_input), SINK_INPUT_MESSAGE_SOURCE_CHANGED, NULL, 0, NULL);
         else
             u->output_thread_info.push_called = false;
 
     } else
         /* Get effective source latency on unsuspend */
+#ifdef __TIZEN__
+        if (u->sink_input)
+#endif
         update_effective_source_latency(u, u->source_output->source, u->sink_input->sink);
 
+#ifdef __TIZEN__
+    if (u->sink_input)
+#endif
     pa_sink_input_cork(u->sink_input, suspended);
 
     update_adjust_timer(u);
@@ -1135,6 +1157,13 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {
     pa_assert_ctl_context();
     pa_assert_se(u = i->userdata);
 
+#ifdef __TIZEN__
+    if (!u->source_output) {
+        pa_log_warn("source_output is already null now, do nothing");
+        return;
+    }
+#endif
+
     output_description = pa_sprintf_malloc("Loopback to %s",
                                            pa_strnull(pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION)));
     pa_source_output_set_property(u->source_output, PA_PROP_MEDIA_NAME, output_description);
@@ -1211,8 +1240,14 @@ static void sink_input_suspend_cb(pa_sink_input *i, pa_sink_state_t old_state, p
 
     } else
         /* Set effective source latency on unsuspend */
+#ifdef __TIZEN__
+        if (u->source_output)
+#endif
         update_effective_source_latency(u, u->source_output->source, u->sink_input->sink);
 
+#ifdef __TIZEN__
+    if (u->source_output)
+#endif
     pa_source_output_cork(u->source_output, suspended);
 
     update_adjust_timer(u);