simply use INTERFACE_Loop for the main-loop

This commit is contained in:
Wim Taymans 2019-06-06 15:20:43 +02:00
parent 4c2b6c7c91
commit 86dc0496a5
20 changed files with 73 additions and 61 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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 },

View file

@ -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 */

View file

@ -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(

View file

@ -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) {

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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++) {

View file

@ -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;
}

View file

@ -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");

View file

@ -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)

View file

@ -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);

View file

@ -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");

View file

@ -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");

View file

@ -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;

View file

@ -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) {

View file

@ -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 */

View file

@ -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,