From 8fbcb0fef1d5ac74c06e7a705570c7465f77cc3c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 9 Mar 2017 19:21:50 +0100 Subject: [PATCH] remove some unused event and seqnum --- pinos/client/connection.c | 6 +-- pinos/client/context.c | 17 ++----- pinos/client/interfaces.h | 12 +---- pinos/client/protocol-native.c | 37 ++-------------- pinos/client/proxy.c | 1 + pinos/client/stream.c | 6 +-- pinos/server/client-node.c | 3 +- pinos/server/core.c | 6 --- pinos/server/protocol-native.c | 81 ++++++++++++---------------------- 9 files changed, 42 insertions(+), 127 deletions(-) diff --git a/pinos/client/connection.c b/pinos/client/connection.c index 8a506dbe1..790a7878c 100644 --- a/pinos/client/connection.c +++ b/pinos/client/connection.c @@ -78,8 +78,6 @@ pinos_connection_add_fd (PinosConnection *conn, return index; } -#define PINOS_DEBUG_MESSAGE(format,args...) pinos_log_trace(format,##args) - static void * connection_ensure_size (PinosConnection *conn, ConnectionBuffer *buf, size_t size) { @@ -129,7 +127,7 @@ refill_buffer (PinosConnection *conn, ConnectionBuffer *buf) buf->n_fds = (cmsg->cmsg_len - ((char *)CMSG_DATA (cmsg) - (char *)cmsg)) / sizeof (int); memcpy (buf->fds, CMSG_DATA (cmsg), buf->n_fds * sizeof (int)); } - PINOS_DEBUG_MESSAGE ("connection %p: %d read %zd bytes and %d fds", conn, conn->fd, len, buf->n_fds); + pinos_log_trace ("connection %p: %d read %zd bytes and %d fds", conn, conn->fd, len, buf->n_fds); return true; @@ -342,7 +340,7 @@ pinos_connection_flush (PinosConnection *conn) } break; } - PINOS_DEBUG_MESSAGE ("connection %p: %d written %zd bytes and %u fds", conn, conn->fd, len, buf->n_fds); + pinos_log_trace ("connection %p: %d written %zd bytes and %u fds", conn, conn->fd, len, buf->n_fds); buf->buffer_size -= len; buf->n_fds = 0; diff --git a/pinos/client/context.c b/pinos/client/context.c index 4d9b4d32d..264f6ed3f 100644 --- a/pinos/client/context.c +++ b/pinos/client/context.c @@ -126,8 +126,6 @@ core_event_done (void *object, PinosContext *this = proxy->context; if (seq == 0) { - pinos_core_do_sync (this->core_proxy, 1); - } else if (seq == 1) { context_set_state (this, PINOS_CONTEXT_STATE_CONNECTED, NULL); } } @@ -193,12 +191,6 @@ static const PinosModuleEvents module_events = { &module_event_info, }; -static void -node_event_done (void *object, - uint32_t seq) -{ -} - static void node_event_info (void *object, PinosNodeInfo *info) @@ -224,7 +216,6 @@ node_event_info (void *object, } static const PinosNodeEvents node_events = { - &node_event_done, &node_event_info }; @@ -403,10 +394,8 @@ on_context_data (SpaSource *source, demarshal = proxy->iface->events; if (demarshal[opcode]) { - if (!demarshal[opcode] (proxy, message, size)) { + if (!demarshal[opcode] (proxy, message, size)) pinos_log_error ("context %p: invalid message received %u", this, opcode); - spa_debug_pod (message); - } } else pinos_log_error ("context %p: function %d not implemented", this, opcode); @@ -612,8 +601,10 @@ pinos_context_connect_fd (PinosContext *context, context->registry_proxy->implementation = ®istry_events; pinos_core_do_get_registry (context->core_proxy, - 0, context->registry_proxy->id); + + pinos_core_do_sync (context->core_proxy, 0); + return true; no_registry: diff --git a/pinos/client/interfaces.h b/pinos/client/interfaces.h index ecbe16f1e..0eb1ad409 100644 --- a/pinos/client/interfaces.h +++ b/pinos/client/interfaces.h @@ -48,16 +48,13 @@ typedef struct { void (*sync) (void *object, uint32_t seq); void (*get_registry) (void *object, - uint32_t seq, uint32_t new_id); void (*create_node) (void *object, - uint32_t seq, const char *factory_name, const char *name, const SpaDict *props, uint32_t new_id); void (*create_client_node) (void *object, - uint32_t seq, const char *name, const SpaDict *props, uint32_t new_id); @@ -114,13 +111,10 @@ typedef struct { #define pinos_module_notify_info(r,...) ((PinosModuleEvents*)r->iface->events)->info(r,__VA_ARGS__) typedef struct { - void (*done) (void *object, - uint32_t seq); void (*info) (void *object, PinosNodeInfo *info); } PinosNodeEvents; -#define pinos_node_notify_done(r,...) ((PinosNodeEvents*)r->iface->events)->done(r,__VA_ARGS__) #define pinos_node_notify_info(r,...) ((PinosNodeEvents*)r->iface->events)->info(r,__VA_ARGS__) struct _PinosClientNodeBuffer { @@ -157,19 +151,17 @@ typedef struct { SpaNodeState state); void (*event) (void *object, SpaNodeEvent *event); - void (*destroy) (void *object, - uint32_t seq); + void (*destroy) (void *object); } PinosClientNodeMethods; #define pinos_client_node_do_update(r,...) ((PinosClientNodeMethods*)r->iface->methods)->update(r,__VA_ARGS__) #define pinos_client_node_do_port_update(r,...) ((PinosClientNodeMethods*)r->iface->methods)->port_update(r,__VA_ARGS__) #define pinos_client_node_do_state_change(r,...) ((PinosClientNodeMethods*)r->iface->methods)->state_change(r,__VA_ARGS__) #define pinos_client_node_do_event(r,...) ((PinosClientNodeMethods*)r->iface->methods)->event(r,__VA_ARGS__) -#define pinos_client_node_do_destroy(r,...) ((PinosClientNodeMethods*)r->iface->methods)->destroy(r,__VA_ARGS__) +#define pinos_client_node_do_destroy(r) ((PinosClientNodeMethods*)r->iface->methods)->destroy(r) typedef struct { void (*done) (void *object, - uint32_t seq, int datafd); void (*event) (void *object, const SpaNodeEvent *event); diff --git a/pinos/client/protocol-native.c b/pinos/client/protocol-native.c index 339f23d2f..8e6c21cc4 100644 --- a/pinos/client/protocol-native.c +++ b/pinos/client/protocol-native.c @@ -94,7 +94,6 @@ core_marshal_sync (void *object, static void core_marshal_get_registry (void *object, - uint32_t seq, uint32_t new_id) { PinosProxy *proxy = object; @@ -104,7 +103,6 @@ core_marshal_get_registry (void *object, spa_pod_builder_add (&b.b, SPA_POD_TYPE_STRUCT, &f, - SPA_POD_TYPE_INT, seq, SPA_POD_TYPE_INT, new_id, -SPA_POD_TYPE_STRUCT, &f, 0); @@ -114,7 +112,6 @@ core_marshal_get_registry (void *object, static void core_marshal_create_node (void *object, - uint32_t seq, const char *factory_name, const char *name, const SpaDict *props, @@ -130,7 +127,6 @@ core_marshal_create_node (void *object, spa_pod_builder_add (&b.b, SPA_POD_TYPE_STRUCT, &f, - SPA_POD_TYPE_INT, seq, SPA_POD_TYPE_STRING, factory_name, SPA_POD_TYPE_STRING, name, SPA_POD_TYPE_INT, n_items, 0); @@ -150,7 +146,6 @@ core_marshal_create_node (void *object, static void core_marshal_create_client_node (void *object, - uint32_t seq, const char *name, const SpaDict *props, uint32_t new_id) @@ -165,7 +160,6 @@ core_marshal_create_client_node (void *object, spa_pod_builder_add (&b.b, SPA_POD_TYPE_STRUCT, &f, - SPA_POD_TYPE_INT, seq, SPA_POD_TYPE_STRING, name, SPA_POD_TYPE_INT, n_items, 0); @@ -314,25 +308,6 @@ module_demarshal_info (void *object, return true; } -static bool -node_demarshal_done (void *object, - void *data, - size_t size) -{ - PinosProxy *proxy = object; - SpaPODIter it; - uint32_t seq; - - if (!spa_pod_iter_struct (&it, data, size) || - !spa_pod_iter_get (&it, - SPA_POD_TYPE_INT, &seq, - 0)) - return false; - - ((PinosNodeEvents*)proxy->implementation)->done (proxy, seq); - return true; -} - static bool node_demarshal_info (void *object, void *data, @@ -517,8 +492,7 @@ client_node_marshal_event (void *object, } static void -client_node_marshal_destroy (void *object, - uint32_t seq) +client_node_marshal_destroy (void *object) { PinosProxy *proxy = object; PinosConnection *connection = proxy->context->protocol_private; @@ -527,7 +501,6 @@ client_node_marshal_destroy (void *object, spa_pod_builder_add (&b.b, SPA_POD_TYPE_STRUCT, &f, - SPA_POD_TYPE_INT, seq, -SPA_POD_TYPE_STRUCT, &f, 0); @@ -542,18 +515,17 @@ client_node_demarshal_done (void *object, PinosProxy *proxy = object; SpaPODIter it; PinosConnection *connection = proxy->context->protocol_private; - int32_t seq, idx; + int32_t idx; int fd; if (!spa_pod_iter_struct (&it, data, size) || !spa_pod_iter_get (&it, - SPA_POD_TYPE_INT, &seq, SPA_POD_TYPE_INT, &idx, 0)) return false; fd = pinos_connection_get_fd (connection, idx); - ((PinosClientNodeEvents*)proxy->implementation)->done (proxy, seq, fd); + ((PinosClientNodeEvents*)proxy->implementation)->done (proxy, fd); return true; } @@ -1031,13 +1003,12 @@ static const PinosInterface pinos_protocol_native_client_module_interface = { }; static const PinosDemarshalFunc pinos_protocol_native_client_node_demarshal[] = { - &node_demarshal_done, &node_demarshal_info, }; static const PinosInterface pinos_protocol_native_client_node_interface = { 0, NULL, - 2, pinos_protocol_native_client_node_demarshal, + 1, pinos_protocol_native_client_node_demarshal, }; static const PinosDemarshalFunc pinos_protocol_native_client_client_demarshal[] = { diff --git a/pinos/client/proxy.c b/pinos/client/proxy.c index 3028589eb..828d84ea6 100644 --- a/pinos/client/proxy.c +++ b/pinos/client/proxy.c @@ -19,6 +19,7 @@ #include #include +#include typedef struct { PinosProxy this; diff --git a/pinos/client/stream.c b/pinos/client/stream.c index d3cfb167d..91cab2042 100644 --- a/pinos/client/stream.c +++ b/pinos/client/stream.c @@ -64,8 +64,6 @@ typedef struct SpaNodeState node_state; - uint32_t seq; - uint32_t n_possible_formats; SpaFormat **possible_formats; @@ -661,7 +659,6 @@ handle_node_command (PinosStream *stream, static void client_node_done (void *object, - uint32_t seq, int datafd) { PinosProxy *proxy = object; @@ -1000,7 +997,6 @@ pinos_stream_connect (PinosStream *stream, impl->node_proxy->implementation = &client_node_events; pinos_core_do_create_client_node (stream->context->core_proxy, - ++impl->seq, "client-node", &stream->properties->dict, impl->node_proxy->id); @@ -1101,7 +1097,7 @@ pinos_stream_disconnect (PinosStream *stream) unhandle_socket (stream); - pinos_client_node_do_destroy (impl->node_proxy, ++impl->seq); + pinos_client_node_do_destroy (impl->node_proxy); return true; } diff --git a/pinos/server/client-node.c b/pinos/server/client-node.c index 5d35ddd38..6a79203a1 100644 --- a/pinos/server/client-node.c +++ b/pinos/server/client-node.c @@ -971,8 +971,7 @@ client_node_event (void *object, } static void -client_node_destroy (void *object, - uint32_t seq) +client_node_destroy (void *object) { PinosResource *resource = object; PinosClientNode *node = resource->object; diff --git a/pinos/server/core.c b/pinos/server/core.c index a580a8ae4..bbebed7cf 100644 --- a/pinos/server/core.c +++ b/pinos/server/core.c @@ -100,7 +100,6 @@ core_sync (void *object, static void core_get_registry (void *object, - uint32_t seq, uint32_t new_id) { PinosResource *resource = object; @@ -126,8 +125,6 @@ core_get_registry (void *object, global->id, spa_id_map_get_uri (this->uri.map, global->type)); - pinos_core_notify_done (client->core_resource, seq); - return; no_mem: @@ -140,7 +137,6 @@ no_mem: static void core_create_node (void *object, - uint32_t seq, const char *factory_name, const char *name, const SpaDict *props, @@ -157,7 +153,6 @@ core_create_node (void *object, static void core_create_client_node (void *object, - uint32_t seq, const char *name, const SpaDict *props, uint32_t new_id) @@ -194,7 +189,6 @@ core_create_client_node (void *object, } pinos_client_node_notify_done (node->resource, - seq, data_fd); return; diff --git a/pinos/server/protocol-native.c b/pinos/server/protocol-native.c index 102d95c52..0e8b953a3 100644 --- a/pinos/server/protocol-native.c +++ b/pinos/server/protocol-native.c @@ -47,7 +47,7 @@ write_pod (SpaPODBuilder *b, uint32_t ref, const void *data, uint32_t size) static void core_marshal_info (void *object, - PinosCoreInfo *info) + PinosCoreInfo *info) { PinosResource *resource = object; PinosConnection *connection = resource->client->protocol_private; @@ -81,7 +81,7 @@ core_marshal_info (void *object, static void core_marshal_done (void *object, - uint32_t seq) + uint32_t seq) { PinosResource *resource = object; PinosConnection *connection = resource->client->protocol_private; @@ -98,9 +98,9 @@ core_marshal_done (void *object, static void core_marshal_error (void *object, - uint32_t id, - SpaResult res, - const char *error, ...) + uint32_t id, + SpaResult res, + const char *error, ...) { PinosResource *resource = object; PinosConnection *connection = resource->client->protocol_private; @@ -126,7 +126,7 @@ core_marshal_error (void *object, static void core_marshal_remove_id (void *object, - uint32_t id) + uint32_t id) { PinosResource *resource = object; PinosConnection *connection = resource->client->protocol_private; @@ -171,8 +171,8 @@ core_demarshal_client_update (void *object, static bool core_demarshal_sync (void *object, - void *data, - size_t size) + void *data, + size_t size) { PinosResource *resource = object; SpaPODIter it; @@ -190,38 +190,36 @@ core_demarshal_sync (void *object, static bool core_demarshal_get_registry (void *object, - void *data, - size_t size) + void *data, + size_t size) { PinosResource *resource = object; SpaPODIter it; - int32_t seq, new_id; + int32_t new_id; if (!spa_pod_iter_struct (&it, data, size) || !spa_pod_iter_get (&it, - SPA_POD_TYPE_INT, &seq, SPA_POD_TYPE_INT, &new_id, 0)) return false; - ((PinosCoreMethods*)resource->implementation)->get_registry (resource, seq, new_id); + ((PinosCoreMethods*)resource->implementation)->get_registry (resource, new_id); return true; } static bool core_demarshal_create_node (void *object, - void *data, - size_t size) + void *data, + size_t size) { PinosResource *resource = object; SpaPODIter it; - uint32_t seq, new_id, i; + uint32_t new_id, i; const char *factory_name, *name; SpaDict props; if (!spa_pod_iter_struct (&it, data, size) || !spa_pod_iter_get (&it, - SPA_POD_TYPE_INT, &seq, SPA_POD_TYPE_STRING, &factory_name, SPA_POD_TYPE_STRING, &name, SPA_POD_TYPE_INT, &props.n_items, @@ -240,7 +238,6 @@ core_demarshal_create_node (void *object, return false; ((PinosCoreMethods*)resource->implementation)->create_node (resource, - seq, factory_name, name, &props, @@ -250,18 +247,17 @@ core_demarshal_create_node (void *object, static bool core_demarshal_create_client_node (void *object, - void *data, - size_t size) + void *data, + size_t size) { PinosResource *resource = object; SpaPODIter it; - uint32_t seq, new_id, i; + uint32_t new_id, i; const char *name; SpaDict props; if (!spa_pod_iter_struct (&it, data, size) || !spa_pod_iter_get (&it, - SPA_POD_TYPE_INT, &seq, SPA_POD_TYPE_STRING, &name, SPA_POD_TYPE_INT, &props.n_items, 0)) @@ -279,7 +275,6 @@ core_demarshal_create_client_node (void *object, return false; ((PinosCoreMethods*)resource->implementation)->create_client_node (resource, - seq, name, &props, new_id); @@ -288,8 +283,8 @@ core_demarshal_create_client_node (void *object, static void registry_marshal_global (void *object, - uint32_t id, - const char *type) + uint32_t id, + const char *type) { PinosResource *resource = object; PinosConnection *connection = resource->client->protocol_private; @@ -307,7 +302,7 @@ registry_marshal_global (void *object, static void registry_marshal_global_remove (void *object, - uint32_t id) + uint32_t id) { PinosResource *resource = object; PinosConnection *connection = resource->client->protocol_private; @@ -324,8 +319,8 @@ registry_marshal_global_remove (void *object, static bool registry_demarshal_bind (void *object, - void *data, - size_t size) + void *data, + size_t size) { PinosResource *resource = object; SpaPODIter it; @@ -374,23 +369,6 @@ module_marshal_info (void *object, pinos_connection_end_write (connection, resource->id, 0, b.b.offset); } -static void -node_marshal_done (void *object, - uint32_t seq) -{ - PinosResource *resource = object; - PinosConnection *connection = resource->client->protocol_private; - Builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; - - spa_pod_builder_add (&b.b, - SPA_POD_TYPE_STRUCT, &f, - SPA_POD_TYPE_INT, seq, - -SPA_POD_TYPE_STRUCT, &f, 0); - - pinos_connection_end_write (connection, resource->id, 0, b.b.offset); -} - static void node_marshal_info (void *object, PinosNodeInfo *info) @@ -435,7 +413,7 @@ node_marshal_info (void *object, } spa_pod_builder_add (&b.b, -SPA_POD_TYPE_STRUCT, &f, 0); - pinos_connection_end_write (connection, resource->id, 1, b.b.offset); + pinos_connection_end_write (connection, resource->id, 0, b.b.offset); } static void @@ -468,7 +446,6 @@ client_marshal_info (void *object, static void client_node_marshal_done (void *object, - uint32_t seq, int datafd) { PinosResource *resource = object; @@ -478,7 +455,6 @@ client_node_marshal_done (void *object, spa_pod_builder_add (&b.b, SPA_POD_TYPE_STRUCT, &f, - SPA_POD_TYPE_INT, seq, SPA_POD_TYPE_INT, pinos_connection_add_fd (connection, datafd), -SPA_POD_TYPE_STRUCT, &f, 0); @@ -884,13 +860,11 @@ client_node_demarshal_destroy (void *object, { PinosResource *resource = object; SpaPODIter it; - uint32_t seq; - if (!spa_pod_iter_struct (&it, data, size) || - !spa_pod_iter_get (&it, SPA_POD_TYPE_INT, &seq, 0)) + if (!spa_pod_iter_struct (&it, data, size)) return false; - ((PinosClientNodeMethods*)resource->implementation)->destroy (resource, seq); + ((PinosClientNodeMethods*)resource->implementation)->destroy (resource); return true; } @@ -960,13 +934,12 @@ const PinosInterface pinos_protocol_native_server_module_interface = { }; static const PinosNodeEvents pinos_protocol_native_server_node_events = { - &node_marshal_done, &node_marshal_info, }; const PinosInterface pinos_protocol_native_server_node_interface = { 0, NULL, - 2, &pinos_protocol_native_server_node_events, + 1, &pinos_protocol_native_server_node_events, }; static const PinosClientEvents pinos_protocol_native_server_client_events = {