device-manager: Fix to apply reconfiguration even though there's no stream on a sink 41/184141/2
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 16 Jul 2018 02:23:37 +0000 (11:23 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 16 Jul 2018 02:58:31 +0000 (11:58 +0900)
The foreach statement to trigger the reconfiguration function is also removed.

[Version] 11.1.18
[Issue Type] Bug fix

Change-Id: Ib0682711161d0a8621ddcfd064068aa0080b2624
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/pulseaudio-modules-tizen.spec
src/device-manager.c

index 32a3a4ecaaef328b595a618486e181e6517acb77..62b94d898b69df5f8ac5cdb61c50972c35db1780 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          11.1.17
+Version:          11.1.18
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 9d52a00322a44dc9e9e58377ad10318c4817a369..5491658a9287fb12c9abd2819c4ae67633fa01e0 100644 (file)
     "type='signal',"                                       \
     " interface='" DBUS_INTERFACE_BLUEZ_HEADSET "', member='PropertyChanged'"
 
+#define FILL_SAMPLE_SPEC_WITH_SELECTED(x_sink, x_spec) \
+do { \
+    x_spec.format = x_sink->selected_sample_format; \
+    x_spec.rate = x_sink->selected_sample_rate; \
+    x_spec.channels = 2; \
+} while(0)
+
 static const char* const valid_alsa_device_modargs[] = {
     "name",
     "sink_name",
@@ -3373,8 +3380,7 @@ static void handle_set_sample_format(DBusConnection *conn, DBusMessage *msg, voi
     pa_sample_format_t prev_selected_sample_format;
     pa_tz_device *device;
     pa_sink *sink;
-    pa_sink_input *si;
-    uint32_t idx;
+    pa_sample_spec spec;
 
     pa_assert(conn);
     pa_assert(msg);
@@ -3412,14 +3418,12 @@ static void handle_set_sample_format(DBusConnection *conn, DBusMessage *msg, voi
     prev_selected_sample_format = sink->selected_sample_format;
     sink->selected_sample_format = pa_parse_sample_format(sample_format);
 
-    PA_IDXSET_FOREACH(si, sink->inputs, idx) {
-        if (pa_sink_reconfigure(sink, &si->sample_spec, pa_sink_input_is_passthrough(si)) == -1) {
-            pa_log_error("failed to reconfigure");
-            pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "%s", "org.tizen.multimedia.audio.Internal");
-            sink->selected_sample_format = prev_selected_sample_format;
-            return;
-        }
-        break;
+    FILL_SAMPLE_SPEC_WITH_SELECTED(sink, spec);
+    if (pa_sink_reconfigure(sink, &spec, false) == -1) {
+        pa_log_error("failed to reconfigure");
+        pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "%s", "org.tizen.multimedia.audio.Internal");
+        sink->selected_sample_format = prev_selected_sample_format;
+        return;
     }
 
     pa_log_info("Set sample format(%s) of the device(id:%d) successfully", sample_format, device_id);
@@ -3546,8 +3550,7 @@ static void handle_set_sample_rate(DBusConnection *conn, DBusMessage *msg, void
     uint32_t prev_selected_sample_rate;
     pa_tz_device *device;
     pa_sink *sink;
-    pa_sink_input *si;
-    uint32_t idx;
+    pa_sample_spec spec;
 
     pa_assert(conn);
     pa_assert(msg);
@@ -3585,14 +3588,12 @@ static void handle_set_sample_rate(DBusConnection *conn, DBusMessage *msg, void
     prev_selected_sample_rate = sink->selected_sample_rate;
     sink->selected_sample_rate = sample_rate;
 
-    PA_IDXSET_FOREACH(si, sink->inputs, idx) {
-        if (pa_sink_reconfigure(sink, &si->sample_spec, pa_sink_input_is_passthrough(si)) == -1) {
-            pa_log_error("failed to reconfigure");
-            pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "%s", "org.tizen.multimedia.audio.Internal");
-            sink->selected_sample_rate = prev_selected_sample_rate;
-            return;
-        }
-        break;
+    FILL_SAMPLE_SPEC_WITH_SELECTED(sink, spec);
+    if (pa_sink_reconfigure(sink, &spec, false) == -1) {
+        pa_log_error("failed to reconfigure");
+        pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "%s", "org.tizen.multimedia.audio.Internal");
+        sink->selected_sample_rate = prev_selected_sample_rate;
+        return;
     }
 
     pa_log_info("Set sample rate(%u) of the device(id:%d) successfully", sample_rate, device_id);
@@ -3730,8 +3731,6 @@ static void handle_set_avoid_resampling(DBusConnection *conn, DBusMessage *msg,
     dbus_bool_t avoid_resampling;
     pa_tz_device *device;
     pa_sink *sink;
-    pa_sink_input *si;
-    uint32_t idx;
 
     pa_assert(conn);
     pa_assert(msg);
@@ -3768,14 +3767,7 @@ static void handle_set_avoid_resampling(DBusConnection *conn, DBusMessage *msg,
     }
 
     sink->avoid_resampling = avoid_resampling;
-    PA_IDXSET_FOREACH(si, sink->inputs, idx) {
-        if (pa_sink_reconfigure(sink, &si->sample_spec, pa_sink_input_is_passthrough(si)) == -1) {
-            pa_log_error("failed to reconfigure");
-            pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "%s", "org.tizen.multimedia.audio.Internal");
-            sink->avoid_resampling = sink->origin_avoid_resampling;
-            return;
-        }
-    }
+
     pa_log_info("Set avoid-resampling(%d) to the device(id:%d)", avoid_resampling, device_id);
 
     pa_assert_se(dbus_connection_send(conn, reply, NULL));