#define NAME_FOR_SKIP_MAX 1
const char* stream_manager_media_names_for_skip[NAME_FOR_SKIP_MAX] = {"pulsesink probe"};
-#define STREAM_FOCUS_NONE "0"
-#define STREAM_FOCUS_PLAYBACK "1"
-#define STREAM_FOCUS_CAPTURE "2"
+#define STREAM_FOCUS_STATE_RELEASED "0"
+#define STREAM_FOCUS_STATE_ACQUIRED "1"
typedef enum _process_stream_result {
PROCESS_STREAM_RESULT_OK,
count = pa_idxset_size(sp->idx_sink_inputs);
PA_IDXSET_FOREACH(stream, sp->idx_sink_inputs, idx) {
pa_proplist_sets(GET_STREAM_PROPLIST(stream, STREAM_SINK_INPUT), PA_PROP_MEDIA_FOCUS_STATUS,
- GET_FOCUS_STATUS(sp->focus_status, STREAM_SINK_INPUT) ? STREAM_FOCUS_PLAYBACK : STREAM_FOCUS_NONE);
+ GET_FOCUS_STATUS(sp->focus_status, STREAM_SINK_INPUT) ? STREAM_FOCUS_STATE_ACQUIRED : STREAM_FOCUS_STATE_RELEASED);
if (--count == 0)
process_stream(m, stream, STREAM_SINK_INPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_FOCUS_CHANGED, false);
}
count = pa_idxset_size(sp->idx_source_outputs);
PA_IDXSET_FOREACH(stream, sp->idx_source_outputs, idx) {
pa_proplist_sets(GET_STREAM_PROPLIST(stream, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_FOCUS_STATUS,
- GET_FOCUS_STATUS(sp->focus_status, STREAM_SOURCE_OUTPUT) ? STREAM_FOCUS_CAPTURE : STREAM_FOCUS_NONE);
+ GET_FOCUS_STATUS(sp->focus_status, STREAM_SOURCE_OUTPUT) ? STREAM_FOCUS_STATE_ACQUIRED : STREAM_FOCUS_STATE_RELEASED);
if (--count == 0)
process_stream(m, stream, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_FOCUS_CHANGED, false);
}
return ret;
}
-/* FIXME : this code is workaround code and needed to be revised soon */
-static void _enable_focus_status_if_radio(void *stream, stream_type_t type, bool is_new_data)
+static void _set_focus_status_forcedly_if_needed(pa_stream_manager *m, void *stream, stream_type_t type, bool is_new_data)
{
- const char *prop_media_role = NULL;
+ const char *role = NULL;
pa_proplist* p = NULL;
+ pa_assert(m);
+ pa_assert(stream);
+
p = (is_new_data ? GET_STREAM_NEW_PROPLIST(stream, type) : GET_STREAM_PROPLIST(stream, type));
if (!p)
return;
- prop_media_role = pa_proplist_gets(p, PA_PROP_MEDIA_ROLE);
- if (prop_media_role) {
- if (pa_safe_streq(prop_media_role, STREAM_ROLE_RADIO)) {
- pa_log_info("This stream is radio, update focus status to 1");
- pa_proplist_setf(p, PA_PROP_MEDIA_FOCUS_STATUS, "%u", 1);
+ if ((role = pa_proplist_gets(p, PA_PROP_MEDIA_ROLE))) {
+ if (!pa_hashmap_get(m->stream_infos, role)) {
+ pa_log_warn("undefined role[%s], skip it", role);
+ return;
+ }
+ if (pa_safe_streq(role, STREAM_ROLE_SOLO)) {
+ pa_log_info("This stream is [%s], update focus status to STREAM_FOCUS_STATE_ACQUIRED", role);
+ pa_proplist_setf(p, PA_PROP_MEDIA_FOCUS_STATUS, "%s", STREAM_FOCUS_STATE_ACQUIRED);
+ }
+ /* FIXME : this code is workaround code and needed to be revised soon */
+ else if (pa_safe_streq(role, STREAM_ROLE_RADIO)) {
+ pa_log_info("This stream is [%s], update focus status to STREAM_FOCUS_STATE_ACQUIRED", role);
+ pa_proplist_setf(p, PA_PROP_MEDIA_FOCUS_STATUS, "%s", STREAM_FOCUS_STATE_ACQUIRED);
}
}
}
else
pa_proplist_setf(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_FOCUS_STATUS, "%u", sp->focus_status);
- /* FIXME : If stream is radio, then fix focus_status to 1 */
- _enable_focus_status_if_radio(stream, type, is_new_data);
-
pa_log_debug("p_idx(%s), idx(%u), focus_status(0x%x, 0x1:playback 0x2:capture 0x3:both)", p_idx, parent_idx, sp->focus_status);
} else {
pa_log_error("could not find matching client for this parent_id(%u)", parent_idx);
}
}
+ /* set focus status regardless of parent id existence */
+ _set_focus_status_forcedly_if_needed(m, stream, type, is_new_data);
+
return true;
}