From cd5204006150b5412da5f32d6f7e26efc15425fc Mon Sep 17 00:00:00 2001 From: Eddy Hsu Date: Tue, 7 May 2024 13:54:12 -0700 Subject: [PATCH] CRAS: utilize spatial audio state in system state Utilize spatial audio state in system state to keep the state of UI selected enablement of spatial audio. BUG=b:317748801 TEST=FEATURES=test USE=asan emerge-${BOARD} adhd Change-Id: I663fe01c1a4c5c5d774ffff2e65347ba3f9eb791 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5523798 Reviewed-by: Hung-Hsien Chen Tested-by: chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com Reviewed-by: Li-Yu Yu Commit-Queue: Eddy Hsu --- cras/src/server/cras_dbus_control.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cras/src/server/cras_dbus_control.c b/cras/src/server/cras_dbus_control.c index 11a023da8..48b83b11f 100644 --- a/cras/src/server/cras_dbus_control.c +++ b/cras/src/server/cras_dbus_control.c @@ -1519,6 +1519,22 @@ static inline DBusHandlerResult handle_get_number_of_arc_streams( return send_int32_reply(conn, message, cras_system_state_num_arc_streams()); } +static DBusHandlerResult handle_set_spatial_audio_enabled(DBusConnection* conn, + DBusMessage* message, + void* arg) { + int rc; + dbus_bool_t enabled; + + rc = get_single_arg(message, DBUS_TYPE_BOOLEAN, &enabled); + if (rc) { + return rc; + } + + cras_s2_set_spatial_audio_enabled(enabled); + + return send_empty_reply(conn, message); +} + // Handle incoming messages. static DBusHandlerResult handle_control_message(DBusConnection* conn, DBusMessage* message, @@ -1752,6 +1768,9 @@ static DBusHandlerResult handle_control_message(DBusConnection* conn, } else if (dbus_message_is_method_call(message, CRAS_CONTROL_INTERFACE, "GetNumberOfArcStreams")) { return handle_get_number_of_arc_streams(conn, message, arg); + } else if (dbus_message_is_method_call(message, CRAS_CONTROL_INTERFACE, + "SetSpatialAudio")) { + return handle_set_spatial_audio_enabled(conn, message, arg); } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;