#define STREAM_MAP_STREAM_AVAIL_OUT_DEVICES "avail-out-devices"
#define STREAM_MAP_STREAM_AVAIL_FRAMEWORKS "avail-frameworks"
+static bool is_valid_command(const char *func, notify_command_type_t command) {
+ if (command >= sizeof(notify_command_type_str) / sizeof(char *)) {
+ pa_log_error("[%s] invalid command: %d", func, command);
+ return false;
+ }
+
+ pa_log_debug("[%s] command: %s", func, notify_command_type_str[command]);
+ return true;
+}
+
bool stream_is_call_family(pa_object *stream) {
const char *stream_role;
pa_proplist *prop;
pa_assert(m);
pa_assert(hook_data);
- pa_log_debug("command: %s", notify_command_type_str[command]);
+
+ if (!is_valid_command(__func__, command))
+ return;
switch (command) {
case NOTIFY_COMMAND_SELECT_PROPER_SINK_OR_SOURCE_FOR_INIT: {
memset(&hook_call_select_data, 0, sizeof(pa_stream_manager_hook_data_for_select));
hook_call_select_data.stream = s = user_data;
- if (!s)
- return ret;
-
hook_call_select_data.stream_type = type;
hook_call_select_data.origins_from_new_data = is_new_data;
if (is_new_data) {
pa_assert(user_data);
memset(&hook_call_route_data, 0, sizeof(pa_stream_manager_hook_data_for_route));
hook_call_route_data.stream = s = user_data;
- if (!s)
- return ret;
if (is_new_data) {
hook_call_route_data.origins_from_new_data = true;
ret_msg_t ret = RET_MSG_OK;
pa_assert(m);
- pa_log_debug("[%s]: type(%d), is_new_data(%d), user_data(%p)", notify_command_type_str[command], type, is_new_data, user_data);
+
+ if (!is_valid_command(__func__, command))
+ return RET_MSG_ERROR_INVALID_ARGUMENT;
switch (command) {
case NOTIFY_COMMAND_SELECT_PROPER_SINK_OR_SOURCE_FOR_INIT: