mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	use interfaces in client
This commit is contained in:
		
							parent
							
								
									e0813b679d
								
							
						
					
					
						commit
						b9a0b067be
					
				
					 10 changed files with 1163 additions and 842 deletions
				
			
		| 
						 | 
					@ -91,7 +91,7 @@ typedef enum {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* PINOS_MESSAGE_CLIENT_UPDATE */
 | 
					/* PINOS_MESSAGE_CLIENT_UPDATE */
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
  SpaDict     *props;
 | 
					  const SpaDict *props;
 | 
				
			||||||
} PinosMessageClientUpdate;
 | 
					} PinosMessageClientUpdate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* PINOS_MESSAGE_SYNC */
 | 
					/* PINOS_MESSAGE_SYNC */
 | 
				
			||||||
| 
						 | 
					@ -169,7 +169,7 @@ typedef struct {
 | 
				
			||||||
  uint32_t       seq;
 | 
					  uint32_t       seq;
 | 
				
			||||||
  const char    *factory_name;
 | 
					  const char    *factory_name;
 | 
				
			||||||
  const char    *name;
 | 
					  const char    *name;
 | 
				
			||||||
  SpaDict     *props;
 | 
					  const SpaDict *props;
 | 
				
			||||||
  uint32_t       new_id;
 | 
					  uint32_t       new_id;
 | 
				
			||||||
} PinosMessageCreateNode;
 | 
					} PinosMessageCreateNode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -182,7 +182,7 @@ typedef struct {
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
  uint32_t       seq;
 | 
					  uint32_t       seq;
 | 
				
			||||||
  const char    *name;
 | 
					  const char    *name;
 | 
				
			||||||
  SpaDict     *props;
 | 
					  const SpaDict *props;
 | 
				
			||||||
  uint32_t       new_id;
 | 
					  uint32_t       new_id;
 | 
				
			||||||
} PinosMessageCreateClientNode;
 | 
					} PinosMessageCreateClientNode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
					@ -33,12 +33,6 @@ typedef struct _PinosContext PinosContext;
 | 
				
			||||||
#include <pinos/client/proxy.h>
 | 
					#include <pinos/client/proxy.h>
 | 
				
			||||||
#include <pinos/client/uri.h>
 | 
					#include <pinos/client/uri.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef SpaResult (*PinosSendFunc)     (void             *object,
 | 
					 | 
				
			||||||
                                        uint32_t          id,
 | 
					 | 
				
			||||||
                                        uint32_t          opcode,
 | 
					 | 
				
			||||||
                                        void             *message,
 | 
					 | 
				
			||||||
                                        bool              flush,
 | 
					 | 
				
			||||||
                                        void             *data);
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * PinosContextState:
 | 
					 * PinosContextState:
 | 
				
			||||||
 * @PINOS_CONTEXT_STATE_ERROR: context is in error
 | 
					 * @PINOS_CONTEXT_STATE_ERROR: context is in error
 | 
				
			||||||
| 
						 | 
					@ -99,16 +93,6 @@ PinosContext *    pinos_context_new                   (PinosLoop         *loop,
 | 
				
			||||||
                                                       PinosProperties   *properties);
 | 
					                                                       PinosProperties   *properties);
 | 
				
			||||||
void              pinos_context_destroy               (PinosContext      *context);
 | 
					void              pinos_context_destroy               (PinosContext      *context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void              pinos_context_set_send              (PinosContext      *context,
 | 
					 | 
				
			||||||
                                                       PinosSendFunc      func,
 | 
					 | 
				
			||||||
                                                       void              *data);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
SpaResult         pinos_context_send_message          (PinosContext      *context,
 | 
					 | 
				
			||||||
                                                       PinosProxy        *proxy,
 | 
					 | 
				
			||||||
                                                       uint32_t           opcode,
 | 
					 | 
				
			||||||
                                                       void              *message,
 | 
					 | 
				
			||||||
                                                       bool               flush);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
bool              pinos_context_connect               (PinosContext      *context);
 | 
					bool              pinos_context_connect               (PinosContext      *context);
 | 
				
			||||||
bool              pinos_context_connect_fd            (PinosContext      *context,
 | 
					bool              pinos_context_connect_fd            (PinosContext      *context,
 | 
				
			||||||
                                                       int                fd);
 | 
					                                                       int                fd);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,6 +61,12 @@ typedef struct {
 | 
				
			||||||
                               uint32_t       new_id);
 | 
					                               uint32_t       new_id);
 | 
				
			||||||
} PinosCoreInterface;
 | 
					} PinosCoreInterface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define pinos_core_do_client_update(r,...)      ((PinosCoreInterface*)r->interface)->client_update(r,__VA_ARGS__)
 | 
				
			||||||
 | 
					#define pinos_core_do_sync(r,...)               ((PinosCoreInterface*)r->interface)->sync(r,__VA_ARGS__)
 | 
				
			||||||
 | 
					#define pinos_core_do_get_registry(r,...)       ((PinosCoreInterface*)r->interface)->get_registry(r,__VA_ARGS__)
 | 
				
			||||||
 | 
					#define pinos_core_do_create_node(r,...)        ((PinosCoreInterface*)r->interface)->create_node(r,__VA_ARGS__)
 | 
				
			||||||
 | 
					#define pinos_core_do_create_client_node(r,...) ((PinosCoreInterface*)r->interface)->create_client_node(r,__VA_ARGS__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
  void (*info)                (void          *object,
 | 
					  void (*info)                (void          *object,
 | 
				
			||||||
                               PinosCoreInfo *info);
 | 
					                               PinosCoreInfo *info);
 | 
				
			||||||
| 
						 | 
					@ -87,6 +93,8 @@ typedef struct {
 | 
				
			||||||
                               uint32_t       new_id);
 | 
					                               uint32_t       new_id);
 | 
				
			||||||
} PinosRegistryInterface;
 | 
					} PinosRegistryInterface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define pinos_registry_do_bind(r,...)        ((PinosRegistryInterface*)r->interface)->bind(r,__VA_ARGS__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
  void (*global)              (void          *object,
 | 
					  void (*global)              (void          *object,
 | 
				
			||||||
                               uint32_t       id,
 | 
					                               uint32_t       id,
 | 
				
			||||||
| 
						 | 
					@ -159,6 +167,11 @@ typedef struct {
 | 
				
			||||||
                                uint32_t           seq);
 | 
					                                uint32_t           seq);
 | 
				
			||||||
} PinosClientNodeInterface;
 | 
					} PinosClientNodeInterface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define pinos_client_node_do_update(r,...)       ((PinosClientNodeInterface*)r->interface)->update(r,__VA_ARGS__)
 | 
				
			||||||
 | 
					#define pinos_client_node_do_port_update(r,...)  ((PinosClientNodeInterface*)r->interface)->port_update(r,__VA_ARGS__)
 | 
				
			||||||
 | 
					#define pinos_client_node_do_state_change(r,...) ((PinosClientNodeInterface*)r->interface)->state_change(r,__VA_ARGS__)
 | 
				
			||||||
 | 
					#define pinos_client_node_do_event(r,...)        ((PinosClientNodeInterface*)r->interface)->event(r,__VA_ARGS__)
 | 
				
			||||||
 | 
					#define pinos_client_node_do_destroy(r,...)      ((PinosClientNodeInterface*)r->interface)->destroy(r,__VA_ARGS__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
  void (*done)                 (void              *object,
 | 
					  void (*done)                 (void              *object,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,9 +22,6 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
  PinosProxy this;
 | 
					  PinosProxy this;
 | 
				
			||||||
 | 
					 | 
				
			||||||
  PinosDispatchFunc  dispatch_func;
 | 
					 | 
				
			||||||
  void              *dispatch_data;
 | 
					 | 
				
			||||||
} PinosProxyImpl;
 | 
					} PinosProxyImpl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PinosProxy *
 | 
					PinosProxy *
 | 
				
			||||||
