mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-25 06:59:57 -05:00
context: use need_flush signal to schedule flush
Use the need_flush signal to signal an event that triggers a flush in the main thread.
This commit is contained in:
parent
3ab17281f6
commit
4c4c0f2a7f
1 changed files with 22 additions and 10 deletions
|
|
@ -38,7 +38,8 @@ typedef struct {
|
||||||
SpaSource source;
|
SpaSource source;
|
||||||
|
|
||||||
bool disconnecting;
|
bool disconnecting;
|
||||||
PinosListener before_iterate;
|
PinosListener need_flush;
|
||||||
|
SpaSource *flush_event;
|
||||||
} PinosContextImpl;
|
} PinosContextImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -374,13 +375,22 @@ static const PinosRegistryEvents registry_events = {
|
||||||
typedef bool (*PinosDemarshalFunc) (void *object, void *data, size_t size);
|
typedef bool (*PinosDemarshalFunc) (void *object, void *data, size_t size);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_before_iterate (PinosListener *listener,
|
do_flush_event (SpaSource *source,
|
||||||
PinosLoop *loop)
|
void *data)
|
||||||
{
|
{
|
||||||
PinosContextImpl *impl = SPA_CONTAINER_OF (listener, PinosContextImpl, before_iterate);
|
PinosContextImpl *impl = data;
|
||||||
pinos_connection_flush (impl->connection);
|
pinos_connection_flush (impl->connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_need_flush (PinosListener *listener,
|
||||||
|
PinosConnection *connection)
|
||||||
|
{
|
||||||
|
PinosContextImpl *impl = SPA_CONTAINER_OF (listener, PinosContextImpl, need_flush);
|
||||||
|
PinosContext *this = &impl->this;
|
||||||
|
pinos_loop_signal_event (this->loop, impl->flush_event);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_context_data (SpaSource *source,
|
on_context_data (SpaSource *source,
|
||||||
int fd,
|
int fd,
|
||||||
|
|
@ -472,11 +482,9 @@ pinos_context_new (PinosLoop *loop,
|
||||||
|
|
||||||
this->loop = loop;
|
this->loop = loop;
|
||||||
|
|
||||||
this->state = PINOS_CONTEXT_STATE_UNCONNECTED;
|
impl->flush_event = pinos_loop_add_event (loop, do_flush_event, impl);
|
||||||
|
|
||||||
pinos_signal_add (&loop->before_iterate,
|
this->state = PINOS_CONTEXT_STATE_UNCONNECTED;
|
||||||
&impl->before_iterate,
|
|
||||||
on_before_iterate);
|
|
||||||
|
|
||||||
pinos_map_init (&this->objects, 64);
|
pinos_map_init (&this->objects, 64);
|
||||||
pinos_map_init (&this->uris, 64);
|
pinos_map_init (&this->uris, 64);
|
||||||
|
|
@ -515,10 +523,10 @@ pinos_context_destroy (PinosContext *context)
|
||||||
spa_list_for_each_safe (proxy, t2, &context->proxy_list, link)
|
spa_list_for_each_safe (proxy, t2, &context->proxy_list, link)
|
||||||
pinos_proxy_destroy (proxy);
|
pinos_proxy_destroy (proxy);
|
||||||
|
|
||||||
pinos_signal_remove (&impl->before_iterate);
|
|
||||||
|
|
||||||
pinos_map_clear (&context->objects);
|
pinos_map_clear (&context->objects);
|
||||||
|
|
||||||
|
pinos_loop_destroy_source (impl->this.loop, impl->flush_event);
|
||||||
|
|
||||||
free (context->name);
|
free (context->name);
|
||||||
if (context->properties)
|
if (context->properties)
|
||||||
pinos_properties_free (context->properties);
|
pinos_properties_free (context->properties);
|
||||||
|
|
@ -607,6 +615,10 @@ pinos_context_connect_fd (PinosContext *context,
|
||||||
|
|
||||||
context->protocol_private = impl->connection;
|
context->protocol_private = impl->connection;
|
||||||
|
|
||||||
|
pinos_signal_add (&impl->connection->need_flush,
|
||||||
|
&impl->need_flush,
|
||||||
|
on_need_flush);
|
||||||
|
|
||||||
impl->fd = fd;
|
impl->fd = fd;
|
||||||
|
|
||||||
pinos_loop_add_io (context->loop,
|
pinos_loop_add_io (context->loop,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue