" <arg name=\"device_id\" direction=\"in\" type=\"i\"/>\n" \
" <arg name=\"stream_role\" direction=\"out\" type=\"s\"/>\n" \
" </method>\n" \
+ " <method name=\"SetAvoidResampling\">\n" \
+ " <arg name=\"device_id\" direction=\"in\" type=\"i\"/>\n" \
+ " <arg name=\"avoid_resampling\" direction=\"in\" type=\"b\"/>\n" \
+ " </method>\n" \
+ " <method name=\"GetAvoidResampling\">\n" \
+ " <arg name=\"device_id\" direction=\"in\" type=\"i\"/>\n" \
+ " <arg name=\"avoid_resampling\" direction=\"out\" type=\"b\"/>\n" \
+ " </method>\n" \
" <method name=\"DumpDeviceList\">\n" \
" </method>\n" \
" <method name=\"TestStatusChange\">\n" \
static void handle_get_sample_rate(DBusConnection *conn, DBusMessage *msg, void *userdata);
static void handle_set_specific_stream_only(DBusConnection *conn, DBusMessage *msg, void *userdata);
static void handle_get_specified_stream(DBusConnection *conn, DBusMessage *msg, void *userdata);
+static void handle_set_avoid_resampling(DBusConnection *conn, DBusMessage *msg, void *userdata);
+static void handle_get_avoid_resampling(DBusConnection *conn, DBusMessage *msg, void *userdata);
static void handle_load_sink(DBusConnection *conn, DBusMessage *msg, void *userdata);
static void handle_unload_sink(DBusConnection *conn, DBusMessage *msg, void *userdata);
static void handle_unload_sink_with_device_string(DBusConnection *conn, DBusMessage *msg, void *userdata);
METHOD_HANDLER_GET_SAMPLE_RATE,
METHOD_HANDLER_SET_SPECIFIC_STREAM_ONLY,
METHOD_HANDLER_GET_SPECIFIED_STREAM,
+ METHOD_HANDLER_SET_AVOID_RESAMPLING,
+ METHOD_HANDLER_GET_AVOID_RESAMPLING,
METHOD_HANDLER_DUMP_DEVICE_LIST,
METHOD_HANDLER_STATUS_TEST,
METHOD_HANDLER_MAX
[METHOD_HANDLER_GET_SPECIFIED_STREAM] = {
.method_name = "GetSpecifiedStream",
.receive_cb = handle_get_specified_stream },
+ [METHOD_HANDLER_SET_AVOID_RESAMPLING] = {
+ .method_name = "SetAvoidResampling",
+ .receive_cb = handle_set_avoid_resampling },
+ [METHOD_HANDLER_GET_AVOID_RESAMPLING] = {
+ .method_name = "GetAvoidResampling",
+ .receive_cb = handle_get_avoid_resampling },
[METHOD_HANDLER_DUMP_DEVICE_LIST] = {
.method_name = "DumpDeviceList",
.receive_cb = handle_dump_device_list },
return;
}
- /* use stream original sample rate if possible */
- if (sample_rate == 0) {
- sink->avoid_resampling = true;
- 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;
- }
- }
- sink->selected_sample_rate = 0;
-
- pa_log_info("Set sample rate to avoid resampling for the device(%u) successfully", device_id);
- pa_assert_se(dbus_connection_send(conn, reply, NULL));
- dbus_message_unref(reply);
- return;
- }
-
/* use a supported sample rate selected by user */
if (!is_supported_sample_rate(sink->supported_sample_rates, sample_rate)) {
pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "%s", "org.tizen.multimedia.audio.InvalidArgument");
}
break;
}
- sink->avoid_resampling = sink->origin_avoid_resampling;
pa_log_info("Set sample rate(%u) of the device(id:%d) successfully", sample_rate, device_id);
pa_assert_se(dbus_connection_send(conn, reply, NULL));
dbus_message_unref(reply);
}
+static void handle_set_avoid_resampling(DBusConnection *conn, DBusMessage *msg, void *userdata) {
+ pa_device_manager *dm;
+ DBusMessage *reply = NULL;
+ dbus_int32_t device_id;
+ 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);
+ pa_assert(userdata);
+
+ pa_assert_se((reply = dbus_message_new_method_return(msg)));
+ dm = (pa_device_manager *)userdata;
+ pa_assert_se(dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_INT32, &device_id,
+ DBUS_TYPE_BOOLEAN, &avoid_resampling,
+ DBUS_TYPE_INVALID));
+
+ pa_log_info("Set the device(id:%d) avoid-resampling(%d)", device_id, avoid_resampling);
+
+ if (!(device = _device_list_get_device_by_id(dm, device_id))) {
+ pa_log_error("could not find any device with id:%d", device_id);
+ pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "%s", "org.tizen.multimedia.audio.InvalidArgument");
+ return;
+ }
+ if (!is_usb_output_device(device)) {
+ pa_dbus_send_error(conn, msg, DBUS_ERROR_NOT_SUPPORTED, "%s", "org.tizen.multimedia.audio.PolicyInternal");
+ return;
+ }
+ if (!(sink = pa_tz_device_get_sink(device, DEVICE_ROLE_NORMAL))) {
+ pa_log_error("could not get sink for normal role");
+ pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "%s", "org.tizen.multimedia.audio.InvalidArgument");
+ return;
+ }
+ if (sink->avoid_resampling == avoid_resampling) {
+ pa_log_info("already set to %d", avoid_resampling);
+ pa_assert_se(dbus_connection_send(conn, reply, NULL));
+ dbus_message_unref(reply);
+ return;
+ }
+
+ 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));
+ dbus_message_unref(reply);
+}
+
+static void handle_get_avoid_resampling(DBusConnection *conn, DBusMessage *msg, void *userdata) {
+ pa_device_manager *dm;
+ DBusMessage *reply = NULL;
+ dbus_int32_t device_id;
+ dbus_bool_t avoid_resampling;
+ pa_tz_device *device;
+ pa_sink *sink;
+
+ pa_assert(conn);
+ pa_assert(msg);
+ pa_assert(userdata);
+
+ dm = (pa_device_manager *)userdata;
+
+ pa_assert_se((reply = dbus_message_new_method_return(msg)));
+
+ pa_assert_se(dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_INT32, &device_id,
+ DBUS_TYPE_INVALID));
+
+ pa_log_info("Get avoid-resampling of the device(id:%d)", device_id);
+
+ if (!(device = _device_list_get_device_by_id(dm, device_id))) {
+ pa_log_error("could not find any device with id:%d", device_id);
+ pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "%s", "org.tizen.multimedia.audio.InvalidArgument");
+ return;
+ }
+ if (!is_usb_output_device(device)) {
+ pa_dbus_send_error(conn, msg, DBUS_ERROR_NOT_SUPPORTED, "%s", "org.tizen.multimedia.audio.PolicyInternal");
+ return;
+ }
+ if (!(sink = pa_tz_device_get_sink(device, DEVICE_ROLE_NORMAL))) {
+ pa_log_error("could not get sink for normal role");
+ pa_dbus_send_error(conn, msg, DBUS_ERROR_INVALID_ARGS, "%s", "org.tizen.multimedia.audio.InvalidArgument");
+ return;
+ }
+
+ avoid_resampling = sink->avoid_resampling;
+ pa_log_info("got avoid-resampling(%d) of the device(id:%d)", avoid_resampling, device_id);
+
+ pa_assert_se((reply = dbus_message_new_method_return(msg)));
+ pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &avoid_resampling, DBUS_TYPE_INVALID));
+ pa_assert_se(dbus_connection_send(conn, reply, NULL));
+ dbus_message_unref(reply);
+}
+
static void handle_test_device_status_change(DBusConnection *conn, DBusMessage *msg, void *userdata) {
pa_device_manager *dm = (pa_device_manager *)userdata;
char *type;