replace sink SET_STATE handlers with callbacks 44/227544/1 accepted/tizen/unified/20200315.214844 submit/tizen/20200313.024309
authorSeungbae Shin <seungbae.shin@samsung.com>
Thu, 12 Mar 2020 12:21:17 +0000 (21:21 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Thu, 12 Mar 2020 12:21:17 +0000 (21:21 +0900)
[Version] 13.0.4
[Issue Type] Bug / Upgrade

Change-Id: Ic762a7ea4262b4d661a6a85191a00e0e45f884a3

packaging/pulseaudio-modules-tizen.spec
src/module-tizenaudio-sink.c

index 236c429ea31310bc202f0cf43928a4f211287f46..0252e9e22ae2e610fbbdf52761c52a36a2cdb303 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          13.0.3
+Version:          13.0.4
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 7d75d5a1a18c5a02f9e52d49be1ff32d77b7ee07..23c009201f3321f33142e5b73f2d592a7f4eb0cc 100644 (file)
@@ -215,6 +215,50 @@ fail:
     return -PA_ERR_IO;
 }
 
+/* Called from the IO thread. */
+static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state, pa_suspend_cause_t new_suspend_cause) {
+    struct userdata *u;
+    int r;
+
+    pa_assert(s);
+    pa_assert_se(u = s->userdata);
+
+    /* It may be that only the suspend cause is changing, in which case there's
+     * nothing to do. */
+    if (new_state == s->thread_info.state)
+        return 0;
+
+    switch (new_state) {
+        case PA_SINK_SUSPENDED: {
+            pa_assert(PA_SINK_IS_OPENED(s->thread_info.state));
+            if ((r = suspend(u)) < 0)
+                return r;
+            break;
+        }
+
+        case PA_SINK_IDLE:
+        case PA_SINK_RUNNING: {
+            if (s->thread_info.state == PA_SINK_INIT) {
+                if (build_pollfd(u) < 0)
+                    return -PA_ERR_IO;
+            }
+
+            if (s->thread_info.state == PA_SINK_SUSPENDED) {
+                if ((r = unsuspend(u)) < 0)
+                    return r;
+            }
+            break;
+        }
+
+        case PA_SINK_UNLINKED:
+        case PA_SINK_INIT:
+        case PA_SINK_INVALID_STATE:
+            break;
+    }
+
+    return 0;
+}
+
 static int sink_process_msg(
         pa_msgobject *o,
         int code,
@@ -223,39 +267,8 @@ static int sink_process_msg(
         pa_memchunk *chunk) {
 
     struct userdata *u = PA_SINK(o)->userdata;
-    int r;
 
     switch (code) {
-        case PA_SINK_MESSAGE_SET_STATE:
-            switch ((pa_sink_state_t)PA_PTR_TO_UINT(data)) {
-                case PA_SINK_SUSPENDED: {
-                    pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));
-                    if ((r = suspend(u)) < 0)
-                        return r;
-                    break;
-                }
-
-                case PA_SINK_IDLE:
-                case PA_SINK_RUNNING: {
-                    if (u->sink->thread_info.state == PA_SINK_INIT) {
-                        if (build_pollfd(u) < 0)
-                            return -PA_ERR_IO;
-                    }
-
-                    if (u->sink->thread_info.state == PA_SINK_SUSPENDED) {
-                        if ((r = unsuspend(u)) < 0)
-                            return r;
-                    }
-                    break;
-                }
-
-                case PA_SINK_UNLINKED:
-                case PA_SINK_INIT:
-                case PA_SINK_INVALID_STATE:
-                    break;
-            }
-            break;
-
         case PA_SINK_MESSAGE_GET_LATENCY: {
             pa_usec_t now = pa_rtclock_now();
             pa_usec_t latency = 0ULL;
@@ -599,6 +612,7 @@ int pa__init(pa_module*m) {
     }
 
     u->sink->parent.process_msg = sink_process_msg;
+    u->sink->set_state_in_io_thread = sink_set_state_in_io_thread_cb;
     u->sink->update_requested_latency = sink_update_requested_latency_cb;
     u->sink->userdata = u;