diff --git a/spa/examples/example-control.c b/spa/examples/example-control.c index 780dd668e..3c22e7642 100644 --- a/spa/examples/example-control.c +++ b/spa/examples/example-control.c @@ -509,7 +509,7 @@ int main(int argc, char *argv[]) data.log->level = atoi(str); data.support[0] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, data.log); - data.support[1] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_MainLoop, &data.data_loop); + data.support[1] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Loop, &data.data_loop); data.support[2] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DataLoop, &data.data_loop); data.n_support = 3; diff --git a/spa/examples/local-v4l2.c b/spa/examples/local-v4l2.c index 66d1aa777..b6d185d14 100644 --- a/spa/examples/local-v4l2.c +++ b/spa/examples/local-v4l2.c @@ -491,7 +491,7 @@ int main(int argc, char *argv[]) data.log->level = atoi(str); data.support[0] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, data.log); - data.support[1] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_MainLoop, data.loop); + data.support[1] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Loop, data.loop); data.support[2] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DataLoop, data.loop); data.n_support = 3; diff --git a/spa/include/spa/utils/type-info.h b/spa/include/spa/utils/type-info.h index 188fedaa9..088c337c9 100644 --- a/spa/include/spa/utils/type-info.h +++ b/spa/include/spa/utils/type-info.h @@ -107,8 +107,8 @@ static const struct spa_type_info spa_types[] = { { SPA_TYPE_INTERFACE_Loop, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "Loop", NULL }, { SPA_TYPE_INTERFACE_LoopControl, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "LoopControl", NULL }, { SPA_TYPE_INTERFACE_LoopUtils, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "LoopUtils", NULL }, + { SPA_TYPE_INTERFACE_DataSystem, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "DataSystem", NULL }, { SPA_TYPE_INTERFACE_DataLoop, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "DataLoop", NULL }, - { SPA_TYPE_INTERFACE_MainLoop, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "MainLoop", NULL }, { SPA_TYPE_INTERFACE_DBus, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "DBus", NULL }, { SPA_TYPE_INTERFACE_Monitor, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "Monitor", NULL }, { SPA_TYPE_INTERFACE_Node, SPA_TYPE_Pointer, SPA_TYPE_INFO_INTERFACE_BASE "Node", NULL }, diff --git a/spa/include/spa/utils/type.h b/spa/include/spa/utils/type.h index 472275047..647b9528f 100644 --- a/spa/include/spa/utils/type.h +++ b/spa/include/spa/utils/type.h @@ -69,11 +69,11 @@ enum { SPA_TYPE_INTERFACE_HandleFactory, /**< factory for object handles */ SPA_TYPE_INTERFACE_Log, /**< log interface */ SPA_TYPE_INTERFACE_System, /**< System functions */ - SPA_TYPE_INTERFACE_Loop, /**< poll loop support */ + SPA_TYPE_INTERFACE_Loop, /**< main loop support */ SPA_TYPE_INTERFACE_LoopControl, /**< control of loops */ SPA_TYPE_INTERFACE_LoopUtils, /**< loop utilities */ + SPA_TYPE_INTERFACE_DataSystem, /**< System functions for data loop */ SPA_TYPE_INTERFACE_DataLoop, /**< a data loop */ - SPA_TYPE_INTERFACE_MainLoop, /**< a main loop */ SPA_TYPE_INTERFACE_DBus, /**< dbus connection */ SPA_TYPE_INTERFACE_Monitor, /**< monitor of devices */ SPA_TYPE_INTERFACE_Node, /**< nodes for data processing */ diff --git a/spa/plugins/alsa/alsa-device.c b/spa/plugins/alsa/alsa-device.c index e25d2b211..9dea4282c 100644 --- a/spa/plugins/alsa/alsa-device.c +++ b/spa/plugins/alsa/alsa-device.c @@ -63,7 +63,6 @@ struct impl { struct spa_device device; struct spa_log *log; - struct spa_loop *main_loop; struct spa_hook_list hooks; @@ -446,14 +445,11 @@ impl_init(const struct spa_handle_factory *factory, this = (struct impl *) handle; for (i = 0; i < n_support; i++) { - if (support[i].type == SPA_TYPE_INTERFACE_Log) + switch (support[i].type) { + case SPA_TYPE_INTERFACE_Log: this->log = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_MainLoop) - this->main_loop = support[i].data; - } - if (this->main_loop == NULL) { - spa_log_error(this->log, "a main-loop is needed"); - return -EINVAL; + break; + } } this->device.iface = SPA_INTERFACE_INIT( diff --git a/spa/plugins/alsa/alsa-monitor.c b/spa/plugins/alsa/alsa-monitor.c index e5475e233..48cf2fc3d 100644 --- a/spa/plugins/alsa/alsa-monitor.c +++ b/spa/plugins/alsa/alsa-monitor.c @@ -444,7 +444,7 @@ impl_init(const struct spa_handle_factory *factory, for (i = 0; i < n_support; i++) { if (support[i].type == SPA_TYPE_INTERFACE_Log) this->log = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_MainLoop) + else if (support[i].type == SPA_TYPE_INTERFACE_Loop) this->main_loop = support[i].data; } if (this->main_loop == NULL) { diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index f0ae3a445..ef8496ce4 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -707,19 +707,24 @@ impl_init(const struct spa_handle_factory *factory, this = (struct state *) handle; for (i = 0; i < n_support; i++) { - if (support[i].type == SPA_TYPE_INTERFACE_Log) + switch (support[i].type) { + case SPA_TYPE_INTERFACE_Log: this->log = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_DataLoop) + break; + case SPA_TYPE_INTERFACE_DataSystem: + this->data_system = support[i].data; + break; + case SPA_TYPE_INTERFACE_DataLoop: this->data_loop = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_MainLoop) - this->main_loop = support[i].data; + break; + } } if (this->data_loop == NULL) { spa_log_error(this->log, "a data loop is needed"); return -EINVAL; } - if (this->main_loop == NULL) { - spa_log_error(this->log, "a main loop is needed"); + if (this->data_system == NULL) { + spa_log_error(this->log, "a data system is needed"); return -EINVAL; } diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index 91e58adf3..20f930a31 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -727,19 +727,24 @@ impl_init(const struct spa_handle_factory *factory, this = (struct state *) handle; for (i = 0; i < n_support; i++) { - if (support[i].type == SPA_TYPE_INTERFACE_Log) + switch (support[i].type) { + case SPA_TYPE_INTERFACE_Log: this->log = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_DataLoop) + break; + case SPA_TYPE_INTERFACE_DataSystem: + this->data_system = support[i].data; + break; + case SPA_TYPE_INTERFACE_DataLoop: this->data_loop = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_MainLoop) - this->main_loop = support[i].data; + break; + } } if (this->data_loop == NULL) { spa_log_error(this->log, "a data loop is needed"); return -EINVAL; } - if (this->main_loop == NULL) { - spa_log_error(this->log, "a main loop is needed"); + if (this->data_system == NULL) { + spa_log_error(this->log, "a data system is needed"); return -EINVAL; } diff --git a/spa/plugins/alsa/alsa-utils.h b/spa/plugins/alsa/alsa-utils.h index 4b1209dfe..94991f2f1 100644 --- a/spa/plugins/alsa/alsa-utils.h +++ b/spa/plugins/alsa/alsa-utils.h @@ -76,7 +76,7 @@ struct state { struct spa_node node; struct spa_log *log; - struct spa_loop *main_loop; + struct spa_system *data_system; struct spa_loop *data_loop; snd_pcm_stream_t stream; diff --git a/spa/plugins/bluez5/bluez5-device.c b/spa/plugins/bluez5/bluez5-device.c index 41c4d16a0..ec0b9d002 100644 --- a/spa/plugins/bluez5/bluez5-device.c +++ b/spa/plugins/bluez5/bluez5-device.c @@ -60,7 +60,6 @@ struct impl { struct spa_device device; struct spa_log *log; - struct spa_loop *main_loop; struct spa_hook_list hooks; @@ -292,14 +291,11 @@ impl_init(const struct spa_handle_factory *factory, this = (struct impl *) handle; for (i = 0; i < n_support; i++) { - if (support[i].type == SPA_TYPE_INTERFACE_Log) + switch (support[i].type) { + case SPA_TYPE_INTERFACE_Log: this->log = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_MainLoop) - this->main_loop = support[i].data; - } - if (this->main_loop == NULL) { - spa_log_error(this->log, "a main-loop is needed"); - return -EINVAL; + break; + } } for (i = 0; info && i < info->n_items; i++) { diff --git a/spa/plugins/bluez5/bluez5-monitor.c b/spa/plugins/bluez5/bluez5-monitor.c index 9dc69558b..67ee0f37b 100644 --- a/spa/plugins/bluez5/bluez5-monitor.c +++ b/spa/plugins/bluez5/bluez5-monitor.c @@ -2236,7 +2236,7 @@ impl_init(const struct spa_handle_factory *factory, case SPA_TYPE_INTERFACE_DBus: this->dbus = support[i].data; break; - case SPA_TYPE_INTERFACE_MainLoop: + case SPA_TYPE_INTERFACE_Loop: this->main_loop = support[i].data; break; } diff --git a/spa/plugins/support/dbus.c b/spa/plugins/support/dbus.c index fecd9c3ec..cb2d1b5b6 100644 --- a/spa/plugins/support/dbus.c +++ b/spa/plugins/support/dbus.c @@ -378,10 +378,14 @@ impl_init(const struct spa_handle_factory *factory, &impl_dbus, this); for (i = 0; i < n_support; i++) { - if (support[i].type == SPA_TYPE_INTERFACE_Log) + switch (support[i].type) { + case SPA_TYPE_INTERFACE_Log: this->log = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_LoopUtils) + break; + case SPA_TYPE_INTERFACE_LoopUtils: this->utils = support[i].data; + break; + } } if (this->utils == NULL) { spa_log_error(this->log, "a LoopUtils is needed"); diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index 839f2da20..18cda5f7e 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -45,6 +45,8 @@ struct impl { struct spa_handle handle; struct spa_log log; + struct spa_system *system; + bool colors; FILE *file; @@ -222,8 +224,14 @@ impl_init(const struct spa_handle_factory *factory, this->log.level = DEFAULT_LOG_LEVEL; for (i = 0; i < n_support; i++) { - if (support[i].type == SPA_TYPE_INTERFACE_MainLoop) + switch (support[i].type) { + case SPA_TYPE_INTERFACE_Loop: loop = support[i].data; + break; + case SPA_TYPE_INTERFACE_System: + this->system = support[i].data; + break; + } } if (info) { if ((str = spa_dict_lookup(info, SPA_KEY_LOG_COLORS)) != NULL) diff --git a/spa/plugins/v4l2/v4l2-device.c b/spa/plugins/v4l2/v4l2-device.c index 892246a09..d463caeae 100644 --- a/spa/plugins/v4l2/v4l2-device.c +++ b/spa/plugins/v4l2/v4l2-device.c @@ -59,7 +59,6 @@ struct impl { struct spa_device device; struct spa_log *log; - struct spa_loop *main_loop; struct props props; @@ -217,14 +216,11 @@ impl_init(const struct spa_handle_factory *factory, handle->clear = impl_clear, this = (struct impl *) handle; for (i = 0; i < n_support; i++) { - if (support[i].type == SPA_TYPE_INTERFACE_Log) + switch (support[i].type) { + case SPA_TYPE_INTERFACE_Log: this->log = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_MainLoop) - this->main_loop = support[i].data; - } - if (this->main_loop == NULL) { - spa_log_error(this->log, "a main_loop is needed"); - return -EINVAL; + break; + } } spa_hook_list_init(&this->hooks); diff --git a/spa/plugins/v4l2/v4l2-monitor.c b/spa/plugins/v4l2/v4l2-monitor.c index 84faebbdb..3abe1ccee 100644 --- a/spa/plugins/v4l2/v4l2-monitor.c +++ b/spa/plugins/v4l2/v4l2-monitor.c @@ -353,10 +353,14 @@ impl_init(const struct spa_handle_factory *factory, this = (struct impl *) handle; for (i = 0; i < n_support; i++) { - if (support[i].type == SPA_TYPE_INTERFACE_Log) + switch (support[i].type) { + case SPA_TYPE_INTERFACE_Log: this->log = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_MainLoop) + break; + case SPA_TYPE_INTERFACE_Loop: this->main_loop = support[i].data; + break; + } } if (this->main_loop == NULL) { spa_log_error(this->log, "a main-loop is needed"); diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 15abedef8..7f41f9bce 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -127,7 +127,6 @@ struct impl { struct spa_node node; struct spa_log *log; - struct spa_loop *main_loop; struct spa_loop *data_loop; uint64_t info_all; @@ -959,16 +958,14 @@ impl_init(const struct spa_handle_factory *factory, this = (struct impl *) handle; for (i = 0; i < n_support; i++) { - if (support[i].type == SPA_TYPE_INTERFACE_Log) + switch (support[i].type) { + case SPA_TYPE_INTERFACE_Log: this->log = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_MainLoop) - this->main_loop = support[i].data; - else if (support[i].type == SPA_TYPE_INTERFACE_DataLoop) + break; + case SPA_TYPE_INTERFACE_DataLoop: this->data_loop = support[i].data; - } - if (this->main_loop == NULL) { - spa_log_error(this->log, "a main_loop is needed"); - return -EINVAL; + break; + } } if (this->data_loop == NULL) { spa_log_error(this->log, "a data_loop is needed"); diff --git a/spa/tools/spa-inspect.c b/spa/tools/spa-inspect.c index 5abfd3c57..e92f6cb4b 100644 --- a/spa/tools/spa-inspect.c +++ b/spa/tools/spa-inspect.c @@ -277,7 +277,7 @@ int main(int argc, char *argv[]) data.log->level = atoi(str); data.support[0] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, data.log); - data.support[1] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_MainLoop, &data.loop); + data.support[1] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Loop, &data.loop); data.support[2] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DataLoop, &data.loop); data.n_support = 3; diff --git a/spa/tools/spa-monitor.c b/spa/tools/spa-monitor.c index 559b472e1..f6c5f49de 100644 --- a/spa/tools/spa-monitor.c +++ b/spa/tools/spa-monitor.c @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) &impl_loop, &data); data.support[1] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, data.log); - data.support[2] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_MainLoop, &data.main_loop); + data.support[2] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Loop, &data.main_loop); data.n_support = 3; if (argc < 2) { diff --git a/src/pipewire/loop.h b/src/pipewire/loop.h index bd87ad603..6f4a7614e 100644 --- a/src/pipewire/loop.h +++ b/src/pipewire/loop.h @@ -40,6 +40,7 @@ extern "C" { * event loops. */ struct pw_loop { + struct spa_system *system; /**< system utils */ struct spa_loop *loop; /**< wrapped loop */ struct spa_loop_control *control; /**< loop control */ struct spa_loop_utils *utils; /**< loop utils */ diff --git a/src/tests/test-core.c b/src/tests/test-core.c index cba7683c6..bb4648aa6 100644 --- a/src/tests/test-core.c +++ b/src/tests/test-core.c @@ -243,7 +243,7 @@ static void test_support(void) uint32_t n_support; uint32_t types[] = { SPA_TYPE_INTERFACE_DataLoop, - SPA_TYPE_INTERFACE_MainLoop, + SPA_TYPE_INTERFACE_Loop, SPA_TYPE_INTERFACE_LoopUtils, SPA_TYPE_INTERFACE_Log, SPA_TYPE_INTERFACE_DBus,