PipeWire  0.2.7
thread-loop.h
Go to the documentation of this file.
1 /* PipeWire
2  * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __PIPEWIRE_THREAD_LOOP_H__
21 #define __PIPEWIRE_THREAD_LOOP_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <pipewire/loop.h>
28 
90 struct pw_thread_loop;
91 
94 #define PW_VERSION_THREAD_LOOP_EVENTS 0
95  uint32_t version;
96 
98  void (*destroy) (void *data);
99 };
100 
102 struct pw_thread_loop *
103 pw_thread_loop_new(struct pw_loop *loop, const char *name);
104 
106 void pw_thread_loop_destroy(struct pw_thread_loop *loop);
107 
110  struct spa_hook *listener,
111  const struct pw_thread_loop_events *events,
112  void *data);
113 
116 
119 
122 
125 
128 
131 
134 int pw_thread_loop_timed_wait(struct pw_thread_loop *loop, int wait_max_sec);
135 
137 void pw_thread_loop_signal(struct pw_thread_loop *loop, bool wait_for_accept);
138 
141 
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif /* __PIPEWIRE_THREAD_LOOP_H__ */
pw_thread_loop_get_loop
struct pw_loop * pw_thread_loop_get_loop(struct pw_thread_loop *loop)
Get the loop implementation of the thread loop.
Definition: thread-loop.c:179
pw_thread_loop_get_loop
SPA_EXPORT struct pw_loop * pw_thread_loop_get_loop(struct pw_thread_loop *loop)
Get the loop implementation of the thread loop.
Definition: thread-loop.c:179
pw_loop_add_event
#define pw_loop_add_event(l,...)
Definition: loop.h:64
pw_loop_signal_event
#define pw_loop_signal_event(l,...)
Definition: loop.h:65
pw_thread_loop::pw_thread_loop_accept
SPA_EXPORT void pw_thread_loop_accept(struct pw_thread_loop *loop)
Signal the loop thread waiting for accept with pw_thread_loop_signal()
Definition: thread-loop.c:343
pw_loop_leave
#define pw_loop_leave(l)
Definition: loop.h:58
pw_loop
Definition: loop.h:37
pw_thread_loop_events::destroy
void(* destroy)(void *data)
the loop is destroyed
Definition: thread-loop.h:98
pw_thread_loop::pw_thread_loop_lock
SPA_EXPORT void pw_thread_loop_lock(struct pw_thread_loop *loop)
Lock the mutex associated with loop.
Definition: thread-loop.c:256
pw_thread_loop::pw_thread_loop_in_thread
SPA_EXPORT bool pw_thread_loop_in_thread(struct pw_thread_loop *loop)
Check if we are inside the thread of the loop.
Definition: thread-loop.c:357
CHECK
#define CHECK(expression, label)
Definition: thread-loop.c:77
pw_thread_loop::pw_thread_loop_new
SPA_EXPORT struct pw_thread_loop * pw_thread_loop_new(struct pw_loop *loop, const char *name)
Create a new pw_thread_loop.
Definition: thread-loop.c:100
pw_loop_destroy_source
#define pw_loop_destroy_source(l,...)
Definition: loop.h:69
pw_thread_loop::pw_thread_loop_wait
SPA_EXPORT void pw_thread_loop_wait(struct pw_thread_loop *loop)
Wait for the loop thread to call pw_thread_loop_signal()
Definition: thread-loop.c:304
pw_thread_loop::pw_thread_loop_unlock
SPA_EXPORT void pw_thread_loop_unlock(struct pw_thread_loop *loop)
Unlock the mutex associated with loop.
Definition: thread-loop.c:268
pw_thread_loop::pw_thread_loop_signal
SPA_EXPORT void pw_thread_loop_signal(struct pw_thread_loop *loop, bool wait_for_accept)
Signal the thread.
Definition: thread-loop.c:284
pw_thread_loop_events
Thread loop events.
Definition: thread-loop.h:93
pw_thread_loop_add_listener
void pw_thread_loop_add_listener(struct pw_thread_loop *loop, struct spa_hook *listener, const struct pw_thread_loop_events *events, void *data)
Add an event listener.
Definition: thread-loop.c:169
pw_thread_loop
PipeWire threaded loop object.
thread-loop.h
pw_thread_loop_events::version
uint32_t version
Definition: thread-loop.h:95
loop.h
pw_thread_loop::pw_thread_loop_timed_wait
SPA_EXPORT int pw_thread_loop_timed_wait(struct pw_thread_loop *loop, int wait_max_sec)
Wait for the loop thread to call pw_thread_loop_signal() or time out.
Definition: thread-loop.c:321
pw_loop_enter
#define pw_loop_enter(l)
Definition: loop.h:56
pw_loop_add_hook
#define pw_loop_add_hook(l,...)
Definition: loop.h:55
pw_thread_loop_events_destroy
#define pw_thread_loop_events_destroy(o)
Definition: thread-loop.c:28
pw_thread_loop_add_listener
SPA_EXPORT void pw_thread_loop_add_listener(struct pw_thread_loop *loop, struct spa_hook *listener, const struct pw_thread_loop_events *events, void *data)
Add an event listener.
Definition: thread-loop.c:169
pw_thread_loop::pw_thread_loop_destroy
SPA_EXPORT void pw_thread_loop_destroy(struct pw_thread_loop *loop)
Destroy a threaded loop.
Definition: thread-loop.c:150
pipewire.h
pw_loop::loop
struct spa_loop * loop
wrapped loop
Definition: loop.h:38
pw_thread_loop::pw_thread_loop_start
SPA_EXPORT int pw_thread_loop_start(struct pw_thread_loop *loop)
Start the thread to handle loop.
Definition: thread-loop.c:212
pw_thread_loop::pw_thread_loop_stop
SPA_EXPORT void pw_thread_loop_stop(struct pw_thread_loop *loop)
Quit the loop and stop its thread.
Definition: thread-loop.c:235
pw_log::pw_log_warn
void pw_log_warn(const char *format,...)
pw_log::pw_log_debug
void pw_log_debug(const char *format,...)
pw_loop_iterate
#define pw_loop_iterate(l,...)
Definition: loop.h:57