From: Seungbae Shin Date: Mon, 13 Jun 2022 12:37:50 +0000 (+0900) Subject: device-manager: Add builtin tv-mic support X-Git-Tag: submit/tizen/20220621.083533^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f8f4353d5463431b54d5ca119d60006df466fff;p=platform%2Fcore%2Fmultimedia%2Fpulseaudio-modules-tizen.git device-manager: Add builtin tv-mic support [Version] 15.0.18 [Issue Type] Improvement Change-Id: If35aa1bffa27588629124e97bf7249688782d492 --- diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index 994fa15..6ec8a2b 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.17 +Version: 15.0.18 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ @@ -45,7 +45,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"; + export CFLAGS+=" -DTIZEN_TV -D__TIZEN_TV_BUILTIN_MIC__"; %else export CFLAGS+=" -D__TIZEN_INTERNAL_BT_SCO__" %endif diff --git a/src/device-manager.c b/src/device-manager.c index 4ba4450..acd3c38 100644 --- a/src/device-manager.c +++ b/src/device-manager.c @@ -99,6 +99,9 @@ typedef enum dm_device_class_type { DM_DEVICE_CLASS_BT, DM_DEVICE_CLASS_NULL, DM_DEVICE_CLASS_ACM, +#ifdef __TIZEN_TV_BUILTIN_MIC__ + DM_DEVICE_CLASS_TVMIC, +#endif DM_DEVICE_CLASS_MAX, } dm_device_class_t; @@ -235,7 +238,14 @@ static const device_module_t module_table[] = { .module_name = { NULL, "module-acm-sink" }, .device_string = "acm", .custom_device_get_func = NULL + }, +#ifdef __TIZEN_TV_BUILTIN_MIC__ + [DM_DEVICE_CLASS_TVMIC] = { + .module_name = { "module-tizentv-builtin-source", NULL }, + .device_string = "tvmic", + .custom_device_get_func = NULL } +#endif }; void simple_device_dump(pa_log_level_t level, const char *prefix, int id, const char *type, const char *name, int direction, int state) { @@ -322,6 +332,10 @@ static dm_device_class_t device_string_get_class(const char *device_string) { return DM_DEVICE_CLASS_TIZEN; else if (device_string == strstr(device_string, "acm")) return DM_DEVICE_CLASS_ACM; +#ifdef __TIZEN_TV_BUILTIN_MIC__ + else if (device_string == strstr(device_string, "tvmic")) + return DM_DEVICE_CLASS_TVMIC; +#endif return DM_DEVICE_CLASS_NONE; } @@ -461,6 +475,18 @@ static bool pulse_device_is_rtsp(pa_object *pdevice) { return pa_safe_streq(pa_proplist_gets(prop, PA_PROP_DEVICE_API), DEVICE_API_RTSP); } +#ifdef __TIZEN_TV_BUILTIN_MIC__ +static bool pulse_device_is_tvmic(pa_object *pdevice) { + if (!pdevice) + return false; + + if (pa_sink_isinstance(pdevice)) + return false; + + return pa_safe_streq(PA_SOURCE(pdevice)->module->name, module_table[DM_DEVICE_CLASS_TVMIC].module_name[0]); +} +#endif + #ifndef __TIZEN_INTERNAL_BT_SCO__ static bool pulse_device_is_btsco(pa_object *pdevice) { pa_proplist *prop = pulse_device_get_proplist(pdevice); @@ -529,6 +555,10 @@ static dm_device_class_t pulse_device_get_class(pa_object *pdevice) { return DM_DEVICE_CLASS_BT; else if (pulse_device_is_acm(pdevice)) return DM_DEVICE_CLASS_ACM; +#ifdef __TIZEN_TV_BUILTIN_MIC__ + else if (pulse_device_is_tvmic(pdevice)) + return DM_DEVICE_CLASS_TVMIC; +#endif return DM_DEVICE_CLASS_NONE; } @@ -805,28 +835,32 @@ static int build_params_to_load_module(const char *device_string, const char *pa pa_assert(params); pa_assert(target); - if ((device_class != DM_DEVICE_CLASS_ALSA) && - (device_class != DM_DEVICE_CLASS_TIZEN) && - (device_class != DM_DEVICE_CLASS_ACM)) - return -1; - - if (device_class == DM_DEVICE_CLASS_ACM) { + switch (device_class) { + case DM_DEVICE_CLASS_ACM: +#ifdef __TIZEN_TV_BUILTIN_MIC__ + /* fall-through */ + case DM_DEVICE_CLASS_TVMIC: +#endif snprintf(target, DEVICE_PARAM_STRING_MAX, "%s ", params); - return 0; - } + break; + + case DM_DEVICE_CLASS_ALSA: + /* fall-through */ + case DM_DEVICE_CLASS_TIZEN: + if (device_string_get_name(device_string, device_name) < 0) { + pa_log_error("Invalid device string '%s'", device_string); + return -1; + } + + snprintf(target, DEVICE_PARAM_STRING_MAX, "device=%s%s %s", + (device_class == DM_DEVICE_CLASS_ALSA) ? "hw:" : "", device_name, params); + break; - if (device_string_get_name(device_string, device_name) < 0) { - pa_log_error("Invalid device string '%s'", device_string); + default: + pa_log_error("unexpected device_class(%d)", device_class); return -1; } - 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) - snprintf(target, DEVICE_PARAM_STRING_MAX, "device=%s ", device_name); - - strncat(target, params, DEVICE_PARAM_STRING_MAX - strlen(target)); - return 0; } @@ -1783,7 +1817,11 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source, pulse_device_set_use_internal_codec(PA_OBJECT(source), false); handle_bt_pulse_device(PA_OBJECT(source), true, dm); return PA_HOOK_OK; - } else if (pulse_device_is_alsa(PA_OBJECT(source)) || pulse_device_is_tizenaudio(PA_OBJECT(source))) { + } else if (pulse_device_is_alsa(PA_OBJECT(source)) || +#ifdef __TIZEN_TV_BUILTIN_MIC__ + pulse_device_is_tvmic(PA_OBJECT(source)) || +#endif + pulse_device_is_tizenaudio(PA_OBJECT(source))) { pulse_device_set_use_internal_codec(PA_OBJECT(source), true); handle_internal_pulse_device(PA_OBJECT(source), true, dm); return PA_HOOK_OK; @@ -1831,7 +1869,11 @@ static pa_hook_result_t source_unlink_hook_callback(pa_core *c, pa_source *sourc pa_log_warn("tunnel but not remote....ignore this"); } return PA_HOOK_OK; - } else if (pulse_device_is_alsa(PA_OBJECT(source)) || pulse_device_is_tizenaudio(PA_OBJECT(source))) { + } else if (pulse_device_is_alsa(PA_OBJECT(source)) || +#ifdef __TIZEN_TV_BUILTIN_MIC__ + pulse_device_is_tvmic(PA_OBJECT(source)) || +#endif + pulse_device_is_tizenaudio(PA_OBJECT(source))) { handle_internal_pulse_device(PA_OBJECT(source), false, dm); return PA_HOOK_OK; } else if (pulse_device_is_rtsp(PA_OBJECT(source))) {