| 
						 | 
					@ -67,42 +64,3 @@ pinos_proxy_destroy (PinosProxy *proxy)
 | 
				
			||||||
  pinos_log_debug ("proxy %p: free", proxy);
 | 
					  pinos_log_debug ("proxy %p: free", proxy);
 | 
				
			||||||
  free (impl);
 | 
					  free (impl);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
void
 | 
					 | 
				
			||||||
pinos_proxy_set_dispatch (PinosProxy        *proxy,
 | 
					 | 
				
			||||||
                          PinosDispatchFunc  func,
 | 
					 | 
				
			||||||
                          void              *data)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  PinosProxyImpl *impl = SPA_CONTAINER_OF (proxy, PinosProxyImpl, this);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  impl->dispatch_func = func;
 | 
					 | 
				
			||||||
  impl->dispatch_data = data;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
SpaResult
 | 
					 | 
				
			||||||
pinos_proxy_send_message (PinosProxy        *proxy,
 | 
					 | 
				
			||||||
                          uint32_t           opcode,
 | 
					 | 
				
			||||||
                          void              *message,
 | 
					 | 
				
			||||||
                          bool               flush)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  return pinos_context_send_message (proxy->context,
 | 
					 | 
				
			||||||
                                     proxy,
 | 
					 | 
				
			||||||
                                     opcode,
 | 
					 | 
				
			||||||
                                     message,
 | 
					 | 
				
			||||||
                                     flush);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
SpaResult
 | 
					 | 
				
			||||||
pinos_proxy_dispatch (PinosProxy        *proxy,
 | 
					 | 
				
			||||||
                      uint32_t           opcode,
 | 
					 | 
				
			||||||
                      void              *message)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  PinosProxyImpl *impl = SPA_CONTAINER_OF (proxy, PinosProxyImpl, this);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (impl->dispatch_func)
 | 
					 | 
				
			||||||
    return impl->dispatch_func (proxy, opcode, message, impl->dispatch_data);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  pinos_log_error ("proxy %p: dispatch func not implemented", proxy);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return SPA_RESULT_NOT_IMPLEMENTED;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,11 +26,6 @@ extern "C" {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct _PinosProxy PinosProxy;
 | 
					typedef struct _PinosProxy PinosProxy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef SpaResult (*PinosDispatchFunc) (void             *object,
 | 
					 | 
				
			||||||
                                        uint32_t          opcode,
 | 
					 | 
				
			||||||
                                        void             *message,
 | 
					 | 
				
			||||||
                                        void             *data);
 | 
					 | 
				
			||||||
#include <pinos/client/connection.h>
 | 
					#include <pinos/client/connection.h>
 | 
				
			||||||
#include <pinos/client/context.h>
 | 
					#include <pinos/client/context.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,6 +38,10 @@ struct _PinosProxy {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void         *user_data;
 | 
					  void         *user_data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const void   *interface;
 | 
				
			||||||
 | 
					  const void   *event;
 | 
				
			||||||
 | 
					  const void   *marshall;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  PINOS_SIGNAL (destroy_signal, (PinosListener *listener,
 | 
					  PINOS_SIGNAL (destroy_signal, (PinosListener *listener,
 | 
				
			||||||
                                 PinosProxy    *proxy));
 | 
					                                 PinosProxy    *proxy));
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -52,21 +51,8 @@ PinosProxy *      pinos_proxy_new                     (PinosContext      *contex
 | 
				
			||||||
                                                       uint32_t           type);
 | 
					                                                       uint32_t           type);
 | 
				
			||||||
