mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
doc: tutorial3: do not use nested functions
Nested functions are a GNU C extension, they are not supported by clang, and by GCC in C++ mode.
This commit is contained in:
parent
04e65a86a1
commit
473809190b
2 changed files with 25 additions and 19 deletions
|
|
@ -7,23 +7,32 @@
|
|||
#include <pipewire/pipewire.h>
|
||||
|
||||
/* [roundtrip] */
|
||||
struct roundtrip_data {
|
||||
int pending;
|
||||
struct pw_main_loop *loop;
|
||||
};
|
||||
|
||||
static void on_core_done(void *data, uint32_t id, int seq)
|
||||
{
|
||||
struct roundtrip_data *d = data;
|
||||
|
||||
if (id == PW_ID_CORE && seq == d->pending)
|
||||
pw_main_loop_quit(d->loop);
|
||||
}
|
||||
|
||||
static int roundtrip(struct pw_core *core, struct pw_main_loop *loop)
|
||||
{
|
||||
struct roundtrip_data d = { .loop = loop };
|
||||
struct spa_hook core_listener;
|
||||
int pending;
|
||||
void core_event_done(void *object, uint32_t id, int seq) {
|
||||
if (id == PW_ID_CORE && seq == pending)
|
||||
pw_main_loop_quit(loop);
|
||||
}
|
||||
const struct pw_core_events core_events = {
|
||||
PW_VERSION_CORE_EVENTS,
|
||||
.done = core_event_done,
|
||||
.done = on_core_done,
|
||||
};
|
||||
|
||||
pw_core_add_listener(core, &core_listener,
|
||||
&core_events, NULL);
|
||||
&core_events, &d);
|
||||
|
||||
pending = pw_core_sync(core, PW_ID_CORE, 0);
|
||||
d.pending = pw_core_sync(core, PW_ID_CORE, 0);
|
||||
|
||||
pw_main_loop_run(loop);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue