From ee67929a7cc1f17f73d735902d70c0d5a3a817e0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 25 Nov 2016 13:38:49 +0100 Subject: [PATCH] cleanups --- pinos/client/context.c | 5 +- pinos/client/context.h | 1 - pinos/client/object.h | 94 ---------------------------- pinos/client/pinos.h | 7 --- pinos/client/signal.h | 7 --- pinos/client/stream.c | 17 ++--- pinos/client/transport.c | 16 ++--- pinos/client/transport.h | 7 ++- pinos/modules/module-protocol-dbus.c | 7 +++ pinos/server/client-node.c | 9 +-- pinos/server/main-loop.c | 1 - 11 files changed, 24 insertions(+), 147 deletions(-) delete mode 100644 pinos/client/object.h diff --git a/pinos/client/context.c b/pinos/client/context.c index 7c52b61d9..c4c541ce8 100644 --- a/pinos/client/context.c +++ b/pinos/client/context.c @@ -116,7 +116,7 @@ core_dispatch_func (void *object, case PINOS_MESSAGE_NOTIFY_GLOBAL: { PinosMessageNotifyGlobal *ng = message; - pinos_log_warn ("global %u %s", ng->id, ng->type); + pinos_log_debug ("got global %u %s", ng->id, ng->type); break; } default: @@ -165,8 +165,6 @@ on_context_data (SpaSource *source, void *p = alloca (size); PinosProxy *proxy; - pinos_log_error ("context %p: got message %d from %u", this, type, id); - if (!pinos_connection_parse_message (conn, p)) { pinos_log_error ("context %p: failed to parse message", this); continue; @@ -193,7 +191,6 @@ context_send_func (void *object, { PinosContextImpl *impl = SPA_CONTAINER_OF (data, PinosContextImpl, this); - pinos_log_error ("context %p: send message %d to %u", &impl->this, type, id); pinos_connection_add_message (impl->connection, id, type, diff --git a/pinos/client/context.h b/pinos/client/context.h index 64faadbeb..f4ebb9308 100644 --- a/pinos/client/context.h +++ b/pinos/client/context.h @@ -94,5 +94,4 @@ bool pinos_context_disconnect (PinosContext *contex } #endif - #endif /* __PINOS_CONTEXT_H__ */ diff --git a/pinos/client/object.h b/pinos/client/object.h deleted file mode 100644 index 1a863cc58..000000000 --- a/pinos/client/object.h +++ /dev/null @@ -1,94 +0,0 @@ -/* Pinos - * Copyright (C) 2015 Wim Taymans - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PINOS_OBJECT_H__ -#define __PINOS_OBJECT_H__ - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _PinosObject PinosObject; -typedef struct _PinosInterface PinosInterface; - -typedef enum { - PINOS_OBJECT_FLAG_NONE = 0, - PINOS_OBJECT_FLAG_DESTROYING = (1 << 0), -} PinosObjectFlags; - -typedef void (*PinosDestroyFunc) (PinosObject *object); - -struct _PinosInterface { - uint32_t type; - void *iface; -}; - -struct _PinosObject { - uint32_t id; - PinosObjectFlags flags; - PinosDestroyFunc destroy; - PINOS_SIGNAL (destroy_signal, (PinosListener *listener, - PinosObject *object)); - unsigned int n_interfaces; - PinosInterface *interfaces; -}; - -static inline void -pinos_object_init (PinosObject *object, - PinosDestroyFunc destroy, - unsigned int n_interfaces, - PinosInterface *interfaces) -{ - object->id = SPA_ID_INVALID; - object->flags = 0; - object->destroy = destroy; - pinos_signal_init (&object->destroy_signal); - object->n_interfaces = n_interfaces; - object->interfaces = interfaces; -} - -static inline void * -pinos_object_get_interface (PinosObject *object, - uint32_t type) -{ - unsigned int i; - for (i = 0; i < object->n_interfaces; i++) - if (object->interfaces[i].type == type) - return object->interfaces[i].iface; - return NULL; -} - -static inline void -pinos_object_destroy (PinosObject *object) -{ - object->flags |= PINOS_OBJECT_FLAG_DESTROYING; - pinos_signal_emit (&object->destroy_signal, object); - if (object->destroy) - object->destroy (object); -} - -#ifdef __cplusplus -} -#endif - -#endif /* __PINOS_OBJECT_H__ */ diff --git a/pinos/client/pinos.h b/pinos/client/pinos.h index 5ceff29a0..e4cb7e9fd 100644 --- a/pinos/client/pinos.h +++ b/pinos/client/pinos.h @@ -37,13 +37,6 @@ extern "C" { #include -#define PINOS_DBUS_SERVICE "org.pinos" -#define PINOS_DBUS_OBJECT_PREFIX "/org/pinos" -#define PINOS_DBUS_OBJECT_SERVER PINOS_DBUS_OBJECT_PREFIX "/server" -#define PINOS_DBUS_OBJECT_CLIENT PINOS_DBUS_OBJECT_PREFIX "/client" -#define PINOS_DBUS_OBJECT_NODE PINOS_DBUS_OBJECT_PREFIX "/node" -#define PINOS_DBUS_OBJECT_LINK PINOS_DBUS_OBJECT_PREFIX "/link" - void pinos_init (int *argc, char **argv[]); char * pinos_client_name (void); diff --git a/pinos/client/signal.h b/pinos/client/signal.h index 6684cabef..84508b3ef 100644 --- a/pinos/client/signal.h +++ b/pinos/client/signal.h @@ -34,13 +34,6 @@ struct _PinosListener { void (*notify) (void *); }; -#if 0 -struct _PinosSignal { - SpaList listeners; - void (*notify) (PinosListener *listener, void *object, void *data); -}; -#endif - #define PINOS_SIGNAL(name,func) \ union { \ SpaList listeners; \ diff --git a/pinos/client/stream.c b/pinos/client/stream.c index 73584b00c..6cc114faf 100644 --- a/pinos/client/stream.c +++ b/pinos/client/stream.c @@ -406,15 +406,6 @@ handle_rtnode_event (PinosStream *stream, PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this); switch (event->type) { - case SPA_NODE_EVENT_TYPE_INVALID: - case SPA_NODE_EVENT_TYPE_ASYNC_COMPLETE: - case SPA_NODE_EVENT_TYPE_ERROR: - case SPA_NODE_EVENT_TYPE_BUFFERING: - case SPA_NODE_EVENT_TYPE_REQUEST_REFRESH: - case SPA_NODE_EVENT_TYPE_REQUEST_CLOCK_UPDATE: - pinos_log_warn ("unexpected node event %d", event->type); - break; - case SPA_NODE_EVENT_TYPE_HAVE_OUTPUT: case SPA_NODE_EVENT_TYPE_NEED_INPUT: pinos_log_warn ("unhandled node event %d", event->type); @@ -436,6 +427,9 @@ handle_rtnode_event (PinosStream *stream, } break; } + default: + pinos_log_warn ("unexpected node event %d", event->type); + break; } } @@ -501,7 +495,6 @@ handle_socket (PinosStream *stream, int rtfd) false, on_rtsocket_condition, stream); - pinos_log_debug ("socket %d", impl->rtfd); impl->timeout_source = pinos_loop_add_timer (stream->context->loop, on_timeout, @@ -831,7 +824,7 @@ stream_dispatch_func (void *object, info.size = p->size; if (impl->trans) - pinos_transport_free (impl->trans); + pinos_transport_destroy (impl->trans); impl->trans = pinos_transport_new_from_info (&info); pinos_log_debug ("transport update %d %p", impl->rtfd, impl->trans); @@ -907,6 +900,7 @@ pinos_stream_connect (PinosStream *stream, items[0].value = port_path; ccn.props = &dict; ccn.id = impl->node_proxy->id; + pinos_proxy_send_message (stream->context->core_proxy, PINOS_MESSAGE_CREATE_CLIENT_NODE, &ccn, @@ -969,7 +963,6 @@ pinos_stream_finish_format (PinosStream *stream, * * Start capturing from @stream. * - * * Returns: %true on success. */ bool diff --git a/pinos/client/transport.c b/pinos/client/transport.c index 684ed61b7..7d842d7d3 100644 --- a/pinos/client/transport.c +++ b/pinos/client/transport.c @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -101,6 +102,7 @@ pinos_transport_new (unsigned int max_inputs, impl->offset = 0; trans = &impl->trans; + pinos_signal_init (&trans->destroy_signal); pinos_memblock_alloc (PINOS_MEMBLOCK_FLAG_WITH_FD | PINOS_MEMBLOCK_FLAG_MAP_READWRITE | @@ -121,11 +123,9 @@ pinos_transport_new_from_info (PinosTransportInfo *info) PinosTransport *trans; void *tmp; - if (info == NULL) - return NULL; - impl = calloc (1, sizeof (PinosTransportImpl)); trans = &impl->trans; + pinos_signal_init (&trans->destroy_signal); impl->mem.flags = PINOS_MEMBLOCK_FLAG_MAP_READWRITE | PINOS_MEMBLOCK_FLAG_WITH_FD; @@ -133,7 +133,7 @@ pinos_transport_new_from_info (PinosTransportInfo *info) impl->mem.size = info->size; impl->mem.ptr = mmap (NULL, info->size, PROT_READ | PROT_WRITE, MAP_SHARED, info->memfd, info->offset); if (impl->mem.ptr == MAP_FAILED) { - pinos_log_warn ("transport %p: failed to map fd %d", impl, info->memfd); + pinos_log_warn ("transport %p: failed to map fd %d: %s", impl, info->memfd, strerror (errno)); goto mmap_failed; } @@ -158,13 +158,10 @@ mmap_failed: void -pinos_transport_free (PinosTransport *trans) +pinos_transport_destroy (PinosTransport *trans) { PinosTransportImpl *impl = (PinosTransportImpl *) trans; - if (impl == NULL) - return; - pinos_memblock_free (&impl->mem); free (impl); } @@ -175,9 +172,6 @@ pinos_transport_get_info (PinosTransport *trans, { PinosTransportImpl *impl = (PinosTransportImpl *) trans; - if (impl == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; - info->memfd = impl->mem.fd; info->offset = impl->offset; info->size = impl->mem.size; diff --git a/pinos/client/transport.h b/pinos/client/transport.h index 369ba66a1..839cebf6f 100644 --- a/pinos/client/transport.h +++ b/pinos/client/transport.h @@ -33,8 +33,8 @@ typedef struct _PinosTransportArea PinosTransportArea; #include #include -#include #include +#include #define PINOS_TRANSPORT_CMD_NONE 0 #define PINOS_TRANSPORT_CMD_NEED_DATA (1<<0) @@ -61,6 +61,9 @@ struct _PinosTransportArea { }; struct _PinosTransport { + PINOS_SIGNAL (destroy_signal, (PinosListener *listener, + PinosTransport *trans)); + PinosTransportArea *area; SpaPortInput *inputs; SpaPortOutput *outputs; @@ -74,7 +77,7 @@ PinosTransport * pinos_transport_new (unsigned int max_inputs, unsigned int max_outputs); PinosTransport * pinos_transport_new_from_info (PinosTransportInfo *info); -void pinos_transport_free (PinosTransport *trans); +void pinos_transport_destroy (PinosTransport *trans); SpaResult pinos_transport_get_info (PinosTransport *trans, PinosTransportInfo *info); diff --git a/pinos/modules/module-protocol-dbus.c b/pinos/modules/module-protocol-dbus.c index 5d8a0da62..2868f466a 100644 --- a/pinos/modules/module-protocol-dbus.c +++ b/pinos/modules/module-protocol-dbus.c @@ -43,6 +43,13 @@ #include "pinos/dbus/org-pinos.h" +#define PINOS_DBUS_SERVICE "org.pinos" +#define PINOS_DBUS_OBJECT_PREFIX "/org/pinos" +#define PINOS_DBUS_OBJECT_SERVER PINOS_DBUS_OBJECT_PREFIX "/server" +#define PINOS_DBUS_OBJECT_CLIENT PINOS_DBUS_OBJECT_PREFIX "/client" +#define PINOS_DBUS_OBJECT_NODE PINOS_DBUS_OBJECT_PREFIX "/node" +#define PINOS_DBUS_OBJECT_LINK PINOS_DBUS_OBJECT_PREFIX "/link" + typedef struct { PinosCore *core; SpaList link; diff --git a/pinos/server/client-node.c b/pinos/server/client-node.c index 83352a218..f639cadf4 100644 --- a/pinos/server/client-node.c +++ b/pinos/server/client-node.c @@ -989,14 +989,7 @@ client_node_dispatch_func (void *object, SpaProxy *this = &impl->proxy; switch (type) { - case PINOS_MESSAGE_INVALID: - case PINOS_MESSAGE_ADD_PORT: - case PINOS_MESSAGE_REMOVE_PORT: - case PINOS_MESSAGE_SET_FORMAT: - case PINOS_MESSAGE_SET_PROPERTY: - case PINOS_MESSAGE_NODE_COMMAND: - case PINOS_MESSAGE_PORT_COMMAND: - case PINOS_MESSAGE_TRANSPORT_UPDATE: + default: spa_log_error (this->log, "proxy %p: got unexpected command %d", this, type); break; diff --git a/pinos/server/main-loop.c b/pinos/server/main-loop.c index f98b7f94c..636470918 100644 --- a/pinos/server/main-loop.c +++ b/pinos/server/main-loop.c @@ -27,7 +27,6 @@ #include "spa/include/spa/list.h" #include "spa/include/spa/ringbuffer.h" #include "pinos/client/log.h" -#include "pinos/client/object.h" #include "pinos/server/main-loop.h" typedef struct _WorkItem WorkItem;