x_device_role = DEVICE_ROLE_NORMAL; \
} \
-#define SET_NEW_DATA_STREAM_TO_NULL_SINK_SOURCE(x_m, x_stream, x_stream_type) { \
- pa_sink *null_sink; \
- pa_source *null_source; \
- if (x_stream_type == STREAM_SINK_INPUT && \
- (!((pa_sink_input_new_data*)x_stream)->sink)) { \
- if ((null_sink = (pa_sink*)pa_namereg_get(x_m->core, SINK_NAME_NULL, PA_NAMEREG_SINK))) \
- ((pa_sink_input_new_data*)x_stream)->sink = null_sink; \
- else \
- pa_log_warn("could not get null_sink"); \
- } else if (x_stream_type == STREAM_SOURCE_OUTPUT && \
- (!((pa_source_output_new_data*)x_stream)->source)) { \
- if ((null_source = (pa_source*)pa_namereg_get(x_m->core, SOURCE_NAME_NULL, PA_NAMEREG_SOURCE))) \
- ((pa_source_output_new_data*)x_stream)->source = null_source; \
- else \
- pa_log_warn("could not get null_source"); \
- } \
-} \
-
static void do_notify(pa_stream_manager *m, notify_command_type_t command, stream_type_t type, bool is_new_data, void *user_data);
static 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);
} else {
/* no need to trigger,
* update active device info if possible */
- if ((active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(cur_max_stream, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV))) {
- if (is_new_data)
- pa_proplist_sets(GET_STREAM_NEW_PROPLIST(mine, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, active_dev);
- else
- pa_proplist_sets(GET_STREAM_PROPLIST(mine, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, active_dev);
+ if (IS_ROUTE_TYPE_FOR_AUTO(route_type_str, route_type) || IS_ROUTE_TYPE_FOR_AUTO_LAST_CONN(route_type_str, route_type)) {
+ if ((active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(cur_max_stream, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV))) {
+ if (is_new_data)
+ pa_proplist_sets(GET_STREAM_NEW_PROPLIST(mine, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, active_dev);
+ else
+ pa_proplist_sets(GET_STREAM_PROPLIST(mine, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, active_dev);
+ }
}
return true;
}
return 0;
}
+static void set_new_data_stream_to_null_sink_source(pa_stream_manager *m, void *stream, stream_type_t type) {
+ pa_sink *null_sink;
+ pa_source *null_source;
+
+ pa_assert(m);
+ pa_assert(stream);
+
+ if (type == STREAM_SINK_INPUT && !((pa_sink_input_new_data*)stream)->sink) {
+ if ((null_sink = (pa_sink*)pa_namereg_get(m->core, SINK_NAME_NULL, PA_NAMEREG_SINK)))
+ ((pa_sink_input_new_data*)stream)->sink = null_sink;
+ else
+ pa_log_warn("could not get null_sink");
+ } else if (type == STREAM_SOURCE_OUTPUT && !((pa_source_output_new_data*)stream)->source) {
+ if ((null_source = (pa_source*)pa_namereg_get(m->core, SOURCE_NAME_NULL, PA_NAMEREG_SOURCE)))
+ ((pa_source_output_new_data*)stream)->source = null_source;
+ else
+ pa_log_warn("could not get null_source");
+ }
+}
+
static 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;
const char *role = NULL;
result = PROCESS_STREAM_RESULT_SKIP;
/* set it to null sink/source */
if (is_new_data)
- SET_NEW_DATA_STREAM_TO_NULL_SINK_SOURCE(m, stream, type);
+ set_new_data_stream_to_null_sink_source(m, stream, type);
goto finish;
}
pa_log_debug("skip notifying for selecting sink/source, rather set it to null sink/source");
/* set it to null sink/source */
if (is_new_data)
- SET_NEW_DATA_STREAM_TO_NULL_SINK_SOURCE(m, stream, type);
+ set_new_data_stream_to_null_sink_source(m, stream, type);
} else {
/* notify to select sink or source */
((route_type == STREAM_ROUTE_TYPE_AUTO) || (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))) {
/* remove activated device info. if it has the AUTO route type */
active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(s, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV);
- if (active_dev && pa_streq(active_dev, device_type))
+ if (pa_safe_streq(active_dev, device_type))
pa_proplist_sets(GET_STREAM_PROPLIST(s, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, ACTIVE_DEV_REMOVED);
}
}
((route_type == STREAM_ROUTE_TYPE_AUTO) || (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))) {
/* remove activated device info. if it has the AUTO route type */
active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(s, STREAM_SINK_INPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV);
- if (active_dev && pa_streq(active_dev, device_type))
+ if (pa_safe_streq(active_dev, device_type))
pa_proplist_sets(GET_STREAM_PROPLIST(s, STREAM_SINK_INPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, ACTIVE_DEV_REMOVED);
}
}