void              pinos_proxy_destroy                 (PinosProxy        *proxy);
 | 
					void              pinos_proxy_destroy                 (PinosProxy        *proxy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void              pinos_proxy_set_dispatch            (PinosProxy        *proxy,
 | 
					 | 
				
			||||||
                                                       PinosDispatchFunc  func,
 | 
					 | 
				
			||||||
                                                       void              *data);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
SpaResult         pinos_proxy_send_message            (PinosProxy        *proxy,
 | 
					 | 
				
			||||||
                                                       uint32_t           opcode,
 | 
					 | 
				
			||||||
                                                       void              *message,
 | 
					 | 
				
			||||||
                                                       bool               flush);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
SpaResult         pinos_proxy_dispatch                (PinosProxy        *proxy,
 | 
					 | 
				
			||||||
                                                       uint32_t           opcode,
 | 
					 | 
				
			||||||
                                                       void              *message);
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif /* __PINOS_PROXY_H__ */
 | 
					#endif /* __PINOS_PROXY_H__ */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -307,33 +307,29 @@ static void
 | 
				
			||||||
add_node_update (PinosStream *stream, uint32_t change_mask, bool flush)
 | 
					add_node_update (PinosStream *stream, uint32_t change_mask, bool flush)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  PinosMessageNodeUpdate nu = { 0, };
 | 
					  unsigned int max_input_ports = 0, max_output_ports = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  nu.change_mask = change_mask;
 | 
					 | 
				
			||||||
  if (change_mask & PINOS_MESSAGE_NODE_UPDATE_MAX_INPUTS)
 | 
					  if (change_mask & PINOS_MESSAGE_NODE_UPDATE_MAX_INPUTS)
 | 
				
			||||||
    nu.max_input_ports = impl->direction == SPA_DIRECTION_INPUT ? 1 : 0;
 | 
					    max_input_ports = impl->direction == SPA_DIRECTION_INPUT ? 1 : 0;
 | 
				
			||||||
  if (change_mask & PINOS_MESSAGE_NODE_UPDATE_MAX_OUTPUTS)
 | 
					  if (change_mask & PINOS_MESSAGE_NODE_UPDATE_MAX_OUTPUTS)
 | 
				
			||||||
    nu.max_output_ports = impl->direction == SPA_DIRECTION_OUTPUT ? 1 : 0;
 | 
					    max_output_ports = impl->direction == SPA_DIRECTION_OUTPUT ? 1 : 0;
 | 
				
			||||||
  nu.props = NULL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_proxy_send_message (impl->node_proxy,
 | 
					  pinos_client_node_do_update (impl->node_proxy,
 | 
				
			||||||
                            PINOS_MESSAGE_NODE_UPDATE,
 | 
					                               change_mask,
 | 
				
			||||||
                            &nu,
 | 
					                               max_input_ports,
 | 
				
			||||||
                            flush);
 | 
					                               max_output_ports,
 | 
				
			||||||
 | 
					                               NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
add_state_change (PinosStream *stream, SpaNodeState state, bool flush)
 | 
					add_state_change (PinosStream *stream, SpaNodeState state, bool flush)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  PinosMessageNodeStateChange sc;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (impl->node_state != state) {
 | 
					  if (impl->node_state != state) {
 | 
				
			||||||
    sc.state = impl->node_state = state;
 | 
					    impl->node_state = state;
 | 
				
			||||||
    pinos_proxy_send_message (impl->node_proxy,
 | 
					    pinos_client_node_do_state_change (impl->node_proxy,
 | 
				
			||||||
                              PINOS_MESSAGE_NODE_STATE_CHANGE,
 | 
					                                       state);
 | 
				
			||||||
                              &sc,
 | 
					 | 
				
			||||||
                              flush);
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -341,26 +337,16 @@ static void
 | 
				
			||||||
add_port_update (PinosStream *stream, uint32_t change_mask, bool flush)
 | 
					add_port_update (PinosStream *stream, uint32_t change_mask, bool flush)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  PinosMessagePortUpdate pu = { 0, };;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pu.direction = impl->direction;
 | 
					  pinos_client_node_do_port_update (impl->node_proxy,
 | 
				
			||||||
  pu.port_id = impl->port_id;
 | 
					                                    impl->direction,
 | 
				
			||||||
  pu.change_mask = change_mask;
 | 
					                                    impl->port_id,
 | 
				
			||||||
  if (change_mask & PINOS_MESSAGE_PORT_UPDATE_POSSIBLE_FORMATS) {
 | 
					                                    change_mask,
 | 
				
			||||||
    pu.n_possible_formats = impl->n_possible_formats;
 | 
					                                    impl->n_possible_formats,
 | 
				
			||||||
    pu.possible_formats = impl->possible_formats;
 | 
					                                    impl->possible_formats,
 | 
				
			||||||
  }
 | 
					                                    impl->format,
 | 
				
			||||||
  if (change_mask & PINOS_MESSAGE_PORT_UPDATE_FORMAT) {
 | 
					                                    NULL,
 | 
				
			||||||
    pu.format = impl->format;
 | 
					                                    &impl->port_info);
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  pu.props = NULL;
 | 
					 | 
				
			||||||
  if (change_mask & PINOS_MESSAGE_PORT_UPDATE_INFO) {
 | 
					 | 
				
			||||||
    pu.info = &impl->port_info;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  pinos_proxy_send_message (impl->node_proxy,
 | 
					 | 
				
			||||||
                            PINOS_MESSAGE_PORT_UPDATE,
 | 
					 | 
				
			||||||
                            &pu,
 | 
					 | 
				
			||||||
                            flush);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline void
 | 
					static inline void
 | 
				
			||||||
| 
						 | 
					@ -401,19 +387,15 @@ static void
 | 
				
			||||||
add_request_clock_update (PinosStream *stream, bool flush)
 | 
					add_request_clock_update (PinosStream *stream, bool flush)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  PinosMessageNodeEvent cne;
 | 
					 | 
				
			||||||
  SpaNodeEventRequestClockUpdate rcu;
 | 
					  SpaNodeEventRequestClockUpdate rcu;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  cne.event = &rcu.event;
 | 
					 | 
				
			||||||
  rcu.event.type = SPA_NODE_EVENT_TYPE_REQUEST_CLOCK_UPDATE;
 | 
					  rcu.event.type = SPA_NODE_EVENT_TYPE_REQUEST_CLOCK_UPDATE;
 | 
				
			||||||
  rcu.event.size = sizeof (rcu);
 | 
					  rcu.event.size = sizeof (rcu);
 | 
				
			||||||
  rcu.update_mask = SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_TIME;
 | 
					  rcu.update_mask = SPA_NODE_EVENT_REQUEST_CLOCK_UPDATE_TIME;
 | 
				
			||||||
  rcu.timestamp = 0;
 | 
					  rcu.timestamp = 0;
 | 
				
			||||||
  rcu.offset = 0;
 | 
					  rcu.offset = 0;
 | 
				
			||||||
  pinos_proxy_send_message (impl->node_proxy,
 | 
					  pinos_client_node_do_event (impl->node_proxy,
 | 
				
			||||||
                            PINOS_MESSAGE_NODE_EVENT,
 | 
					                              &rcu.event);
 | 
				
			||||||
                            &cne,
 | 
					 | 
				
			||||||
                            flush);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -423,18 +405,14 @@ add_async_complete (PinosStream  *stream,
 | 
				
			||||||
                    bool          flush)
 | 
					                    bool          flush)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  PinosMessageNodeEvent cne;
 | 
					 | 
				
			||||||
  SpaNodeEventAsyncComplete ac;
 | 
					  SpaNodeEventAsyncComplete ac;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  cne.event = &ac.event;
 | 
					 | 
				
			||||||
  ac.event.type = SPA_NODE_EVENT_TYPE_ASYNC_COMPLETE;
 | 
					  ac.event.type = SPA_NODE_EVENT_TYPE_ASYNC_COMPLETE;
 | 
				
			||||||
  ac.event.size = sizeof (ac);
 | 
					  ac.event.size = sizeof (ac);
 | 
				
			||||||
  ac.seq = seq;
 | 
					  ac.seq = seq;
 | 
				
			||||||
  ac.res = res;
 | 
					  ac.res = res;
 | 
				
			||||||
  pinos_proxy_send_message (impl->node_proxy,
 | 
					  pinos_client_node_do_event (impl->node_proxy,
 | 
				
			||||||
                            PINOS_MESSAGE_NODE_EVENT,
 | 
					                              &ac.event);
 | 
				
			||||||
                            &cne,
 | 
					 | 
				
			||||||
                            flush);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -678,81 +656,125 @@ handle_node_command (PinosStream    *stream,
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static SpaResult
 | 
					static void
 | 
				
			||||||
stream_dispatch_func (void             *object,
 | 
					client_node_done (void              *object,
 | 
				
			||||||
                      PinosMessageType  type,
 | 
					                  uint32_t           seq,
 | 
				
			||||||
                      void             *message,
 | 
					                  int                datafd)
 | 
				
			||||||
                      void             *data)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosStream *stream = data;
 | 
					  PinosProxy *proxy = object;
 | 
				
			||||||
  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
					  PinosStream *stream = proxy->user_data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  switch (type) {
 | 
					  pinos_log_warn ("create client node done");
 | 
				
			||||||
    case PINOS_MESSAGE_CREATE_NODE_DONE:
 | 
					  handle_socket (stream, datafd);
 | 
				
			||||||
      pinos_log_warn ("create node done %d", type);
 | 
					 | 
				
			||||||
      break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    case PINOS_MESSAGE_CREATE_CLIENT_NODE_DONE:
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      PinosMessageCreateClientNodeDone *cnd = message;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      pinos_log_warn ("create client node done %d", type);
 | 
					 | 
				
			||||||
      handle_socket (stream, cnd->datafd);
 | 
					 | 
				
			||||||
  do_node_init (stream);
 | 
					  do_node_init (stream);
 | 
				
			||||||
      break;
 | 
					}
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_MESSAGE_ADD_PORT:
 | 
					static void
 | 
				
			||||||
    case PINOS_MESSAGE_REMOVE_PORT:
 | 
					client_node_event (void              *object,
 | 
				
			||||||
      pinos_log_warn ("add/remove port not supported");
 | 
					                   SpaNodeEvent      *event)
 | 
				
			||||||
      break;
 | 
					{
 | 
				
			||||||
 | 
					  PinosProxy *proxy = object;
 | 
				
			||||||
 | 
					  PinosStream *stream = proxy->user_data;
 | 
				
			||||||
 | 
					  handle_node_event (stream, event);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_MESSAGE_SET_FORMAT:
 | 
					static void
 | 
				
			||||||
    {
 | 
					client_node_add_port (void              *object,
 | 
				
			||||||
      PinosMessageSetFormat *p = message;
 | 
					                      uint32_t           seq,
 | 
				
			||||||
 | 
					                      SpaDirection       direction,
 | 
				
			||||||
 | 
					                      uint32_t           port_id)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  pinos_log_warn ("add port not supported");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					client_node_remove_port (void              *object,
 | 
				
			||||||
 | 
					                         uint32_t           seq,
 | 
				
			||||||
 | 
					                         SpaDirection       direction,
 | 
				
			||||||
 | 
					                         uint32_t           port_id)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  pinos_log_warn ("remove port not supported");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					client_node_set_format (void              *object,
 | 
				
			||||||
 | 
					                        uint32_t           seq,
 | 
				
			||||||
 | 
					                        SpaDirection       direction,
 | 
				
			||||||
 | 
					                        uint32_t           port_id,
 | 
				
			||||||
 | 
					                        SpaPortFormatFlags flags,
 | 
				
			||||||
 | 
					                        const SpaFormat   *format)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PinosProxy *proxy = object;
 | 
				
			||||||
 | 
					  PinosStream *stream = proxy->user_data;
 | 
				
			||||||
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  void *mem;
 | 
					  void *mem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (impl->format)
 | 
					  if (impl->format)
 | 
				
			||||||
    free (impl->format);
 | 
					    free (impl->format);
 | 
				
			||||||
      mem = malloc (pinos_serialize_format_get_size (p->format));
 | 
					  mem = malloc (pinos_serialize_format_get_size (format));
 | 
				
			||||||
      impl->format = pinos_serialize_format_copy_into (mem, p->format);
 | 
					  impl->format = pinos_serialize_format_copy_into (mem, format);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      impl->pending_seq = p->seq;
 | 
					  impl->pending_seq = seq;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_signal_emit (&stream->format_changed, stream, impl->format);
 | 
					  pinos_signal_emit (&stream->format_changed, stream, impl->format);
 | 
				
			||||||
  stream_set_state (stream, PINOS_STREAM_STATE_READY, NULL);
 | 
					  stream_set_state (stream, PINOS_STREAM_STATE_READY, NULL);
 | 
				
			||||||
      break;
 | 
					}
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    case PINOS_MESSAGE_SET_PROPERTY:
 | 
					 | 
				
			||||||
      pinos_log_warn ("set property not implemented");
 | 
					 | 
				
			||||||
      break;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case PINOS_MESSAGE_ADD_MEM:
 | 
					static void
 | 
				
			||||||
    {
 | 
					client_node_set_property (void              *object,
 | 
				
			||||||
      PinosMessageAddMem *p = message;
 | 
					                          uint32_t           seq,
 | 
				
			||||||
 | 
					                          uint32_t           id,
 | 
				
			||||||
 | 
					                          size_t             size,
 | 
				
			||||||
 | 
					                          void              *value)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  pinos_log_warn ("set property not implemented");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					client_node_add_mem (void              *object,
 | 
				
			||||||
 | 
					                     SpaDirection       direction,
 | 
				
			||||||
 | 
					                     uint32_t           port_id,
 | 
				
			||||||
 | 
					                     uint32_t           mem_id,
 | 
				
			||||||
 | 
					                     SpaDataType        type,
 | 
				
			||||||
 | 
					                     int                memfd,
 | 
				
			||||||
 | 
					                     uint32_t           flags,
 | 
				
			||||||
 | 
					                     off_t              offset,
 | 
				
			||||||
 | 
					                     size_t             size)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PinosProxy *proxy = object;
 | 
				
			||||||
 | 
					  PinosStream *stream = proxy->user_data;
 | 
				
			||||||
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  MemId *m;
 | 
					  MemId *m;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      m = find_mem (stream, p->mem_id);
 | 
					  m = find_mem (stream, mem_id);
 | 
				
			||||||
  if (m) {
 | 
					  if (m) {
 | 
				
			||||||
    pinos_log_debug ("update mem %u, fd %d, flags %d, off %zd, size %zd",
 | 
					    pinos_log_debug ("update mem %u, fd %d, flags %d, off %zd, size %zd",
 | 
				
			||||||
            p->mem_id, p->memfd, p->flags, p->offset, p->size);
 | 
					        mem_id, memfd, flags, offset, size);
 | 
				
			||||||
    clear_memid (m);
 | 
					    clear_memid (m);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    m = pinos_array_add (&impl->mem_ids, sizeof (MemId));
 | 
					    m = pinos_array_add (&impl->mem_ids, sizeof (MemId));
 | 
				
			||||||
    pinos_log_debug ("add mem %u, fd %d, flags %d, off %zd, size %zd",
 | 
					    pinos_log_debug ("add mem %u, fd %d, flags %d, off %zd, size %zd",
 | 
				
			||||||
            p->mem_id, p->memfd, p->flags, p->offset, p->size);
 | 
					        mem_id, memfd, flags, offset, size);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
      m->id = p->mem_id;
 | 
					  m->id = mem_id;
 | 
				
			||||||
      m->fd = p->memfd;
 | 
					  m->fd = memfd;
 | 
				
			||||||
      m->flags = p->flags;
 | 
					  m->flags = flags;
 | 
				
			||||||
  m->ptr = NULL;
 | 
					  m->ptr = NULL;
 | 
				
			||||||
      m->offset = p->offset;
 | 
					  m->offset = offset;
 | 
				
			||||||
      m->size = p->size;
 | 
					  m->size = size;
 | 
				
			||||||
      break;
 | 
					}
 | 
				
			||||||
    }
 | 
					
 | 
				
			||||||
    case PINOS_MESSAGE_USE_BUFFERS:
 | 
					static void
 | 
				
			||||||
    {
 | 
					client_node_use_buffers (void                  *object,
 | 
				
			||||||
      PinosMessageUseBuffers *p = message;
 | 
					                         uint32_t               seq,
 | 
				
			||||||
 | 
					                         SpaDirection           direction,
 | 
				
			||||||
 | 
					                         uint32_t               port_id,
 | 
				
			||||||
 | 
					                         unsigned int           n_buffers,
 | 
				
			||||||
 | 
					                         PinosClientNodeBuffer *buffers)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PinosProxy *proxy = object;
 | 
				
			||||||
 | 
					  PinosStream *stream = proxy->user_data;
 | 
				
			||||||
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  BufferId *bid;
 | 
					  BufferId *bid;
 | 
				
			||||||
  unsigned int i, j, len;
 | 
					  unsigned int i, j, len;
 | 
				
			||||||
  SpaBuffer *b;
 | 
					  SpaBuffer *b;
 | 
				
			||||||
| 
						 | 
					@ -760,12 +782,12 @@ stream_dispatch_func (void             *object,
 | 
				
			||||||
  /* clear previous buffers */
 | 
					  /* clear previous buffers */
 | 
				
			||||||
  clear_buffers (stream);
 | 
					  clear_buffers (stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      for (i = 0; i < p->n_buffers; i++) {
 | 
					  for (i = 0; i < n_buffers; i++) {
 | 
				
			||||||
    off_t offset = 0;
 | 
					    off_t offset = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        MemId *mid = find_mem (stream, p->buffers[i].mem_id);
 | 
					    MemId *mid = find_mem (stream, buffers[i].mem_id);
 | 
				
			||||||
    if (mid == NULL) {
 | 
					    if (mid == NULL) {
 | 
				
			||||||
          pinos_log_warn ("unknown memory id %u", p->buffers[i].mem_id);
 | 
					      pinos_log_warn ("unknown memory id %u", buffers[i].mem_id);
 | 
				
			||||||
      continue;
 | 
					      continue;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -782,15 +804,15 @@ stream_dispatch_func (void             *object,
 | 
				
			||||||
    bid = pinos_array_add (&impl->buffer_ids, sizeof (BufferId));
 | 
					    bid = pinos_array_add (&impl->buffer_ids, sizeof (BufferId));
 | 
				
			||||||
    bid->used = false;
 | 
					    bid->used = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        b = p->buffers[i].buffer;
 | 
					    b = buffers[i].buffer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bid->buf_ptr = SPA_MEMBER (mid->ptr, p->buffers[i].offset, void);
 | 
					    bid->buf_ptr = SPA_MEMBER (mid->ptr, buffers[i].offset, void);
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      size_t size;
 | 
					      size_t size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          size = pinos_serialize_buffer_get_size (p->buffers[i].buffer);
 | 
					      size = pinos_serialize_buffer_get_size (buffers[i].buffer);
 | 
				
			||||||
      b = bid->buf = malloc (size);
 | 
					      b = bid->buf = malloc (size);
 | 
				
			||||||
          pinos_serialize_buffer_copy_into (b, p->buffers[i].buffer);
 | 
					      pinos_serialize_buffer_copy_into (b, buffers[i].buffer);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    bid->id = b->id;
 | 
					    bid->id = b->id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -798,7 +820,7 @@ stream_dispatch_func (void             *object,
 | 
				
			||||||
      pinos_log_warn ("unexpected id %u found, expected %u", bid->id, len);
 | 
					      pinos_log_warn ("unexpected id %u found, expected %u", bid->id, len);
 | 
				
			||||||
      impl->in_order = false;
 | 
					      impl->in_order = false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
        pinos_log_debug ("add buffer %d %d %zd", mid->id, bid->id, p->buffers[i].offset);
 | 
					    pinos_log_debug ("add buffer %d %d %zd", mid->id, bid->id, buffers[i].offset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (j = 0; j < b->n_metas; j++) {
 | 
					    for (j = 0; j < b->n_metas; j++) {
 | 
				
			||||||
      SpaMeta *m = &b->metas[j];
 | 
					      SpaMeta *m = &b->metas[j];
 | 
				
			||||||
| 
						 | 
					@ -836,62 +858,81 @@ stream_dispatch_func (void             *object,
 | 
				
			||||||
    pinos_signal_emit (&stream->add_buffer, stream, bid->id);
 | 
					    pinos_signal_emit (&stream->add_buffer, stream, bid->id);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (p->n_buffers) {
 | 
					  if (n_buffers) {
 | 
				
			||||||
    add_state_change (stream, SPA_NODE_STATE_PAUSED, false);
 | 
					    add_state_change (stream, SPA_NODE_STATE_PAUSED, false);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    clear_mems (stream);
 | 
					    clear_mems (stream);
 | 
				
			||||||
    add_state_change (stream, SPA_NODE_STATE_READY, false);
 | 
					    add_state_change (stream, SPA_NODE_STATE_READY, false);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
      add_async_complete (stream, p->seq, SPA_RESULT_OK, true);
 | 
					  add_async_complete (stream, seq, SPA_RESULT_OK, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (p->n_buffers)
 | 
					  if (n_buffers)
 | 
				
			||||||
    stream_set_state (stream, PINOS_STREAM_STATE_PAUSED, NULL);
 | 
					    stream_set_state (stream, PINOS_STREAM_STATE_PAUSED, NULL);
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    stream_set_state (stream, PINOS_STREAM_STATE_READY, NULL);
 | 
					    stream_set_state (stream, PINOS_STREAM_STATE_READY, NULL);
 | 
				
			||||||
      break;
 | 
					}
 | 
				
			||||||
    }
 | 
					
 | 
				
			||||||
    case PINOS_MESSAGE_NODE_EVENT:
 | 
					static void
 | 
				
			||||||
    {
 | 
					client_node_node_command (void              *object,
 | 
				
			||||||
      PinosMessageNodeEvent *p = message;
 | 
					                          uint32_t           seq,
 | 
				
			||||||
      handle_node_event (stream, p->event);
 | 
					                          SpaNodeCommand    *command)
 | 
				
			||||||
      break;
 | 
					{
 | 
				
			||||||
    }
 | 
					  PinosProxy *proxy = object;
 | 
				
			||||||
    case PINOS_MESSAGE_NODE_COMMAND:
 | 
					  PinosStream *stream = proxy->user_data;
 | 
				
			||||||
    {
 | 
					  handle_node_command (stream, seq, command);
 | 
				
			||||||
      PinosMessageNodeCommand *p = message;
 | 
					}
 | 
				
			||||||
      handle_node_command (stream, p->seq, p->command);
 | 
					
 | 
				
			||||||
      break;
 | 
					static void
 | 
				
			||||||
    }
 | 
					client_node_port_command (void              *object,
 | 
				
			||||||
    case PINOS_MESSAGE_PORT_COMMAND:
 | 
					                          uint32_t           port_id,
 | 
				
			||||||
    {
 | 
					                          SpaNodeCommand    *command)
 | 
				
			||||||
      break;
 | 
					{
 | 
				
			||||||
    }
 | 
					  pinos_log_warn ("port command not supported");
 | 
				
			||||||
    case PINOS_MESSAGE_TRANSPORT_UPDATE:
 | 
					}
 | 
				
			||||||
    {
 | 
					
 | 
				
			||||||
      PinosMessageTransportUpdate *p = message;
 | 
					static void
 | 
				
			||||||
 | 
					client_node_transport (void              *object,
 | 
				
			||||||
 | 
					                       int                memfd,
 | 
				
			||||||
 | 
					                       off_t              offset,
 | 
				
			||||||
 | 
					                       size_t             size)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PinosProxy *proxy = object;
 | 
				
			||||||
 | 
					  PinosStream *stream = proxy->user_data;
 | 
				
			||||||
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  PinosTransportInfo info;
 | 
					  PinosTransportInfo info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      info.memfd =  p->memfd;
 | 
					  info.memfd =  memfd;
 | 
				
			||||||
  if (info.memfd == -1)
 | 
					  if (info.memfd == -1)
 | 
				
			||||||
        break;
 | 
					    return;
 | 
				
			||||||
      info.offset = p->offset;
 | 
					  info.offset = offset;
 | 
				
			||||||
      info.size = p->size;
 | 
					  info.size = size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (impl->trans)
 | 
					  if (impl->trans)
 | 
				
			||||||
    pinos_transport_destroy (impl->trans);
 | 
					    pinos_transport_destroy (impl->trans);
 | 
				
			||||||
  impl->trans = pinos_transport_new_from_info (&info);
 | 
					  impl->trans = pinos_transport_new_from_info (&info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_log_debug ("transport update %d %p", impl->rtfd, impl->trans);
 | 
					  pinos_log_debug ("transport update %d %p", impl->rtfd, impl->trans);
 | 
				
			||||||
      break;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    default:
 | 
					 | 
				
			||||||
    case PINOS_MESSAGE_INVALID:
 | 
					 | 
				
			||||||
      pinos_log_warn ("unhandled message %d", type);
 | 
					 | 
				
			||||||
      break;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return SPA_RESULT_OK;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const PinosClientNodeEvent client_node_events = {
 | 
				
			||||||
 | 
					  &client_node_done,
 | 
				
			||||||
 | 
					  &client_node_event,
 | 
				
			||||||
 | 
					  &client_node_add_port,
 | 
				
			||||||
 | 
					  &client_node_remove_port,
 | 
				
			||||||
 | 
					  &client_node_set_format,
 | 
				
			||||||
 | 
					  &client_node_set_property,
 | 
				
			||||||
 | 
					  &client_node_add_mem,
 | 
				
			||||||
 | 
					  &client_node_use_buffers,
 | 
				
			||||||
 | 
					  &client_node_node_command,
 | 
				
			||||||
 | 
					  &client_node_port_command,
 | 
				
			||||||
 | 
					  &client_node_transport
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef void (*MarshallFunc) (void *object, void *data, size_t size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern const PinosClientNodeInterface client_node_interface;
 | 
				
			||||||
 | 
					extern const MarshallFunc client_node_marshall[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_node_proxy_destroy (PinosListener *listener,
 | 
					on_node_proxy_destroy (PinosListener *listener,
 | 
				
			||||||
                       PinosProxy    *proxy)
 | 
					                       PinosProxy    *proxy)
 | 
				
			||||||
| 
						 | 
					@ -932,7 +973,6 @@ pinos_stream_connect (PinosStream      *stream,
 | 
				
			||||||
                      SpaFormat       **possible_formats)
 | 
					                      SpaFormat       **possible_formats)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  PinosMessageCreateClientNode ccn;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  impl->direction = direction == PINOS_DIRECTION_INPUT ? SPA_DIRECTION_INPUT : SPA_DIRECTION_OUTPUT;
 | 
					  impl->direction = direction == PINOS_DIRECTION_INPUT ? SPA_DIRECTION_INPUT : SPA_DIRECTION_OUTPUT;
 | 
				
			||||||
  impl->port_id = 0;
 | 
					  impl->port_id = 0;
 | 
				
			||||||
| 
						 | 
					@ -961,19 +1001,16 @@ pinos_stream_connect (PinosStream      *stream,
 | 
				
			||||||
                    &impl->node_proxy_destroy,
 | 
					                    &impl->node_proxy_destroy,
 | 
				
			||||||
                    on_node_proxy_destroy);
 | 
					                    on_node_proxy_destroy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pinos_proxy_set_dispatch (impl->node_proxy,
 | 
					  impl->node_proxy->user_data = stream;
 | 
				
			||||||
                            stream_dispatch_func,
 | 
					  impl->node_proxy->interface = &client_node_interface;
 | 
				
			||||||
                            impl);
 | 
					  impl->node_proxy->event = &client_node_events;
 | 
				
			||||||
 | 
					  impl->node_proxy->marshall = &client_node_marshall;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ccn.seq = ++impl->seq;
 | 
					  pinos_core_do_create_client_node (stream->context->core_proxy,
 | 
				
			||||||
  ccn.name = "client-node";
 | 
					                                    ++impl->seq,
 | 
				
			||||||
  ccn.props = &stream->properties->dict;
 | 
					                                    "client-node",
 | 
				
			||||||
  ccn.new_id = impl->node_proxy->id;
 | 
					                                    &stream->properties->dict,
 | 
				
			||||||
 | 
					                                    impl->node_proxy->id);
 | 
				
			||||||
  pinos_proxy_send_message (stream->context->core_proxy,
 | 
					 | 
				
			||||||
                            PINOS_MESSAGE_CREATE_CLIENT_NODE,
 | 
					 | 
				
			||||||
                            &ccn,
 | 
					 | 
				
			||||||
                            true);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1066,17 +1103,13 @@ bool
 | 
				
			||||||
pinos_stream_disconnect (PinosStream *stream)
 | 
					pinos_stream_disconnect (PinosStream *stream)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  PinosMessageDestroy msg;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  impl->disconnecting = true;
 | 
					  impl->disconnecting = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  unhandle_socket (stream);
 | 
					  unhandle_socket (stream);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  msg.seq = ++impl->seq;
 | 
					  pinos_client_node_do_destroy (impl->node_proxy,
 | 
				
			||||||
  pinos_proxy_send_message (impl->node_proxy,
 | 
					                                ++impl->seq);
 | 
				
			||||||
                            PINOS_MESSAGE_DESTROY,
 | 
					 | 
				
			||||||
                            &msg,
 | 
					 | 
				
			||||||
                            true);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -103,9 +103,8 @@ core_event_info (void          *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
					  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
				
			||||||
  PinosMessageCoreInfo m;
 | 
					  PinosMessageCoreInfo m = { info };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m.info = info;
 | 
					 | 
				
			||||||
  pinos_connection_add_message (client->connection,
 | 
					  pinos_connection_add_message (client->connection,
 | 
				
			||||||
                                resource->id,
 | 
					                                resource->id,
 | 
				
			||||||
                                PINOS_MESSAGE_CORE_INFO,
 | 
					                                PINOS_MESSAGE_CORE_INFO,
 | 
				
			||||||
| 
						 | 
					@ -119,9 +118,8 @@ core_event_done (void          *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
					  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
				
			||||||
  PinosMessageNotifyDone m;
 | 
					  PinosMessageNotifyDone m = { seq };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m.seq = seq;
 | 
					 | 
				
			||||||
  pinos_connection_add_message (client->connection,
 | 
					  pinos_connection_add_message (client->connection,
 | 
				
			||||||
                                resource->id,
 | 
					                                resource->id,
 | 
				
			||||||
                                PINOS_MESSAGE_NOTIFY_DONE,
 | 
					                                PINOS_MESSAGE_NOTIFY_DONE,
 | 
				
			||||||
| 
						 | 
					@ -137,17 +135,14 @@ core_event_error (void          *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
					  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
				
			||||||
  PinosMessageError m;
 | 
					 | 
				
			||||||
  char buffer[128];
 | 
					  char buffer[128];
 | 
				
			||||||
 | 
					  PinosMessageError m = { id, res, buffer };
 | 
				
			||||||
  va_list ap;
 | 
					  va_list ap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  va_start (ap, error);
 | 
					  va_start (ap, error);
 | 
				
			||||||
  vsnprintf (buffer, sizeof (buffer), error, ap);
 | 
					  vsnprintf (buffer, sizeof (buffer), error, ap);
 | 
				
			||||||
  va_end (ap);
 | 
					  va_end (ap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m.id = id;
 | 
					 | 
				
			||||||
  m.res = res;
 | 
					 | 
				
			||||||
  m.error = buffer;
 | 
					 | 
				
			||||||
  pinos_connection_add_message (client->connection,
 | 
					  pinos_connection_add_message (client->connection,
 | 
				
			||||||
                                resource->id,
 | 
					                                resource->id,
 | 
				
			||||||
                                PINOS_MESSAGE_ERROR,
 | 
					                                PINOS_MESSAGE_ERROR,
 | 
				
			||||||
| 
						 | 
					@ -161,9 +156,8 @@ core_event_remove_id (void          *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
					  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
				
			||||||
  PinosMessageRemoveId m;
 | 
					  PinosMessageRemoveId m = { id };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m.id = id;
 | 
					 | 
				
			||||||
  pinos_connection_add_message (client->connection,
 | 
					  pinos_connection_add_message (client->connection,
 | 
				
			||||||
                                resource->id,
 | 
					                                resource->id,
 | 
				
			||||||
                                PINOS_MESSAGE_REMOVE_ID,
 | 
					                                PINOS_MESSAGE_REMOVE_ID,
 | 
				
			||||||
| 
						 | 
					@ -172,47 +166,43 @@ core_event_remove_id (void          *object,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
core_client_update (void  *object,
 | 
					core_marshall_client_update (void  *object,
 | 
				
			||||||
                             void  *data,
 | 
					                             void  *data,
 | 
				
			||||||
                             size_t size)
 | 
					                             size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosMessageClientUpdate *m = data;
 | 
					  PinosMessageClientUpdate *m = data;
 | 
				
			||||||
 | 
					  pinos_core_do_client_update (resource, m->props);
 | 
				
			||||||
  ((PinosCoreInterface*)resource->interface)->client_update (resource, m->props);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
core_sync (void  *object,
 | 
					core_marshall_sync (void  *object,
 | 
				
			||||||
                    void  *data,
 | 
					                    void  *data,
 | 
				
			||||||
                    size_t size)
 | 
					                    size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosMessageSync *m = data;
 | 
					  PinosMessageSync *m = data;
 | 
				
			||||||
 | 
					  pinos_core_do_sync (resource, m->seq);
 | 
				
			||||||
  ((PinosCoreInterface*)resource->interface)->sync (resource, m->seq);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
core_get_registry (void  *object,
 | 
					core_marshall_get_registry (void  *object,
 | 
				
			||||||
                            void  *data,
 | 
					                            void  *data,
 | 
				
			||||||
                            size_t size)
 | 
					                            size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosMessageGetRegistry *m = data;
 | 
					  PinosMessageGetRegistry *m = data;
 | 
				
			||||||
 | 
					  pinos_core_do_get_registry (resource, m->seq, m->new_id);
 | 
				
			||||||
  ((PinosCoreInterface*)resource->interface)->get_registry (resource, m->seq, m->new_id);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
core_create_node (void  *object,
 | 
					core_marshall_create_node (void  *object,
 | 
				
			||||||
                           void  *data,
 | 
					                           void  *data,
 | 
				
			||||||
                           size_t size)
 | 
					                           size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosMessageCreateNode *m = data;
 | 
					  PinosMessageCreateNode *m = data;
 | 
				
			||||||
 | 
					  pinos_core_do_create_node (resource,
 | 
				
			||||||
  ((PinosCoreInterface*)resource->interface)->create_node (resource,
 | 
					 | 
				
			||||||
                             m->seq,
 | 
					                             m->seq,
 | 
				
			||||||
                             m->factory_name,
 | 
					                             m->factory_name,
 | 
				
			||||||
                             m->name,
 | 
					                             m->name,
 | 
				
			||||||
| 
						 | 
					@ -221,14 +211,13 @@ core_create_node (void  *object,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
core_create_client_node (void  *object,
 | 
					core_marshall_create_client_node (void  *object,
 | 
				
			||||||
                                  void  *data,
 | 
					                                  void  *data,
 | 
				
			||||||
                                  size_t size)
 | 
					                                  size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosMessageCreateClientNode *m = data;
 | 
					  PinosMessageCreateClientNode *m = data;
 | 
				
			||||||
 | 
					  pinos_core_do_create_client_node (resource,
 | 
				
			||||||
  ((PinosCoreInterface*)resource->interface)->create_client_node (resource,
 | 
					 | 
				
			||||||
                                    m->seq,
 | 
					                                    m->seq,
 | 
				
			||||||
                                    m->name,
 | 
					                                    m->name,
 | 
				
			||||||
                                    m->props,
 | 
					                                    m->props,
 | 
				
			||||||
| 
						 | 
					@ -242,10 +231,8 @@ registry_event_global (void          *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
					  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
				
			||||||
  PinosMessageNotifyGlobal m;
 | 
					  PinosMessageNotifyGlobal m = { id, type };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m.id = id;
 | 
					 | 
				
			||||||
  m.type = type;
 | 
					 | 
				
			||||||
  pinos_connection_add_message (client->connection,
 | 
					  pinos_connection_add_message (client->connection,
 | 
				
			||||||
                                resource->id,
 | 
					                                resource->id,
 | 
				
			||||||
                                PINOS_MESSAGE_NOTIFY_GLOBAL,
 | 
					                                PINOS_MESSAGE_NOTIFY_GLOBAL,
 | 
				
			||||||
| 
						 | 
					@ -259,9 +246,8 @@ registry_event_global_remove (void          *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
					  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
				
			||||||
  PinosMessageNotifyGlobalRemove m;
 | 
					  PinosMessageNotifyGlobalRemove m = { id };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m.id = id;
 | 
					 | 
				
			||||||
  pinos_connection_add_message (client->connection,
 | 
					  pinos_connection_add_message (client->connection,
 | 
				
			||||||
                                resource->id,
 | 
					                                resource->id,
 | 
				
			||||||
                                PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE,
 | 
					                                PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE,
 | 
				
			||||||
| 
						 | 
					@ -270,14 +256,13 @@ registry_event_global_remove (void          *object,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
registry_bind (void  *object,
 | 
					registry_marshall_bind (void  *object,
 | 
				
			||||||
                        void  *data,
 | 
					                        void  *data,
 | 
				
			||||||
                        size_t size)
 | 
					                        size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosMessageBind *m = data;
 | 
					  PinosMessageBind *m = data;
 | 
				
			||||||
 | 
					  pinos_registry_do_bind (resource,
 | 
				
			||||||
  ((PinosRegistryInterface*)resource->interface)->bind (resource,
 | 
					 | 
				
			||||||
                          m->id,
 | 
					                          m->id,
 | 
				
			||||||
                          m->new_id);
 | 
					                          m->new_id);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -288,9 +273,8 @@ module_event_info (void            *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
					  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
				
			||||||
  PinosMessageModuleInfo m;
 | 
					  PinosMessageModuleInfo m = { info };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m.info = info;
 | 
					 | 
				
			||||||
  pinos_connection_add_message (client->connection,
 | 
					  pinos_connection_add_message (client->connection,
 | 
				
			||||||
                                resource->id,
 | 
					                                resource->id,
 | 
				
			||||||
                                PINOS_MESSAGE_MODULE_INFO,
 | 
					                                PINOS_MESSAGE_MODULE_INFO,
 | 
				
			||||||
| 
						 | 
					@ -304,9 +288,8 @@ node_event_done (void          *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
					  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
				
			||||||
  PinosMessageCreateNodeDone m;
 | 
					  PinosMessageCreateNodeDone m = { seq };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m.seq = seq;
 | 
					 | 
				
			||||||
  pinos_connection_add_message (client->connection,
 | 
					  pinos_connection_add_message (client->connection,
 | 
				
			||||||
                                resource->id,
 | 
					                                resource->id,
 | 
				
			||||||
                                PINOS_MESSAGE_CREATE_NODE_DONE,
 | 
					                                PINOS_MESSAGE_CREATE_NODE_DONE,
 | 
				
			||||||
| 
						 | 
					@ -320,9 +303,8 @@ node_event_info (void          *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
					  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
				
			||||||
  PinosMessageNodeInfo m;
 | 
					  PinosMessageNodeInfo m = { info };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m.info = info;
 | 
					 | 
				
			||||||
  pinos_connection_add_message (client->connection,
 | 
					  pinos_connection_add_message (client->connection,
 | 
				
			||||||
                                resource->id,
 | 
					                                resource->id,
 | 
				
			||||||
                                PINOS_MESSAGE_NODE_INFO,
 | 
					                                PINOS_MESSAGE_NODE_INFO,
 | 
				
			||||||
| 
						 | 
					@ -336,9 +318,8 @@ client_event_info (void          *object,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
					  PinosProtocolNativeClient *client = resource->client->protocol_private;
 | 
				
			||||||
  PinosMessageClientInfo m;
 | 
					  PinosMessageClientInfo m = { info };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  m.info = info;
 | 
					 | 
				
			||||||
  pinos_connection_add_message (client->connection,
 | 
					  pinos_connection_add_message (client->connection,
 | 
				
			||||||
                                resource->id,
 | 
					                                resource->id,
 | 
				
			||||||
                                PINOS_MESSAGE_CLIENT_INFO,
 | 
					                                PINOS_MESSAGE_CLIENT_INFO,
 | 
				
			||||||
| 
						 | 
					@ -533,13 +514,13 @@ client_node_event_transport (void              *object,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
client_node_update (void  *object,
 | 
					client_node_marshall_update (void  *object,
 | 
				
			||||||
                             void  *data,
 | 
					                             void  *data,
 | 
				
			||||||
                             size_t size)
 | 
					                             size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosMessageNodeUpdate *m = data;
 | 
					  PinosMessageNodeUpdate *m = data;
 | 
				
			||||||
  ((PinosClientNodeInterface*)resource->interface)->update (object,
 | 
					  pinos_client_node_do_update (resource,
 | 
				
			||||||
                               m->change_mask,
 | 
					                               m->change_mask,
 | 
				
			||||||
                               m->max_input_ports,
 | 
					                               m->max_input_ports,
 | 
				
			||||||
                               m->max_output_ports,
 | 
					                               m->max_output_ports,
 | 
				
			||||||
| 
						 | 
					@ -547,13 +528,13 @@ client_node_update (void  *object,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
client_node_port_update (void  *object,
 | 
					client_node_marshall_port_update (void  *object,
 | 
				
			||||||
                                  void  *data,
 | 
					                                  void  *data,
 | 
				
			||||||
                                  size_t size)
 | 
					                                  size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosMessagePortUpdate *m = data;
 | 
					  PinosMessagePortUpdate *m = data;
 | 
				
			||||||
  ((PinosClientNodeInterface*)resource->interface)->port_update (object,
 | 
					  pinos_client_node_do_port_update (resource,
 | 
				
			||||||
                                    m->direction,
 | 
					                                    m->direction,
 | 
				
			||||||
                                    m->port_id,
 | 
					                                    m->port_id,
 | 
				
			||||||
                                    m->change_mask,
 | 
					                                    m->change_mask,
 | 
				
			||||||
| 
						 | 
					@ -565,36 +546,33 @@ client_node_port_update (void  *object,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
client_node_state_change (void  *object,
 | 
					client_node_marshall_state_change (void  *object,
 | 
				
			||||||
                                   void  *data,
 | 
					                                   void  *data,
 | 
				
			||||||
                                   size_t size)
 | 
					                                   size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosMessageNodeStateChange *m = data;
 | 
					  PinosMessageNodeStateChange *m = data;
 | 
				
			||||||
  ((PinosClientNodeInterface*)resource->interface)->state_change (object,
 | 
					  pinos_client_node_do_state_change (resource, m->state);
 | 
				
			||||||
                                                                  m->state);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
client_node_event (void   *object,
 | 
					client_node_marshall_event (void   *object,
 | 
				
			||||||
                            void   *data,
 | 
					                            void   *data,
 | 
				
			||||||
                            size_t  size)
 | 
					                            size_t  size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosMessageNodeEvent *m = data;
 | 
					  PinosMessageNodeEvent *m = data;
 | 
				
			||||||
  ((PinosClientNodeInterface*)resource->interface)->event (object,
 | 
					  pinos_client_node_do_event (resource, m->event);
 | 
				
			||||||
                                                           m->event);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
client_node_destroy (void   *object,
 | 
					client_node_marshall_destroy (void   *object,
 | 
				
			||||||
                              void   *data,
 | 
					                              void   *data,
 | 
				
			||||||
                              size_t  size)
 | 
					                              size_t  size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosResource *resource = object;
 | 
					  PinosResource *resource = object;
 | 
				
			||||||
  PinosMessageDestroy *m = data;
 | 
					  PinosMessageDestroy *m = data;
 | 
				
			||||||
  ((PinosClientNodeInterface*)resource->interface)->destroy (object,
 | 
					  pinos_client_node_do_destroy (resource, m->seq);
 | 
				
			||||||
                                                             m->seq);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -626,11 +604,11 @@ on_resource_added (PinosListener *listener,
 | 
				
			||||||
      &core_event_remove_id
 | 
					      &core_event_remove_id
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    static const MarshallFunc core_marshall[] = {
 | 
					    static const MarshallFunc core_marshall[] = {
 | 
				
			||||||
      [PINOS_MESSAGE_CLIENT_UPDATE] = &core_client_update,
 | 
					      [PINOS_MESSAGE_CLIENT_UPDATE] = &core_marshall_client_update,
 | 
				
			||||||
      [PINOS_MESSAGE_SYNC] = &core_sync,
 | 
					      [PINOS_MESSAGE_SYNC] = &core_marshall_sync,
 | 
				
			||||||
      [PINOS_MESSAGE_GET_REGISTRY] = &core_get_registry,
 | 
					      [PINOS_MESSAGE_GET_REGISTRY] = &core_marshall_get_registry,
 | 
				
			||||||
      [PINOS_MESSAGE_CREATE_NODE] = &core_create_node,
 | 
					      [PINOS_MESSAGE_CREATE_NODE] = &core_marshall_create_node,
 | 
				
			||||||
      [PINOS_MESSAGE_CREATE_CLIENT_NODE] = &core_create_client_node
 | 
					      [PINOS_MESSAGE_CREATE_CLIENT_NODE] = &core_marshall_create_client_node
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    resource->event = &core_event;
 | 
					    resource->event = &core_event;
 | 
				
			||||||
    resource->marshall = &core_marshall;
 | 
					    resource->marshall = &core_marshall;
 | 
				
			||||||
| 
						 | 
					@ -641,7 +619,7 @@ on_resource_added (PinosListener *listener,
 | 
				
			||||||
      ®istry_event_global_remove,
 | 
					      ®istry_event_global_remove,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    static const MarshallFunc registry_marshall[] = {
 | 
					    static const MarshallFunc registry_marshall[] = {
 | 
				
			||||||
      [PINOS_MESSAGE_BIND] = ®istry_bind,
 | 
					      [PINOS_MESSAGE_BIND] = ®istry_marshall_bind,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    resource->event = ®istry_event;
 | 
					    resource->event = ®istry_event;
 | 
				
			||||||
    resource->marshall = ®istry_marshall;
 | 
					    resource->marshall = ®istry_marshall;
 | 
				
			||||||
| 
						 | 
					@ -683,11 +661,11 @@ on_resource_added (PinosListener *listener,
 | 
				
			||||||
      &client_node_event_transport,
 | 
					      &client_node_event_transport,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    static const MarshallFunc client_node_marshall[] = {
 | 
					    static const MarshallFunc client_node_marshall[] = {
 | 
				
			||||||
      [PINOS_MESSAGE_NODE_UPDATE] = &client_node_update,
 | 
					      [PINOS_MESSAGE_NODE_UPDATE] = &client_node_marshall_update,
 | 
				
			||||||
      [PINOS_MESSAGE_PORT_UPDATE] = &client_node_port_update,
 | 
					      [PINOS_MESSAGE_PORT_UPDATE] = &client_node_marshall_port_update,
 | 
				
			||||||
      [PINOS_MESSAGE_NODE_STATE_CHANGE] = &client_node_state_change,
 | 
					      [PINOS_MESSAGE_NODE_STATE_CHANGE] = &client_node_marshall_state_change,
 | 
				
			||||||
      [PINOS_MESSAGE_NODE_EVENT] = &client_node_event,
 | 
					      [PINOS_MESSAGE_NODE_EVENT] = &client_node_marshall_event,
 | 
				
			||||||
      [PINOS_MESSAGE_DESTROY] = &client_node_destroy,
 | 
					      [PINOS_MESSAGE_DESTROY] = &client_node_marshall_destroy,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    resource->event = &client_node_events;
 | 
					    resource->event = &client_node_events;
 | 
				
			||||||
    resource->marshall = &client_node_marshall;
 | 
					    resource->marshall = &client_node_marshall;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,13 +35,6 @@ typedef struct _PinosClient PinosClient;
 | 
				
			||||||
#include <pinos/server/core.h>
 | 
					#include <pinos/server/core.h>
 | 
				
			||||||
#include <pinos/server/resource.h>
 | 
					#include <pinos/server/resource.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef SpaResult (*PinosSendFunc) (void             *object,
 | 
					 | 
				
			||||||
                                    uint32_t          id,
 | 
					 | 
				
			||||||
                                    uint32_t          opcode,
 | 
					 | 
				
			||||||
                                    void             *message,
 | 
					 | 
				
			||||||
                                    bool              flush,
 | 
					 | 
				
			||||||
                                    void             *data);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * PinosClient:
 | 
					 * PinosClient:
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,9 +24,6 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
  PinosResource this;
 | 
					  PinosResource this;
 | 
				
			||||||
 | 
					 | 
				
			||||||
  PinosDispatchFunc  dispatch_func;
 | 
					 | 
				
			||||||
  void              *dispatch_data;
 | 
					 | 
				
			||||||
} PinosResourceImpl;
 | 
					} PinosResourceImpl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PinosResource *
 | 
					PinosResource *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue