From bc7543428b524d85b6391d069b3414346d80a623 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Thu, 18 Oct 2018 11:49:24 +0900 Subject: [PATCH 01/16] tizenaudio-sink/source: Remove card of module argument This card argument is removed and is incorporated into the device argument. User can pass the device argument as below. e.g.) in case of card 0, device 0 device=0,0 rate=44100 device-manager is also revised to parse the device-string from device-map.json properly in case of device class is for tizen. [Version] 11.1.29 [Issue type] Bug fix Change-Id: I56d99dbc29ad7729c5842e41110f7f0c24478fee Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/device-manager.c | 51 +++--------------------------- src/module-tizenaudio-sink.c | 56 ++++++++++++++++++++++++++++----- src/module-tizenaudio-source.c | 56 ++++++++++++++++++++++++++++----- 4 files changed, 103 insertions(+), 62 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index a78b672..75a6851 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: 11.1.28 +Version: 11.1.29 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/device-manager.c b/src/device-manager.c index 98abee1..c3a28f8 100644 --- a/src/device-manager.c +++ b/src/device-manager.c @@ -320,7 +320,7 @@ static dm_device_class_t device_string_get_class(const char *device_string) { } } -/* device_string looks like "alsa:0,0" +/* device_string looks like "alsa:0,0" or "tizen:0,0" * in this case name is "0,0" */ static int device_string_get_name(const char *device_string, char *name) { char *colon_p; @@ -346,42 +346,6 @@ static int device_string_get_name(const char *device_string, char *name) { return 0; } -static int device_name_get_card(const char *device_name, char *card) { - const char *name_p; - char *card_p; - - if (!strchr(device_name, ',')) { - pa_log_error("Failed to parse name : no comma"); - return -1; - } - - name_p = device_name; - card_p = card; - while (*name_p != ',') - *(card_p++) = *(name_p++); - *card_p = '\0'; - - return 0; -} - -static int device_name_get_device(const char *device_name, char *device) { - const char *comma_p; - char *device_p; - - if (!(comma_p = strchr(device_name, ','))) { - pa_log_error("Failed to parse name : no comma"); - return -1; - } - - comma_p++; - device_p = device; - while (*comma_p != '\0') - *(device_p++) = *(comma_p++); - *device_p = '\0'; - - return 0; -} - static pa_proplist* pulse_device_get_proplist(pa_object *pdevice) { if (pa_sink_isinstance(pdevice)) return PA_SINK(pdevice)->proplist; @@ -842,17 +806,10 @@ static int build_params_to_load_device(const char *device_string, const char *pa return -1; } - if (device_class == DM_DEVICE_CLASS_ALSA) { + if (device_class == DM_DEVICE_CLASS_ALSA) snprintf(target, DEVICE_PARAM_STRING_MAX, "device=hw:%s ", device_name); - } else if (device_class == DM_DEVICE_CLASS_TIZEN) { - char card[DEVICE_NAME_MAX]; - char device[DEVICE_NAME_MAX]; - - device_name_get_card(device_name, card); - device_name_get_device(device_name, device); - - snprintf(target, DEVICE_PARAM_STRING_MAX, "card=%s device=%s ", card, device); - } + else if (device_class == DM_DEVICE_CLASS_TIZEN) + snprintf(target, DEVICE_PARAM_STRING_MAX, "device=%s ", device_name); if (params) strncat(target, params, DEVICE_PARAM_STRING_MAX - strlen(target)); diff --git a/src/module-tizenaudio-sink.c b/src/module-tizenaudio-sink.c index 3d81cbb..7fe87db 100644 --- a/src/module-tizenaudio-sink.c +++ b/src/module-tizenaudio-sink.c @@ -55,8 +55,7 @@ PA_MODULE_LOAD_ONCE(false); PA_MODULE_USAGE( "sink_name= " "sink_properties= " - "card= " - "device= " + "device= " "format= " "rate= " "channels= " @@ -74,6 +73,8 @@ PA_MODULE_USAGE( /* Sink device consumes that amount of maximum buffer at every request */ #define DEFAULT_MAX_REQUEST_USEC (PA_USEC_PER_SEC * 0.032) +#define DEVICE_NAME_MAX 30 + struct userdata { pa_core *core; pa_module *module; @@ -105,7 +106,6 @@ struct userdata { static const char* const valid_modargs[] = { "sink_name", "sink_properties", - "card", "device", "format", "rate", @@ -459,6 +459,42 @@ finish: pa_log_debug("Thread shutting down"); } +static int parse_to_get_card(const char *modarg_device, char *card) { + const char *name_p; + char *card_p; + + if (!strchr(modarg_device, ',')) { + pa_log_error("Failed to parse device argument : no comma"); + return -1; + } + + name_p = modarg_device; + card_p = card; + while (*name_p != ',') + *(card_p++) = *(name_p++); + *card_p = '\0'; + + return 0; +} + +static int parse_to_get_device(const char *modarg_device, char *device) { + const char *comma_p; + char *device_p; + + if (!(comma_p = strchr(modarg_device, ','))) { + pa_log_error("Failed to parse device argument : no comma"); + return -1; + } + + comma_p++; + device_p = device; + while (*comma_p != '\0') + *(device_p++) = *(comma_p++); + *device_p = '\0'; + + return 0; +} + int pa__init(pa_module*m) { struct userdata *u = NULL; pa_sample_spec ss; @@ -468,7 +504,9 @@ int pa__init(pa_module*m) { uint32_t alternate_sample_rate; uint32_t block_msec; uint32_t max_request_msec; - const char *card, *device; + const char *modarg_device; + char card[DEVICE_NAME_MAX]; + char device[DEVICE_NAME_MAX]; pa_assert(m); @@ -498,9 +536,13 @@ int pa__init(pa_module*m) { u->rtpoll = pa_rtpoll_new(); pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll); - if (!(card = pa_modargs_get_value(ma, "card", NULL)) || - !(device = pa_modargs_get_value(ma, "device", NULL))) { - pa_log_error("card or device are invalid"); + if (!(modarg_device = pa_modargs_get_value(ma, "device", NULL))) { + pa_log_error("device is invalid"); + goto fail; + } + + if (parse_to_get_card(modarg_device, card) || parse_to_get_device(modarg_device, device)) { + pa_log_error("failed to parse device module argument, %s", modarg_device); goto fail; } diff --git a/src/module-tizenaudio-source.c b/src/module-tizenaudio-source.c index f4c12ab..613025a 100644 --- a/src/module-tizenaudio-source.c +++ b/src/module-tizenaudio-source.c @@ -55,8 +55,7 @@ PA_MODULE_LOAD_ONCE(false); PA_MODULE_USAGE( "source_name= " "source_properties= " - "card= " - "device= " + "device= " "format= " "rate= " "channels= " @@ -70,6 +69,8 @@ PA_MODULE_USAGE( /* BLOCK_USEC should be less than amount of fragment_size * fragments */ #define BLOCK_USEC (PA_USEC_PER_SEC * 0.032) +#define DEVICE_NAME_MAX 30 + struct userdata { pa_core *core; pa_module *module; @@ -100,7 +101,6 @@ struct userdata { static const char* const valid_modargs[] = { "source_name", "source_properties", - "card", "device", "format", "rate", @@ -405,6 +405,42 @@ finish: pa_log_debug("Thread shutting down"); } +static int parse_to_get_card(const char *modarg_device, char *card) { + const char *name_p; + char *card_p; + + if (!strchr(modarg_device, ',')) { + pa_log_error("Failed to parse device argument : no comma"); + return -1; + } + + name_p = modarg_device; + card_p = card; + while (*name_p != ',') + *(card_p++) = *(name_p++); + *card_p = '\0'; + + return 0; +} + +static int parse_to_get_device(const char *modarg_device, char *device) { + const char *comma_p; + char *device_p; + + if (!(comma_p = strchr(modarg_device, ','))) { + pa_log_error("Failed to parse device argument : no comma"); + return -1; + } + + comma_p++; + device_p = device; + while (*comma_p != '\0') + *(device_p++) = *(comma_p++); + *device_p = '\0'; + + return 0; +} + int pa__init(pa_module*m) { struct userdata *u = NULL; pa_sample_spec ss; @@ -412,7 +448,9 @@ int pa__init(pa_module*m) { pa_modargs *ma = NULL; pa_source_new_data data; uint32_t alternate_sample_rate; - const char *card, *device; + const char *modarg_device; + char card[DEVICE_NAME_MAX]; + char device[DEVICE_NAME_MAX]; pa_assert(m); @@ -442,9 +480,13 @@ int pa__init(pa_module*m) { u->rtpoll = pa_rtpoll_new(); pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll); - if (!(card = pa_modargs_get_value(ma, "card", NULL)) || - !(device = pa_modargs_get_value(ma, "device", NULL))) { - pa_log_error("card or device are invalid"); + if (!(modarg_device = pa_modargs_get_value(ma, "device", NULL))) { + pa_log_error("device is invalid"); + goto fail; + } + + if (parse_to_get_card(modarg_device, card) || parse_to_get_device(modarg_device, device)) { + pa_log_error("failed to parse device module argument, %s", modarg_device); goto fail; } -- 2.7.4 From 20e292707eb4fda31445f0cede41bc58b8147271 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Wed, 28 Nov 2018 16:43:32 +0900 Subject: [PATCH 02/16] device-manager-dbus: Fix build break It is revised according to the pulseaudio patch. : 'Sync with upstream code' (78c3d68d7183f0daa9e0570de24f0be92bac3659) [Version] 11.1.30 [Issue type] Build break Change-Id: Ic1cf6e95b676d1fecd777d5266d9d1d4998084cb Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/device-manager-dbus.c | 36 ++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 75a6851..6414212 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: 11.1.29 +Version: 11.1.30 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/device-manager-dbus.c b/src/device-manager-dbus.c index 3587b82..2ad1377 100644 --- a/src/device-manager-dbus.c +++ b/src/device-manager-dbus.c @@ -1126,16 +1126,18 @@ static void handle_set_sample_format(DBusConnection *conn, DBusMessage *msg, voi prev_selected_sample_format = sink->selected_sample_format; sink->selected_sample_format = pa_parse_sample_format(sample_format); - FILL_SAMPLE_SPEC_WITH_SELECTED(spec, sink); - if (pa_sink_reconfigure(sink, &spec, false) == -1) { - pa_log_error("failed to reconfigure"); - pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "%s", "org.tizen.multimedia.audio.Internal"); - sink->selected_sample_format = prev_selected_sample_format; - return; + if (prev_selected_sample_format != sink->selected_sample_format) { + FILL_SAMPLE_SPEC_WITH_SELECTED(spec, sink); + pa_sink_reconfigure(sink, &spec, false); + if (sink->selected_sample_format != sink->sample_spec.format) { + pa_log_error("failed to reconfigure"); + pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "%s", "org.tizen.multimedia.audio.Internal"); + sink->selected_sample_format = prev_selected_sample_format; + return; + } + save_preference(dm, sink); } - save_preference(dm, sink); - pa_log_info("Set sample format(%s) of the device(id:%d) successfully", sample_format, device_id); pa_assert_se(dbus_connection_send(conn, reply, NULL)); dbus_message_unref(reply); @@ -1296,16 +1298,18 @@ static void handle_set_sample_rate(DBusConnection *conn, DBusMessage *msg, void prev_selected_sample_rate = sink->selected_sample_rate; sink->selected_sample_rate = sample_rate; - FILL_SAMPLE_SPEC_WITH_SELECTED(spec, sink); - if (pa_sink_reconfigure(sink, &spec, false) == -1) { - pa_log_error("failed to reconfigure"); - pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "%s", "org.tizen.multimedia.audio.Internal"); - sink->selected_sample_rate = prev_selected_sample_rate; - return; + if (prev_selected_sample_rate != sink->selected_sample_rate) { + FILL_SAMPLE_SPEC_WITH_SELECTED(spec, sink); + pa_sink_reconfigure(sink, &spec, false); + if (sink->selected_sample_rate != sink->sample_spec.rate) { + pa_log_error("failed to reconfigure"); + pa_dbus_send_error(conn, msg, DBUS_ERROR_FAILED, "%s", "org.tizen.multimedia.audio.Internal"); + sink->selected_sample_rate = prev_selected_sample_rate; + return; + } + save_preference(dm, sink); } - save_preference(dm, sink); - pa_log_info("Set sample rate(%u) of the device(id:%d) successfully", sample_rate, device_id); pa_assert_se(dbus_connection_send(conn, reply, NULL)); dbus_message_unref(reply); -- 2.7.4 From 9f1bc5fd3c574249ebf312ec5a8cc7dd07dd3590 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Fri, 11 Jan 2019 14:38:21 +0900 Subject: [PATCH 03/16] tizenaudio-policy: Apply volume type to output stream of module-loopback Output stream of module-loopback has not been applied volume type. It is fixed and now it is possible to control the volume of the output stream in case of loopback feature if a volume type is defined to the loopback role in stream-map.json. Here's an example to use media volume type.(in stream-map.json) { "role":"loopback", "priority" : 2, "route-type" : "manual", "volume-types":{"in":"none","out":"media"}, "avail-in-devices":["builtin-mic","usb-audio"], "avail-out-devices":["builtin-speaker","usb-audio","bt-a2dp"], "avail-frameworks":["sound-manager"] }, Change-Id: I8335f84817ff6a3d7282c283c150c96baccf6f99 Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/module-tizenaudio-policy.c | 7 +++++-- src/stream-manager.c | 14 ++++++++++++++ src/stream-manager.h | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 6414212..89e2287 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: 11.1.30 +Version: 11.1.31 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/module-tizenaudio-policy.c b/src/module-tizenaudio-policy.c index ba9bb16..3f938cf 100644 --- a/src/module-tizenaudio-policy.c +++ b/src/module-tizenaudio-policy.c @@ -463,6 +463,7 @@ static void update_bt_sco_option(struct userdata *u, const char* role) { /* Load/Unload module-loopback */ static void update_loopback_module(struct userdata *u, bool load) { char *args = NULL; + const char *volume_type; pa_assert(u); @@ -472,9 +473,11 @@ static void update_loopback_module(struct userdata *u, bool load) { if (!u->loopback_args.adjust_sec) u->loopback_args.adjust_sec = LOOPBACK_DEFAULT_ADJUST_SEC; - args = pa_sprintf_malloc("sink=%s source=%s latency_msec=%d adjust_time=%d", + volume_type = pa_stream_manager_get_volume_type(u->stream_manager, STREAM_SINK_INPUT, STREAM_ROLE_LOOPBACK); + args = pa_sprintf_malloc("sink=%s source=%s latency_msec=%d adjust_time=%d sink_input_properties=%s=%s", u->loopback_args.sink->name, u->loopback_args.source->name, - u->loopback_args.latency_msec, u->loopback_args.adjust_sec); + u->loopback_args.latency_msec, u->loopback_args.adjust_sec, + PA_PROP_MEDIA_TIZEN_VOLUME_TYPE, volume_type); if (u->module_loopback) pa_module_unload(u->module_loopback, true); diff --git a/src/stream-manager.c b/src/stream-manager.c index d7a7f0f..33ca9b3 100644 --- a/src/stream-manager.c +++ b/src/stream-manager.c @@ -3116,6 +3116,20 @@ bool pa_stream_manager_is_valid_stream_role(pa_core *c, const char *role) { return true; } +const char* pa_stream_manager_get_volume_type(pa_stream_manager *m, stream_type_t stream_type, const char *role) { + stream_info *s = NULL; + + pa_assert(m); + pa_assert(role); + + if (!(s = pa_hashmap_get(m->stream_infos, role))) { + pa_log_warn("%s is not valid role, return NULL", role); + return NULL; + } + + return s->volume_types[stream_type == STREAM_SINK_INPUT ? STREAM_DIRECTION_OUT : STREAM_DIRECTION_IN]; +} + pa_stream_manager* pa_stream_manager_get(pa_core *c) { pa_stream_manager *m; diff --git a/src/stream-manager.h b/src/stream-manager.h index 85385ff..98c0804 100644 --- a/src/stream-manager.h +++ b/src/stream-manager.h @@ -147,6 +147,7 @@ int32_t pa_stream_manager_get_route_type(void *stream, stream_type_t stream_type bool pa_stream_manager_check_name_is_vstream(void *stream, stream_type_t type, bool is_new_data); bool pa_stream_manager_check_filter_apply_stream(void *stream, stream_type_t stream_type); bool pa_stream_manager_is_valid_stream_role(pa_core *c, const char *role); +const char* pa_stream_manager_get_volume_type(pa_stream_manager *m, stream_type_t stream_type, const char *role); pa_stream_manager* pa_stream_manager_get(pa_core *c); pa_stream_manager* pa_stream_manager_ref(pa_stream_manager *m); -- 2.7.4 From 65889b1aba3ec8878b036aa840f9fcb31b010ebb Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Tue, 29 Jan 2019 15:03:19 +0900 Subject: [PATCH 04/16] stream-manager: Save mute state to vconf [Version] 11.1.32 [Issue type] Enhancement Change-Id: If866ff2fe8489de4bfd28a4ceb9ccf1df27f7542 Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/stream-manager-dbus.c | 7 +++++++ src/stream-manager-volume-priv.h | 2 ++ src/stream-manager-volume.c | 30 +++++++++++++++++++++++++++++- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 89e2287..96a9a01 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: 11.1.31 +Version: 11.1.32 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-dbus.c b/src/stream-manager-dbus.c index c2047eb..e193bc1 100644 --- a/src/stream-manager-dbus.c +++ b/src/stream-manager-dbus.c @@ -689,6 +689,7 @@ static void handle_set_volume_mute(DBusConnection *conn, DBusMessage *msg, void stream_type_t stream_type = STREAM_SINK_INPUT; DBusMessage *reply = NULL; pa_stream_manager *m = (pa_stream_manager*)userdata; + int ret = 0; pa_assert(conn); pa_assert(msg); @@ -712,6 +713,12 @@ static void handle_set_volume_mute(DBusConnection *conn, DBusMessage *msg, void goto finish; } + /* check vconf update here, mute will not be set if update fails */ + if ((ret = update_mute_vconf(type, do_mute))) { + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); + goto finish; + } + if (set_volume_mute_by_type(m, stream_type, type, (bool)do_mute)) pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); else diff --git a/src/stream-manager-volume-priv.h b/src/stream-manager-volume-priv.h index 8d9dc79..097d5e5 100644 --- a/src/stream-manager-volume-priv.h +++ b/src/stream-manager-volume-priv.h @@ -28,6 +28,7 @@ #include #define VCONFKEY_OUT_VOLUME_PREFIX "file/private/sound/volume/" +#define VCONFKEY_OUT_MUTE_PREFIX "file/private/sound/mute/" #define MASTER_VOLUME_TYPE "master" #define MASTER_VOLUME_LEVEL_MAX 100 @@ -48,5 +49,6 @@ int32_t set_volume_mute_by_idx(pa_stream_manager *m, stream_type_t stream_type, int32_t set_volume_mute_with_new_data(pa_stream_manager *m, void *stream, stream_type_t stream_type, bool volume_mute); int32_t get_volume_mute_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t stream_idx, bool *volume_mute); int32_t update_volume_vconf(const char *type, unsigned int value); +int32_t update_mute_vconf(const char *type, unsigned int mute); #endif diff --git a/src/stream-manager-volume.c b/src/stream-manager-volume.c index 4804264..79f3a6c 100644 --- a/src/stream-manager-volume.c +++ b/src/stream-manager-volume.c @@ -32,6 +32,7 @@ #define VOLUME_INI_DEFAULT_PATH SYSCONFDIR"/multimedia/mmfw_audio_volume.ini" /* SYSCONFDIR is defined at .spec */ #define VOLUME_INI_TUNED_PATH "/opt/system/mmfw_audio_volume.ini" #define DEFAULT_TABLE "volumes" +#define VCONF_PATH_MAX 128 #define CONVERT_TO_HAL_DIRECTION(stream_type)\ ((stream_type == STREAM_SINK_INPUT) ? DIRECTION_OUT : DIRECTION_IN) @@ -229,7 +230,7 @@ static int get_volume_value(pa_stream_manager *m, stream_type_t stream_type, boo int32_t update_volume_vconf(const char *type, unsigned int value) { - char str[128]; + char str[VCONF_PATH_MAX]; pa_snprintf(str, sizeof(str), "%s%s", VCONFKEY_OUT_VOLUME_PREFIX, type); @@ -245,6 +246,24 @@ int32_t update_volume_vconf(const char *type, unsigned int value) return 0; } +int32_t update_mute_vconf(const char *type, unsigned int mute) +{ + char str[VCONF_PATH_MAX]; + + pa_snprintf(str, sizeof(str), "%s%s", VCONFKEY_OUT_MUTE_PREFIX, type); + + /* Set mute value to VCONF */ + if ((vconf_set_bool(str, mute)) != 0) { + pa_log_error("vconf_set_bool(%s) failed...errno(%d)", + str, vconf_get_ext_errno()); + return -1; + } + + pa_log_info("mute set type(%s) value(%d)", str, mute); + + return 0; +} + int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type, const char *volume_type, uint32_t volume_level) { bool is_hal_volume = false; volume_info *v = NULL; @@ -738,6 +757,7 @@ int32_t init_volumes(pa_stream_manager *m) { char vconf_vol_type_addr[VCONF_ADDR_LEN] = {0,}; const char *volume_type = NULL; int level = 10; + int muted = 0; state = NULL; while ((v = pa_hashmap_iterate(m->volume_infos, &state, (const void**)&volume_type))) { memset(vconf_vol_type_addr, 0, VCONF_ADDR_LEN); @@ -748,6 +768,14 @@ int32_t init_volumes(pa_stream_manager *m) { set_volume_level_by_type(m, STREAM_SINK_INPUT, volume_type, (uint32_t)level); pa_log_debug("type[%s], current level[%u]", volume_type, v->values[STREAM_DIRECTION_OUT].current_level); } + memset(vconf_vol_type_addr, 0, VCONF_ADDR_LEN); + pa_snprintf(vconf_vol_type_addr, VCONF_ADDR_LEN, "%s%s", VCONFKEY_OUT_MUTE_PREFIX, volume_type); + if (vconf_get_bool(vconf_vol_type_addr, &muted)) + pa_log_error("failed to get mute state of the vconf[%s]", vconf_vol_type_addr); + else { + set_volume_mute_by_type(m, STREAM_SINK_INPUT, volume_type, (bool)muted); + pa_log_debug("type[%s], is_muted[%d]", volume_type, v->values[STREAM_DIRECTION_OUT].is_muted); + } } } #if 0 -- 2.7.4 From feb69e75487c19b839b25e49a050e178503f2132 Mon Sep 17 00:00:00 2001 From: Seungbae Shin Date: Mon, 11 Mar 2019 11:28:29 +0900 Subject: [PATCH 05/16] device-manager-dbus: Fix SVACE defect (DEREF_OF_NULL.RET.STAT) in addition, all other usages for pa_streq is also replaced by pa_safe_streq [Version] 11.1.33 [Issue type] SVACE Change-Id: I0b959cc6687a04d0e96c603f22287c944ab9df88 --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/device-manager-dbus.c | 12 +-- src/device-manager.c | 42 +++++------ src/module-sound-player.c | 4 +- src/module-tizenaudio-policy.c | 78 ++++++++++---------- src/stream-manager-dbus.c | 38 +++++----- src/stream-manager-filter.c | 8 +- src/stream-manager-restriction.c | 2 +- src/stream-manager-volume.c | 12 +-- src/stream-manager.c | 43 ++++++----- src/stream-manager.h | 23 ++++-- src/tizen-device-def.c | 126 ++++++++++++++------------------ src/tizen-device.c | 41 ++++++----- 13 files changed, 209 insertions(+), 222 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 96a9a01..579184a 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: 11.1.32 +Version: 11.1.33 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/device-manager-dbus.c b/src/device-manager-dbus.c index 2ad1377..08cb2e8 100644 --- a/src/device-manager-dbus.c +++ b/src/device-manager-dbus.c @@ -498,7 +498,7 @@ static DBusHandlerResult dbus_filter_device_detect_handler(DBusConnection *c, DB dbus_bool_t value; char *name = NULL; dbus_message_iter_get_basic(&variant_iter, &value); - if (pa_streq(property_name, "Connected")) { + if (pa_safe_streq(property_name, "Connected")) { pa_log_info("HFP Connection : %d", value); if (value) { method_call_bt_get_name(c, dbus_message_get_path(s), &name); @@ -512,7 +512,7 @@ static DBusHandlerResult dbus_filter_device_detect_handler(DBusConnection *c, DB } handle_device_status_changed(dm, DEVICE_TYPE_BT_SCO, name, dbus_message_get_path(s), detected); - } else if (pa_streq(property_name, "Playing")) { + } else if (pa_safe_streq(property_name, "Playing")) { pa_tz_device *device; pa_log_info("SCO Playing : %d", value); if ((device = device_list_get_device(dm, DEVICE_TYPE_BT_SCO, NULL)) != NULL) { @@ -994,7 +994,7 @@ static bool is_usb_output_device(pa_tz_device *device) { pa_assert(device); type = pa_tz_device_get_type(device); - if (!pa_streq(type, DEVICE_TYPE_USB_AUDIO)) { + if (!pa_safe_streq(type, DEVICE_TYPE_USB_AUDIO)) { pa_log_error("device(id:%d, %s) is not USB AUDIO type", pa_tz_device_get_id(device), type); return false; } @@ -1387,7 +1387,7 @@ static void handle_set_specific_stream_only(DBusConnection *conn, DBusMessage *m pa_dbus_send_error(conn, msg, DBUS_ERROR_NOT_SUPPORTED, "%s", "org.tizen.multimedia.audio.InvalidOperation"); return; } - if (!pa_streq(stream_role, "none") && !pa_stream_manager_is_valid_stream_role(dm->core, stream_role)) { + if (!pa_safe_streq(stream_role, "none") && !pa_stream_manager_is_valid_stream_role(dm->core, stream_role)) { pa_dbus_send_error(conn, msg, DBUS_ERROR_NOT_SUPPORTED, "%s", "org.tizen.multimedia.audio.InvalidOperation"); return; } @@ -1613,7 +1613,7 @@ static DBusHandlerResult method_call_handler(DBusConnection *c, DBusMessage *m, pa_log_info("DeviceManager Method Call Handler : path=%s, interface=%s, member=%s", path, interface, member); - if (!pa_streq(path, DBUS_OBJECT_DEVICE_MANAGER)) + if (!pa_safe_streq(path, DBUS_OBJECT_DEVICE_MANAGER)) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) { @@ -1867,4 +1867,4 @@ void deinit_dm_dbus(pa_device_manager *dm) { dm->dbus_conn = NULL; } } -#endif \ No newline at end of file +#endif diff --git a/src/device-manager.c b/src/device-manager.c index c3a28f8..842eb9c 100644 --- a/src/device-manager.c +++ b/src/device-manager.c @@ -361,7 +361,7 @@ static bool pulse_device_is_alsa(pa_object *pdevice) { return false; if ((api_name = pa_proplist_gets(prop, PA_PROP_DEVICE_API))) { - if (pa_streq(api_name, DEVICE_API_ALSA)) { + if (pa_safe_streq(api_name, DEVICE_API_ALSA)) { return true; } else { return false; @@ -379,7 +379,7 @@ static bool pulse_device_is_bluez(pa_object *pdevice) { return false; if ((api_name = pa_proplist_gets(prop, PA_PROP_DEVICE_API))) { - if (pa_streq(api_name, DEVICE_API_BLUEZ)) { + if (pa_safe_streq(api_name, DEVICE_API_BLUEZ)) { return true; } else { return false; @@ -405,10 +405,10 @@ static bool pulse_device_is_tizenaudio(pa_object *pdevice) { if (pa_sink_isinstance(pdevice)) { pa_sink *sink = PA_SINK(pdevice); - return pa_streq(sink->module->name, "module-tizenaudio-sink"); + return pa_safe_streq(sink->module->name, "module-tizenaudio-sink"); } else { pa_source *source = PA_SOURCE(pdevice); - return pa_streq(source->module->name, "module-tizenaudio-source"); + return pa_safe_streq(source->module->name, "module-tizenaudio-source"); } } @@ -420,7 +420,7 @@ static bool pulse_device_is_usb(pa_object *pdevice) { return false; if ((bus_name = pa_proplist_gets(prop, PA_PROP_DEVICE_BUS))) { - if (pa_streq(bus_name, DEVICE_BUS_USB)) { + if (pa_safe_streq(bus_name, DEVICE_BUS_USB)) { return true; } else { return false; @@ -440,10 +440,10 @@ static bool pulse_device_is_null(pa_object *pdevice) { if (pa_sink_isinstance(pdevice)) { sink = PA_SINK(pdevice); - return pa_streq(sink->module->name, "module-null-sink"); + return pa_safe_streq(sink->module->name, "module-null-sink"); } else { source = PA_SOURCE(pdevice); - return pa_streq(source->module->name, "module-null-source"); + return pa_safe_streq(source->module->name, "module-null-source"); } } @@ -530,7 +530,7 @@ static bool pulse_device_is_monitor(pa_object *pdevice) { prop = pulse_device_get_proplist(pdevice); if ((device_class = pa_proplist_gets(prop, PA_PROP_DEVICE_CLASS))) { - if (device_class && pa_streq(device_class, DEVICE_CLASS_MONITOR)) { + if (pa_safe_streq(device_class, DEVICE_CLASS_MONITOR)) { return true; } else { return false; @@ -613,10 +613,8 @@ static struct device_file_info* _device_manager_get_file_info(pa_idxset *file_in pa_assert(file_infos); PA_IDXSET_FOREACH(file_info, file_infos, file_idx) { - if (file_info->device_string) { - if (pa_streq(file_info->device_string, device_string)) { - return file_info; - } + if (pa_safe_streq(file_info->device_string, device_string)) { + return file_info; } } @@ -662,7 +660,7 @@ static struct device_status_info* _get_device_status(pa_device_manager *manager, return status_info; else if (status_info->system_id == NULL) continue; - else if (pa_streq(status_info->system_id, system_id)) + else if (pa_safe_streq(status_info->system_id, system_id)) return status_info; else continue; @@ -758,13 +756,13 @@ pa_tz_device* device_list_get_device(pa_device_manager *manager, const char *typ PA_IDXSET_FOREACH(device, manager->device_list, idx) { _type = pa_tz_device_get_type(device); _system_id = pa_tz_device_get_system_id(device); - if (pa_streq(_type, type)) { + if (pa_safe_streq(_type, type)) { if (device_type_is_avail_multi_device(type)) { if (system_id == NULL) return device; else if (_system_id == NULL) continue; - else if (pa_streq(_system_id, system_id)) + else if (pa_safe_streq(_system_id, system_id)) return device; else continue; @@ -840,7 +838,7 @@ static bool device_params_is_equal(const char *params1, const char *params2) { for (state = NULL, key = pa_modargs_iterate(modargs1, &state); key; key = pa_modargs_iterate(modargs1, &state)) { value1 = pa_modargs_get_value(modargs1, key, NULL); value2 = pa_modargs_get_value(modargs2, key, NULL); - if (!value1 || !value2 || !pa_streq(value1, value2)) { + if (!value1 || !value2 || !pa_safe_streq(value1, value2)) { equal = false; goto finish; } @@ -849,7 +847,7 @@ static bool device_params_is_equal(const char *params1, const char *params2) { for (state = NULL, key = pa_modargs_iterate(modargs2, &state); key; key = pa_modargs_iterate(modargs2, &state)) { value1 = pa_modargs_get_value(modargs1, key, NULL); value2 = pa_modargs_get_value(modargs2, key, NULL); - if (!value1 || !value2 || !pa_streq(value1, value2)) { + if (!value1 || !value2 || !pa_safe_streq(value1, value2)) { equal = false; goto finish; } @@ -931,7 +929,7 @@ static bool pulse_device_same_device_string(pa_object *pdevice, const char *devi if (pulse_device_get_device_string(pdevice, _device_string) < 0) return false; - return pa_streq(_device_string, device_string); + return pa_safe_streq(_device_string, device_string); } static const char* device_type_info_get_device_string(struct device_type_info *type_info, bool is_playback, const char *role) { @@ -1629,14 +1627,14 @@ static pa_hook_result_t sink_source_state_changed_hook_cb(pa_core *c, pa_object pa_sink *s = PA_SINK(pdevice); pa_sink_state_t state = pa_sink_get_state(s); pa_log_debug("=========== Sink(%p,%s) state has been changed to [%d](0:RUNNING, 1:IDLE, 2:SUSPEND) ==========", s, s->name, state); - if (!s->use_internal_codec && !pa_streq(s->name, SINK_NAME_NULL)) + if (!s->use_internal_codec && !pa_safe_streq(s->name, SINK_NAME_NULL)) if ((device = pa_device_manager_get_device_with_sink(s))) pa_tz_device_set_running_and_notify(device, (state == PA_SINK_RUNNING)); } else if (pa_source_isinstance(pdevice)) { pa_source *s = PA_SOURCE(pdevice); pa_source_state_t state = pa_source_get_state(s); pa_log_debug("=========== Source(%p,%s) state has been changed to [%d](0:RUNNING, 1:IDLE, 2:SUSPEND) ==========", s, s->name, state); - if (!s->use_internal_codec && !pa_streq(s->name, SOURCE_NAME_NULL)) + if (!s->use_internal_codec && !pa_safe_streq(s->name, SOURCE_NAME_NULL)) if ((device = pa_device_manager_get_device_with_source(s))) pa_tz_device_set_running_and_notify(device, (state == PA_SOURCE_RUNNING)); } @@ -2340,7 +2338,7 @@ pa_sink* pa_device_manager_load_sink(pa_device_manager *dm, const char *type, co pa_log_info("Load Sink for '%s.%s'", type, role); PA_IDXSET_FOREACH(device, dm->device_list, device_idx) { - if (pa_streq(type, pa_tz_device_get_type(device))) { + if (pa_safe_streq(type, pa_tz_device_get_type(device))) { if (pa_tz_device_get_sink(device, role)) { pa_log_warn("Proper sink for '%s.%s' already loaded", type, role); return NULL; @@ -2438,7 +2436,7 @@ pa_source* pa_device_manager_load_source(pa_device_manager *dm, const char *type pa_log_info("Load Source for '%s.%s'", type, role); PA_IDXSET_FOREACH(device, dm->device_list, device_idx) { - if (pa_streq(type, pa_tz_device_get_type(device))) { + if (pa_safe_streq(type, pa_tz_device_get_type(device))) { if (pa_tz_device_get_source(device, role)) { pa_log_warn("Proper source for '%s.%s' already loaded", type, role); return NULL; diff --git a/src/module-sound-player.c b/src/module-sound-player.c index 7ef1a7e..310b631 100644 --- a/src/module-sound-player.c +++ b/src/module-sound-player.c @@ -358,7 +358,7 @@ static DBusHandlerResult handle_methods(DBusConnection *conn, DBusMessage *msg, for (idx = 0; idx < METHOD_HANDLER_MAX; idx++) { if (dbus_message_is_method_call(msg, SOUND_PLAYER_INTERFACE, method_handlers[idx].method_name)) { - if (pa_streq(dbus_message_get_signature(msg), signature_args_for_in[idx])) { + if (pa_safe_streq(dbus_message_get_signature(msg), signature_args_for_in[idx])) { method_handlers[idx].receive_cb(conn, msg, userdata); return DBUS_HANDLER_RESULT_HANDLED; } else { @@ -386,7 +386,7 @@ static DBusHandlerResult method_handler_for_vt(DBusConnection *c, DBusMessage *m pa_log_debug("dbus: path=%s, interface=%s, member=%s", path, interface, member); - if (!pa_streq(path, SOUND_PLAYER_OBJECT_PATH)) + if (!pa_safe_streq(path, SOUND_PLAYER_OBJECT_PATH)) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) { diff --git a/src/module-tizenaudio-policy.c b/src/module-tizenaudio-policy.c index 3f938cf..a60be73 100644 --- a/src/module-tizenaudio-policy.c +++ b/src/module-tizenaudio-policy.c @@ -126,25 +126,25 @@ int cached_connected_devices[DEVICE_MAX][CACHED_DEVICE_DIRECTION_MAX]; static device_type_t convert_device_type_str(const char *device) { - if (pa_streq(device, DEVICE_TYPE_SPEAKER)) + if (pa_safe_streq(device, DEVICE_TYPE_SPEAKER)) return DEVICE_BUILTIN_SPEAKER; - else if (pa_streq(device, DEVICE_TYPE_RECEIVER)) + else if (pa_safe_streq(device, DEVICE_TYPE_RECEIVER)) return DEVICE_BUILTIN_RECEIVER; - else if (pa_streq(device, DEVICE_TYPE_MIC)) + else if (pa_safe_streq(device, DEVICE_TYPE_MIC)) return DEVICE_BUILTIN_MIC; - else if (pa_streq(device, DEVICE_TYPE_AUDIO_JACK)) + else if (pa_safe_streq(device, DEVICE_TYPE_AUDIO_JACK)) return DEVICE_AUDIO_JACK; - else if (pa_streq(device, DEVICE_TYPE_BT_A2DP)) + else if (pa_safe_streq(device, DEVICE_TYPE_BT_A2DP)) return DEVICE_BT_A2DP; - else if (pa_streq(device, DEVICE_TYPE_BT_SCO)) + else if (pa_safe_streq(device, DEVICE_TYPE_BT_SCO)) return DEVICE_BT_SCO; - else if (pa_streq(device, DEVICE_TYPE_HDMI)) + else if (pa_safe_streq(device, DEVICE_TYPE_HDMI)) return DEVICE_HDMI; - else if (pa_streq(device, DEVICE_TYPE_FORWARDING)) + else if (pa_safe_streq(device, DEVICE_TYPE_FORWARDING)) return DEVICE_FORWARDING; - else if (pa_streq(device, DEVICE_TYPE_USB_AUDIO)) + else if (pa_safe_streq(device, DEVICE_TYPE_USB_AUDIO)) return DEVICE_USB_AUDIO; - else if (pa_streq(device, DEVICE_TYPE_RAOP)) + else if (pa_safe_streq(device, DEVICE_TYPE_RAOP)) return DEVICE_RAOP; @@ -228,7 +228,7 @@ static pa_tz_device* _get_sco_connected_device(pa_device_manager *dm) { device_list = pa_device_manager_get_device_list(dm); PA_IDXSET_FOREACH(device, device_list, device_idx) { - if (pa_streq(device->type, DEVICE_TYPE_BT_SCO)) { + if (pa_safe_streq(device->type, DEVICE_TYPE_BT_SCO)) { return device; } } @@ -256,7 +256,7 @@ static bool is_bt_a2dp_connected(pa_device_manager *dm) { device_list = pa_device_manager_get_device_list(dm); PA_IDXSET_FOREACH(device, device_list, device_idx) { - if (pa_streq(device->type, DEVICE_TYPE_BT_A2DP)) { + if (pa_safe_streq(device->type, DEVICE_TYPE_BT_A2DP)) { return true; } } @@ -346,8 +346,8 @@ static int bt_sco_open(struct userdata *u, const char *role) { return 0; } - if (pa_streq(role, STREAM_ROLE_VOICE_RECOGNITION) || - pa_streq(role, STREAM_ROLE_VOICE_RECOGNITION_SERVICE)) + if (pa_safe_streq(role, STREAM_ROLE_VOICE_RECOGNITION) || + pa_safe_streq(role, STREAM_ROLE_VOICE_RECOGNITION_SERVICE)) pa_tz_device_sco_enable_pcm(bt_device, true); if (pa_tz_device_sco_open(bt_device) < 0) { @@ -510,9 +510,9 @@ static void unload_combine_sink_module(struct userdata *u, const char *combine_s pa_assert(combine_sink_name); pa_assert(dst_sink); - if (pa_streq(combine_sink_name, SINK_NAME_COMBINED)) { + if (pa_safe_streq(combine_sink_name, SINK_NAME_COMBINED)) { combine_sink_module = &u->module_combine_sink; - } else if (pa_streq(combine_sink_name, SINK_NAME_COMBINED_EX)) { + } else if (pa_safe_streq(combine_sink_name, SINK_NAME_COMBINED_EX)) { combine_sink_module = &u->module_combine_sink_for_ex; } else { pa_log_error("unknown combine_sink_name(%s)", combine_sink_name); @@ -542,7 +542,7 @@ static bool skip_device(const char *stream_role, const char *device_type) { int sound_on = 1; - if (pa_streq(device_type, DEVICE_TYPE_FORWARDING)) + if (pa_safe_streq(device_type, DEVICE_TYPE_FORWARDING)) return true; /* get sound profile */ @@ -551,7 +551,7 @@ static bool skip_device(const char *stream_role, const char *device_type) return false; } - if (!sound_on && IS_ROLE_RINGTONE(stream_role) && pa_streq(device_type, DEVICE_TYPE_SPEAKER)) { + if (!sound_on && IS_ROLE_RINGTONE(stream_role) && pa_safe_streq(device_type, DEVICE_TYPE_SPEAKER)) { pa_log_info("sound status is 0 with ringtone-call stream, skip built-in speaker"); return true; } @@ -564,7 +564,7 @@ static bool skip_bt_sco_device(struct userdata *u, const char *stream_role, cons pa_assert(stream_role); pa_assert(device_type); - if (pa_streq(stream_role, STREAM_ROLE_VOICE_INFORMATION) && pa_streq(device_type, DEVICE_TYPE_BT_SCO)) { + if (pa_safe_streq(stream_role, STREAM_ROLE_VOICE_INFORMATION) && pa_safe_streq(device_type, DEVICE_TYPE_BT_SCO)) { if (!is_bt_sco_connected(u->device_manager)) { pa_log_warn("It is VOICE_INFORMATION, BT SCO is not connected, skip this device"); return true; @@ -592,7 +592,7 @@ static bool skip_bt_sco_device(struct userdata *u, const char *stream_role, cons static bool is_supported_stream_role_for_usb(const char *role) { pa_assert(role); - if (pa_streq(STREAM_ROLE_MEDIA, role)) + if (pa_safe_streq(STREAM_ROLE_MEDIA, role)) return true; pa_log_error("not supported role for usb(%s)", role); @@ -606,14 +606,14 @@ static bool skip_usb_device(const char *stream_role, pa_tz_device *device) { pa_assert(stream_role); pa_assert(device); - if (!pa_streq(pa_tz_device_get_type(device), DEVICE_TYPE_USB_AUDIO)) + if (!pa_safe_streq(pa_tz_device_get_type(device), DEVICE_TYPE_USB_AUDIO)) return false; if (!(specified_stream_role = pa_tz_device_get_specified_stream_role(device))) return false; if (is_supported_stream_role_for_usb(specified_stream_role) && - pa_streq(stream_role, specified_stream_role)) + pa_safe_streq(stream_role, specified_stream_role)) return false; pa_log_info("skip this usb device, stream role(%s), specified stream role(%s)", stream_role, specified_stream_role); @@ -703,7 +703,7 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre dm_device_id = pa_tz_device_get_id(device); pa_log_debug(" -- type[%-16s], direction[0x%x], id[%u]", dm_device_type, dm_device_direction, dm_device_id); - if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { + if (pa_safe_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { pa_log_info(" ** found a matched device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction); if (skip_bt_sco_device(u, data->stream_role, dm_device_type)) continue; @@ -742,7 +742,7 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre creation_time = pa_tz_device_get_creation_time(device); pa_log_debug(" -- type[%-16s], direction[0x%x], id[%u], creation_time[%llu]", dm_device_type, dm_device_direction, dm_device_id, creation_time); - if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { + if (pa_safe_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { if (skip_bt_sco_device(u, data->stream_role, dm_device_type)) continue; if (skip_usb_device(data->stream_role, device)) @@ -779,7 +779,7 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre dm_device_direction = pa_tz_device_get_direction(device); pa_log_debug(" -- type[%-16s], direction[0x%x], device id[%u]", dm_device_type, dm_device_direction, *device_id); - if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { + if (pa_safe_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { pa_log_info(" ** found a matched device: type[%-16s], direction[0x%x]", device_type, dm_device_direction); if (data->stream_type == STREAM_SINK_INPUT) { if ((*(data->proper_sink)) == null_sink) @@ -808,7 +808,7 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre dm_device_direction = pa_tz_device_get_direction(device); pa_log_debug(" -- type[%-16s], direction[0x%x], device id[%u]", dm_device_type, dm_device_direction, *device_id); - if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { + if (pa_safe_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { pa_log_info(" ** found a matched device: type[%-16s], direction[0x%x]", device_type, dm_device_direction); /* currently, we support two sinks for combining */ if (data->stream_type == STREAM_SINK_INPUT) { @@ -819,7 +819,7 @@ static pa_hook_result_t select_proper_sink_or_source_hook_cb(pa_core *c, pa_stre pa_log_warn(" -- could not get combine_sink_arg1"); } else if (!combine_sink_arg2) { sink = combine_sink_arg2 = pa_tz_device_get_sink(device, DEVICE_ROLE_NORMAL); - if (sink && !pa_streq(sink->name, combine_sink_arg1->name)) { + if (sink && !pa_safe_streq(sink->name, combine_sink_arg1->name)) { uint32_t s_idx = 0; pa_log_info(" -- combine_sink_arg2[%s]", sink->name); @@ -1130,7 +1130,7 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_ dm_device_id = pa_tz_device_get_id(device); pa_log_debug(" -- type[%-16s], direction[0x%x], id[%u]", dm_device_type, dm_device_direction, dm_device_id); - if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { + if (pa_safe_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { pa_log_debug(" ** found a matched device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction); if (skip_usb_device(data->stream_role, device)) continue; @@ -1164,7 +1164,7 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_ pa_log_error("[ROUTE][AUTO] could not get sink"); } - if (pa_streq(dm_device_type, DEVICE_TYPE_BT_SCO)) { + if (pa_safe_streq(dm_device_type, DEVICE_TYPE_BT_SCO)) { if (IS_ROLE_AVAILABLE_BT_SCO_OPEN(route_info.role)) { if (update_bt_sco_state(u, true, false, route_info.role)) { pa_log_error(" ** could not open BT SCO"); @@ -1196,7 +1196,7 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_ pa_log_error("[ROUTE][AUTO_ALL] could not get sink from pa_device_manager_get_sink"); } else if (data->stream_type == STREAM_SINK_INPUT && !combine_sink_arg2) { sink = combine_sink_arg2 = pa_tz_device_get_sink(device, data->device_role); - if (sink && !pa_streq(sink->name, combine_sink_arg1->name)) { + if (sink && !pa_safe_streq(sink->name, combine_sink_arg1->name)) { pa_log_info("[ROUTE][AUTO_ALL] combine_sink_arg2[%s]", sink->name); /* load combine sink */ if (!u->module_combine_sink) { @@ -1261,7 +1261,7 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_ creation_time = pa_tz_device_get_creation_time(device); pa_log_debug(" -- type[%-16s], direction[0x%x], id[%u], creation_time[%llu]", dm_device_type, dm_device_direction, dm_device_id, creation_time); - if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { + if (pa_safe_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) { if (skip_usb_device(data->stream_role, device)) continue; use_internal_codec = pa_tz_device_is_use_internal_codec(device); @@ -1303,7 +1303,7 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_ pa_log_error("[ROUTE][AUTO_LAST_CONN] could not get sink"); } - if (pa_streq(dm_device_type, DEVICE_TYPE_BT_SCO)) { + if (pa_safe_streq(dm_device_type, DEVICE_TYPE_BT_SCO)) { if (IS_ROLE_AVAILABLE_BT_SCO_OPEN(route_info.role)) { if (update_bt_sco_state(u, true, false, route_info.role)) { pa_log_error(" ** could not open BT SCO"); @@ -1332,13 +1332,13 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_ if (!(device = pa_device_manager_get_device_by_id(u->device_manager, *device_id))) continue; dm_device_type = pa_tz_device_get_type(device); - if (!pa_streq(device_type, dm_device_type)) + if (!pa_safe_streq(device_type, dm_device_type)) continue; dm_device_direction = pa_tz_device_get_direction(device); pa_log_debug(" ** found a matched device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction); /* Check for availability for opening Bluetooth SCO */ - if (pa_streq(dm_device_type, DEVICE_TYPE_BT_SCO) && IS_ROLE_AVAILABLE_BT_SCO_OPEN(route_info.role)) { + if (pa_safe_streq(dm_device_type, DEVICE_TYPE_BT_SCO) && IS_ROLE_AVAILABLE_BT_SCO_OPEN(route_info.role)) { /* update BT SCO: open */ if (update_bt_sco_state(u, true, false, route_info.role)) { pa_log_error(" ** could not open BT SCO"); @@ -1350,7 +1350,7 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_ update_bt_sco_state(u, false, false, NULL); } /* Check for in/out devices in case of loopback */ - if (pa_streq(data->stream_role, STREAM_ROLE_LOOPBACK)) { + if (pa_safe_streq(data->stream_role, STREAM_ROLE_LOOPBACK)) { if ((data->stream_type == STREAM_SINK_INPUT) && (dm_device_direction & DM_DEVICE_DIRECTION_OUT)) u->loopback_args.sink = pa_tz_device_get_sink(device, DEVICE_ROLE_NORMAL); else if ((data->stream_type == STREAM_SOURCE_OUTPUT) && (dm_device_direction & DM_DEVICE_DIRECTION_IN)) @@ -1366,7 +1366,7 @@ static pa_hook_result_t route_change_hook_cb(pa_core *c, pa_stream_manager_hook_ } } } - if (pa_streq(data->stream_role, STREAM_ROLE_LOOPBACK)) { + if (pa_safe_streq(data->stream_role, STREAM_ROLE_LOOPBACK)) { /* load module-loopback */ if (u->loopback_args.sink && u->loopback_args.source) update_loopback_module(u, true); @@ -1396,11 +1396,11 @@ static pa_hook_result_t update_info_hook_cb(pa_core *c, pa_stream_manager_hook_d pa_assert(data); pa_assert(u); - if (pa_streq(data->stream_role, STREAM_ROLE_LOOPBACK)) { + if (pa_safe_streq(data->stream_role, STREAM_ROLE_LOOPBACK)) { pa_log_info("[UPDATE] stream_role(%s) [name(%s)/value(%d)]", data->stream_role, data->name, data->value); - if (pa_streq(data->name, MSG_FOR_LOOPBACK_ARG_LATENCY)) + if (pa_safe_streq(data->name, MSG_FOR_LOOPBACK_ARG_LATENCY)) u->loopback_args.latency_msec = data->value; - else if (pa_streq(data->name, MSG_FOR_LOOPBACK_ARG_ADJUST_TIME)) + else if (pa_safe_streq(data->name, MSG_FOR_LOOPBACK_ARG_ADJUST_TIME)) u->loopback_args.adjust_sec = data->value; } diff --git a/src/stream-manager-dbus.c b/src/stream-manager-dbus.c index e193bc1..5c402ec 100644 --- a/src/stream-manager-dbus.c +++ b/src/stream-manager-dbus.c @@ -568,9 +568,9 @@ static void handle_set_volume_level(DBusConnection *conn, DBusMessage *msg, void pa_assert_se((reply = dbus_message_new_method_return(msg))); - if (pa_streq(direction, "in")) + if (pa_safe_streq(direction, "in")) stream_type = STREAM_SOURCE_OUTPUT; - else if (pa_streq(direction, "out")) + else if (pa_safe_streq(direction, "out")) stream_type = STREAM_SINK_INPUT; else { pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); @@ -617,9 +617,9 @@ static void handle_get_volume_level(DBusConnection *conn, DBusMessage *msg, void pa_assert_se((reply = dbus_message_new_method_return(msg))); - if (pa_streq(direction, "in")) + if (pa_safe_streq(direction, "in")) stream_type = STREAM_SOURCE_OUTPUT; - else if (pa_streq(direction, "out")) + else if (pa_safe_streq(direction, "out")) stream_type = STREAM_SINK_INPUT; else { pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID)); @@ -660,9 +660,9 @@ static void handle_get_volume_max_level(DBusConnection *conn, DBusMessage *msg, pa_assert_se((reply = dbus_message_new_method_return(msg))); - if (pa_streq(direction, "in")) + if (pa_safe_streq(direction, "in")) stream_type = STREAM_SOURCE_OUTPUT; - else if (pa_streq(direction, "out")) + else if (pa_safe_streq(direction, "out")) stream_type = STREAM_SINK_INPUT; else { pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID)); @@ -704,9 +704,9 @@ static void handle_set_volume_mute(DBusConnection *conn, DBusMessage *msg, void pa_assert_se((reply = dbus_message_new_method_return(msg))); - if (pa_streq(direction, "in")) + if (pa_safe_streq(direction, "in")) stream_type = STREAM_SOURCE_OUTPUT; - else if (pa_streq(direction, "out")) + else if (pa_safe_streq(direction, "out")) stream_type = STREAM_SINK_INPUT; else { pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); @@ -749,9 +749,9 @@ static void handle_get_volume_mute(DBusConnection *conn, DBusMessage *msg, void pa_assert_se((reply = dbus_message_new_method_return(msg))); - if (pa_streq(direction, "in")) + if (pa_safe_streq(direction, "in")) stream_type = STREAM_SOURCE_OUTPUT; - else if (pa_streq(direction, "out")) + else if (pa_safe_streq(direction, "out")) stream_type = STREAM_SINK_INPUT; else { pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID)); @@ -793,10 +793,10 @@ static void handle_get_current_volume_type(DBusConnection *conn, DBusMessage *ms pa_assert_se((reply = dbus_message_new_method_return(msg))); - if (pa_streq(direction, "in")) { + if (pa_safe_streq(direction, "in")) { stream_type = STREAM_SOURCE_OUTPUT; streams = m->core->source_outputs; - } else if (pa_streq(direction, "out")) { + } else if (pa_safe_streq(direction, "out")) { stream_type = STREAM_SINK_INPUT; streams = m->core->sink_inputs; } else { @@ -864,9 +864,9 @@ static void handle_get_current_media_routing_path(DBusConnection *conn, DBusMess pa_assert_se((reply = dbus_message_new_method_return(msg))); - if (pa_streq(direction, "in")) { + if (pa_safe_streq(direction, "in")) { dm_device_direction = DM_DEVICE_DIRECTION_IN; - } else if (pa_streq(direction, "out")) { + } else if (pa_safe_streq(direction, "out")) { dm_device_direction = DM_DEVICE_DIRECTION_OUT; } else { pa_log_error("invalid direction[%s]", direction); @@ -1121,7 +1121,7 @@ static void handle_update_call_parameters(DBusConnection *conn, DBusMessage *msg /* Currently, we only use network band */ route_option.name = "call-wideband"; - if (pa_streq(network_band, "wb")) + if (pa_safe_streq(network_band, "wb")) route_option.value = 1; else route_option.value = 0; @@ -1286,9 +1286,9 @@ static void handle_check_stream_exist_by_pid(DBusConnection *conn, DBusMessage * pa_assert_se((reply = dbus_message_new_method_return(msg))); - if (pa_streq(direction, "in")) + if (pa_safe_streq(direction, "in")) stream_type = STREAM_SOURCE_OUTPUT; - else if (pa_streq(direction, "out")) + else if (pa_safe_streq(direction, "out")) stream_type = STREAM_SINK_INPUT; else { pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INVALID_ARGUMENT], @@ -1320,7 +1320,7 @@ static DBusHandlerResult handle_methods(DBusConnection *conn, DBusMessage *msg, for (idx = 0; idx < METHOD_HANDLER_MAX; idx++) { if (dbus_message_is_method_call(msg, STREAM_MANAGER_INTERFACE, method_handlers[idx].method_name)) { pa_log_debug("Message signature [%s] (Expected [%s])", dbus_message_get_signature(msg), signature_args_for_in[idx]); - if (pa_streq(dbus_message_get_signature(msg), signature_args_for_in[idx])) { + if (pa_safe_streq(dbus_message_get_signature(msg), signature_args_for_in[idx])) { method_handlers[idx].receive_cb(conn, msg, userdata); return DBUS_HANDLER_RESULT_HANDLED; } else { @@ -1348,7 +1348,7 @@ static DBusHandlerResult method_handler_for_vt(DBusConnection *c, DBusMessage *m pa_log_debug("dbus: path=%s, interface=%s, member=%s", path, interface, member); - if (!pa_streq(path, STREAM_MANAGER_OBJECT_PATH)) + if (!pa_safe_streq(path, STREAM_MANAGER_OBJECT_PATH)) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) { diff --git a/src/stream-manager-filter.c b/src/stream-manager-filter.c index 9aeb9cb..a0d0842 100644 --- a/src/stream-manager-filter.c +++ b/src/stream-manager-filter.c @@ -202,7 +202,7 @@ static void update_prop_filter_apply_params(pa_sink_input *si, filter_info *f, c int32_t apply_filter_to_sink_input(pa_sink_input *si, filter_info *f, bool need_to_hook) { pa_assert(si); - if (f && (!f->filter_apply || pa_streq(f->filter_apply, ""))) { + if (f && (!f->filter_apply || pa_safe_streq(f->filter_apply, ""))) { pa_log_error("Try to applying empty filter module"); return -1; } @@ -326,7 +326,7 @@ int32_t control_filter(pa_stream_manager *m, const char *filter_name, const char uint32_t s_idx = 0; pa_sink *s = NULL; - if (pa_streq(filter_name, "") || pa_streq(filter_controls, "")) { + if (pa_safe_streq(filter_name, "") || pa_safe_streq(filter_controls, "")) { pa_log_error("Empty filter name or controls"); return -1; } @@ -509,7 +509,7 @@ void init_filters(pa_stream_manager *m) { /* Load module-filter-apply */ PA_IDXSET_FOREACH(i, m->core->modules, idx) { - if (pa_streq(i->name, MODULE_FILTER_APPLY)) { + if (pa_safe_streq(i->name, MODULE_FILTER_APPLY)) { module = i; pa_log("module-filter-apply loaded already"); break; @@ -531,7 +531,7 @@ void deinit_filters(pa_stream_manager *m) { /* Unload module-filter-apply */ PA_IDXSET_FOREACH(i, m->core->modules, idx) { - if (pa_streq(i->name, MODULE_FILTER_APPLY)) { + if (pa_safe_streq(i->name, MODULE_FILTER_APPLY)) { pa_module_unload(i, true); pa_log("module-filter-apply unloaded"); break; diff --git a/src/stream-manager-restriction.c b/src/stream-manager-restriction.c index fa5ec58..818b6c5 100644 --- a/src/stream-manager-restriction.c +++ b/src/stream-manager-restriction.c @@ -33,7 +33,7 @@ int32_t handle_restrictions(pa_stream_manager *m, const char *name, uint32_t val pa_assert(m); - if (pa_streq(name, STREAM_MANAGER_METHOD_ARGS_BLOCK_RECORDING_MEDIA) ) { + if (pa_safe_streq(name, STREAM_MANAGER_METHOD_ARGS_BLOCK_RECORDING_MEDIA) ) { if (value == 1) { pa_log_info("block MEDIA recording"); m->restrictions.block_recording_media = true; diff --git a/src/stream-manager-volume.c b/src/stream-manager-volume.c index 79f3a6c..db3c4b7 100644 --- a/src/stream-manager-volume.c +++ b/src/stream-manager-volume.c @@ -297,18 +297,18 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type return -1; } - if (pa_streq(volume_type, MASTER_VOLUME_TYPE) && MASTER_VOLUME_LEVEL_MAX < volume_level) { + if (pa_safe_streq(volume_type, MASTER_VOLUME_TYPE) && MASTER_VOLUME_LEVEL_MAX < volume_level) { pa_log_error("could not set volume level of MASTER type, out of range[%u]", volume_level); return -1; } v->values[stream_type].current_level = volume_level; - if (is_hal_volume && pa_streq(volume_type, MASTER_VOLUME_TYPE)) { + if (is_hal_volume && pa_safe_streq(volume_type, MASTER_VOLUME_TYPE)) { /* no need to update the value of pulseaudio stream */ return 0; } - if (!pa_streq(volume_type, MASTER_VOLUME_TYPE)) { + if (!pa_safe_streq(volume_type, MASTER_VOLUME_TYPE)) { if (get_volume_value(m, stream_type, is_hal_volume, volume_type, volume_level, &volume_linear)) return -1; @@ -320,7 +320,7 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE); /* Update volume level of stream if it has requested the volume type */ - if (pa_streq(volume_type_str, volume_type)) { + if (pa_safe_streq(volume_type_str, volume_type)) { if (modifier_gain) { if (m->volume_modifiers) { if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { @@ -411,7 +411,7 @@ int32_t get_volume_level_by_type(pa_stream_manager *m, pa_volume_get_command_t c } } else if (command == GET_VOLUME_MAX_LEVEL) { /* If it is the master volume type */ - if (pa_streq(volume_type, MASTER_VOLUME_TYPE)) { + if (pa_safe_streq(volume_type, MASTER_VOLUME_TYPE)) { *volume_level = MASTER_VOLUME_LEVEL_MAX; } else { /* Get max level */ @@ -574,7 +574,7 @@ int32_t set_volume_mute_by_type(pa_stream_manager *m, stream_type_t stream_type, } /* Update mute of stream if it has requested the volume type */ - if (pa_streq(volume_type_str, volume_type)) { + if (pa_safe_streq(volume_type_str, volume_type)) { if (stream_type == STREAM_SINK_INPUT) pa_sink_input_set_mute((pa_sink_input*)s, volume_mute, true); else if (stream_type == STREAM_SOURCE_OUTPUT) diff --git a/src/stream-manager.c b/src/stream-manager.c index 33ca9b3..0370154 100644 --- a/src/stream-manager.c +++ b/src/stream-manager.c @@ -146,15 +146,15 @@ static int32_t convert_route_type(const char *route_type_str, stream_route_type_ pa_assert(route_type); pa_assert(route_type_str); - if (pa_streq("auto", route_type_str)) + if (pa_safe_streq("auto", route_type_str)) *route_type = STREAM_ROUTE_TYPE_AUTO; - else if (pa_streq("auto-last-connected", route_type_str)) + else if (pa_safe_streq("auto-last-connected", route_type_str)) *route_type = STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED; - else if (pa_streq("auto-all", route_type_str)) + else if (pa_safe_streq("auto-all", route_type_str)) *route_type = STREAM_ROUTE_TYPE_AUTO_ALL; - else if (pa_streq("manual", route_type_str)) + else if (pa_safe_streq("manual", route_type_str)) *route_type = STREAM_ROUTE_TYPE_MANUAL; - else if (pa_streq("manual-ext", route_type_str)) + else if (pa_safe_streq("manual-ext", route_type_str)) *route_type = STREAM_ROUTE_TYPE_MANUAL_EXT; else { ret = -1; @@ -874,7 +874,7 @@ static bool check_name_to_skip(pa_stream_manager *m, process_command_type_t comm if (command == PROCESS_COMMAND_PREPARE && is_new_data) { if ((name = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_NAME))) { for (i = 0; i < NAME_FOR_SKIP_MAX; i++) - if (pa_streq(name, stream_manager_media_names_for_skip[i])) { + if (pa_safe_streq(name, stream_manager_media_names_for_skip[i])) { ret = true; pa_proplist_sets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_ROLE, SKIP_ROLE); break; @@ -887,7 +887,7 @@ static bool check_name_to_skip(pa_stream_manager *m, process_command_type_t comm else role = pa_proplist_gets(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_ROLE); - if (role && pa_streq(role, SKIP_ROLE)) + if (pa_safe_streq(role, SKIP_ROLE)) ret = true; } @@ -904,7 +904,7 @@ static bool check_role_to_skip(pa_stream_manager *m, process_command_type_t comm if ((s = pa_hashmap_get(m->stream_infos, role))) ret = false; - if (s && pa_streq(role, STREAM_ROLE_LOOPBACK_MIRRORING) && + if (s && pa_safe_streq(role, STREAM_ROLE_LOOPBACK_MIRRORING) && (command == PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_STARTED || command == PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_ENDED)) ret = true; @@ -943,11 +943,10 @@ static bool check_name_is_vstream(void *stream, stream_type_t type, bool is_new_ name = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_NAME); else name = pa_proplist_gets(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_NAME); - if (name) { - if (pa_streq(name, VIRTUAL_STREAM_NAME)) { - ret = true; - pa_log_info("name is [%s]", name); - } + + if (pa_safe_streq(name, VIRTUAL_STREAM_NAME)) { + ret = true; + pa_log_info("name is [%s]", name); } return ret; @@ -1005,7 +1004,7 @@ static bool update_volume_type_of_stream(pa_stream_manager *m, void *stream, str if ((s = pa_hashmap_get(m->stream_infos, role))) volume_type = s->volume_types[type]; - if (volume_type && (!pa_streq(volume_type, "none"))) { + if (volume_type && (!pa_safe_streq(volume_type, "none"))) { pa_proplist_sets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE, volume_type); ret = true; } else @@ -1684,7 +1683,7 @@ static void update_mirroring_streams(pa_stream_manager *m, pa_source_output *o, pa_assert(o); if ((role = pa_proplist_gets(GET_STREAM_PROPLIST(o, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_ROLE)) && - pa_streq(role, STREAM_ROLE_LOOPBACK_MIRRORING)) { + pa_safe_streq(role, STREAM_ROLE_LOOPBACK_MIRRORING)) { if (put) pa_idxset_put(m->mirroring_streams, o, NULL); else @@ -1812,7 +1811,7 @@ process_stream_result_t process_stream(pa_stream_manager *m, void *stream, strea goto finish; } /* load forwarding device */ - if (type == STREAM_SOURCE_OUTPUT && pa_streq(role, STREAM_ROLE_LOOPBACK_MIRRORING)) + if (type == STREAM_SOURCE_OUTPUT && pa_safe_streq(role, STREAM_ROLE_LOOPBACK_MIRRORING)) update_forwarding_device(m, true); } /* update the priority of this stream */ @@ -1926,7 +1925,7 @@ process_stream_result_t process_stream(pa_stream_manager *m, void *stream, strea role = pa_proplist_gets(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_ROLE); if (role) { /* unload forwarding device */ - if (type == STREAM_SOURCE_OUTPUT && pa_streq(role, STREAM_ROLE_LOOPBACK_MIRRORING)) + if (type == STREAM_SOURCE_OUTPUT && pa_safe_streq(role, STREAM_ROLE_LOOPBACK_MIRRORING)) update_forwarding_device(m, false); /* skip roles */ @@ -2326,7 +2325,7 @@ static void find_next_device_for_auto_route(pa_stream_manager *m, stream_route_t if (route_type == STREAM_ROUTE_TYPE_AUTO) { PA_IDXSET_FOREACH(device_type, devices, idx) { - if (pa_streq(device_type, cur_device_type)) { + if (pa_safe_streq(device_type, cur_device_type)) { ret_next = true; continue; } @@ -2386,12 +2385,12 @@ static void is_available_device_for_auto_route(pa_stream_manager *m, stream_rout PA_IDXSET_FOREACH(device_type, devices, idx) { if (route_type == STREAM_ROUTE_TYPE_AUTO) { - if (pa_streq(device_type, cur_device_type)) { + if (pa_safe_streq(device_type, cur_device_type)) { pa_log_debug("cur_device[%s]'s priority is more higher than new_device[%s]", cur_device_type, new_device_type); break; } } - if (pa_streq(device_type, new_device_type)) { + if (pa_safe_streq(device_type, new_device_type)) { *available = true; break; } @@ -2700,7 +2699,7 @@ static void update_sink_or_source_as_device_change(pa_stream_manager *m, stream_ PA_IDXSET_FOREACH(s, streams, s_idx) { /* streams: core->source_outputs/core->sink_inputs */ if ((cur_device_type = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV))) { for (cnt = 0; cached_prev_dev_list[cnt].device_type; cnt++) { - if (pa_streq(cur_device_type, cached_prev_dev_list[cnt].device_type)) + if (pa_safe_streq(cur_device_type, cached_prev_dev_list[cnt].device_type)) cached_prev_dev_list[cnt].count++; } } @@ -3006,7 +3005,7 @@ static void subscribe_cb(pa_core *core, pa_subscription_event_type_t t, uint32_t return; } name = pa_proplist_gets(client->proplist, PA_PROP_APPLICATION_NAME); - if (!name || (name && !pa_streq(name, STREAM_MANAGER_CLIENT_NAME))) { + if (!pa_safe_streq(name, STREAM_MANAGER_CLIENT_NAME)) { pa_log_warn(" - this is not a client(%s) that we should take care of, skip it", name); return; } diff --git a/src/stream-manager.h b/src/stream-manager.h index 98c0804..55f2572 100644 --- a/src/stream-manager.h +++ b/src/stream-manager.h @@ -25,7 +25,8 @@ #include #define IS_AUTO_ROUTE_TYPE_SERIES(route_type_enum) \ - ((route_type_enum == STREAM_ROUTE_TYPE_AUTO) || (route_type_enum == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED) || \ + ((route_type_enum == STREAM_ROUTE_TYPE_AUTO) || \ + (route_type_enum == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED) || \ (route_type_enum == STREAM_ROUTE_TYPE_AUTO_ALL)) #define IS_MANUAL_ROUTE_TYPE_SERIES(route_type_enum) \ @@ -41,17 +42,23 @@ (route_type_str && !pa_atoi(route_type_str, (int32_t*)&route_type) && (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED)) #define IS_ROLE_COMMUNICATION(stream_role) \ - (stream_role && (pa_streq(stream_role, STREAM_ROLE_CALL_VOICE) || pa_streq(stream_role, STREAM_ROLE_CALL_VIDEO) || \ - pa_streq(stream_role, STREAM_ROLE_VOIP) || pa_streq(stream_role, STREAM_ROLE_RINGBACKTONE_CALL))) + (pa_safe_streq(stream_role, STREAM_ROLE_CALL_VOICE) || \ + pa_safe_streq(stream_role, STREAM_ROLE_CALL_VIDEO) || \ + pa_safe_streq(stream_role, STREAM_ROLE_VOIP) || \ + pa_safe_streq(stream_role, STREAM_ROLE_RINGBACKTONE_CALL)) #define IS_ROLE_RINGTONE(stream_role) \ - (pa_streq(stream_role, STREAM_ROLE_RINGTONE_CALL) || pa_streq(stream_role, STREAM_ROLE_RINGTONE_VOIP)) + (pa_safe_streq(stream_role, STREAM_ROLE_RINGTONE_CALL) || \ + pa_safe_streq(stream_role, STREAM_ROLE_RINGTONE_VOIP)) #define IS_ROLE_AVAILABLE_BT_SCO_OPEN(stream_role) \ - (stream_role && (pa_streq(stream_role, STREAM_ROLE_CALL_VOICE) || pa_streq(stream_role, STREAM_ROLE_CALL_VIDEO) || \ - pa_streq(stream_role, STREAM_ROLE_VOIP) || pa_streq(stream_role, STREAM_ROLE_RINGBACKTONE_CALL) || \ - pa_streq(stream_role, STREAM_ROLE_VOICE_RECOGNITION) || pa_streq(stream_role, STREAM_ROLE_VOICE_RECOGNITION_SERVICE) || \ - pa_streq(stream_role, STREAM_ROLE_VOICE_INFORMATION))) + (pa_safe_streq(stream_role, STREAM_ROLE_CALL_VOICE) || \ + pa_safe_streq(stream_role, STREAM_ROLE_CALL_VIDEO) || \ + pa_safe_streq(stream_role, STREAM_ROLE_VOIP) || \ + pa_safe_streq(stream_role, STREAM_ROLE_RINGBACKTONE_CALL) || \ + pa_safe_streq(stream_role, STREAM_ROLE_VOICE_RECOGNITION) || \ + pa_safe_streq(stream_role, STREAM_ROLE_VOICE_RECOGNITION_SERVICE) || \ + pa_safe_streq(stream_role, STREAM_ROLE_VOICE_INFORMATION)) #define CONVERT_TO_DEVICE_ROLE(x_stream_role, x_device_role) \ do { \ diff --git a/src/tizen-device-def.c b/src/tizen-device-def.c index acd1fc2..22f6612 100644 --- a/src/tizen-device-def.c +++ b/src/tizen-device-def.c @@ -14,7 +14,7 @@ static inline bool pa_safe_streq2(const char *a, const char *b) { if (a && b) - return pa_streq(a, b); + return pa_safe_streq(a, b); if (!a && !b) return true; return false; @@ -24,87 +24,77 @@ bool device_type_is_equal(const char *device_type1, const char *device_type2) { pa_assert(device_type1); pa_assert(device_type2); - return pa_streq(device_type1, device_type2); + return pa_safe_streq(device_type1, device_type2); } bool device_type_is_builtin(const char *device_type) { - if (!device_type) - return false; - else if (pa_streq(device_type, DEVICE_TYPE_SPEAKER)) + if (pa_safe_streq(device_type, DEVICE_TYPE_SPEAKER)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_RECEIVER)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_RECEIVER)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_MIC)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_MIC)) return true; else return false; } bool device_type_is_valid(const char *device_type) { - if (!device_type) - return false; - else if (pa_streq(device_type, DEVICE_TYPE_SPEAKER)) + if (pa_safe_streq(device_type, DEVICE_TYPE_SPEAKER)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_RECEIVER)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_RECEIVER)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_MIC)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_MIC)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_AUDIO_JACK)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_AUDIO_JACK)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_BT_A2DP)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_BT_SCO)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_BT_SCO)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_HDMI)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_HDMI)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_FORWARDING)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_FORWARDING)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_USB_AUDIO)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_USB_AUDIO)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_RAOP)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_RAOP)) return true; else return false; } bool device_type_is_use_external_card(const char *device_type) { - if (!device_type) - return false; - else if (pa_streq(device_type, DEVICE_TYPE_USB_AUDIO)) + if (pa_safe_streq(device_type, DEVICE_TYPE_USB_AUDIO)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_BT_A2DP)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_RAOP)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_RAOP)) return true; else return false; } bool device_type_is_avail_multi_device(const char *device_type) { - if (!device_type) - return false; - else if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP)) + if (pa_safe_streq(device_type, DEVICE_TYPE_BT_A2DP)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_BT_SCO)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_BT_SCO)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_USB_AUDIO)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_USB_AUDIO)) return true; - else if (pa_streq(device_type, DEVICE_TYPE_RAOP)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_RAOP)) return true; else return false; } bool device_type_is_need_detect(const char *type) { - if (!type) - return false; - else if (pa_streq(type, DEVICE_TYPE_AUDIO_JACK)) + if (pa_safe_streq(type, DEVICE_TYPE_AUDIO_JACK)) return true; - else if (pa_streq(type, DEVICE_TYPE_HDMI)) + else if (pa_safe_streq(type, DEVICE_TYPE_HDMI)) return true; - else if (pa_streq(type, DEVICE_TYPE_FORWARDING)) + else if (pa_safe_streq(type, DEVICE_TYPE_FORWARDING)) return true; - else if (pa_streq(type, DEVICE_TYPE_BT_SCO)) + else if (pa_safe_streq(type, DEVICE_TYPE_BT_SCO)) return true; else return false; @@ -117,17 +107,17 @@ bool device_type_is_need_detect(const char *type) { dm_device_direction_t device_type_get_static_direction(const char *type) { if (!type) return DM_DEVICE_DIRECTION_NONE; - else if (pa_streq(type, DEVICE_TYPE_SPEAKER)) + else if (pa_safe_streq(type, DEVICE_TYPE_SPEAKER)) return DM_DEVICE_DIRECTION_OUT; - else if (pa_streq(type, DEVICE_TYPE_RECEIVER)) + else if (pa_safe_streq(type, DEVICE_TYPE_RECEIVER)) return DM_DEVICE_DIRECTION_OUT; - else if (pa_streq(type, DEVICE_TYPE_MIC)) + else if (pa_safe_streq(type, DEVICE_TYPE_MIC)) return DM_DEVICE_DIRECTION_IN; else if (device_type_is_equal(type, DEVICE_TYPE_BT_SCO)) return DM_DEVICE_DIRECTION_BOTH; - else if (pa_streq(type, DEVICE_TYPE_HDMI)) + else if (pa_safe_streq(type, DEVICE_TYPE_HDMI)) return DM_DEVICE_DIRECTION_OUT; - else if (pa_streq(type, DEVICE_TYPE_FORWARDING)) + else if (pa_safe_streq(type, DEVICE_TYPE_FORWARDING)) return DM_DEVICE_DIRECTION_BOTH; else return DM_DEVICE_DIRECTION_NONE; @@ -139,34 +129,33 @@ bool device_type_is_valid_direction(const char *device_type, dm_device_direction if (!device_type || direction == DM_DEVICE_DIRECTION_NONE) return false; - if (pa_streq(device_type, DEVICE_TYPE_SPEAKER)) + if (pa_safe_streq(device_type, DEVICE_TYPE_SPEAKER)) return direction == DM_DEVICE_DIRECTION_OUT; - else if (pa_streq(device_type, DEVICE_TYPE_RECEIVER)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_RECEIVER)) return direction == DM_DEVICE_DIRECTION_OUT; - else if (pa_streq(device_type, DEVICE_TYPE_MIC)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_MIC)) return direction == DM_DEVICE_DIRECTION_IN; - else if (pa_streq(device_type, DEVICE_TYPE_AUDIO_JACK)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_AUDIO_JACK)) return direction == DM_DEVICE_DIRECTION_OUT || direction == DM_DEVICE_DIRECTION_BOTH; - else if (pa_streq(device_type, DEVICE_TYPE_BT_SCO)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_BT_SCO)) return direction == DM_DEVICE_DIRECTION_BOTH; - else if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_BT_A2DP)) return direction == DM_DEVICE_DIRECTION_OUT || direction == DM_DEVICE_DIRECTION_IN; - else if (pa_streq(device_type, DEVICE_TYPE_HDMI)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_HDMI)) return direction == DM_DEVICE_DIRECTION_OUT; - else if (pa_streq(device_type, DEVICE_TYPE_FORWARDING)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_FORWARDING)) return direction == DM_DEVICE_DIRECTION_BOTH; - else if (pa_streq(device_type, DEVICE_TYPE_USB_AUDIO)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_USB_AUDIO)) return direction == DM_DEVICE_DIRECTION_BOTH || direction == DM_DEVICE_DIRECTION_OUT || direction == DM_DEVICE_DIRECTION_IN; - else if (pa_streq(device_type, DEVICE_TYPE_RAOP)) + else if (pa_safe_streq(device_type, DEVICE_TYPE_RAOP)) return direction == DM_DEVICE_DIRECTION_OUT; else return false; } const char* device_direction_to_string(dm_device_direction_t direction) { - if (direction > DM_DEVICE_DIRECTION_BOTH) { + if (direction > DM_DEVICE_DIRECTION_BOTH) return NULL; - } if (direction == DM_DEVICE_DIRECTION_NONE) return DEVICE_DIRECTION_STR_NONE; @@ -181,40 +170,33 @@ const char* device_direction_to_string(dm_device_direction_t direction) { } bool device_role_is_valid(const char *device_role) { - if (!device_role) - return false; - else if (pa_streq(device_role, DEVICE_ROLE_NORMAL)) + if (pa_safe_streq(device_role, DEVICE_ROLE_NORMAL)) return true; - else if (pa_streq(device_role, DEVICE_ROLE_CALL_VOICE)) + else if (pa_safe_streq(device_role, DEVICE_ROLE_CALL_VOICE)) return true; - else if (pa_streq(device_role, DEVICE_ROLE_CALL_VIDEO)) + else if (pa_safe_streq(device_role, DEVICE_ROLE_CALL_VIDEO)) return true; - else if (pa_streq(device_role, DEVICE_ROLE_VOIP)) + else if (pa_safe_streq(device_role, DEVICE_ROLE_VOIP)) return true; - else if (pa_streq(device_role, DEVICE_ROLE_LOW_LATENCY)) + else if (pa_safe_streq(device_role, DEVICE_ROLE_LOW_LATENCY)) return true; - else if (pa_streq(device_role, DEVICE_ROLE_HIGH_LATENCY)) + else if (pa_safe_streq(device_role, DEVICE_ROLE_HIGH_LATENCY)) return true; - else if (pa_streq(device_role, DEVICE_ROLE_UHQA)) + else if (pa_safe_streq(device_role, DEVICE_ROLE_UHQA)) return true; else return false; } dm_device_direction_t device_direction_to_int(const char *device_direction) { - if (!device_direction) { - return -1; - } - - if (pa_streq(device_direction, DEVICE_DIRECTION_STR_NONE)) { + if (pa_safe_streq(device_direction, DEVICE_DIRECTION_STR_NONE)) return DM_DEVICE_DIRECTION_NONE; - } else if (pa_streq(device_direction, DEVICE_DIRECTION_STR_OUT)) { + else if (pa_safe_streq(device_direction, DEVICE_DIRECTION_STR_OUT)) return DM_DEVICE_DIRECTION_OUT; - } else if (pa_streq(device_direction, DEVICE_DIRECTION_STR_IN)) { + else if (pa_safe_streq(device_direction, DEVICE_DIRECTION_STR_IN)) return DM_DEVICE_DIRECTION_IN; - } else if (pa_streq(device_direction, DEVICE_DIRECTION_STR_BOTH)) { + else if (pa_safe_streq(device_direction, DEVICE_DIRECTION_STR_BOTH)) return DM_DEVICE_DIRECTION_BOTH; - } else { + else return -1; - } } diff --git a/src/tizen-device.c b/src/tizen-device.c index 56e5479..81f3401 100644 --- a/src/tizen-device.c +++ b/src/tizen-device.c @@ -696,7 +696,7 @@ int pa_tz_device_get_product_id(pa_tz_device *device) { char* pa_tz_device_get_specified_stream_role(pa_tz_device *device) { pa_assert(device); - if (pa_streq("none", device->specified_stream_role)) + if (pa_safe_streq("none", device->specified_stream_role)) return NULL; return device->specified_stream_role; @@ -861,33 +861,34 @@ static int method_call_bt_sco_get_property(pa_dbus_connection *conn, bool *is_wi while (dbus_message_iter_get_arg_type(&reply_iter_entry) == DBUS_TYPE_DICT_ENTRY) { DBusMessageIter dict_entry, dict_entry_val; + dbus_message_iter_recurse(&reply_iter_entry, &dict_entry); dbus_message_iter_get_basic(&dict_entry, &property); pa_log_debug("String received = %s", property); - if (property) { - if (pa_streq("codec", property) && is_wide_band) { - dbus_message_iter_next(&dict_entry); - dbus_message_iter_recurse(&dict_entry, &dict_entry_val); - if (dbus_message_iter_get_arg_type(&dict_entry_val) != DBUS_TYPE_UINT32) - continue; - dbus_message_iter_get_basic(&dict_entry_val, &codec); - pa_log_debug("Codec = [%d]", codec); - *is_wide_band = (codec == BT_MSBC_CODEC_ID) ? true : false; - } else if (pa_streq("nrec", property) && is_nrec) { - dbus_message_iter_next(&dict_entry); - dbus_message_iter_recurse(&dict_entry, &dict_entry_val); - if (dbus_message_iter_get_arg_type(&dict_entry_val) != DBUS_TYPE_BOOLEAN) - continue; - dbus_message_iter_get_basic(&dict_entry_val, &nrec); - pa_log_debug("nrec= [%d]", nrec); - *is_nrec = nrec; - } + + if (pa_safe_streq("codec", property) && is_wide_band) { + dbus_message_iter_next(&dict_entry); + dbus_message_iter_recurse(&dict_entry, &dict_entry_val); + if (dbus_message_iter_get_arg_type(&dict_entry_val) != DBUS_TYPE_UINT32) + continue; + dbus_message_iter_get_basic(&dict_entry_val, &codec); + pa_log_debug("Codec = [%d]", codec); + *is_wide_band = (codec == BT_MSBC_CODEC_ID) ? true : false; + } else if (pa_safe_streq("nrec", property) && is_nrec) { + dbus_message_iter_next(&dict_entry); + dbus_message_iter_recurse(&dict_entry, &dict_entry_val); + if (dbus_message_iter_get_arg_type(&dict_entry_val) != DBUS_TYPE_BOOLEAN) + continue; + dbus_message_iter_get_basic(&dict_entry_val, &nrec); + pa_log_debug("nrec= [%d]", nrec); + *is_nrec = nrec; } + dbus_message_iter_next(&reply_iter_entry); } - dbus_message_unref(reply); + return 0; } -- 2.7.4 From a120c0f0c5f15fb2848d1ba7ab6345f9e1e211b3 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Fri, 8 Mar 2019 15:07:33 +0900 Subject: [PATCH 06/16] stream-manager: Add callback for ramp finished [Version] 11.1.34 [Issue type] New feature Change-Id: Ibdf744e79efd08da4c8083f6be2d657a4be7b116 Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/stream-manager-priv.h | 1 + src/stream-manager.c | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 579184a..216a3b9 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: 11.1.33 +Version: 11.1.34 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-priv.h b/src/stream-manager-priv.h index 8fc0175..6722e8e 100644 --- a/src/stream-manager-priv.h +++ b/src/stream-manager-priv.h @@ -223,6 +223,7 @@ struct _stream_manager { *sink_input_state_changed_slot, *sink_input_move_start_slot, *sink_input_move_finish_slot, + *sink_input_ramp_finish_slot, *source_output_new_slot, *source_output_put_slot, *source_output_unlink_slot, diff --git a/src/stream-manager.c b/src/stream-manager.c index 0370154..6486172 100644 --- a/src/stream-manager.c +++ b/src/stream-manager.c @@ -2189,6 +2189,24 @@ static pa_hook_result_t sink_input_move_finish_cb(pa_core *core, pa_sink_input * return PA_HOOK_OK; } +static pa_hook_result_t sink_input_ramp_finish_cb(pa_core *core, pa_sink_input *i, pa_stream_manager *m) { + pa_core_assert_ref(core); + pa_sink_input_assert_ref(i); + + /* There's no point in doing anything if the core is shut down anyway */ + if (core->state == PA_CORE_SHUTDOWN) + return PA_HOOK_OK; + + pa_log_debug("sink-input(%p, index:%u)", i, i->index); + + /* Find a context id from all the ducked stream list by this stream index. + * Check the number of managed streams of the context id, if it is the last one + * then broadcast a signal with context id.*/ + // send_command_signal(pa_dbus_connection_get(m->dbus_conn), "ducking_finished", context_id); + + return PA_HOOK_OK; +} + static pa_hook_result_t source_output_new_cb(pa_core *core, pa_source_output_new_data *new_data, pa_stream_manager *m) { pa_core_assert_ref(core); @@ -3174,6 +3192,7 @@ pa_stream_manager* pa_stream_manager_get(pa_core *c) { m->sink_input_state_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED], PA_HOOK_EARLY, (pa_hook_cb_t) sink_input_state_changed_cb, m); m->sink_input_move_start_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_START], PA_HOOK_EARLY, (pa_hook_cb_t) sink_input_move_start_cb, m); m->sink_input_move_finish_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH], PA_HOOK_EARLY, (pa_hook_cb_t) sink_input_move_finish_cb, m); + m->sink_input_ramp_finish_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_RAMP_FINISH], PA_HOOK_EARLY, (pa_hook_cb_t) sink_input_ramp_finish_cb, m); m->source_output_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) source_output_new_cb, m); m->source_output_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PUT], PA_HOOK_EARLY, (pa_hook_cb_t) source_output_put_cb, m); m->source_output_unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK], PA_HOOK_EARLY, (pa_hook_cb_t) source_output_unlink_cb, m); @@ -3257,6 +3276,8 @@ void pa_stream_manager_unref(pa_stream_manager *m) { pa_hook_slot_free(m->sink_input_move_start_slot); if (m->sink_input_move_finish_slot) pa_hook_slot_free(m->sink_input_move_finish_slot); + if (m->sink_input_ramp_finish_slot) + pa_hook_slot_free(m->sink_input_ramp_finish_slot); if (m->source_output_new_slot) pa_hook_slot_free(m->source_output_new_slot); if (m->source_output_put_slot) -- 2.7.4 From ab75d7dc9b85e60db5df599e44dd2ccf9b6dbf16 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Thu, 14 Mar 2019 17:01:11 +0900 Subject: [PATCH 07/16] stream-manager: Consider virtual streams when a device connection is changed Null device of a virtual stream is taken into account in case of the device connection changes. The device of the virtual stream should always be a null device. In addition, the available device defined in stream-map.json for virtual stream type is used to set the audio routing path of internal codec, so these information must propagate to the audio HAL properly. [Version] 11.1.35 [Issue type] Bug fix Change-Id: Idb18334db04ed7d28ca657b1e58a4bb263e6af73 Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/stream-manager.c | 79 +++++++++++++++++++++------------ 2 files changed, 52 insertions(+), 29 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 216a3b9..96f254c 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: 11.1.34 +Version: 11.1.35 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager.c b/src/stream-manager.c index 6486172..d2f931f 100644 --- a/src/stream-manager.c +++ b/src/stream-manager.c @@ -946,7 +946,7 @@ static bool check_name_is_vstream(void *stream, stream_type_t type, bool is_new_ if (pa_safe_streq(name, VIRTUAL_STREAM_NAME)) { ret = true; - pa_log_info("name is [%s]", name); + pa_log_debug("name is [%s]", name); } return ret; @@ -2625,9 +2625,13 @@ static void update_sink_or_source_as_device_change(pa_stream_manager *m, stream_ if ((cur_device_type = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV))) { is_available_device_for_auto_route(m, route_type, cur_device_type, device_type, role, stream_type, &available); if (available) { - pa_sink_input_move_to(s, sink, false); - pa_log_debug(" -- *** sink-input(%p,%u) moves to sink(%p,%s), new device(%s)", - s, ((pa_sink_input*)s)->index, sink, sink->name, device_type); + if (check_name_is_vstream(s, STREAM_SINK_INPUT, false)) { + pa_log_debug(" -- *** keep null sink for a virtual stream"); + } else { + pa_sink_input_move_to(s, sink, false); + pa_log_debug(" -- *** sink-input(%p,%u) moves to sink(%p,%s), new device(%s)", + s, ((pa_sink_input*)s)->index, sink, sink->name, device_type); + } } } else pa_log_error(" -- could not find current device type for s->sink(%p)", ((pa_sink_input*)s)->sink); @@ -2635,9 +2639,13 @@ static void update_sink_or_source_as_device_change(pa_stream_manager *m, stream_ if ((cur_device_type = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV))) { is_available_device_for_auto_route(m, route_type, cur_device_type, device_type, role, stream_type, &available); if (available) { - pa_source_output_move_to(s, source, false); - pa_log_debug(" -- *** source-output(%p,%u) moves to source(%p,%s), new device(%s)", - s, ((pa_source_output*)s)->index, source, source->name, device_type); + if (check_name_is_vstream(s, STREAM_SOURCE_OUTPUT, false)) { + pa_log_debug(" -- *** keep null source for a virtual stream"); + } else { + pa_source_output_move_to(s, source, false); + pa_log_debug(" -- *** source-output(%p,%u) moves to source(%p,%s), new device(%s)", + s, ((pa_source_output*)s)->index, source, source->name, device_type); + } } } else pa_log_error(" -- could not find current device type for s->source(%p)", ((pa_source_output*)s)->source); @@ -2651,7 +2659,7 @@ static void update_sink_or_source_as_device_change(pa_stream_manager *m, stream_ } } else if (!is_connected) { /* DISCONNECTED: find a connected device that has the next priority */ - if ((sink && (sink == ((pa_sink_input*)s)->sink))) { + if (sink && ((sink == ((pa_sink_input*)s)->sink) || check_name_is_vstream(s, STREAM_SINK_INPUT, false))) { if (!is_active_device_of_stream(s, stream_type, device_type)) continue; find_next_device_for_auto_route(m, route_type, role, stream_type, device_type, &next_device); @@ -2664,10 +2672,14 @@ static void update_sink_or_source_as_device_change(pa_stream_manager *m, stream_ /* trigger to update routing path if the next device uses internal audio codec */ process_stream_as_device_change_for_auto_route(m, s, stream_type, is_connected, next_device); - pa_sink_input_move_to(s, next_sink, false); - pa_log_debug(" -- *** sink-input(%p,%u) moves to sink(%p,%s), new device(%s)", - s, ((pa_sink_input*)s)->index, next_sink, next_sink->name, new_device_type); + if (check_name_is_vstream(s, STREAM_SINK_INPUT, false)) { + pa_log_debug(" -- *** keep null sink for a virtual stream"); + } else { + pa_sink_input_move_to(s, next_sink, false); + pa_log_debug(" -- *** sink-input(%p,%u) moves to sink(%p,%s), new device(%s)", + s, ((pa_sink_input*)s)->index, next_sink, next_sink->name, new_device_type); } + } } if (!next_device || !next_sink) { @@ -2676,7 +2688,7 @@ static void update_sink_or_source_as_device_change(pa_stream_manager *m, stream_ s, ((pa_sink_input*)s)->index, null_sink, null_sink->name); } - } else if (source && (source == ((pa_source_output*)s)->source)) { + } else if (source && ((source == ((pa_source_output*)s)->source) || check_name_is_vstream(s, STREAM_SOURCE_OUTPUT, false))) { if (!is_active_device_of_stream(s, stream_type, device_type)) continue; find_next_device_for_auto_route(m, route_type, role, stream_type, device_type, &next_device); @@ -2690,10 +2702,14 @@ static void update_sink_or_source_as_device_change(pa_stream_manager *m, stream_ if (next_source->use_internal_codec) process_stream_as_device_change_for_auto_route(m, s, stream_type, is_connected, next_device); - pa_source_output_move_to(s, next_source, false); - pa_log_warn(" -- *** source-output(%p,%u) moves to source(%p,%s), new device(%s)", - s, ((pa_source_output*)s)->index, next_source, next_source->name, new_device_type); + if (check_name_is_vstream(s, STREAM_SOURCE_OUTPUT, false)) { + pa_log_debug(" -- *** keep null source for a virtual stream"); + } else { + pa_source_output_move_to(s, next_source, false); + pa_log_warn(" -- *** source-output(%p,%u) moves to source(%p,%s), new device(%s)", + s, ((pa_source_output*)s)->index, next_source, next_source->name, new_device_type); } + } } if (!next_device || !next_source) { pa_source_output_move_to(s, null_source, false); @@ -2881,6 +2897,8 @@ static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_devi pa_sink *sink = NULL; pa_source *source = NULL; pa_sink_input *si = NULL; + pa_sink_input *highest_prior_si = NULL; + pa_source_output *highest_prior_so = NULL; pa_assert(c); pa_assert(data); @@ -2951,10 +2969,11 @@ static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_devi } /* If the route type is AUTO SERIES, notify again */ - if ((device_direction & DM_DEVICE_DIRECTION_IN) && m->cur_highest_priority.source_output && - !get_route_type(m->cur_highest_priority.source_output, STREAM_SOURCE_OUTPUT, false, &route_type)) { + highest_prior_so = m->cur_highest_priority.source_output; + if ((device_direction & DM_DEVICE_DIRECTION_IN) && highest_prior_so && + !get_route_type(highest_prior_so, STREAM_SOURCE_OUTPUT, false, &route_type)) { if (IS_AUTO_ROUTE_TYPE_SERIES(route_type) && use_internal_codec) { - PA_IDXSET_FOREACH(s, m->cur_highest_priority.source_output->source->outputs, s_idx) { + PA_IDXSET_FOREACH(s, highest_prior_so->source->outputs, s_idx) { if (!data->is_connected && !get_route_type(s, STREAM_SOURCE_OUTPUT, false, &route_type) && ((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 */ @@ -2963,20 +2982,22 @@ static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_devi pa_proplist_sets(GET_STREAM_PROPLIST(s, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, ACTIVE_DEV_REMOVED); } } - do_notify(m, NOTIFY_COMMAND_CHANGE_ROUTE_START, STREAM_SOURCE_OUTPUT, false, m->cur_highest_priority.source_output); - if (!((pa_source_output*)(m->cur_highest_priority.source_output))->source->use_internal_codec) { + do_notify(m, NOTIFY_COMMAND_CHANGE_ROUTE_START, STREAM_SOURCE_OUTPUT, false, highest_prior_so); + if (!highest_prior_so->source->use_internal_codec && + !check_name_is_vstream(highest_prior_so, STREAM_SOURCE_OUTPUT, false)) { /* If the source of the cur_highest_priority stream uses external codec, it should be updated. * As only the process_stream(PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_ENDED) * can update the cur_highest_priority, call it here */ - process_stream(m, m->cur_highest_priority.source_output, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_ENDED, false); + process_stream(m, highest_prior_so, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_ENDED, false); } } } - if ((device_direction & DM_DEVICE_DIRECTION_OUT) && m->cur_highest_priority.sink_input && - !get_route_type(m->cur_highest_priority.sink_input, STREAM_SINK_INPUT, false, &route_type)) { + highest_prior_si = m->cur_highest_priority.sink_input; + if ((device_direction & DM_DEVICE_DIRECTION_OUT) && highest_prior_si && + !get_route_type(highest_prior_si, STREAM_SINK_INPUT, false, &route_type)) { if (IS_AUTO_ROUTE_TYPE_SERIES(route_type) && use_internal_codec) { - PA_IDXSET_FOREACH(s, m->cur_highest_priority.sink_input->sink->inputs, s_idx) { + PA_IDXSET_FOREACH(s, highest_prior_si->sink->inputs, s_idx) { if (!data->is_connected && !get_route_type(s, STREAM_SINK_INPUT, false, &route_type) && ((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 */ @@ -2985,16 +3006,18 @@ static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_devi pa_proplist_sets(GET_STREAM_PROPLIST(s, STREAM_SINK_INPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, ACTIVE_DEV_REMOVED); } } - do_notify(m, NOTIFY_COMMAND_CHANGE_ROUTE_START, STREAM_SINK_INPUT, false, m->cur_highest_priority.sink_input); + do_notify(m, NOTIFY_COMMAND_CHANGE_ROUTE_START, STREAM_SINK_INPUT, false, highest_prior_si); if (((route_type == STREAM_ROUTE_TYPE_AUTO) || (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED)) && - (!((pa_sink_input*)(m->cur_highest_priority.sink_input))->sink->use_internal_codec) && !is_filter_apply_stream(m->cur_highest_priority.sink_input, STREAM_SINK_INPUT)) { + !highest_prior_si->sink->use_internal_codec && + !check_name_is_vstream(highest_prior_si, STREAM_SINK_INPUT, false) && + !is_filter_apply_stream(highest_prior_si, STREAM_SINK_INPUT)) { /* If the sink of the cur_highest_priority stream uses external codec, it should be updated. * As only the process_stream(PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_ENDED) * can update the cur_highest_priority, call it here */ - process_stream(m, m->cur_highest_priority.sink_input, STREAM_SINK_INPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_ENDED, false); + process_stream(m, highest_prior_si, STREAM_SINK_INPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_ENDED, false); } } else if (route_type == STREAM_ROUTE_TYPE_AUTO_ALL) - do_notify(m, NOTIFY_COMMAND_CHANGE_ROUTE_START, STREAM_SINK_INPUT, false, m->cur_highest_priority.sink_input); + do_notify(m, NOTIFY_COMMAND_CHANGE_ROUTE_START, STREAM_SINK_INPUT, false, highest_prior_si); } if (m->on_call) { -- 2.7.4 From b2cd2a0deea5e77673f10b4a7b22e3d413cd70a6 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Mon, 25 Mar 2019 17:49:41 +0900 Subject: [PATCH 08/16] stream-manager-volume: Revise codes to improve readability [Version] 11.1.36 [Issue type] Refactoring Change-Id: Ieb917f9e6b7b068cd934304bc923cb86bac35615 Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/stream-manager-volume.c | 52 ++++++++++++++++----------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 96f254c..bb0b593 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: 11.1.35 +Version: 11.1.36 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-volume.c b/src/stream-manager-volume.c index db3c4b7..99beaeb 100644 --- a/src/stream-manager-volume.c +++ b/src/stream-manager-volume.c @@ -309,6 +309,7 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type } if (!pa_safe_streq(volume_type, MASTER_VOLUME_TYPE)) { + /* Get volume value */ if (get_volume_value(m, stream_type, is_hal_volume, volume_type, volume_level, &volume_linear)) return -1; @@ -316,53 +317,50 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type if (!(volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) continue; + /* Update volume level of stream if it has requested the volume type */ + if (!pa_safe_streq(volume_type_str, volume_type)) + continue; + /* Get modifier for gain */ modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE); - - /* Update volume level of stream if it has requested the volume type */ - if (pa_safe_streq(volume_type_str, volume_type)) { - if (modifier_gain) { - if (m->volume_modifiers) { - if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { - volume_linear *= (*modifier_gain_value); - pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", - modifier_gain, *modifier_gain_value, volume_linear); - } - } + if (modifier_gain && m->volume_modifiers) { + if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { + volume_linear *= (*modifier_gain_value); + pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", + modifier_gain, *modifier_gain_value, volume_linear); } - pa_cvolume_set(&cv, GET_STREAM_SAMPLE_SPEC(s, stream_type).channels, pa_sw_volume_from_linear(volume_linear)); - if (stream_type == STREAM_SINK_INPUT) - pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true); - else if (stream_type == STREAM_SOURCE_OUTPUT) - pa_source_output_set_volume((pa_source_output*)s, &cv, true, true); } + + pa_cvolume_set(&cv, GET_STREAM_SAMPLE_SPEC(s, stream_type).channels, pa_sw_volume_from_linear(volume_linear)); + if (stream_type == STREAM_SINK_INPUT) + pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true); + else if (stream_type == STREAM_SOURCE_OUTPUT) + pa_source_output_set_volume((pa_source_output*)s, &cv, true, true); } } else { PA_IDXSET_FOREACH(s, stream_type == STREAM_SINK_INPUT ? m->core->sink_inputs : m->core->source_outputs, idx) { if (!(volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) continue; - /* Get modifier for gain */ - modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE); - /* Get volume level of this type */ if (!(v = pa_hashmap_get(volumes, volume_type_str))) continue; - volume_level = v->values[stream_type].current_level; + /* Get volume value */ if (get_volume_value(m, stream_type, is_hal_volume, volume_type_str, volume_level, &volume_linear)) continue; - if (modifier_gain) { - if (m->volume_modifiers) { - if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { - volume_linear *= (*modifier_gain_value); - pa_log_info("set_volume_level_by_type() : apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", - modifier_gain, *modifier_gain_value, volume_linear); - } + /* Get modifier for gain */ + modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE); + if (modifier_gain && m->volume_modifiers) { + if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { + volume_linear *= (*modifier_gain_value); + pa_log_info("set_volume_level_by_type() : apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", + modifier_gain, *modifier_gain_value, volume_linear); } } + pa_cvolume_set(&cv, GET_STREAM_SAMPLE_SPEC(s, stream_type).channels, pa_sw_volume_from_linear(volume_linear)); if (stream_type == STREAM_SINK_INPUT) pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true); -- 2.7.4 From a445179096b89f383d7ef3e958d0de271279b8a9 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Fri, 5 Apr 2019 12:22:49 +0900 Subject: [PATCH 09/16] stream-manager-volume: Apply individual volume ratio In Tizen, a stream has one volume type such as media, notification, alarm. Each type is so-called a volume group which has its own volume value of a certain volume level. Therefore, all streams that belong to the same volume group have the same volume value of the group. This patch adds to calculate volume value including the individual volume ratio of each stream's volume value to the value of its volume group. [Version] 11.1.37 [Issue type] New feature Change-Id: Ie3099f37ec8f2e513b828bfc11b4dcbdb2572954 Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/stream-manager-volume.c | 66 +++++++++++++++++++++++++-------- 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index bb0b593..dbf0505 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: 11.1.36 +Version: 11.1.37 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-volume.c b/src/stream-manager-volume.c index 99beaeb..bbb7c90 100644 --- a/src/stream-manager-volume.c +++ b/src/stream-manager-volume.c @@ -264,6 +264,35 @@ int32_t update_mute_vconf(const char *type, unsigned int mute) return 0; } +void apply_individual_ratio(pa_stream_manager *m, pa_object *stream, double volume_linear, pa_cvolume *result) { + double individual_ratio; + double result_linear; + pa_volume_t volume; + uint32_t index; + unsigned channels; + + pa_assert(m); + pa_assert(stream); + pa_assert(volume_linear); + + if (pa_sink_input_isinstance(stream)) { + individual_ratio = ((pa_sink_input*)stream)->individual_volume_ratio; + index = ((pa_sink_input*)stream)->index; + channels = ((pa_sink_input*)stream)->sample_spec.channels; + } else { + individual_ratio = ((pa_source_output*)stream)->individual_volume_ratio; + index = ((pa_source_output*)stream)->index; + channels = ((pa_sink_input*)stream)->sample_spec.channels; + } + + volume = pa_sw_volume_from_linear(volume_linear) * individual_ratio; + result = pa_cvolume_set(result, channels, volume); + result_linear = pa_sw_volume_to_linear(volume); + + pa_log_info("apply the individual ratio[%f] to stream[idx:%u], result volume linear[%f]", + individual_ratio, index, result_linear); +} + int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type, const char *volume_type, uint32_t volume_level) { bool is_hal_volume = false; volume_info *v = NULL; @@ -331,7 +360,8 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type } } - pa_cvolume_set(&cv, GET_STREAM_SAMPLE_SPEC(s, stream_type).channels, pa_sw_volume_from_linear(volume_linear)); + apply_individual_ratio(m, s, volume_linear, &cv); + if (stream_type == STREAM_SINK_INPUT) pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true); else if (stream_type == STREAM_SOURCE_OUTPUT) @@ -356,12 +386,13 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type if (modifier_gain && m->volume_modifiers) { if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { volume_linear *= (*modifier_gain_value); - pa_log_info("set_volume_level_by_type() : apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", + pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", modifier_gain, *modifier_gain_value, volume_linear); } } - pa_cvolume_set(&cv, GET_STREAM_SAMPLE_SPEC(s, stream_type).channels, pa_sw_volume_from_linear(volume_linear)); + apply_individual_ratio(m, s, volume_linear, &cv); + if (stream_type == STREAM_SINK_INPUT) pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true); else if (stream_type == STREAM_SOURCE_OUTPUT) @@ -465,23 +496,26 @@ int32_t set_volume_level_by_idx(pa_stream_manager *m, stream_type_t stream_type, if (pa_hal_interface_set_volume_level(m->hal, volume_type_str, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level)) return -1; + if (get_volume_value(m, stream_type, is_hal_volume, volume_type_str, volume_level, &volume_linear)) + return -1; + /* Get modifier for gain */ modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE); - - if (!get_volume_value(m, stream_type, is_hal_volume, volume_type_str, volume_level, &volume_linear)) { - if (modifier_gain) { - if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { - volume_linear *= (*modifier_gain_value); - pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", - modifier_gain, *modifier_gain_value, volume_linear); - } + if (modifier_gain && m->volume_modifiers) { + if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { + volume_linear *= (*modifier_gain_value); + pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", + modifier_gain, *modifier_gain_value, volume_linear); } - pa_cvolume_set(&cv, GET_STREAM_SAMPLE_SPEC(s, stream_type).channels, pa_sw_volume_from_linear(volume_linear)); - if (stream_type == STREAM_SINK_INPUT) - pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true); - else if (stream_type == STREAM_SOURCE_OUTPUT) - pa_source_output_set_volume((pa_source_output*)s, &cv, true, true); } + + apply_individual_ratio(m, s, volume_linear, &cv); + + if (stream_type == STREAM_SINK_INPUT) + pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true); + else if (stream_type == STREAM_SOURCE_OUTPUT) + pa_source_output_set_volume((pa_source_output*)s, &cv, true, true); + pa_log_debug("stream_type[%d], idx[%u]=>volume_type[%s], level[%u], value[%f]", stream_type, idx, volume_type_str, volume_level, volume_linear); -- 2.7.4 From 4dd3016f3ac36ef663eb38fd70e97173a523c0bd Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Mon, 8 Apr 2019 17:00:54 +0900 Subject: [PATCH 10/16] stream-manager-dbus: Fix bug of error case Invalid parameters of dbus_message_append_args() are fixed. [Version] 11.1.38 [Issue type] Bug fix Change-Id: I2c03e3690780a468d076f4b12581f5ffd3249529 Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/stream-manager-dbus-priv.h | 4 ++-- src/stream-manager-dbus.c | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index dbf0505..2c5a0ce 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: 11.1.37 +Version: 11.1.38 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-dbus-priv.h b/src/stream-manager-dbus-priv.h index f0447fe..019cf9c 100644 --- a/src/stream-manager-dbus-priv.h +++ b/src/stream-manager-dbus-priv.h @@ -101,8 +101,8 @@ pa_dbus_interface_info stream_manager_interface_info = { " " \ " " \ " " \ - " " \ - " " \ + " " \ + " " \ " " \ " "\ " " \ diff --git a/src/stream-manager-dbus.c b/src/stream-manager-dbus.c index 5c402ec..7afa05b 100644 --- a/src/stream-manager-dbus.c +++ b/src/stream-manager-dbus.c @@ -622,13 +622,13 @@ static void handle_get_volume_level(DBusConnection *conn, DBusMessage *msg, void else if (pa_safe_streq(direction, "out")) stream_type = STREAM_SINK_INPUT; else { - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, &level, DBUS_TYPE_INVALID)); pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); goto finish; } if (get_volume_level_by_type(m, GET_VOLUME_CURRENT_LEVEL, stream_type, type, &level)) { - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, &level, DBUS_TYPE_INVALID)); pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); } else { pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, &level, DBUS_TYPE_INVALID)); @@ -665,13 +665,13 @@ static void handle_get_volume_max_level(DBusConnection *conn, DBusMessage *msg, else if (pa_safe_streq(direction, "out")) stream_type = STREAM_SINK_INPUT; else { - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, &level, DBUS_TYPE_INVALID)); pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); goto finish; } if (get_volume_level_by_type(m, GET_VOLUME_MAX_LEVEL, stream_type, type, &level)) { - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, &level, DBUS_TYPE_INVALID)); pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); } else { pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, &level, DBUS_TYPE_INVALID)); @@ -754,13 +754,13 @@ static void handle_get_volume_mute(DBusConnection *conn, DBusMessage *msg, void else if (pa_safe_streq(direction, "out")) stream_type = STREAM_SINK_INPUT; else { - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, &is_muted, DBUS_TYPE_INVALID)); pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); goto fail; } if (get_volume_mute_by_type(m, stream_type, type, (bool*)&is_muted)) { - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, 0, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, &is_muted, DBUS_TYPE_INVALID)); pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INTERNAL], DBUS_TYPE_INVALID)); } else { pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, &is_muted, DBUS_TYPE_INVALID)); -- 2.7.4 From 424f79c7fef19d69db4e35cc7be1ae55ab5ea507 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Mon, 8 Apr 2019 16:05:13 +0900 Subject: [PATCH 11/16] stream-manager-dbus: Add new DBus medhod to get the pid of the lastest stream server : org.pulseaudio.Server object path : /org/pulseaudio/StreamManager interface : org.pulseaudio.StreamManager method name : GetPidOfLatestStream method argument : string for direction ('in' or 'out') string array for stream types (e.g. 'media','alarm','notification') return value : unsigned int for PID string for return message - success : "STREAM_MANAGER_RETURN_OK" - no match found : "STREAM_MANAGER_RETURN_ERROR_NO_STREAM" - invalid argument : "STREAM_MANAGER_RETURN_ERROR_INVALID_ARGUMENT" [Version] 11.1.39 [Issue type] New feature Change-Id: Idaa2f56ed5d27d001f5e4ce566b1b361d6248388 Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/stream-manager-dbus-priv.h | 2 + src/stream-manager-dbus.c | 123 +++++++++++++++++++++++++++++++- src/stream-manager-priv.h | 3 + 4 files changed, 128 insertions(+), 2 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 2c5a0ce..c44a3b8 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: 11.1.38 +Version: 11.1.39 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-dbus-priv.h b/src/stream-manager-dbus-priv.h index 019cf9c..d464a36 100644 --- a/src/stream-manager-dbus-priv.h +++ b/src/stream-manager-dbus-priv.h @@ -45,6 +45,7 @@ #define STREAM_MANAGER_METHOD_NAME_UNSET_FILTER "UnsetFilter" #define STREAM_MANAGER_METHOD_NAME_CONTROL_FILTER "ControlFilter" #define STREAM_MANAGER_METHOD_NAME_CHECK_STREAM_EXIST_BY_PID "CheckStreamExistByPid" +#define STREAM_MANAGER_METHOD_NAME_GET_PID_OF_LATEST_STREAM "GetPidOfLatestStream" /* signal */ #define STREAM_MANAGER_SIGNAL_NAME_VOLUME_CHANGED "VolumeChanged" #define STREAM_MANAGER_SIGNAL_NAME_COMMAND "Command" @@ -69,6 +70,7 @@ enum method_handler_index { METHOD_HANDLER_UNSET_FILTER, METHOD_HANDLER_CONTROL_FILTER, METHOD_HANDLER_CHECK_STREAM_EXIST_BY_PID, + METHOD_HANDLER_GET_PID_OF_LATEST_STREAM, METHOD_HANDLER_MAX }; diff --git a/src/stream-manager-dbus.c b/src/stream-manager-dbus.c index 7afa05b..ea8eece 100644 --- a/src/stream-manager-dbus.c +++ b/src/stream-manager-dbus.c @@ -60,6 +60,7 @@ static void handle_set_filter(DBusConnection *conn, DBusMessage *msg, void *user static void handle_unset_filter(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_control_filter(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_check_stream_exist_by_pid(DBusConnection *conn, DBusMessage *msg, void *userdata); +static void handle_get_pid_of_latest_stream(DBusConnection *conn, DBusMessage *msg, void *userdata); static void send_volume_changed_signal(DBusConnection *conn, const char *direction, const char *volume_type, const uint32_t volume_level); static pa_dbus_arg_info get_stream_info_args[] = { { "stream_type", "s", "in" }, @@ -131,7 +132,11 @@ static pa_dbus_arg_info check_stream_exist_by_pid_args[] = { { "pid", "u", "in" { "stream_type", "s", "in" }, { "io_direction", "s", "in" }, { "ret_msg", "s", "out" } }; -static const char* signature_args_for_in[] = { "s", "", "uauau", "usi", "ssu", "ss", "ss", "ssu", "ss", "s", "s", "uu", "iu", "su", "s", "ssss", "s", "sss", "uss"}; +static pa_dbus_arg_info get_pid_of_latest_stream_args[] = { { "io_direction", "s", "in" }, + { "stream_types", "as", "in" }, + { "pid", "u", "out" }, + { "ret_msg", "s", "out" } }; +static const char* signature_args_for_in[] = { "s", "", "uauau", "usi", "ssu", "ss", "ss", "ssu", "ss", "s", "s", "uu", "iu", "su", "s", "ssss", "s", "sss", "uss","sas"}; static pa_dbus_method_handler method_handlers[METHOD_HANDLER_MAX] = { [METHOD_HANDLER_GET_STREAM_INFO] = { @@ -229,6 +234,11 @@ static pa_dbus_method_handler method_handlers[METHOD_HANDLER_MAX] = { .arguments = check_stream_exist_by_pid_args, .n_arguments = sizeof(check_stream_exist_by_pid_args) / sizeof(pa_dbus_arg_info), .receive_cb = handle_check_stream_exist_by_pid }, + [METHOD_HANDLER_GET_PID_OF_LATEST_STREAM] = { + .method_name = STREAM_MANAGER_METHOD_NAME_GET_PID_OF_LATEST_STREAM, + .arguments = get_pid_of_latest_stream_args, + .n_arguments = sizeof(get_pid_of_latest_stream_args) / sizeof(pa_dbus_arg_info), + .receive_cb = handle_get_pid_of_latest_stream }, }; static DBusHandlerResult handle_introspect(DBusConnection *conn, DBusMessage *msg, void *userdata) { @@ -1309,6 +1319,117 @@ fail: dbus_message_unref(reply); } +static bool find_the_lastest_stream(pa_stream_manager *m, stream_type_t type, const char ** stream_roles, int length, uint32_t *pid) { + void *stream = NULL; + uint32_t idx = 0; + const char *role; + const char *app_pid_str = NULL; + uint32_t latest_pid = 0; + pa_usec_t latest_time = 0; + uint32_t tmp_pid = 0; + pa_usec_t tmp_time = 0; + int i; + + pa_assert(m); + pa_assert(stream_roles); + pa_assert(pid); + + PA_IDXSET_FOREACH(stream, (type == STREAM_SINK_INPUT) ? m->core->sink_inputs : m->core->source_outputs, idx) { + if (!CHECK_STREAM_RUNNING(stream, type)) { + pa_log_debug("stream(%p, index:%u) is not in running state, skip it.", stream, GET_STREAM_INDEX(stream, type)); + continue; + } + + for (i = 0; i 0) { + *pid = latest_pid; + pa_log_info("found the stream(pid:%u)", *pid); + return true; + } + + pa_log_info("no match is found"); + return false; +} + +static void handle_get_pid_of_latest_stream(DBusConnection *conn, DBusMessage *msg, void *userdata) { + const char *direction; + const char **types; + int length; + stream_type_t stream_type = STREAM_SINK_INPUT; + uint32_t pid = 0; + ret_msg_t ret_msg = RET_MSG_OK; + + DBusMessage *reply = NULL; + pa_stream_manager *m = (pa_stream_manager*)userdata; + + pa_assert(conn); + pa_assert(msg); + pa_assert(m); + + pa_assert_se(dbus_message_get_args(msg, NULL, + DBUS_TYPE_STRING, &direction, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &types, &length, + DBUS_TYPE_INVALID)); + + pa_assert_se((reply = dbus_message_new_method_return(msg))); + + if (pa_safe_streq(direction, "in")) + stream_type = STREAM_SOURCE_OUTPUT; + else if (pa_safe_streq(direction, "out")) + stream_type = STREAM_SINK_INPUT; + else { + pa_log_error("invalid direction[%s]", direction); + goto invalid_argument; + } + + if (length <= 0) { + pa_log_error("At least one stream type should be contained"); + goto invalid_argument; + } + + if (!find_the_lastest_stream(m, stream_type, types, length, &pid)) + ret_msg = RET_MSG_ERROR_NO_STREAM; + + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[ret_msg], + DBUS_TYPE_INVALID)); + pa_assert_se(dbus_connection_send(conn, reply, NULL)); + dbus_message_unref(reply); + return; + +invalid_argument: + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_UINT32, &pid, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INVALID_ARGUMENT], + DBUS_TYPE_INVALID)); + pa_assert_se(dbus_connection_send(conn, reply, NULL)); + dbus_message_unref(reply); +} + static DBusHandlerResult handle_methods(DBusConnection *conn, DBusMessage *msg, void *userdata) { int idx = 0; pa_stream_manager *m = (pa_stream_manager*)userdata; diff --git a/src/stream-manager-priv.h b/src/stream-manager-priv.h index 6722e8e..c9254ad 100644 --- a/src/stream-manager-priv.h +++ b/src/stream-manager-priv.h @@ -96,6 +96,9 @@ typedef enum _notify_command_type { #define GET_STREAM_INDEX(stream, type) \ (type == STREAM_SINK_INPUT ? ((pa_sink_input*)stream)->index : ((pa_source_output*)stream)->index) +#define GET_STREAM_LAST_RUN_TIME(stream, type) \ + (type == STREAM_SINK_INPUT ? ((pa_sink_input*)stream)->time_of_start_to_run : ((pa_source_output*)stream)->time_of_start_to_run) + #define GET_FOCUS_STATUS(focus, type) \ (type == STREAM_SINK_INPUT ? (focus & STREAM_FOCUS_ACQUIRED_PLAYBACK) : (focus & STREAM_FOCUS_ACQUIRED_CAPTURE)) -- 2.7.4 From 5c4fea2100d90600bcecc53458948069b9b4ac01 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Fri, 5 Apr 2019 14:18:05 +0900 Subject: [PATCH 12/16] stream-manager-dbus: Add new DBus methods to set/get volume rate server : org.pulseaudio.Server object path : /org/pulseaudio/StreamManager interface : org.pulseaudio.StreamManager method name : SetVolumeRate method argument : string for direction ('in' or 'out') unsigned int for stream index double for rate (0.0 ~ 1.0) return value : string for return message - success : "STREAM_MANAGER_RETURN_OK" - no match found : "STREAM_MANAGER_RETURN_ERROR_NO_STREAM" - internal error : "STREAM_MANAGER_RETURN_ERROR_INTERNAL" method name : GetVolumeRate method argument : string for direction ('in' or 'out') unsigned int for stream index return value : double for rate (0.0 ~ 1.0) string for return message - success : "STREAM_MANAGER_RETURN_OK" - no match found : "STREAM_MANAGER_RETURN_ERROR_NO_STREAM" [Version] 11.1.40 [Issue type] New feature Change-Id: I8a5b3ce87af5851c208df3a4ffa39ab6c8949a09 Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/stream-manager-dbus-priv.h | 16 ++++ src/stream-manager-dbus.c | 128 +++++++++++++++++++++++++++++++- src/stream-manager-volume-priv.h | 2 + src/stream-manager-volume.c | 90 ++++++++++++++++++++++ 5 files changed, 233 insertions(+), 5 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index c44a3b8..5a975f2 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: 11.1.39 +Version: 11.1.40 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-dbus-priv.h b/src/stream-manager-dbus-priv.h index d464a36..45eb105 100644 --- a/src/stream-manager-dbus-priv.h +++ b/src/stream-manager-dbus-priv.h @@ -35,6 +35,8 @@ #define STREAM_MANAGER_METHOD_NAME_GET_VOLUME_MAX_LEVEL "GetVolumeMaxLevel" #define STREAM_MANAGER_METHOD_NAME_SET_VOLUME_MUTE "SetVolumeMute" #define STREAM_MANAGER_METHOD_NAME_GET_VOLUME_MUTE "GetVolumeMute" +#define STREAM_MANAGER_METHOD_NAME_SET_VOLUME_RATE "SetVolumeRate" +#define STREAM_MANAGER_METHOD_NAME_GET_VOLUME_RATE "GetVolumeRate" #define STREAM_MANAGER_METHOD_NAME_GET_CURRENT_VOLUME_TYPE "GetCurrentVolumeType" /* The type that belongs to the stream of the current max priority */ #define STREAM_MANAGER_METHOD_NAME_GET_CURRENT_MEDIA_ROUTING_PATH "GetCurrentMediaRoutingPath" #define STREAM_MANAGER_METHOD_NAME_UPDATE_FOCUS_STATUS "UpdateFocusStatus" @@ -60,6 +62,8 @@ enum method_handler_index { METHOD_HANDLER_GET_VOLUME_MAX_LEVEL, METHOD_HANDLER_SET_VOLUME_MUTE, METHOD_HANDLER_GET_VOLUME_MUTE, + METHOD_HANDLER_SET_VOLUME_RATE, + METHOD_HANDLER_GET_VOLUME_RATE, METHOD_HANDLER_GET_CURRENT_VOLUME_TYPE, METHOD_HANDLER_GET_CURRENT_MEDIA_ROUTING_PATH, METHOD_HANDLER_UPDATE_FOCUS_STATUS, @@ -148,6 +152,18 @@ pa_dbus_interface_info stream_manager_interface_info = { " " \ " " \ " " \ + " " \ + " " \ + " " \ + " " \ + " " \ + " " \ + " " \ + " " \ + " " \ + " " \ + " " \ + " " \ " " \ " " \ " " \ diff --git a/src/stream-manager-dbus.c b/src/stream-manager-dbus.c index ea8eece..6256280 100644 --- a/src/stream-manager-dbus.c +++ b/src/stream-manager-dbus.c @@ -50,6 +50,8 @@ static void handle_get_volume_level(DBusConnection *conn, DBusMessage *msg, void static void handle_get_volume_max_level(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_set_volume_mute(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_get_volume_mute(DBusConnection *conn, DBusMessage *msg, void *userdata); +static void handle_set_volume_rate(DBusConnection *conn, DBusMessage *msg, void *userdata); +static void handle_get_volume_rate(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_get_current_volume_type(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_get_current_media_routing_path(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_update_focus_status(DBusConnection *conn, DBusMessage *msg, void *userdata); @@ -100,6 +102,14 @@ static pa_dbus_arg_info get_volume_mute_args[] = { { "io_direction", "s", "in" { "type", "s", "in" }, { "on", "u", "out" }, { "ret_msg", "s", "out" } }; +static pa_dbus_arg_info set_volume_rate_args[] = { { "io_direction", "s", "in" }, + { "idx", "u", "in" }, + { "rate", "d", "in" }, + { "ret_msg", "s", "out" } }; +static pa_dbus_arg_info get_volume_rate_args[] = { { "io_direction", "s", "in" }, + { "idx", "u", "in" }, + { "rate", "d", "out" }, + { "ret_msg", "s", "out" } }; static pa_dbus_arg_info get_current_volume_type_args[] = { { "io_direction", "s", "in" }, { "type", "s", "out" }, { "ret_msg", "s", "out" } }; @@ -133,10 +143,10 @@ static pa_dbus_arg_info check_stream_exist_by_pid_args[] = { { "pid", "u", "in" { "io_direction", "s", "in" }, { "ret_msg", "s", "out" } }; static pa_dbus_arg_info get_pid_of_latest_stream_args[] = { { "io_direction", "s", "in" }, - { "stream_types", "as", "in" }, - { "pid", "u", "out" }, - { "ret_msg", "s", "out" } }; -static const char* signature_args_for_in[] = { "s", "", "uauau", "usi", "ssu", "ss", "ss", "ssu", "ss", "s", "s", "uu", "iu", "su", "s", "ssss", "s", "sss", "uss","sas"}; + { "stream_types", "as", "in" }, + { "pid", "u", "out" }, + { "ret_msg", "s", "out" } }; +static const char* signature_args_for_in[] = { "s", "", "uauau", "usi", "ssu", "ss", "ss", "ssu", "ss", "sud", "su", "s", "s", "uu", "iu", "su", "s", "ssss", "s", "sss", "uss","sas"}; static pa_dbus_method_handler method_handlers[METHOD_HANDLER_MAX] = { [METHOD_HANDLER_GET_STREAM_INFO] = { @@ -184,6 +194,16 @@ static pa_dbus_method_handler method_handlers[METHOD_HANDLER_MAX] = { .arguments = get_volume_mute_args, .n_arguments = sizeof(get_volume_mute_args) / sizeof(pa_dbus_arg_info), .receive_cb = handle_get_volume_mute }, + [METHOD_HANDLER_SET_VOLUME_RATE] = { + .method_name = STREAM_MANAGER_METHOD_NAME_SET_VOLUME_RATE, + .arguments = set_volume_rate_args, + .n_arguments = sizeof(set_volume_rate_args) / sizeof(pa_dbus_arg_info), + .receive_cb = handle_set_volume_rate }, + [METHOD_HANDLER_GET_VOLUME_RATE] = { + .method_name = STREAM_MANAGER_METHOD_NAME_GET_VOLUME_RATE, + .arguments = get_volume_rate_args, + .n_arguments = sizeof(get_volume_rate_args) / sizeof(pa_dbus_arg_info), + .receive_cb = handle_get_volume_rate }, [METHOD_HANDLER_GET_CURRENT_VOLUME_TYPE] = { .method_name = STREAM_MANAGER_METHOD_NAME_GET_CURRENT_VOLUME_TYPE, .arguments = get_current_volume_type_args, @@ -782,6 +802,106 @@ fail: dbus_message_unref(reply); } +static void handle_set_volume_rate(DBusConnection *conn, DBusMessage *msg, void *userdata) { + const char *direction = NULL; + uint32_t idx; + double rate; + stream_type_t stream_type = STREAM_SINK_INPUT; + DBusMessage *reply = NULL; + pa_stream_manager *m = (pa_stream_manager*)userdata; + int ret = 0; + ret_msg_t ret_msg = RET_MSG_ERROR_INTERNAL; + + pa_assert(conn); + pa_assert(msg); + pa_assert(m); + + pa_assert_se(dbus_message_get_args(msg, NULL, + DBUS_TYPE_STRING, &direction, + DBUS_TYPE_UINT32, &idx, + DBUS_TYPE_DOUBLE, &rate, + DBUS_TYPE_INVALID)); + pa_log_info("direction[%s], idx[%u], rate[%f]", direction, idx, rate); + + pa_assert_se((reply = dbus_message_new_method_return(msg))); + + if (pa_safe_streq(direction, "in")) + stream_type = STREAM_SOURCE_OUTPUT; + else if (pa_safe_streq(direction, "out")) + stream_type = STREAM_SINK_INPUT; + else { + pa_log_error("invalid direction[%s]", direction); + goto invalid_argument; + } + + /* Check the rate range (0.0 ~ 1.0) */ + if (rate < 0 || rate > 1) { + pa_log_error("invalid range, rate[%f]", rate); + goto invalid_argument; + } + + if ((ret = set_volume_rate_by_idx(m, stream_type, idx, rate))) { + if (ret == -2) + ret_msg = RET_MSG_ERROR_NO_STREAM; + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[ret_msg], DBUS_TYPE_INVALID)); + } else { + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_OK], DBUS_TYPE_INVALID)); + } + + pa_assert_se(dbus_connection_send(conn, reply, NULL)); + dbus_message_unref(reply); + return; + +invalid_argument: + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INVALID_ARGUMENT], + DBUS_TYPE_INVALID)); + pa_assert_se(dbus_connection_send(conn, reply, NULL)); + dbus_message_unref(reply); +} + +static void handle_get_volume_rate(DBusConnection *conn, DBusMessage *msg, void *userdata) { + const char *direction = NULL; + uint32_t idx = 0; + double rate; + stream_type_t stream_type = STREAM_SINK_INPUT; + DBusMessage *reply = NULL; + pa_stream_manager *m = (pa_stream_manager*)userdata; + + pa_assert(conn); + pa_assert(msg); + pa_assert(m); + + pa_assert_se(dbus_message_get_args(msg, NULL, + DBUS_TYPE_STRING, &direction, + DBUS_TYPE_UINT32, &idx, + DBUS_TYPE_INVALID)); + pa_log_info("direction[%s], idx[%u]", direction, idx); + + pa_assert_se((reply = dbus_message_new_method_return(msg))); + + if (pa_safe_streq(direction, "in")) + stream_type = STREAM_SOURCE_OUTPUT; + else if (pa_safe_streq(direction, "out")) + stream_type = STREAM_SINK_INPUT; + else { + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_DOUBLE, 0, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INVALID_ARGUMENT], DBUS_TYPE_INVALID)); + goto finish; + } + + if (get_volume_rate_by_idx(m, stream_type, idx, &rate)) { + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_DOUBLE, &rate, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_NO_STREAM], DBUS_TYPE_INVALID)); + } else { + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_DOUBLE, &rate, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_OK], DBUS_TYPE_INVALID)); + } + +finish: + pa_assert_se(dbus_connection_send(conn, reply, NULL)); + dbus_message_unref(reply); +} + static void handle_get_current_volume_type(DBusConnection *conn, DBusMessage *msg, void *userdata) { const char *direction = NULL; const char *type = NULL; diff --git a/src/stream-manager-volume-priv.h b/src/stream-manager-volume-priv.h index 097d5e5..8d4ab47 100644 --- a/src/stream-manager-volume-priv.h +++ b/src/stream-manager-volume-priv.h @@ -43,6 +43,8 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type int32_t get_volume_level_by_type(pa_stream_manager *m, pa_volume_get_command_t command, stream_type_t stream_type, const char *volume_type, uint32_t *volume_level); int32_t set_volume_level_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t idx, uint32_t volume_level); int32_t set_volume_level_with_new_data(pa_stream_manager *m, void *stream, stream_type_t stream_type, uint32_t volume_level); +int32_t set_volume_rate_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t idx, double rate); +int32_t get_volume_rate_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t idx, double *rate); int32_t set_volume_mute_by_type(pa_stream_manager *m, stream_type_t stream_type, const char *volume_type, bool volume_mute); int32_t get_volume_mute_by_type(pa_stream_manager *m, stream_type_t stream_type, const char *volume_type, bool *volume_mute); int32_t set_volume_mute_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t stream_idx, bool volume_mute); diff --git a/src/stream-manager-volume.c b/src/stream-manager-volume.c index bbb7c90..c5b475e 100644 --- a/src/stream-manager-volume.c +++ b/src/stream-manager-volume.c @@ -571,6 +571,96 @@ int32_t set_volume_level_with_new_data(pa_stream_manager *m, void *stream, strea return 0; } +int32_t set_volume_rate_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t idx, double rate) { + bool is_hal_volume = false; + void *s = NULL; + void *volumes = NULL; + volume_info *v = NULL; + uint32_t volume_level; + pa_cvolume cv; + double volume_linear = 1.0; + double *modifier_gain_value = NULL; + const char *volume_type_str = NULL; + const char *modifier_gain = NULL; + + pa_assert(m); + + if (!(s = pa_idxset_get_by_index(stream_type == STREAM_SINK_INPUT ? m->core->sink_inputs : m->core->source_outputs, idx))) { + pa_log_error("failed to get stream...[%u]", idx); + return -2; + } + + if (!(volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) { + pa_log_debug("idx[%u] doesn't have volume type", idx); + return -1; + } + + /* Check if it is related to HAL volume */ + if (is_hal_volume_by_type(m, volume_type_str, &is_hal_volume)) { + pa_log_error("failed to is_hal_volume_by_type(), volume_type[%s]", volume_type_str); + return -1; + } + + /* Get current level of this volume type */ + volumes = m->volume_infos; + if (!(v = pa_hashmap_get(volumes, volume_type_str))) { + pa_log_error("could not get volume_info, stream_type[%d], volume_type[%s]", stream_type, volume_type_str); + return -1; + } + volume_level = v->values[stream_type].current_level; + + /* Get volume value */ + if (get_volume_value(m, stream_type, is_hal_volume, volume_type_str, volume_level, &volume_linear)) + return -1; + + /* Get modifier for gain */ + modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE); + if (modifier_gain) { + if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { + volume_linear *= (*modifier_gain_value); + pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", + modifier_gain, *modifier_gain_value, volume_linear); + } + } + + if (stream_type == STREAM_SINK_INPUT) + ((pa_sink_input*)s)->individual_volume_ratio = rate; + else + ((pa_source_output*)s)->individual_volume_ratio = rate; + apply_individual_ratio(m, s, volume_linear, &cv); + + if (stream_type == STREAM_SINK_INPUT) + pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true); + else if (stream_type == STREAM_SOURCE_OUTPUT) + pa_source_output_set_volume((pa_source_output*)s, &cv, true, true); + + pa_log_debug("stream_type[%d], idx[%u]=>volume_type[%s], level[%u], rate[%f], value[%f]", + stream_type, idx, volume_type_str, volume_level, rate, volume_linear); + + return 0; +} + +int32_t get_volume_rate_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t idx, double *rate) { + void *s = NULL; + + pa_assert(m); + pa_assert(rate); + + if (!(s = pa_idxset_get_by_index(stream_type == STREAM_SINK_INPUT ? m->core->sink_inputs : m->core->source_outputs, idx))) { + pa_log_error("failed to get stream...[%u]", idx); + return -1; + } + + if (stream_type == STREAM_SINK_INPUT) + *rate = ((pa_sink_input*)s)->individual_volume_ratio; + else + *rate = ((pa_source_output*)s)->individual_volume_ratio; + + pa_log_info("individual ratio of stream[idx:%u] is [%f]", idx, *rate); + + return 0; +} + int32_t set_volume_mute_by_type(pa_stream_manager *m, stream_type_t stream_type, const char *volume_type, bool volume_mute) { bool is_hal_volume = false; volume_info *v = NULL; -- 2.7.4 From 75820156ba2e6e6ea7de54b2fef9b27d256810ac Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Wed, 17 Apr 2019 13:39:27 +0900 Subject: [PATCH 13/16] hal-interface, stream-manager: Add support for setting volume ratio to HAL It is an extension of the previous patches regarding the individual volume feature. The 'ratio' parameter of the new HAL API is calculated considering master volume ratio, group volume ratio and individual volume ratio. The two former factors are affected only when the volume type of the target stream is not the HAL volume type defined in stream-map.json. [Version] 11.1.41 [Issue type] New feature Change-Id: I912a0f6eb1edc3fe33e058ef6290f4aba1267ed0 Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/hal-interface.c | 25 +++++++++ src/hal-interface.h | 1 + src/stream-manager-volume.c | 89 +++++++++++++++++++++++---------- src/stream-manager.c | 31 +++++++++--- 5 files changed, 113 insertions(+), 35 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 5a975f2..5a58c7f 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: 11.1.40 +Version: 11.1.41 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/hal-interface.c b/src/hal-interface.c index 1692a80..bbd2d33 100644 --- a/src/hal-interface.c +++ b/src/hal-interface.c @@ -64,6 +64,7 @@ pa_hal_interface* pa_hal_interface_get(pa_core *core) { h->intf.get_volume_value = dlsym(h->dl_handle, "audio_get_volume_value"); h->intf.get_volume_mute = dlsym(h->dl_handle, "audio_get_volume_mute"); h->intf.set_volume_mute = dlsym(h->dl_handle, "audio_set_volume_mute"); + h->intf.set_volume_ratio = dlsym(h->dl_handle, "audio_set_volume_ratio"); h->intf.update_route = dlsym(h->dl_handle, "audio_update_route"); h->intf.update_route_option = dlsym(h->dl_handle, "audio_update_route_option"); h->intf.notify_stream_connection_changed = dlsym(h->dl_handle, "audio_notify_stream_connection_changed"); @@ -246,6 +247,30 @@ int32_t pa_hal_interface_set_volume_mute(pa_hal_interface *h, const char *volume return ret; } +int32_t pa_hal_interface_set_volume_ratio(pa_hal_interface *h, const char *stream_role, io_direction_t direction, uint32_t idx, double ratio) { + int32_t ret = 0; + audio_return_t hal_ret = AUDIO_RET_OK; + audio_stream_info_t info = {NULL, 0, 0}; + + pa_assert(h); + pa_assert(stream_role); + + if (h->intf.set_volume_ratio == NULL) { + pa_log_warn("there is no set_volume_ratio symbol in this audio hal, skip it"); + return -1; + } + + info.role = stream_role; + info.direction = direction; + info.idx = idx; + + if (AUDIO_RET_OK != (hal_ret = h->intf.set_volume_ratio(h->ah_handle, &info, ratio))) { + pa_log_error("set_volume_ratio returns error:0x%x", hal_ret); + ret = -1; + } + return ret; +} + int32_t pa_hal_interface_update_route(pa_hal_interface *h, hal_route_info *info) { int32_t ret = 0; audio_return_t hal_ret = AUDIO_RET_OK; diff --git a/src/hal-interface.h b/src/hal-interface.h index 20c14f8..b654845 100644 --- a/src/hal-interface.h +++ b/src/hal-interface.h @@ -90,6 +90,7 @@ int32_t pa_hal_interface_set_volume_level(pa_hal_interface *h, const char *volum int32_t pa_hal_interface_get_volume_value(pa_hal_interface *h, const char *volume_type, const char *gain_type, io_direction_t direction, uint32_t level, double *value); int32_t pa_hal_interface_get_volume_mute(pa_hal_interface *h, const char *volume_type, io_direction_t direction, uint32_t *mute); int32_t pa_hal_interface_set_volume_mute(pa_hal_interface *h, const char *volume_type, io_direction_t direction, uint32_t mute); +int32_t pa_hal_interface_set_volume_ratio(pa_hal_interface *h, const char *stream_role, io_direction_t direction, uint32_t idx, double ratio); int32_t pa_hal_interface_update_route(pa_hal_interface *h, hal_route_info *info); int32_t pa_hal_interface_update_route_option(pa_hal_interface *h, hal_route_option *option); int32_t pa_hal_interface_notify_stream_connection_changed(pa_hal_interface *h, hal_stream_connection_info *info); diff --git a/src/stream-manager-volume.c b/src/stream-manager-volume.c index c5b475e..295533a 100644 --- a/src/stream-manager-volume.c +++ b/src/stream-manager-volume.c @@ -265,25 +265,32 @@ int32_t update_mute_vconf(const char *type, unsigned int mute) } void apply_individual_ratio(pa_stream_manager *m, pa_object *stream, double volume_linear, pa_cvolume *result) { - double individual_ratio; + bool is_sink_input = false; double result_linear; + double individual_ratio; + double master_ratio; + double group_ratio; + double result_ratio; pa_volume_t volume; uint32_t index; unsigned channels; + io_direction_t io_direction; + const char *role; + const char *volume_type; + pa_hashmap *volumes = NULL; + volume_info *v = NULL; + stream_type_t stream_type; + stream_direction_t stream_direction; pa_assert(m); pa_assert(stream); - pa_assert(volume_linear); + pa_assert(result); - if (pa_sink_input_isinstance(stream)) { - individual_ratio = ((pa_sink_input*)stream)->individual_volume_ratio; - index = ((pa_sink_input*)stream)->index; - channels = ((pa_sink_input*)stream)->sample_spec.channels; - } else { - individual_ratio = ((pa_source_output*)stream)->individual_volume_ratio; - index = ((pa_source_output*)stream)->index; - channels = ((pa_sink_input*)stream)->sample_spec.channels; - } + is_sink_input = pa_sink_input_isinstance(stream); + individual_ratio = is_sink_input ? ((pa_sink_input*)stream)->individual_volume_ratio : + ((pa_source_output*)stream)->individual_volume_ratio; + channels = is_sink_input ? ((pa_sink_input*)stream)->sample_spec.channels : + ((pa_source_output*)stream)->sample_spec.channels; volume = pa_sw_volume_from_linear(volume_linear) * individual_ratio; result = pa_cvolume_set(result, channels, volume); @@ -291,6 +298,34 @@ void apply_individual_ratio(pa_stream_manager *m, pa_object *stream, double volu pa_log_info("apply the individual ratio[%f] to stream[idx:%u], result volume linear[%f]", individual_ratio, index, result_linear); + + /* Here's calculation before calling HAL API */ + stream_type = is_sink_input ? STREAM_SINK_INPUT : STREAM_SOURCE_OUTPUT; + if (!(volume_type = pa_proplist_gets(GET_STREAM_PROPLIST(stream, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) { + pa_log_error("no volume type"); + return; + } + role = pa_proplist_gets(GET_STREAM_PROPLIST(stream, stream_type), PA_PROP_MEDIA_ROLE); + stream_direction = is_sink_input ? STREAM_DIRECTION_OUT : STREAM_DIRECTION_IN; + volumes = m->volume_infos; + if (!(v = pa_hashmap_get(volumes, MASTER_VOLUME_TYPE))) { + pa_log_error("could not get volume_info, volume_type[%s]", MASTER_VOLUME_TYPE); + return; + } + master_ratio = v->is_hal_volume_type ? 1.0 : (double)v->values[stream_direction].current_level / MASTER_VOLUME_LEVEL_MAX; + if (!(v = pa_hashmap_get(volumes, volume_type))) { + pa_log_error("could not get volume_info, volume_type[%s]", volume_type); + return; + } + group_ratio = v->is_hal_volume_type ? 1.0 : (double)v->values[stream_direction].current_level / (pa_idxset_size(v->values[stream_direction].idx_volume_values) - 1); + result_ratio = master_ratio * group_ratio * individual_ratio; + pa_log_debug("role(%s), volume_type(%s) : master_ratio(%f), group_ratio(%f), individual_ratio(%f) => result_ratio(%f)", + role, volume_type, master_ratio, group_ratio, individual_ratio, result_ratio); + + index = GET_STREAM_INDEX(stream, stream_type); + io_direction = is_sink_input ? DIRECTION_OUT : DIRECTION_IN; + + pa_hal_interface_set_volume_ratio(m->hal, role, io_direction, index, result_ratio); } int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type, const char *volume_type, uint32_t volume_level) { @@ -526,6 +561,7 @@ int32_t set_volume_level_with_new_data(pa_stream_manager *m, void *stream, strea bool is_hal_volume = false; pa_cvolume cv; double volume_linear = 1.0; + double *modifier_gain_value = NULL; const char *volume_type_str = NULL; const char *modifier_gain = NULL; @@ -547,24 +583,25 @@ int32_t set_volume_level_with_new_data(pa_stream_manager *m, void *stream, strea if (pa_hal_interface_set_volume_level(m->hal, volume_type_str, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level)) return -1; + if (get_volume_value(m, stream_type, is_hal_volume, volume_type_str, volume_level, &volume_linear)) + return -1; + /* Get modifier for gain */ modifier_gain = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE); - - if (!get_volume_value(m, stream_type, is_hal_volume, volume_type_str, volume_level, &volume_linear)) { - if (modifier_gain) { - double *modifier_gain_value = NULL; - if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { - volume_linear *= (*modifier_gain_value); - pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", - modifier_gain, *modifier_gain_value, volume_linear); - } + if (modifier_gain && m->volume_modifiers) { + if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { + volume_linear *= (*modifier_gain_value); + pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", + modifier_gain, *modifier_gain_value, volume_linear); } - pa_cvolume_set(&cv, GET_STREAM_NEW_SAMPLE_SPEC(stream, stream_type).channels, pa_sw_volume_from_linear(volume_linear)); - if (stream_type == STREAM_SINK_INPUT) - pa_sink_input_new_data_set_volume((pa_sink_input_new_data*)stream, &cv); - else if (stream_type == STREAM_SOURCE_OUTPUT) - pa_source_output_new_data_set_volume((pa_source_output_new_data*)stream, &cv); } + + pa_cvolume_set(&cv, GET_STREAM_NEW_SAMPLE_SPEC(stream, stream_type).channels, pa_sw_volume_from_linear(volume_linear)); + if (stream_type == STREAM_SINK_INPUT) + pa_sink_input_new_data_set_volume((pa_sink_input_new_data*)stream, &cv); + else if (stream_type == STREAM_SOURCE_OUTPUT) + pa_source_output_new_data_set_volume((pa_source_output_new_data*)stream, &cv); + pa_log_debug("stream_type[%d], volume_type[%s], level[%u], value[%f]", stream_type, volume_type_str, volume_level, volume_linear); @@ -615,7 +652,7 @@ int32_t set_volume_rate_by_idx(pa_stream_manager *m, stream_type_t stream_type, /* Get modifier for gain */ modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE); - if (modifier_gain) { + if (modifier_gain && m->volume_modifiers) { if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) { volume_linear *= (*modifier_gain_value); pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]", diff --git a/src/stream-manager.c b/src/stream-manager.c index d2f931f..370b770 100644 --- a/src/stream-manager.c +++ b/src/stream-manager.c @@ -2000,18 +2000,31 @@ process_stream_result_t process_stream(pa_stream_manager *m, void *stream, strea pa_log_warn("role is null, skip it"); } - } else if (command == PROCESS_COMMAND_UPDATE_VOLUME && is_new_data) { - if ((si_volume_type_str = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) { - v = pa_hashmap_get(m->volume_infos, si_volume_type_str); - if (v && v->values[type].idx_volume_values) { + } else if (command == PROCESS_COMMAND_UPDATE_VOLUME) { + if (is_new_data) + si_volume_type_str = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE); + else + si_volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE); + + if (!si_volume_type_str) + goto finish; + + v = pa_hashmap_get(m->volume_infos, si_volume_type_str); + if (v && v->values[type].idx_volume_values) { + if (is_new_data) { /* Update volume-level */ if ((volume_ret = set_volume_level_with_new_data(m, stream, type, v->values[type].current_level))) - pa_log_error("failed to set_volume_level_by_idx(), stream_type(%d), level(%u), ret(0x%x)", - type, v->values[type].current_level, volume_ret); + pa_log_error("failed to set_volume_level_with_new_data(), stream_type(%d), level(%u), ret(0x%x)", + type, v->values[type].current_level, volume_ret); /* Update volume-mute */ if ((volume_ret = set_volume_mute_with_new_data(m, stream, type, v->values[type].is_muted))) - pa_log_error("failed to set_volume_mute_by_idx(), stream_type(%d), mute(%d), ret(0x%x)", - type, v->values[type].is_muted, volume_ret); + pa_log_error("failed to set_volume_mute_with_new_data(), stream_type(%d), mute(%d), ret(0x%x)", + type, v->values[type].is_muted, volume_ret); + } else { + /* Update volume-level by stream index*/ + if ((volume_ret = set_volume_level_by_idx(m, type, GET_STREAM_INDEX(stream, type), v->values[type].current_level))) + pa_log_error("failed to set_volume_level_by_idx(), stream_type(%d), index(%u), level(%u), ret(0x%x)", + type, GET_STREAM_INDEX(stream, type), v->values[type].current_level, volume_ret); } } @@ -2110,6 +2123,7 @@ static pa_hook_result_t sink_input_put_cb(pa_core *core, pa_sink_input *i, pa_st process_stream(m, i, STREAM_SINK_INPUT, PROCESS_COMMAND_ADD_PARENT_ID, false); process_stream(m, i, STREAM_SINK_INPUT, PROCESS_COMMAND_APPLY_FILTER, false); + process_stream(m, i, STREAM_SINK_INPUT, PROCESS_COMMAND_UPDATE_VOLUME, false); if (stream_is_call_family(PA_OBJECT(i))) { change_active_route_for_call(m, PA_OBJECT(i), true); m->on_call = true; @@ -2230,6 +2244,7 @@ static pa_hook_result_t source_output_put_cb(pa_core *core, pa_source_output *o, update_mirroring_streams(m, o, true); process_stream(m, o, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_ADD_PARENT_ID, false); + process_stream(m, o, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_UPDATE_VOLUME, false); if (stream_is_call_family(PA_OBJECT(o))) { change_active_route_for_call(m, PA_OBJECT(o), true); m->on_call = true; -- 2.7.4 From b275d0ce26b4d0a5bbaa64db96c1d12211942c0c Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Mon, 22 Apr 2019 08:48:25 +0900 Subject: [PATCH 14/16] stream-manager-dbus: Rename methods and fix bug set[get]_volume_rate() are changed to set[get]_volume_ratio(). invalid parameter to dbus_message_append_args() is fixed. [Version] 11.1.42 [Issue type] Revision Change-Id: I4f4da6a0730621144f374e8a99bd75b9b76ad0fc Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/stream-manager-dbus-priv.h | 16 ++++----- src/stream-manager-dbus.c | 60 ++++++++++++++++----------------- src/stream-manager-volume.c | 20 +++++------ 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 5a58c7f..4e607fb 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: 11.1.41 +Version: 11.1.42 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-dbus-priv.h b/src/stream-manager-dbus-priv.h index 45eb105..92f0ecd 100644 --- a/src/stream-manager-dbus-priv.h +++ b/src/stream-manager-dbus-priv.h @@ -35,8 +35,8 @@ #define STREAM_MANAGER_METHOD_NAME_GET_VOLUME_MAX_LEVEL "GetVolumeMaxLevel" #define STREAM_MANAGER_METHOD_NAME_SET_VOLUME_MUTE "SetVolumeMute" #define STREAM_MANAGER_METHOD_NAME_GET_VOLUME_MUTE "GetVolumeMute" -#define STREAM_MANAGER_METHOD_NAME_SET_VOLUME_RATE "SetVolumeRate" -#define STREAM_MANAGER_METHOD_NAME_GET_VOLUME_RATE "GetVolumeRate" +#define STREAM_MANAGER_METHOD_NAME_SET_VOLUME_RATIO "SetVolumeRatio" +#define STREAM_MANAGER_METHOD_NAME_GET_VOLUME_RATIO "GetVolumeRatio" #define STREAM_MANAGER_METHOD_NAME_GET_CURRENT_VOLUME_TYPE "GetCurrentVolumeType" /* The type that belongs to the stream of the current max priority */ #define STREAM_MANAGER_METHOD_NAME_GET_CURRENT_MEDIA_ROUTING_PATH "GetCurrentMediaRoutingPath" #define STREAM_MANAGER_METHOD_NAME_UPDATE_FOCUS_STATUS "UpdateFocusStatus" @@ -62,8 +62,8 @@ enum method_handler_index { METHOD_HANDLER_GET_VOLUME_MAX_LEVEL, METHOD_HANDLER_SET_VOLUME_MUTE, METHOD_HANDLER_GET_VOLUME_MUTE, - METHOD_HANDLER_SET_VOLUME_RATE, - METHOD_HANDLER_GET_VOLUME_RATE, + METHOD_HANDLER_SET_VOLUME_RATIO, + METHOD_HANDLER_GET_VOLUME_RATIO, METHOD_HANDLER_GET_CURRENT_VOLUME_TYPE, METHOD_HANDLER_GET_CURRENT_MEDIA_ROUTING_PATH, METHOD_HANDLER_UPDATE_FOCUS_STATUS, @@ -152,16 +152,16 @@ pa_dbus_interface_info stream_manager_interface_info = { " " \ " " \ " " \ - " " \ + " " \ " " \ " " \ - " " \ + " " \ " " \ " " \ - " " \ + " " \ " " \ " " \ - " " \ + " " \ " " \ " " \ " " \ diff --git a/src/stream-manager-dbus.c b/src/stream-manager-dbus.c index 6256280..84789ee 100644 --- a/src/stream-manager-dbus.c +++ b/src/stream-manager-dbus.c @@ -50,8 +50,8 @@ static void handle_get_volume_level(DBusConnection *conn, DBusMessage *msg, void static void handle_get_volume_max_level(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_set_volume_mute(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_get_volume_mute(DBusConnection *conn, DBusMessage *msg, void *userdata); -static void handle_set_volume_rate(DBusConnection *conn, DBusMessage *msg, void *userdata); -static void handle_get_volume_rate(DBusConnection *conn, DBusMessage *msg, void *userdata); +static void handle_set_volume_ratio(DBusConnection *conn, DBusMessage *msg, void *userdata); +static void handle_get_volume_ratio(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_get_current_volume_type(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_get_current_media_routing_path(DBusConnection *conn, DBusMessage *msg, void *userdata); static void handle_update_focus_status(DBusConnection *conn, DBusMessage *msg, void *userdata); @@ -102,13 +102,13 @@ static pa_dbus_arg_info get_volume_mute_args[] = { { "io_direction", "s", "in" { "type", "s", "in" }, { "on", "u", "out" }, { "ret_msg", "s", "out" } }; -static pa_dbus_arg_info set_volume_rate_args[] = { { "io_direction", "s", "in" }, +static pa_dbus_arg_info set_volume_ratio_args[] = { { "io_direction", "s", "in" }, { "idx", "u", "in" }, - { "rate", "d", "in" }, + { "ratio", "d", "in" }, { "ret_msg", "s", "out" } }; -static pa_dbus_arg_info get_volume_rate_args[] = { { "io_direction", "s", "in" }, +static pa_dbus_arg_info get_volume_ratio_args[] = { { "io_direction", "s", "in" }, { "idx", "u", "in" }, - { "rate", "d", "out" }, + { "ratio", "d", "out" }, { "ret_msg", "s", "out" } }; static pa_dbus_arg_info get_current_volume_type_args[] = { { "io_direction", "s", "in" }, { "type", "s", "out" }, @@ -194,16 +194,16 @@ static pa_dbus_method_handler method_handlers[METHOD_HANDLER_MAX] = { .arguments = get_volume_mute_args, .n_arguments = sizeof(get_volume_mute_args) / sizeof(pa_dbus_arg_info), .receive_cb = handle_get_volume_mute }, - [METHOD_HANDLER_SET_VOLUME_RATE] = { - .method_name = STREAM_MANAGER_METHOD_NAME_SET_VOLUME_RATE, - .arguments = set_volume_rate_args, - .n_arguments = sizeof(set_volume_rate_args) / sizeof(pa_dbus_arg_info), - .receive_cb = handle_set_volume_rate }, - [METHOD_HANDLER_GET_VOLUME_RATE] = { - .method_name = STREAM_MANAGER_METHOD_NAME_GET_VOLUME_RATE, - .arguments = get_volume_rate_args, - .n_arguments = sizeof(get_volume_rate_args) / sizeof(pa_dbus_arg_info), - .receive_cb = handle_get_volume_rate }, + [METHOD_HANDLER_SET_VOLUME_RATIO] = { + .method_name = STREAM_MANAGER_METHOD_NAME_SET_VOLUME_RATIO, + .arguments = set_volume_ratio_args, + .n_arguments = sizeof(set_volume_ratio_args) / sizeof(pa_dbus_arg_info), + .receive_cb = handle_set_volume_ratio }, + [METHOD_HANDLER_GET_VOLUME_RATIO] = { + .method_name = STREAM_MANAGER_METHOD_NAME_GET_VOLUME_RATIO, + .arguments = get_volume_ratio_args, + .n_arguments = sizeof(get_volume_ratio_args) / sizeof(pa_dbus_arg_info), + .receive_cb = handle_get_volume_ratio }, [METHOD_HANDLER_GET_CURRENT_VOLUME_TYPE] = { .method_name = STREAM_MANAGER_METHOD_NAME_GET_CURRENT_VOLUME_TYPE, .arguments = get_current_volume_type_args, @@ -802,10 +802,10 @@ fail: dbus_message_unref(reply); } -static void handle_set_volume_rate(DBusConnection *conn, DBusMessage *msg, void *userdata) { +static void handle_set_volume_ratio(DBusConnection *conn, DBusMessage *msg, void *userdata) { const char *direction = NULL; uint32_t idx; - double rate; + double ratio; stream_type_t stream_type = STREAM_SINK_INPUT; DBusMessage *reply = NULL; pa_stream_manager *m = (pa_stream_manager*)userdata; @@ -819,9 +819,9 @@ static void handle_set_volume_rate(DBusConnection *conn, DBusMessage *msg, void pa_assert_se(dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &direction, DBUS_TYPE_UINT32, &idx, - DBUS_TYPE_DOUBLE, &rate, + DBUS_TYPE_DOUBLE, &ratio, DBUS_TYPE_INVALID)); - pa_log_info("direction[%s], idx[%u], rate[%f]", direction, idx, rate); + pa_log_info("direction[%s], idx[%u], ratio[%f]", direction, idx, ratio); pa_assert_se((reply = dbus_message_new_method_return(msg))); @@ -834,13 +834,13 @@ static void handle_set_volume_rate(DBusConnection *conn, DBusMessage *msg, void goto invalid_argument; } - /* Check the rate range (0.0 ~ 1.0) */ - if (rate < 0 || rate > 1) { - pa_log_error("invalid range, rate[%f]", rate); + /* Check the ratio range (0.0 ~ 1.0) */ + if (ratio < 0 || ratio > 1) { + pa_log_error("invalid range, ratio[%f]", ratio); goto invalid_argument; } - if ((ret = set_volume_rate_by_idx(m, stream_type, idx, rate))) { + if ((ret = set_volume_ratio_by_idx(m, stream_type, idx, ratio))) { if (ret == -2) ret_msg = RET_MSG_ERROR_NO_STREAM; pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[ret_msg], DBUS_TYPE_INVALID)); @@ -859,10 +859,10 @@ invalid_argument: dbus_message_unref(reply); } -static void handle_get_volume_rate(DBusConnection *conn, DBusMessage *msg, void *userdata) { +static void handle_get_volume_ratio(DBusConnection *conn, DBusMessage *msg, void *userdata) { const char *direction = NULL; uint32_t idx = 0; - double rate; + double ratio; stream_type_t stream_type = STREAM_SINK_INPUT; DBusMessage *reply = NULL; pa_stream_manager *m = (pa_stream_manager*)userdata; @@ -884,16 +884,16 @@ static void handle_get_volume_rate(DBusConnection *conn, DBusMessage *msg, void else if (pa_safe_streq(direction, "out")) stream_type = STREAM_SINK_INPUT; else { - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_DOUBLE, 0, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_DOUBLE, &ratio, DBUS_TYPE_INVALID)); pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_INVALID_ARGUMENT], DBUS_TYPE_INVALID)); goto finish; } - if (get_volume_rate_by_idx(m, stream_type, idx, &rate)) { - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_DOUBLE, &rate, DBUS_TYPE_INVALID)); + if (get_volume_ratio_by_idx(m, stream_type, idx, &ratio)) { + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_DOUBLE, &ratio, DBUS_TYPE_INVALID)); pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_ERROR_NO_STREAM], DBUS_TYPE_INVALID)); } else { - pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_DOUBLE, &rate, DBUS_TYPE_INVALID)); + pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_DOUBLE, &ratio, DBUS_TYPE_INVALID)); pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_OK], DBUS_TYPE_INVALID)); } diff --git a/src/stream-manager-volume.c b/src/stream-manager-volume.c index 295533a..aeb6b5e 100644 --- a/src/stream-manager-volume.c +++ b/src/stream-manager-volume.c @@ -608,7 +608,7 @@ int32_t set_volume_level_with_new_data(pa_stream_manager *m, void *stream, strea return 0; } -int32_t set_volume_rate_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t idx, double rate) { +int32_t set_volume_ratio_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t idx, double ratio) { bool is_hal_volume = false; void *s = NULL; void *volumes = NULL; @@ -661,9 +661,9 @@ int32_t set_volume_rate_by_idx(pa_stream_manager *m, stream_type_t stream_type, } if (stream_type == STREAM_SINK_INPUT) - ((pa_sink_input*)s)->individual_volume_ratio = rate; + ((pa_sink_input*)s)->individual_volume_ratio = ratio; else - ((pa_source_output*)s)->individual_volume_ratio = rate; + ((pa_source_output*)s)->individual_volume_ratio = ratio; apply_individual_ratio(m, s, volume_linear, &cv); if (stream_type == STREAM_SINK_INPUT) @@ -671,17 +671,17 @@ int32_t set_volume_rate_by_idx(pa_stream_manager *m, stream_type_t stream_type, else if (stream_type == STREAM_SOURCE_OUTPUT) pa_source_output_set_volume((pa_source_output*)s, &cv, true, true); - pa_log_debug("stream_type[%d], idx[%u]=>volume_type[%s], level[%u], rate[%f], value[%f]", - stream_type, idx, volume_type_str, volume_level, rate, volume_linear); + pa_log_debug("stream_type[%d], idx[%u]=>volume_type[%s], level[%u], ratio[%f], value[%f]", + stream_type, idx, volume_type_str, volume_level, ratio, volume_linear); return 0; } -int32_t get_volume_rate_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t idx, double *rate) { +int32_t get_volume_ratio_by_idx(pa_stream_manager *m, stream_type_t stream_type, uint32_t idx, double *ratio) { void *s = NULL; pa_assert(m); - pa_assert(rate); + pa_assert(ratio); if (!(s = pa_idxset_get_by_index(stream_type == STREAM_SINK_INPUT ? m->core->sink_inputs : m->core->source_outputs, idx))) { pa_log_error("failed to get stream...[%u]", idx); @@ -689,11 +689,11 @@ int32_t get_volume_rate_by_idx(pa_stream_manager *m, stream_type_t stream_type, } if (stream_type == STREAM_SINK_INPUT) - *rate = ((pa_sink_input*)s)->individual_volume_ratio; + *ratio = ((pa_sink_input*)s)->individual_volume_ratio; else - *rate = ((pa_source_output*)s)->individual_volume_ratio; + *ratio = ((pa_source_output*)s)->individual_volume_ratio; - pa_log_info("individual ratio of stream[idx:%u] is [%f]", idx, *rate); + pa_log_info("individual ratio of stream[idx:%u] is [%f]", idx, *ratio); return 0; } -- 2.7.4 From e9d3211619ed9498d3be470364aec3b2673b13a7 Mon Sep 17 00:00:00 2001 From: Seungbae Shin Date: Wed, 8 May 2019 16:08:02 +0900 Subject: [PATCH 15/16] stream-manager-volume: fix svace defect (UNINIT.LOCAL_VAR.EX) [Version] 11.1.43 [Issue type] SVACE Change-Id: I7e170c4af028d113d8007abea4cdeed3e25ff7e9 --- src/stream-manager-volume.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stream-manager-volume.c b/src/stream-manager-volume.c index aeb6b5e..10cda8e 100644 --- a/src/stream-manager-volume.c +++ b/src/stream-manager-volume.c @@ -295,12 +295,13 @@ void apply_individual_ratio(pa_stream_manager *m, pa_object *stream, double volu volume = pa_sw_volume_from_linear(volume_linear) * individual_ratio; result = pa_cvolume_set(result, channels, volume); result_linear = pa_sw_volume_to_linear(volume); + stream_type = is_sink_input ? STREAM_SINK_INPUT : STREAM_SOURCE_OUTPUT; + index = GET_STREAM_INDEX(stream, stream_type); pa_log_info("apply the individual ratio[%f] to stream[idx:%u], result volume linear[%f]", - individual_ratio, index, result_linear); + individual_ratio, index, result_linear); /* Here's calculation before calling HAL API */ - stream_type = is_sink_input ? STREAM_SINK_INPUT : STREAM_SOURCE_OUTPUT; if (!(volume_type = pa_proplist_gets(GET_STREAM_PROPLIST(stream, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) { pa_log_error("no volume type"); return; @@ -322,7 +323,6 @@ void apply_individual_ratio(pa_stream_manager *m, pa_object *stream, double volu pa_log_debug("role(%s), volume_type(%s) : master_ratio(%f), group_ratio(%f), individual_ratio(%f) => result_ratio(%f)", role, volume_type, master_ratio, group_ratio, individual_ratio, result_ratio); - index = GET_STREAM_INDEX(stream, stream_type); io_direction = is_sink_input ? DIRECTION_OUT : DIRECTION_IN; pa_hal_interface_set_volume_ratio(m->hal, role, io_direction, index, result_ratio); -- 2.7.4 From 7c2dbd60ca95aa412f53dc4f5167f0462f7de853 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Thu, 9 May 2019 12:23:52 +0900 Subject: [PATCH 16/16] tizenaudio-policy: Add missing unsuspend sink/source due to INTERNAL cause Tizen specific logic regarding to unsuspending automatically in case of PA_SUSPEND_INTERNAL cause has been removed, so it has to be added for valid behavior when starting a stream later on. [Version] 11.1.44 [Issue type] Bug fix Change-Id: Ie0c48b7990a2499cad31669e4c4f5c1caea1f1ed Signed-off-by: Sangchul Lee --- packaging/pulseaudio-modules-tizen.spec | 2 +- src/module-tizenaudio-policy.c | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 4e607fb..1b6a094 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: 11.1.42 +Version: 11.1.44 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/module-tizenaudio-policy.c b/src/module-tizenaudio-policy.c index a60be73..d3b106b 100644 --- a/src/module-tizenaudio-policy.c +++ b/src/module-tizenaudio-policy.c @@ -934,7 +934,6 @@ static void route_change_move_streams(struct userdata *u, pa_stream_manager_hook return; if (!data->stream) return; - if (!IS_ROLE_COMMUNICATION(data->stream_role)) return; @@ -943,20 +942,22 @@ static void route_change_move_streams(struct userdata *u, pa_stream_manager_hook if (data->stream_type == STREAM_SINK_INPUT) { if (!(sink = pa_tz_device_get_sink(device, DEVICE_ROLE_NORMAL)) || !(dst_sink = pa_tz_device_get_sink(device, device_role)) || - sink == dst_sink) + sink == dst_sink) { pa_log_info("[ROUTE][MOVE][%s] no need to move streams, sink(%p), dst_sink(%p)", data->stream_role, sink, dst_sink); - else - streams = sink->inputs; + return; + } + streams = sink->inputs; } else if (data->stream_type == STREAM_SOURCE_OUTPUT) { if (!(source = pa_tz_device_get_source(device, DEVICE_ROLE_NORMAL)) || !(dst_source = pa_tz_device_get_source(device, device_role)) || - source == dst_source) + source == dst_source) { pa_log_info("[ROUTE][MOVE][%s] no need to move streams, source(%p), dst_source(%p)", data->stream_role, source, dst_source); - else - streams = source->outputs; + return; + } + streams = source->outputs; } - if (!streams) + if (!streams || (pa_idxset_size(streams) == 0)) return; /* move other streams that belong to the device of NORMAL role */ @@ -996,7 +997,7 @@ static void route_change_rollback_streams(struct userdata *u, pa_stream_manager_ /* if it's from new_data, return here */ if (!device || data->origins_from_new_data) return; - if (!data->stream || !data->idx_streams) + if (!data->stream || !data->idx_streams || pa_idxset_size(data->idx_streams) == 0) return; if (!IS_AUTO_ROUTE_TYPE_SERIES(data->route_type)) return; @@ -1004,9 +1005,11 @@ static void route_change_rollback_streams(struct userdata *u, pa_stream_manager_ if (data->stream_type == STREAM_SINK_INPUT) { if (!(sink = pa_tz_device_get_sink(device, data->device_role))) return; + pa_sink_suspend(sink, false, PA_SUSPEND_INTERNAL); } else if (data->stream_type == STREAM_SOURCE_OUTPUT) { if (!(source = pa_tz_device_get_source(device, data->device_role))) return; + pa_source_suspend(source, false, PA_SUSPEND_INTERNAL); } PA_IDXSET_FOREACH(s, data->idx_streams, idx) { -- 2.7.4