From: Seungbae Shin Date: Tue, 10 Jul 2018 02:54:24 +0000 (+0900) Subject: device-manager: Add DEVICE_TYPE_RAOP X-Git-Tag: accepted/tizen/unified/20180928.142113^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F96%2F188796%2F2;p=platform%2Fcore%2Fmultimedia%2Fpulseaudio-modules-tizen.git device-manager: Add DEVICE_TYPE_RAOP [Version] 11.1.26 [Issue type] Feature Change-Id: I6ee61d3a0837dca6b1061153fb5c445dc0b7d3de --- diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index c0eb8bd..86cd8c9 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.25 +Version: 11.1.26 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/device-manager.c b/src/device-manager.c index 755b7ed..98abee1 100644 --- a/src/device-manager.c +++ b/src/device-manager.c @@ -78,6 +78,7 @@ #define DEVICE_API_BLUEZ "bluez" #define DEVICE_API_ALSA "alsa" #define DEVICE_API_NULL "null" +#define DEVICE_API_RAOP "raop" #define DEVICE_BUS_USB "usb" #define DEVICE_CLASS_SOUND "sound" #define DEVICE_CLASS_MONITOR "monitor" @@ -424,6 +425,16 @@ static bool pulse_device_is_bluez(pa_object *pdevice) { } } +static bool pulse_device_is_raop(pa_object *pdevice) { + pa_proplist *prop = pulse_device_get_proplist(pdevice); + + if (!prop) + return false; + + return pa_safe_streq(pa_proplist_gets(prop, PA_PROP_DEVICE_API), DEVICE_API_RAOP); +} + + static bool pulse_device_is_tizenaudio(pa_object *pdevice) { if (!pdevice) return false; @@ -1147,6 +1158,8 @@ static const char* pulse_device_get_system_id(pa_object *pdevice) { return pa_proplist_gets(prop, "sysfs.path"); else if (pulse_device_is_bluez(pdevice)) return pa_proplist_gets(prop, "bluez.path"); + else if (pulse_device_is_raop(pdevice)) + return pa_proplist_gets(prop, PA_PROP_DEVICE_STRING); else return NULL; } @@ -1444,6 +1457,38 @@ static void handle_bt_pulse_device(pa_object *pdevice, bool is_loaded, pa_device } } +static void handle_raop_pulse_device(pa_object *pdevice, bool is_loaded, pa_device_manager *dm) { + pa_tz_device *device; + const char *system_id; + + pa_assert(pdevice); + pa_assert(dm); + + pa_log_info("Handle RAOP pulse device"); + + system_id = pulse_device_get_system_id(pdevice); + + if (is_loaded) { + pa_tz_device_new_data data; + + pa_proplist *prop = pulse_device_get_proplist(pdevice); + const char *name = pa_proplist_gets(prop, PA_PROP_DEVICE_DESCRIPTION); + + pa_tz_device_new_data_init(&data, dm->device_list, dm->comm, dm->dbus_conn); + _fill_new_data_basic(&data, DEVICE_TYPE_RAOP, DM_DEVICE_DIRECTION_OUT, false, dm); + pa_tz_device_new_data_set_name(&data, name); + pa_tz_device_new_data_set_system_id(&data, system_id); + pa_tz_device_new_data_add_sink(&data, DEVICE_ROLE_NORMAL, PA_SINK(pdevice)); + pa_tz_device_new(&data); + pa_tz_device_new_data_done(&data); + } else { + if (!(device = device_list_get_device(dm, DEVICE_TYPE_RAOP, system_id))) + pa_log_warn("Can't get RAOP device for %s", system_id); + else + pa_tz_device_free(device); + } +} + static void handle_internal_pulse_device(pa_object *pdevice, bool is_loaded, pa_device_manager *dm) { pa_tz_device *device; struct composite_type *ctype; @@ -1515,6 +1560,10 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, pa_dev pulse_device_set_use_internal_codec(PA_OBJECT(sink), false); handle_bt_pulse_device(PA_OBJECT(sink), true, dm); return PA_HOOK_OK; + } else if (pulse_device_is_raop(PA_OBJECT(sink))) { + pulse_device_set_use_internal_codec(PA_OBJECT(sink), false); + handle_raop_pulse_device(PA_OBJECT(sink), true, dm); + return PA_HOOK_OK; } else if (pulse_device_is_alsa(PA_OBJECT(sink)) || pulse_device_is_tizenaudio(PA_OBJECT(sink))) { pulse_device_set_use_internal_codec(PA_OBJECT(sink), true); handle_internal_pulse_device(PA_OBJECT(sink), true, dm); @@ -1542,6 +1591,9 @@ static pa_hook_result_t sink_unlink_hook_callback(pa_core *c, pa_sink *sink, pa_ } else if (pulse_device_is_bluez(PA_OBJECT(sink))) { handle_bt_pulse_device(PA_OBJECT(sink), false, dm); return PA_HOOK_OK; + } else if (pulse_device_is_raop(PA_OBJECT(sink))) { + handle_raop_pulse_device(PA_OBJECT(sink), false, dm); + return PA_HOOK_OK; } else if (pulse_device_is_alsa(PA_OBJECT(sink)) || pulse_device_is_tizenaudio(PA_OBJECT(sink))) { handle_internal_pulse_device(PA_OBJECT(sink), false, dm); return PA_HOOK_OK; diff --git a/src/module-tizenaudio-policy.c b/src/module-tizenaudio-policy.c index 3456371..ba9bb16 100644 --- a/src/module-tizenaudio-policy.c +++ b/src/module-tizenaudio-policy.c @@ -111,6 +111,7 @@ typedef enum _device_type { DEVICE_HDMI, DEVICE_FORWARDING, DEVICE_USB_AUDIO, + DEVICE_RAOP, DEVICE_UNKNOWN, DEVICE_MAX, } device_type_t; @@ -143,6 +144,9 @@ static device_type_t convert_device_type_str(const char *device) return DEVICE_FORWARDING; else if (pa_streq(device, DEVICE_TYPE_USB_AUDIO)) return DEVICE_USB_AUDIO; + else if (pa_streq(device, DEVICE_TYPE_RAOP)) + return DEVICE_RAOP; + pa_log_warn("unknown device (%s)", device); return DEVICE_UNKNOWN; diff --git a/src/tizen-device-def.c b/src/tizen-device-def.c index 37a192d..acd1fc2 100644 --- a/src/tizen-device-def.c +++ b/src/tizen-device-def.c @@ -61,6 +61,8 @@ bool device_type_is_valid(const char *device_type) { return true; else if (pa_streq(device_type, DEVICE_TYPE_USB_AUDIO)) return true; + else if (pa_streq(device_type, DEVICE_TYPE_RAOP)) + return true; else return false; } @@ -72,6 +74,8 @@ bool device_type_is_use_external_card(const char *device_type) { return true; else if (pa_streq(device_type, DEVICE_TYPE_BT_A2DP)) return true; + else if (pa_streq(device_type, DEVICE_TYPE_RAOP)) + return true; else return false; } @@ -85,6 +89,8 @@ bool device_type_is_avail_multi_device(const char *device_type) { return true; else if (pa_streq(device_type, DEVICE_TYPE_USB_AUDIO)) return true; + else if (pa_streq(device_type, DEVICE_TYPE_RAOP)) + return true; else return false; } @@ -151,6 +157,8 @@ bool device_type_is_valid_direction(const char *device_type, dm_device_direction return direction == DM_DEVICE_DIRECTION_BOTH; else if (pa_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)) + return direction == DM_DEVICE_DIRECTION_OUT; else return false; } diff --git a/src/tizen-device-def.h b/src/tizen-device-def.h index 4688cec..d1bd862 100644 --- a/src/tizen-device-def.h +++ b/src/tizen-device-def.h @@ -13,6 +13,7 @@ #define DEVICE_TYPE_HDMI "hdmi" #define DEVICE_TYPE_FORWARDING "forwarding" #define DEVICE_TYPE_USB_AUDIO "usb-audio" +#define DEVICE_TYPE_RAOP "raop" #define DEVICE_TYPE_NONE "none" #define DEVICE_ROLE_NORMAL "normal"