From: Seungbae Shin Date: Fri, 7 Apr 2023 11:55:35 +0000 (+0900) Subject: device-manager: support external tv source device for tv product X-Git-Tag: accepted/tizen/unified/20230531.034435~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2c8c870aca034f51f9f1dbae7fefb150ef7410f7;p=platform%2Fcore%2Fmultimedia%2Fpulseaudio-modules-tizen.git device-manager: support external tv source device for tv product [Version] 15.0.39 [Issue Type] Product - tv source will use DEVICE_TYPE_FORWARDING - unnecessary public operation code related to DEVICE_TYPE_FORWARDING will be disabled for the tv product build. Change-Id: I18c18ffe5ff2b7d5417d45dd0b2868e5068393fa --- diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 3b41d31..5082fab 100644 --- a/packaging/pulseaudio-modules-tizen.spec +++ b/packaging/pulseaudio-modules-tizen.spec @@ -2,7 +2,7 @@ Name: pulseaudio-modules-tizen Summary: Pulseaudio modules for Tizen -Version: 15.0.38 +Version: 15.0.39 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ @@ -48,7 +48,7 @@ PulseAudio module-acm-sink for sending PCM data to ACM core. %build export CFLAGS="%{optflags} -fno-strict-aliasing -D__TIZEN__ -DSYSCONFDIR=\\\"%{_hal_sysconfdir}\\\" " %if "%{tizen_profile_name}" == "tv" -export CFLAGS+=" -DTIZEN_TV -D__TIZEN_TV_EXTERNAL_BT_SCO__ -D__TIZEN_TV_BUILTIN_MIC__"; +export CFLAGS+=" -DTIZEN_TV -D__TIZEN_TV_EXTERNAL_BT_SCO__ -D__TIZEN_TV_BUILTIN_MIC__ -D__TIZEN_TV_EXTERNAL_TV_SOURCE__"; %endif export LD_AS_NEEDED=0 diff --git a/src/device-manager.c b/src/device-manager.c index 1e05eba..0aa07f9 100644 --- a/src/device-manager.c +++ b/src/device-manager.c @@ -499,6 +499,18 @@ static bool pulse_device_is_btsco(pa_object *pdevice) { } #endif +#ifdef __TIZEN_TV_EXTERNAL_TV_SOURCE__ +static bool pulse_device_is_tvsource(pa_object *pdevice) { + pa_proplist *prop = pulse_device_get_proplist(pdevice); + + if (pa_sink_isinstance(pdevice)) + return false; + + return pa_safe_streq(pa_proplist_gets(prop, "device.type"), DEVICE_TYPE_FORWARDING); +} +#endif + + static bool pulse_device_is_hdmi(pa_object *pdevice) { const char *bus_path_name = NULL; pa_proplist *prop = pulse_device_get_proplist(pdevice); @@ -1205,6 +1217,11 @@ static const char* pulse_device_get_system_id(pa_object *pdevice) { prop = pulse_device_get_proplist(pdevice); +#ifdef __TIZEN_TV_EXTERNAL_TV_SOURCE__ + if (pulse_device_is_tvsource(pdevice)) + return pa_proplist_gets(prop, PA_PROP_DEVICE_DESCRIPTION); +#endif + if (pulse_device_is_usb(pdevice) || pulse_device_is_hdmi(pdevice)) return pa_proplist_gets(prop, "sysfs.path"); else if (pulse_device_is_bluez(pdevice)) @@ -1723,6 +1740,47 @@ static void handle_external_btsco_pulse_device(pa_object *pdevice, bool is_loade } #endif /* __TIZEN_TV_EXTERNAL_BT_SCO__ */ +#ifdef __TIZEN_TV_EXTERNAL_TV_SOURCE__ +static void handle_external_tvsource_pulse_device(pa_object *pdevice, bool is_loaded, pa_device_manager *dm) { + const char *name, *system_id; + dm_device_direction_t direction; + pa_tz_device *device; + + pa_assert(pdevice); + pa_assert(dm); + + pa_log_info("Handle tvsource pulse device"); + + system_id = pulse_device_get_system_id(pdevice); + direction = pulse_device_get_direction(pdevice); + + if (is_loaded) { + pa_tz_device_new_data data; + pa_proplist *prop; + + prop = pulse_device_get_proplist(pdevice); + name = pa_proplist_gets(prop, PA_PROP_DEVICE_DESCRIPTION); + + pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, NULL); + pa_tz_device_new_data_set_type(&data, DEVICE_TYPE_FORWARDING); + pa_tz_device_new_data_set_name(&data, name); + pa_tz_device_new_data_set_direction(&data, direction); + pa_tz_device_new_data_set_system_id(&data, system_id); + pa_tz_device_new_data_set_use_internal_codec(&data, false); + pa_tz_device_new_data_add_source(&data, DEVICE_ROLE_NORMAL, PA_SOURCE(pdevice)); + + pa_tz_device_new(&data); + pa_tz_device_new_data_done(&data); + } else { + if (!(device = device_list_get_device(dm, DEVICE_TYPE_FORWARDING, NULL, system_id))) + pa_log_warn("Can't get tvsource device for %s", system_id); + else + pa_tz_device_free(device); + } +} +#endif /* __TIZEN_TV_EXTERNAL_TV_SOURCE__ */ + + static void handle_internal_pulse_device(pa_object *pdevice, bool is_loaded, pa_device_manager *dm) { pa_tz_device *device; struct composite_type *ctype; @@ -1875,6 +1933,14 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source, if (pulse_device_is_monitor(PA_OBJECT(source))) return PA_HOOK_OK; +#ifdef __TIZEN_TV_EXTERNAL_TV_SOURCE__ + if (pulse_device_is_tvsource(PA_OBJECT(source))) { + pulse_device_set_use_internal_codec(PA_OBJECT(source), false); + handle_external_tvsource_pulse_device(PA_OBJECT(source), true, dm); + return PA_HOOK_OK; + } +#endif + if (pulse_device_is_usb(PA_OBJECT(source))) { pulse_device_set_use_internal_codec(PA_OBJECT(source), false); handle_usb_pulse_device(PA_OBJECT(source), true, dm); @@ -1899,6 +1965,7 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source, } else if (pulse_device_is_btsco(PA_OBJECT(source))) { pulse_device_set_use_internal_codec(PA_OBJECT(source), false); handle_external_btsco_pulse_device(PA_OBJECT(source), true, dm); + return PA_HOOK_OK; #endif } @@ -1917,6 +1984,13 @@ static pa_hook_result_t source_unlink_hook_callback(pa_core *c, pa_source *sourc if (pulse_device_is_monitor(PA_OBJECT(source))) return PA_HOOK_OK; +#ifdef __TIZEN_TV_EXTERNAL_TV_SOURCE__ + if (pulse_device_is_tvsource(PA_OBJECT(source))) { + handle_external_tvsource_pulse_device(PA_OBJECT(source), false, dm); + return PA_HOOK_OK; + } +#endif + if (pulse_device_is_usb(PA_OBJECT(source))) { handle_usb_pulse_device(PA_OBJECT(source), false, dm); return PA_HOOK_OK; @@ -2186,6 +2260,7 @@ static int _load_type_devices(device_type_info *type_info, bool is_playback, pa_ return 0; } +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ static pa_tz_device* _load_forwarding_device(pa_device_manager *dm) { pa_tz_device_new_data data; pa_tz_device *spk_device, *forwarding_device; @@ -2222,6 +2297,7 @@ static pa_tz_device* _load_forwarding_device(pa_device_manager *dm) { return forwarding_device; } +#endif /* Handle device connection detected through dbus. @@ -2275,8 +2351,10 @@ void handle_device_connected(pa_device_manager *dm, const char *type, const char pa_tz_device_new(&data); pa_tz_device_new_data_done(&data); +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ } else if (device_type_is_equal(type, DEVICE_TYPE_FORWARDING)) { _load_forwarding_device(dm); +#endif } else { dm_device_direction_t direction; bool use_internal_codec = true; @@ -2681,7 +2759,7 @@ static void device_type_status_init(pa_device_manager *manager) { } else if (device_type_is_equal(type, DEVICE_TYPE_HDMI)) { device_set_detected(manager, type, NULL, NULL, DEVICE_DISCONNECTED); - +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ } else if (device_type_is_equal(type, DEVICE_TYPE_FORWARDING)) { int miracast_wfd_status = 0; if (vconf_get_bool(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, &miracast_wfd_status) < 0) { @@ -2690,7 +2768,7 @@ static void device_type_status_init(pa_device_manager *manager) { } if (miracast_wfd_status == FORWARDING_CONNECTED) device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED); - +#endif } else { device_set_detected(manager, type, NULL, NULL, DEVICE_CONNECTED); } @@ -2936,10 +3014,11 @@ pa_tz_device* pa_device_manager_get_device_with_source(pa_source *source) { return source->device_item; } - +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ pa_tz_device* pa_device_manager_load_forwarding(pa_device_manager *dm) { return _load_forwarding_device(dm); } +#endif void pa_device_manager_unload_forwarding(pa_device_manager *dm) { pa_tz_device *forwarding_device; diff --git a/src/device-manager.h b/src/device-manager.h index 38c01b0..fa08d65 100644 --- a/src/device-manager.h +++ b/src/device-manager.h @@ -45,9 +45,11 @@ pa_tz_device* pa_device_manager_get_device_by_id(pa_device_manager *dm, uint32_t pa_tz_device* pa_device_manager_get_device_with_sink(pa_sink *sink); pa_tz_device* pa_device_manager_get_device_with_source(pa_source *source); +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ /* trigger for create/destroy forwarding device */ pa_tz_device* pa_device_manager_load_forwarding(pa_device_manager *dm); void pa_device_manager_unload_forwarding(pa_device_manager *dm); +#endif /* load pulse device */ pa_sink* pa_device_manager_load_sink(pa_device_manager *dm, const char *type, const char *role); diff --git a/src/stream-manager-priv.h b/src/stream-manager-priv.h index b7c019f..b4eb25e 100644 --- a/src/stream-manager-priv.h +++ b/src/stream-manager-priv.h @@ -253,7 +253,9 @@ struct _stream_manager { pa_hashmap *stream_parents; pa_hashmap *muted_streams; pa_hashmap *stream_duckings; +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ pa_idxset *mirroring_streams; +#endif cur_max_priority_stream cur_highest_priority; stream_restrictions restrictions; bool on_call; diff --git a/src/stream-manager.c b/src/stream-manager.c index 36351ed..c01afbb 100644 --- a/src/stream-manager.c +++ b/src/stream-manager.c @@ -1947,6 +1947,7 @@ ret_msg_t do_notify(pa_stream_manager *m, notify_command_type_t command, stream_ return ret; } +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ static void update_mirroring_streams(pa_stream_manager *m, pa_source_output *o, bool put) { const char *role; @@ -1987,6 +1988,7 @@ static int update_forwarding_device(pa_stream_manager *m, bool load) { return 0; } +#endif static void set_new_data_stream_to_null_sink_source(pa_stream_manager *m, void *stream, stream_type_t type) { pa_sink *null_sink; @@ -2076,9 +2078,11 @@ static process_stream_result_t handle_command_prepare(pa_stream_manager *m, void if (is_invalid_role(m, role)) return PROCESS_STREAM_RESULT_SKIP; +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ /* load forwarding device */ if (type == STREAM_SOURCE_OUTPUT && pa_safe_streq(role, STREAM_ROLE_LOOPBACK_MIRRORING)) update_forwarding_device(m, true); +#endif } /* update the priority of this stream */ if (!update_priority_of_stream(m, stream, type, role, is_new_data)) { @@ -2241,9 +2245,11 @@ static process_stream_result_t handle_command_change_route_by_stream_ended(pa_st } } +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ /* unload forwarding device */ if (type == STREAM_SOURCE_OUTPUT && pa_safe_streq(role, STREAM_ROLE_LOOPBACK_MIRRORING)) update_forwarding_device(m, false); +#endif /* skip roles */ if (is_invalid_role(m, role)) @@ -2783,7 +2789,9 @@ static pa_hook_result_t source_output_put_cb(pa_core *core, pa_source_output *o, pa_log_info("source-output(%p, index:%u)", o, o->index); +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ update_mirroring_streams(m, o, true); +#endif process_stream(m, o, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_ADD_STREAM, false); process_stream(m, o, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_UPDATE_VOLUME, false); if (is_stream_related_call_active_routing(PA_OBJECT(o))) { @@ -2804,7 +2812,9 @@ static pa_hook_result_t source_output_unlink_cb(pa_core *core, pa_source_output m->on_call = false; set_media_active_device(m); } +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ update_mirroring_streams(m, o, false); +#endif process_stream(m, o, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_ENDED, false); process_stream(m, o, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_REMOVE_STREAM, false); @@ -3928,7 +3938,9 @@ pa_stream_manager* pa_stream_manager_get(pa_core *c) { init_filters(m); m->stream_parents = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); m->muted_streams = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ m->mirroring_streams = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); +#endif m->stream_duckings = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); m->sink_input_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) sink_input_new_cb, m); @@ -4070,11 +4082,13 @@ void pa_stream_manager_unref(pa_stream_manager *m) { pa_hashmap_free(m->muted_streams); } +#ifndef __TIZEN_TV_EXTERNAL_TV_SOURCE__ if (m->mirroring_streams) { if (pa_idxset_size(m->mirroring_streams)) update_forwarding_device(m, false); pa_idxset_free(m->mirroring_streams, NULL); } +#endif if (m->stream_parents) pa_hashmap_free(m->stream_parents);