context: support foreign mainloop_api

Detect if the mainloop_api is one of ours and use the loop directly in
that case. Otherwise, make a new loop and add the fd to the foreign
mainloop_api. Make sure we clean up as well.

Fixes #345
This commit is contained in:
Wim Taymans 2020-10-22 12:24:49 +02:00
parent 7782352e8d
commit 55b4042512
3 changed files with 51 additions and 5 deletions

View file

@ -346,6 +346,8 @@ struct pa_context {
int refcount;
uint32_t client_index;
pa_io_event *io;
bool fallback_loop;
struct pw_loop *loop;
struct pw_context *context;
@ -504,6 +506,7 @@ struct pa_operation
void *state_userdata;
};
bool pa_mainloop_api_is_pipewire(pa_mainloop_api *api);
pa_operation *pa_operation_new(pa_context *c, pa_stream *s, pa_operation_cb_t cb, size_t userdata_size);
void pa_operation_done(pa_operation *o);