context: hide data_loop_impl

This commit is contained in:
Wim Taymans 2023-04-28 17:04:29 +02:00
parent 216d788ce5
commit 2112216d28
3 changed files with 20 additions and 16 deletions

View file

@ -38,6 +38,8 @@ struct impl {
struct spa_plugin_loader plugin_loader; struct spa_plugin_loader plugin_loader;
unsigned int recalc:1; unsigned int recalc:1;
unsigned int recalc_pending:1; unsigned int recalc_pending:1;
struct pw_data_loop *data_loop_impl;
}; };
@ -83,10 +85,11 @@ static void fill_properties(struct pw_context *context)
static int context_set_freewheel(struct pw_context *context, bool freewheel) static int context_set_freewheel(struct pw_context *context, bool freewheel)
{ {
struct impl *impl = SPA_CONTAINER_OF(context, struct impl, this);
struct spa_thread *thr; struct spa_thread *thr;
int res = 0; int res = 0;
if ((thr = pw_data_loop_get_thread(context->data_loop_impl)) == NULL) if ((thr = pw_data_loop_get_thread(impl->data_loop_impl)) == NULL)
return -EIO; return -EIO;
if (freewheel) { if (freewheel) {
@ -274,9 +277,9 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop,
if ((str = pw_properties_get(pr, "context.data-loop." PW_KEY_LIBRARY_NAME_SYSTEM))) if ((str = pw_properties_get(pr, "context.data-loop." PW_KEY_LIBRARY_NAME_SYSTEM)))
pw_properties_set(pr, PW_KEY_LIBRARY_NAME_SYSTEM, str); pw_properties_set(pr, PW_KEY_LIBRARY_NAME_SYSTEM, str);
this->data_loop_impl = pw_data_loop_new(&pr->dict); impl->data_loop_impl = pw_data_loop_new(&pr->dict);
pw_properties_free(pr); pw_properties_free(pr);
if (this->data_loop_impl == NULL) { if (impl->data_loop_impl == NULL) {
res = -errno; res = -errno;
goto error_free; goto error_free;
} }
@ -287,7 +290,7 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop,
goto error_free; goto error_free;
} }
this->data_loop = pw_data_loop_get_loop(this->data_loop_impl); this->data_loop = pw_data_loop_get_loop(impl->data_loop_impl);
this->data_system = this->data_loop->system; this->data_system = this->data_loop->system;
this->main_loop = main_loop; this->main_loop = main_loop;
@ -353,10 +356,10 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop,
goto error_free; goto error_free;
pw_log_info("%p: parsed %d context.exec items", this, res); pw_log_info("%p: parsed %d context.exec items", this, res);
if ((res = pw_data_loop_start(this->data_loop_impl)) < 0) if ((res = pw_data_loop_start(impl->data_loop_impl)) < 0)
goto error_free; goto error_free;
pw_data_loop_invoke(this->data_loop_impl, pw_data_loop_invoke(impl->data_loop_impl,
do_data_loop_setup, 0, NULL, 0, false, this); do_data_loop_setup, 0, NULL, 0, false, this);
pw_settings_expose(this); pw_settings_expose(this);
@ -409,8 +412,8 @@ void pw_context_destroy(struct pw_context *context)
spa_list_consume(resource, &context->registry_resource_list, link) spa_list_consume(resource, &context->registry_resource_list, link)
pw_resource_destroy(resource); pw_resource_destroy(resource);
if (context->data_loop_impl) if (impl->data_loop_impl)
pw_data_loop_stop(context->data_loop_impl); pw_data_loop_stop(impl->data_loop_impl);
spa_list_consume(module, &context->module_list, link) spa_list_consume(module, &context->module_list, link)
pw_impl_module_destroy(module); pw_impl_module_destroy(module);
@ -427,8 +430,8 @@ void pw_context_destroy(struct pw_context *context)
pw_log_debug("%p: free", context); pw_log_debug("%p: free", context);
pw_context_emit_free(context); pw_context_emit_free(context);
if (context->data_loop_impl) if (impl->data_loop_impl)
pw_data_loop_destroy(context->data_loop_impl); pw_data_loop_destroy(impl->data_loop_impl);
if (context->pool) if (context->pool)
pw_mempool_destroy(context->pool); pw_mempool_destroy(context->pool);
@ -491,7 +494,8 @@ struct pw_loop *pw_context_get_main_loop(struct pw_context *context)
SPA_EXPORT SPA_EXPORT
struct pw_data_loop *pw_context_get_data_loop(struct pw_context *context) struct pw_data_loop *pw_context_get_data_loop(struct pw_context *context)
{ {
return context->data_loop_impl; struct impl *impl = SPA_CONTAINER_OF(context, struct impl, this);
return impl->data_loop_impl;
} }
SPA_EXPORT SPA_EXPORT
@ -1609,6 +1613,7 @@ SPA_EXPORT
int pw_context_set_object(struct pw_context *context, const char *type, void *value) int pw_context_set_object(struct pw_context *context, const char *type, void *value)
{ {
struct object_entry *entry; struct object_entry *entry;
struct impl *impl = SPA_CONTAINER_OF(context, struct impl, this);
entry = find_object(context, type); entry = find_object(context, type);
@ -1626,8 +1631,8 @@ int pw_context_set_object(struct pw_context *context, const char *type, void *va
} }
if (spa_streq(type, SPA_TYPE_INTERFACE_ThreadUtils)) { if (spa_streq(type, SPA_TYPE_INTERFACE_ThreadUtils)) {
context->thread_utils = value; context->thread_utils = value;
if (context->data_loop_impl) if (impl->data_loop_impl)
pw_data_loop_set_thread_utils(context->data_loop_impl, pw_data_loop_set_thread_utils(impl->data_loop_impl,
context->thread_utils); context->thread_utils);
} }
return 0; return 0;

View file

@ -146,7 +146,7 @@ do_node_add(struct spa_loop *loop, bool async, uint32_t seq, const void *data, s
this->added = true; this->added = true;
if (this->source.loop == NULL) { if (this->source.loop == NULL) {
struct spa_system *data_system = this->data_loop->system; struct spa_system *data_system = this->data_system;
uint64_t dummy; uint64_t dummy;
int res; int res;
@ -1126,7 +1126,7 @@ static inline int process_node(void *data)
struct pw_impl_node *this = data; struct pw_impl_node *this = data;
struct pw_impl_port *p; struct pw_impl_port *p;
struct pw_node_activation *a = this->rt.activation; struct pw_node_activation *a = this->rt.activation;
struct spa_system *data_system = this->data_loop->system; struct spa_system *data_system = this->data_system;
int status; int status;
uint64_t nsec; uint64_t nsec;

View file

@ -475,7 +475,6 @@ struct pw_context {
struct spa_thread_utils *thread_utils; struct spa_thread_utils *thread_utils;
struct pw_loop *main_loop; /**< main loop for control */ struct pw_loop *main_loop; /**< main loop for control */
struct pw_loop *data_loop; /**< data loop for data passing */ struct pw_loop *data_loop; /**< data loop for data passing */
struct pw_data_loop *data_loop_impl;
struct spa_system *data_system; /**< data system for data passing */ struct spa_system *data_system; /**< data system for data passing */
struct pw_work_queue *work_queue; /**< work queue */ struct pw_work_queue *work_queue; /**< work queue */