From 7a395bccaf3a44478e08c1721cee4bfe0fdcc92e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 6 Feb 2020 16:56:19 +0100 Subject: [PATCH] improve v2 compat mode Always send the server types when we got the first client types and don't rely on the message sequence number. Add some more types in the typemap. --- .../module-protocol-native/v0/protocol-native.c | 12 ++++++++---- src/modules/module-protocol-native/v0/typemap.h | 4 ++-- src/pipewire/private.h | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/modules/module-protocol-native/v0/protocol-native.c b/src/modules/module-protocol-native/v0/protocol-native.c index 9929ff6cc..5f310aed2 100644 --- a/src/modules/module-protocol-native/v0/protocol-native.c +++ b/src/modules/module-protocol-native/v0/protocol-native.c @@ -77,14 +77,14 @@ update_types_server(struct pw_resource *resource) static void core_marshal_info(void *object, const struct pw_core_info *info) { struct pw_resource *resource = object; + struct pw_impl_client *client = pw_resource_get_client(resource); + struct protocol_compat_v2 *compat_v2 = client->compat_v2; struct spa_pod_builder *b; uint32_t i, n_items; uint64_t change_mask = 0; struct spa_pod_frame f; struct pw_protocol_native_message *msg; - b = pw_protocol_native_begin_resource(resource, PW_CORE_V0_EVENT_INFO, &msg); - #define PW_CORE_V0_CHANGE_MASK_USER_NAME (1 << 0) #define PW_CORE_V0_CHANGE_MASK_HOST_NAME (1 << 1) #define PW_CORE_V0_CHANGE_MASK_VERSION (1 << 2) @@ -92,15 +92,16 @@ static void core_marshal_info(void *object, const struct pw_core_info *info) #define PW_CORE_V0_CHANGE_MASK_COOKIE (1 << 4) #define PW_CORE_V0_CHANGE_MASK_PROPS (1 << 5) - if (msg->seq == 0) { + if (compat_v2->send_types) { update_types_server(resource); - b = pw_protocol_native_begin_resource(resource, PW_CORE_V0_EVENT_INFO, &msg); change_mask |= PW_CORE_V0_CHANGE_MASK_USER_NAME | PW_CORE_V0_CHANGE_MASK_HOST_NAME | PW_CORE_V0_CHANGE_MASK_VERSION | PW_CORE_V0_CHANGE_MASK_NAME | PW_CORE_V0_CHANGE_MASK_COOKIE; + compat_v2->send_types = false; } + b = pw_protocol_native_begin_resource(resource, PW_CORE_V0_EVENT_INFO, &msg); n_items = info->props ? info->props->n_items : 0; @@ -711,6 +712,9 @@ static int core_demarshal_update_types_server(void *object, const struct pw_prot NULL) < 0) return -EINVAL; + if (first_id == 0) + compat_v2->send_types = true; + types = alloca(n_types * sizeof(char *)); for (i = 0; i < n_types; i++) { if (spa_pod_parser_get(&prs, "s", &types[i], NULL) < 0) diff --git a/src/modules/module-protocol-native/v0/typemap.h b/src/modules/module-protocol-native/v0/typemap.h index eaaa7ac1c..0efd80d0c 100644 --- a/src/modules/module-protocol-native/v0/typemap.h +++ b/src/modules/module-protocol-native/v0/typemap.h @@ -139,8 +139,8 @@ const struct type_info { { "Spa:POD:Object:Param:Format:Video:format", SPA_TYPE_INFO_FORMAT_VIDEO_BASE "format", SPA_FORMAT_VIDEO_format,}, { "Spa:POD:Object:Param:Format:Video:size", SPA_TYPE_INFO_FORMAT_VIDEO_BASE "size", SPA_FORMAT_VIDEO_size,}, { "Spa:POD:Object:Param:Format:Video:framerate", SPA_TYPE_INFO_FORMAT_VIDEO_BASE "framerate", SPA_FORMAT_VIDEO_framerate}, - { "Spa:POD:Object:Param:Format:Video:max-framerate", }, - { "Spa:POD:Object:Param:Format:Video:views", }, + { "Spa:POD:Object:Param:Format:Video:max-framerate", SPA_TYPE_INFO_FORMAT_VIDEO_BASE "maxFramerate", SPA_FORMAT_VIDEO_maxFramerate}, + { "Spa:POD:Object:Param:Format:Video:views", SPA_TYPE_INFO_FORMAT_VIDEO_BASE "views", SPA_FORMAT_VIDEO_views}, { "Spa:POD:Object:Param:Format:Video:interlace-mode", }, { "Spa:POD:Object:Param:Format:Video:pixel-aspect-ratio", }, { "Spa:POD:Object:Param:Format:Video:multiview-mode", }, diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 97f8aadb9..7a1d720ac 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -100,6 +100,7 @@ typedef uint32_t (*pw_permission_func_t) (struct pw_global *global, struct protocol_compat_v2 { /* v2 typemap */ struct pw_map types; + unsigned int send_types:1; }; #define pw_impl_core_emit(s,m,v,...) spa_hook_list_call(&s->listener_list, struct pw_impl_core_events, m, v, ##__VA_ARGS__)