From 84e799edfe81f530a284271b839474e0244ab8f0 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Tue, 4 Oct 2016 16:53:33 +0900 Subject: [PATCH] stream-manager: Modify handle_update_focus_status() to update only if needed Previously, all the playback/recording streams are updated even if only one focus type(playback/capture) is changed. It is fixed to update only if needed by checking change of each focus type. [Version] 5.0.83 [Profile] Common [Issue Type] Feature enhancement Change-Id: Icfc6434d706a76ca51a7727f5585f7bd6127ce77 Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/stream-manager-priv.h | 2 +- src/stream-manager.c | 25 +++++++++++++------------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 1105206..d662d86 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: 5.0.82 +Version: 5.0.83 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-priv.h b/src/stream-manager-priv.h index 343d9e5..ec71b6e 100644 --- a/src/stream-manager-priv.h +++ b/src/stream-manager-priv.h @@ -57,7 +57,7 @@ typedef enum _stream_direction { #define GET_STREAM_SAMPLE_SPEC(stream, type) \ (type == STREAM_SINK_INPUT ? ((pa_sink_input*)stream)->sample_spec : ((pa_source_output*)stream)->sample_spec) -#define IS_FOCUS_ACQUIRED(focus, type) \ +#define GET_FOCUS_STATUS(focus, type) \ (type == STREAM_SINK_INPUT ? (focus & STREAM_FOCUS_ACQUIRED_PLAYBACK) : (focus & STREAM_FOCUS_ACQUIRED_CAPTURE)) typedef struct _volume_info { diff --git a/src/stream-manager.c b/src/stream-manager.c index d2f7918..8652fbf 100644 --- a/src/stream-manager.c +++ b/src/stream-manager.c @@ -1112,6 +1112,7 @@ static void handle_update_focus_status(DBusConnection *conn, DBusMessage *msg, v void *stream = NULL; DBusMessage *reply = NULL; pa_stream_manager *m = (pa_stream_manager*)userdata; + int prev_status = STREAM_FOCUS_ACQUIRED_NONE; pa_assert(conn); pa_assert(msg); @@ -1125,25 +1126,25 @@ static void handle_update_focus_status(DBusConnection *conn, DBusMessage *msg, v pa_assert_se((reply = dbus_message_new_method_return(msg))); - sp = pa_hashmap_get(m->stream_parents, (const void*)id); - if (sp) { - if (sp->focus_status != (acquired_focus_status & (STREAM_FOCUS_ACQUIRED_PLAYBACK|STREAM_FOCUS_ACQUIRED_CAPTURE))) { + if ((sp = pa_hashmap_get(m->stream_parents, (const void*)id))) { + if (sp->focus_status != acquired_focus_status) { /* need to update */ - sp->focus_status = acquired_focus_status & (STREAM_FOCUS_ACQUIRED_PLAYBACK|STREAM_FOCUS_ACQUIRED_CAPTURE); - if (sp->idx_sink_inputs) { + prev_status = sp->focus_status; + sp->focus_status = acquired_focus_status; + if (((prev_status ^ sp->focus_status) & STREAM_FOCUS_ACQUIRED_PLAYBACK) && sp->idx_sink_inputs) { 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, - IS_FOCUS_ACQUIRED(sp->focus_status, STREAM_SINK_INPUT) ? STREAM_FOCUS_PLAYBACK : STREAM_FOCUS_NONE); + GET_FOCUS_STATUS(sp->focus_status, STREAM_SINK_INPUT) ? STREAM_FOCUS_PLAYBACK : STREAM_FOCUS_NONE); if (--count == 0) process_stream(m, stream, STREAM_SINK_INPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_FOCUS_CHANGED, false); } } - if (sp->idx_source_outputs) { + if (((prev_status ^ sp->focus_status) & STREAM_FOCUS_ACQUIRED_CAPTURE) && sp->idx_source_outputs) { 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, - IS_FOCUS_ACQUIRED(sp->focus_status, STREAM_SOURCE_OUTPUT) ? STREAM_FOCUS_CAPTURE : STREAM_FOCUS_NONE); + GET_FOCUS_STATUS(sp->focus_status, STREAM_SOURCE_OUTPUT) ? STREAM_FOCUS_CAPTURE : STREAM_FOCUS_NONE); if (--count == 0) process_stream(m, stream, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_FOCUS_CHANGED, false); } @@ -1942,8 +1943,8 @@ static bool update_the_highest_priority_stream(pa_stream_manager *m, process_com return false; } else { if (priority && cur_max_priority) { - if (IS_FOCUS_ACQUIRED(focus_status, type) || - (!IS_FOCUS_ACQUIRED(cur_max_focus_status, type) && *priority >= *cur_max_priority)) { + if (GET_FOCUS_STATUS(focus_status, type) || + (!GET_FOCUS_STATUS(cur_max_focus_status, type) && *priority >= *cur_max_priority)) { *need_to_update = true; pa_log_debug("update cur_highest to mine(%s)", role); } else { @@ -2009,8 +2010,8 @@ static bool update_the_highest_priority_stream(pa_stream_manager *m, process_com cur_max_role = _role; } if (cur_max_priority && priority) { - if (IS_FOCUS_ACQUIRED(cur_max_focus_status, type) || - (!IS_FOCUS_ACQUIRED(focus_status, type) && (*cur_max_priority > *priority))) { + if (GET_FOCUS_STATUS(cur_max_focus_status, type) || + (!GET_FOCUS_STATUS(focus_status, type) && (*cur_max_priority > *priority))) { /* skip */ } else { cur_max_priority = priority; -- 2.7.4