From bacbaab8c9e15966a378f97199421da9f559e576 Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Wed, 6 Nov 2019 12:48:38 +0900 Subject: [PATCH] stream-manager: Add error handling code for ducking instead of assertion [Version] 11.1.86 [Profile] Common [Issue Type] Error handling Change-Id: I146f886a47c623fabd8f2729d8c0d5bf41d2e0f5 Signed-off-by: Jeongmo Yang --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/stream-manager-dbus.c | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index f55bed1..ff8af3f 100644 --- a/packaging/pulseaudio-modules-tizen.spec +++ b/packaging/pulseaudio-modules-tizen.spec @@ -1,6 +1,6 @@ Name: pulseaudio-modules-tizen Summary: Pulseaudio modules for Tizen -Version: 11.1.85 +Version: 11.1.86 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-dbus.c b/src/stream-manager-dbus.c index 5698015..d4deb67 100644 --- a/src/stream-manager-dbus.c +++ b/src/stream-manager-dbus.c @@ -32,7 +32,7 @@ #include "stream-manager-restriction-priv.h" static const char *dbus_str_none = "none"; -static const char* stream_manager_dbus_ret_str[] = {"STREAM_MANAGER_RETURN_OK", +static const char *stream_manager_dbus_ret_str[] = {"STREAM_MANAGER_RETURN_OK", "STREAM_MANAGER_RETURN_ERROR_INTERNAL", "STREAM_MANAGER_RETURN_ERROR_NO_STREAM", "STREAM_MANAGER_RETURN_ERROR_INVALID_ARGUMENT", @@ -1891,7 +1891,16 @@ static void handle_activate_ducking(DBusConnection *conn, DBusMessage *msg, void pa_assert_se((reply = dbus_message_new_method_return(msg))); /* get stream_ducking */ - pa_assert_se((sd = pa_hashmap_get(m->stream_duckings, (const void*)id))); + sd = pa_hashmap_get(m->stream_duckings, (const void*)id); + if (!sd) { + pa_log_error("no matched stream ducking for id[%u]", id); + + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); + pa_assert_se(dbus_connection_send(conn, reply, NULL)); + dbus_message_unref(reply); + + return; + } sd->duration = duration; sd->ratio = ratio; @@ -1976,6 +1985,8 @@ static void handle_get_ducking_state(DBusConnection *conn, DBusMessage *msg, voi DBusMessage *reply = NULL; pa_stream_manager *m = (pa_stream_manager*)userdata; stream_ducking *sd = NULL; + dbus_bool_t is_ducked = FALSE; + ret_msg_t msg_index = RET_MSG_OK; pa_assert(conn); pa_assert(msg); @@ -1988,12 +1999,17 @@ static void handle_get_ducking_state(DBusConnection *conn, DBusMessage *msg, voi pa_assert_se((reply = dbus_message_new_method_return(msg))); /* get stream_ducking */ - pa_assert_se((sd = pa_hashmap_get(m->stream_duckings, (const void*)id))); - - pa_log_info("id[%u], is_ducked[%p,%u]", id, sd, sd->is_ducked); + sd = pa_hashmap_get(m->stream_duckings, (const void *)id); + if (sd) { + is_ducked = (dbus_bool_t)sd->is_ducked; + pa_log_info("id[%u], is_ducked[%p,%u]", id, sd, sd->is_ducked); + } else { + msg_index = RET_MSG_ERROR_INTERNAL; + pa_log_error("no matched stream ducking for id[%u]", id); + } - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &sd->is_ducked, DBUS_TYPE_INVALID)); - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_OK], DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &is_ducked, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[msg_index], DBUS_TYPE_INVALID)); pa_assert_se(dbus_connection_send(conn, reply, NULL)); dbus_message_unref(reply); -- 2.7.4