#include <pulsecore/modargs.h>
#include <pulsecore/macro.h>
#include <pulsecore/shared.h>
+#include <pulsecore/core-util.h>
+
#include <json.h>
#include "stream-manager.h"
#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;
- }
+static bool is_valid_notify_command(notify_command_type_t command) {
+ return (command < sizeof(notify_command_type_str) / sizeof(char *));
+}
- pa_log_debug("[%s] command: %s", func, notify_command_type_str[command]);
- return true;
+static bool is_valid_process_command(process_command_type_t command) {
+ return (command < sizeof(process_command_type_str) / sizeof(char *));
}
bool stream_is_call_family(pa_object *stream) {
pa_idxset_remove_by_data(type == STREAM_SINK_INPUT ? (sp->idx_sink_inputs) : (sp->idx_source_outputs), stream, NULL);
return true;
} else {
- pa_log_error("invalid command(%d)", command);
+ pa_log_error("invalid process command(%d)", command);
return false;
}
} else {
pa_assert(m);
pa_assert(mine);
if (!role) {
- pa_log_error("invalid input, role(%s)", role);
+ pa_log_error("invalid input, role(%s)", pa_strnull(role));
return false;
}
pa_assert(m);
pa_assert(hook_data);
- if (!is_valid_command(__func__, command))
+ if (!is_valid_notify_command(command)) {
+ pa_log_error("invalid notify command: %d", command);
return;
+ }
+ pa_log_info("command: %s", notify_command_type_str[command]);
switch (command) {
case NOTIFY_COMMAND_SELECT_PROPER_SINK_OR_SOURCE_FOR_INIT: {
pa_assert(m);
- if (!is_valid_command(__func__, command))
+ if (!is_valid_notify_command(command)) {
+ pa_log_error("invalid notify command: %d", command);
return RET_MSG_ERROR_INVALID_ARGUMENT;
+ }
+ pa_log_info("command: %s", notify_command_type_str[command]);
switch (command) {
case NOTIFY_COMMAND_SELECT_PROPER_SINK_OR_SOURCE_FOR_INIT:
process_stream_result_t process_stream(pa_stream_manager *m, void *stream, stream_type_t type, process_command_type_t command, bool is_new_data) {
process_stream_result_t result = PROCESS_STREAM_RESULT_OK;
- pa_log_info(">>> [%s]: stream(%p), stream_type(%d), is_new_data(%d)",
- process_command_type_str[command], stream, type, is_new_data);
-
pa_assert(m);
pa_assert(stream);
+ if (!is_valid_process_command(command)) {
+ pa_log_error("invalid process command: %d", command);
+ return PROCESS_STREAM_RESULT_SKIP;
+ }
+ pa_log_info(">>> [%s]: stream(%p), stream_type(%d), is_new_data(%d)",
+ process_command_type_str[command], stream, type, is_new_data);
+
if (check_name_to_skip(m, command, stream, type, is_new_data)) {
result = PROCESS_STREAM_RESULT_SKIP;
/* set it to null sink/source */