/* PipeWire * Copyright (C) 2018 Wim Taymans * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include #include #include #include #include "internal.h" struct pa_threaded_mainloop { pa_mainloop *loop; struct pw_thread_loop *tloop; }; pa_threaded_mainloop *pa_threaded_mainloop_new(void) { pa_threaded_mainloop *m; m = calloc(1, sizeof(pa_threaded_mainloop)); if (m == NULL) return NULL; m->loop = pa_mainloop_new(); if (m->loop == NULL) goto no_mem; m->tloop = pw_thread_loop_new(m->loop->loop, NULL); if (m->tloop == NULL) goto no_mem; return m; no_mem: if (m->loop) pa_mainloop_free(m->loop); free(m); return NULL; } void pa_threaded_mainloop_free(pa_threaded_mainloop* m) { pw_thread_loop_destroy(m->tloop); pa_mainloop_free(m->loop); free(m); } int pa_threaded_mainloop_start(pa_threaded_mainloop *m) { return pw_thread_loop_start(m->tloop); } void pa_threaded_mainloop_stop(pa_threaded_mainloop *m) { pw_thread_loop_stop(m->tloop); } void pa_threaded_mainloop_lock(pa_threaded_mainloop *m) { pw_thread_loop_lock(m->tloop); } void pa_threaded_mainloop_unlock(pa_threaded_mainloop *m) { pw_thread_loop_unlock(m->tloop); } void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) { pw_thread_loop_wait(m->tloop); } void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept) { pw_thread_loop_signal(m->tloop, wait_for_accept); } void pa_threaded_mainloop_accept(pa_threaded_mainloop *m) { pw_thread_loop_accept(m->tloop); } int pa_threaded_mainloop_get_retval(pa_threaded_mainloop *m) { return pa_mainloop_get_retval(m->loop); } pa_mainloop_api* pa_threaded_mainloop_get_api(pa_threaded_mainloop*m) { return pa_mainloop_get_api(m->loop); } int pa_threaded_mainloop_in_thread(pa_threaded_mainloop *m) { return pw_thread_loop_in_thread(m->tloop); } void pa_threaded_mainloop_set_name(pa_threaded_mainloop *m, const char *name) { }