context: add option to disable registry

This commit is contained in:
Wim Taymans 2017-04-21 16:39:14 +02:00
parent c29fed1ac8
commit 02d4dc0efd
9 changed files with 44 additions and 23 deletions

View file

@ -33,6 +33,8 @@
typedef struct {
PinosContext this;
bool no_proxy;
int fd;
PinosConnection *connection;
SpaSource source;
@ -304,8 +306,12 @@ registry_event_global (void *object,
{
PinosProxy *registry_proxy = object;
PinosContext *this = registry_proxy->context;
PinosContextImpl *impl = SPA_CONTAINER_OF (this, PinosContextImpl, this);
PinosProxy *proxy = NULL;
if (impl->no_proxy)
return;
pinos_log_debug ("got global %u %s", id, type);
if (!strcmp (type, PINOS_TYPE__Node)) {
@ -342,7 +348,7 @@ registry_event_global (void *object,
proxy->implementation = &link_events;
}
if (proxy) {
pinos_registry_do_bind (this->registry_proxy, id, proxy->id);
pinos_registry_do_bind (registry_proxy, id, proxy->id);
}
return;
@ -547,7 +553,8 @@ pinos_context_destroy (PinosContext *context)
* Returns: %TRUE on success.
*/
bool
pinos_context_connect (PinosContext *context)
pinos_context_connect (PinosContext *context,
PinosContextFlags flags)
{
struct sockaddr_un addr;
socklen_t size;
@ -589,7 +596,7 @@ pinos_context_connect (PinosContext *context)
goto error_close;
}
return pinos_context_connect_fd (context, fd);
return pinos_context_connect_fd (context, flags, fd);
error_close:
close (fd);
@ -606,8 +613,9 @@ error_close:
* Returns: %TRUE on success.
*/
bool
pinos_context_connect_fd (PinosContext *context,
int fd)
pinos_context_connect_fd (PinosContext *context,
PinosContextFlags flags,
int fd)
{
PinosContextImpl *impl = SPA_CONTAINER_OF (context, PinosContextImpl, this);
@ -643,16 +651,20 @@ pinos_context_connect_fd (PinosContext *context,
pinos_core_do_client_update (context->core_proxy,
&context->properties->dict);
context->registry_proxy = pinos_proxy_new (context,
SPA_ID_INVALID,
context->type.registry);
if (context->registry_proxy == NULL)
goto no_registry;
if (!(flags & PINOS_CONTEXT_FLAG_NO_REGISTRY)) {
context->registry_proxy = pinos_proxy_new (context,
SPA_ID_INVALID,
context->type.registry);
if (context->registry_proxy == NULL)
goto no_registry;
context->registry_proxy->implementation = &registry_events;
context->registry_proxy->implementation = &registry_events;
pinos_core_do_get_registry (context->core_proxy,
context->registry_proxy->id);
pinos_core_do_get_registry (context->core_proxy,
context->registry_proxy->id);
}
impl->no_proxy = !!(flags & PINOS_CONTEXT_FLAG_NO_PROXY);
pinos_core_do_sync (context->core_proxy, 0);

View file

@ -49,6 +49,12 @@ typedef enum {
PINOS_CONTEXT_STATE_CONNECTED = 2,
} PinosContextState;
typedef enum {
PINOS_CONTEXT_FLAG_NONE = 0,
PINOS_CONTEXT_FLAG_NO_REGISTRY = (1 << 0),
PINOS_CONTEXT_FLAG_NO_PROXY = (1 << 1),
} PinosContextFlags;
const char * pinos_context_state_as_string (PinosContextState state);
/**
@ -97,8 +103,10 @@ PinosContext * pinos_context_new (PinosLoop *loop,
PinosProperties *properties);
void pinos_context_destroy (PinosContext *context);
bool pinos_context_connect (PinosContext *context);
bool pinos_context_connect (PinosContext *context,
PinosContextFlags flags);
bool pinos_context_connect_fd (PinosContext *context,
PinosContextFlags flags,
int fd);
bool pinos_context_disconnect (PinosContext *context);

View file

@ -44,12 +44,12 @@ typedef enum {
const char * pinos_stream_state_as_string (PinosStreamState state);
typedef enum {
PINOS_STREAM_FLAG_NONE = 0,
PINOS_STREAM_FLAG_NONE = 0,
PINOS_STREAM_FLAG_AUTOCONNECT = (1 << 0),
} PinosStreamFlags;
typedef enum {
PINOS_STREAM_MODE_BUFFER = 0,
PINOS_STREAM_MODE_BUFFER = 0,
PINOS_STREAM_MODE_RINGBUFFER = 1,
} PinosStreamMode;

View file

@ -401,7 +401,7 @@ main (int argc, char *argv[])
&data.on_state_changed,
on_state_changed);
pinos_context_connect (data.context);
pinos_context_connect (data.context, PINOS_CONTEXT_FLAG_NO_REGISTRY);
pinos_loop_enter (data.loop);
while (data.running) {

View file

@ -269,7 +269,8 @@ main (int argc, char *argv[])
&data.on_state_changed,
on_state_changed);
pinos_context_connect (data.context);
pinos_context_connect (data.context,
PINOS_CONTEXT_FLAG_NO_REGISTRY);
pinos_loop_enter (data.loop);
while (data.running) {

View file

@ -373,7 +373,7 @@ gst_pinos_device_provider_probe (GstDeviceProvider * provider)
if (!(c = pinos_context_new (l, self->client_name, NULL)))
goto failed;
pinos_context_connect (c);
pinos_context_connect (c, 0);
for (;;) {
PinosContextState state;
@ -479,7 +479,7 @@ gst_pinos_device_provider_start (GstDeviceProvider * provider)
&self->ctx_subscription,
on_context_subscription);
pinos_context_connect (self->context);
pinos_context_connect (self->context, 0);
for (;;) {
PinosContextState state;

View file

@ -823,7 +823,7 @@ gst_pinos_sink_open (GstPinosSink * pinossink)
pinos_signal_add (&pinossink->ctx->state_changed, &pinossink->ctx_state_changed, on_ctx_state_changed);
pinos_context_connect (pinossink->ctx);
pinos_context_connect (pinossink->ctx, PINOS_CONTEXT_FLAG_NO_REGISTRY);
while (TRUE) {
PinosContextState state = pinossink->ctx->state;

View file

@ -1037,7 +1037,7 @@ gst_pinos_src_open (GstPinosSrc * pinossrc)
pinos_signal_add (&pinossrc->ctx->state_changed, &pinossrc->ctx_state_changed, on_ctx_state_changed);
pinos_context_connect (pinossrc->ctx);
pinos_context_connect (pinossrc->ctx, PINOS_CONTEXT_FLAG_NO_REGISTRY);
while (TRUE) {
PinosContextState state = pinossrc->ctx->state;

View file

@ -288,7 +288,7 @@ main (int argc, char *argv[])
&data.on_subscription,
on_subscription);
pinos_context_connect (data.context);
pinos_context_connect (data.context, 0);
pinos_loop_enter (data.loop);
while (data.running) {