mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
core: add user_data to core
This commit is contained in:
parent
fb5ae6df43
commit
979d155382
19 changed files with 37 additions and 20 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 3d9fab3aaf1e52c2481a445255841675e75def0c
|
||||
Subproject commit 5a8c6d457e846639e4e949461ecf3f494cabba39
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 25b8a7919f021e5b6354febe37e320adc8b9a297
|
||||
Subproject commit a8fb217ebac920a8fd545dc182b3f292e4599002
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit ac4ad7c8f1e36e178b7d4a230b50fd5aafba5524
|
||||
Subproject commit 5680e29716f3d621fa25b26bfd60234778ec02b9
|
||||
|
|
@ -104,7 +104,7 @@ int main(int argc, char *argv[])
|
|||
pw_loop_add_signal(pw_main_loop_get_loop(loop), SIGINT, do_quit, loop);
|
||||
pw_loop_add_signal(pw_main_loop_get_loop(loop), SIGTERM, do_quit, loop);
|
||||
|
||||
core = pw_core_new(pw_main_loop_get_loop(loop), props);
|
||||
core = pw_core_new(pw_main_loop_get_loop(loop), props, 0);
|
||||
|
||||
if (pw_daemon_config_run_commands(config, core) < 0) {
|
||||
pw_log_error("failed to run config commands");
|
||||
|
|
|
|||
|
|
@ -555,7 +555,7 @@ int main(int argc, char *argv[])
|
|||
pw_init(&argc, &argv);
|
||||
|
||||
data.loop = pw_main_loop_new(NULL);
|
||||
data.core = pw_core_new(pw_main_loop_get_loop(data.loop), NULL);
|
||||
data.core = pw_core_new(pw_main_loop_get_loop(data.loop), NULL, 0);
|
||||
data.remote = pw_remote_new(data.core, NULL, 0);
|
||||
data.path = argc > 1 ? argv[1] : NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -542,7 +542,7 @@ int main(int argc, char *argv[])
|
|||
pw_init(&argc, &argv);
|
||||
|
||||
data.loop = pw_main_loop_new(NULL);
|
||||
data.core = pw_core_new(pw_main_loop_get_loop(data.loop), NULL);
|
||||
data.core = pw_core_new(pw_main_loop_get_loop(data.loop), NULL, 0);
|
||||
data.remote = pw_remote_new(data.core, NULL, 0);
|
||||
data.path = argc > 1 ? argv[1] : NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ int main(int argc, char *argv[])
|
|||
l = pw_main_loop_get_loop(data.loop);
|
||||
pw_loop_add_signal(l, SIGINT, do_quit, &data);
|
||||
pw_loop_add_signal(l, SIGTERM, do_quit, &data);
|
||||
data.core = pw_core_new(l, NULL);
|
||||
data.core = pw_core_new(l, NULL, 0);
|
||||
data.remote = pw_remote_new(data.core, NULL, 0);
|
||||
data.library = argv[1];
|
||||
data.factory = argv[2];
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ int main(int argc, char *argv[])
|
|||
pw_init(&argc, &argv);
|
||||
|
||||
data.loop = pw_main_loop_new(NULL);
|
||||
data.core = pw_core_new(pw_main_loop_get_loop(data.loop), NULL);
|
||||
data.core = pw_core_new(pw_main_loop_get_loop(data.loop), NULL, 0);
|
||||
|
||||
pw_module_load(data.core, "libpipewire-module-spa-node-factory", NULL, NULL, NULL, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -1329,7 +1329,7 @@ int main(int argc, char *argv[])
|
|||
pw_init(&argc, &argv);
|
||||
|
||||
impl.loop = pw_main_loop_new(NULL);
|
||||
impl.core = pw_core_new(pw_main_loop_get_loop(impl.loop), NULL);
|
||||
impl.core = pw_core_new(pw_main_loop_get_loop(impl.loop), NULL, 0);
|
||||
impl.remote = pw_remote_new(impl.core, NULL, 0);
|
||||
|
||||
pw_map_init(&impl.globals, 64, 64);
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ int main(int argc, char *argv[])
|
|||
pw_init(&argc, &argv);
|
||||
|
||||
data.loop = pw_main_loop_new(NULL);
|
||||
data.core = pw_core_new(pw_main_loop_get_loop(data.loop), NULL);
|
||||
data.core = pw_core_new(pw_main_loop_get_loop(data.loop), NULL, 0);
|
||||
data.remote = pw_remote_new(data.core, NULL, 0);
|
||||
|
||||
data.timer = pw_loop_add_timer(pw_main_loop_get_loop(data.loop), on_timeout, &data);
|
||||
|
|
|
|||
|
|
@ -533,7 +533,7 @@ gst_pipewire_device_provider_probe (GstDeviceProvider * provider)
|
|||
if (!(l = pw_loop_new (NULL)))
|
||||
return NULL;
|
||||
|
||||
if (!(c = pw_core_new (l, NULL)))
|
||||
if (!(c = pw_core_new (l, NULL, 0)))
|
||||
return NULL;
|
||||
|
||||
if (!(r = pw_remote_new (c, NULL, sizeof(*data))))
|
||||
|
|
@ -619,7 +619,7 @@ gst_pipewire_device_provider_start (GstDeviceProvider * provider)
|
|||
goto failed_main_loop;
|
||||
}
|
||||
|
||||
if (!(self->core = pw_core_new (self->loop, NULL))) {
|
||||
if (!(self->core = pw_core_new (self->loop, NULL, 0))) {
|
||||
GST_ERROR_OBJECT (self, "Could not create PipeWire core");
|
||||
goto failed_core;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ gst_pipewire_sink_init (GstPipeWireSink * sink)
|
|||
|
||||
sink->loop = pw_loop_new (NULL);
|
||||
sink->main_loop = pw_thread_loop_new (sink->loop, "pipewire-sink-loop");
|
||||
sink->core = pw_core_new (sink->loop, NULL);
|
||||
sink->core = pw_core_new (sink->loop, NULL, 0);
|
||||
GST_DEBUG ("loop %p %p", sink->loop, sink->main_loop);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ gst_pipewire_src_init (GstPipeWireSrc * src)
|
|||
src->pool = gst_pipewire_pool_new ();
|
||||
src->loop = pw_loop_new (NULL);
|
||||
src->main_loop = pw_thread_loop_new (src->loop, "pipewire-main-loop");
|
||||
src->core = pw_core_new (src->loop, NULL);
|
||||
src->core = pw_core_new (src->loop, NULL, 0);
|
||||
GST_DEBUG ("loop %p, mainloop %p", src->loop, src->main_loop);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -396,13 +396,15 @@ static const struct pw_global_events global_events = {
|
|||
*
|
||||
* \memberof pw_core
|
||||
*/
|
||||
struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *properties)
|
||||
struct pw_core *pw_core_new(struct pw_loop *main_loop,
|
||||
struct pw_properties *properties,
|
||||
size_t user_data_size)
|
||||
{
|
||||
struct impl *impl;
|
||||
struct pw_core *this;
|
||||
const char *name;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
impl = calloc(1, sizeof(struct impl) + user_data_size);
|
||||
if (impl == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -410,6 +412,9 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro
|
|||
|
||||
pw_log_debug("core %p: new", this);
|
||||
|
||||
if (user_data_size > 0)
|
||||
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
|
||||
|
||||
if (properties == NULL)
|
||||
properties = pw_properties_new(NULL, NULL);
|
||||
if (properties == NULL)
|
||||
|
|
@ -545,6 +550,11 @@ void pw_core_destroy(struct pw_core *core)
|
|||
free(core);
|
||||
}
|
||||
|
||||
void *pw_core_get_user_data(struct pw_core *core)
|
||||
{
|
||||
return core->user_data;
|
||||
}
|
||||
|
||||
const struct pw_core_info *pw_core_get_info(struct pw_core *core)
|
||||
{
|
||||
return &core->info;
|
||||
|
|
|
|||
|
|
@ -109,11 +109,16 @@ struct pw_core_events {
|
|||
#define PW_CORE_PROP_DAEMON "pipewire.daemon"
|
||||
|
||||
/** Make a new core object for a given main_loop. Ownership of the properties is taken */
|
||||
struct pw_core * pw_core_new(struct pw_loop *main_loop, struct pw_properties *props);
|
||||
struct pw_core * pw_core_new(struct pw_loop *main_loop, /**< a main loop to run in */
|
||||
struct pw_properties *props, /**< extra properties */
|
||||
size_t user_data_size /**< extra user data size */);
|
||||
|
||||
/** destroy a core object, all resources except the main_loop will be destroyed */
|
||||
void pw_core_destroy(struct pw_core *core);
|
||||
|
||||
/** Get the core user data */
|
||||
void *pw_core_get_user_data(struct pw_core *core);
|
||||
|
||||
/** Add a new event listener to a core */
|
||||
void pw_core_add_listener(struct pw_core *core,
|
||||
struct spa_hook *listener,
|
||||
|
|
|
|||
|
|
@ -192,6 +192,8 @@ struct pw_core {
|
|||
struct pw_client *current_client; /**< client currently executing code in mainloop */
|
||||
|
||||
long sc_pagesize;
|
||||
|
||||
void *user_data; /**< extra user data */
|
||||
};
|
||||
|
||||
#define pw_data_loop_events_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_data_loop_events, m, v, ##__VA_ARGS__)
|
||||
|
|
|
|||
|
|
@ -940,7 +940,7 @@ pw_stream_new_simple(struct pw_loop *loop,
|
|||
struct pw_core *core;
|
||||
struct pw_remote *remote;
|
||||
|
||||
core = pw_core_new(loop, NULL);
|
||||
core = pw_core_new(loop, NULL, 0);
|
||||
remote = pw_remote_new(core, NULL, 0);
|
||||
|
||||
stream = pw_stream_new(remote, name, props);
|
||||
|
|
|
|||
|
|
@ -1332,7 +1332,7 @@ int main(int argc, char *argv[])
|
|||
spa_list_init(&data.remotes);
|
||||
pw_map_init(&data.vars, 64, 16);
|
||||
|
||||
data.core = pw_core_new(l, pw_properties_new(PW_CORE_PROP_DAEMON, "1", NULL));
|
||||
data.core = pw_core_new(l, pw_properties_new(PW_CORE_PROP_DAEMON, "1", NULL), 0);
|
||||
info = pw_core_get_info(data.core);
|
||||
|
||||
pw_module_load(data.core, "libpipewire-module-link-factory", NULL, NULL, NULL, NULL);
|
||||
|
|
|
|||
|
|
@ -675,7 +675,7 @@ int main(int argc, char *argv[])
|
|||
pw_loop_add_signal(l, SIGINT, do_quit, &data);
|
||||
pw_loop_add_signal(l, SIGTERM, do_quit, &data);
|
||||
|
||||
data.core = pw_core_new(l, NULL);
|
||||
data.core = pw_core_new(l, NULL, 0);
|
||||
if (data.core == NULL)
|
||||
return -1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue