PipeWire  0.3.15
thread-loop.h
Go to the documentation of this file.
1 /* PipeWire
2  *
3  * Copyright © 2018 Wim Taymans
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef PIPEWIRE_THREAD_LOOP_H
26 #define PIPEWIRE_THREAD_LOOP_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <pipewire/loop.h>
33 
95 struct pw_thread_loop;
96 
99 #define PW_VERSION_THREAD_LOOP_EVENTS 0
100  uint32_t version;
101 
103  void (*destroy) (void *data);
104 };
105 
107 struct pw_thread_loop *
108 pw_thread_loop_new(const char *name, const struct spa_dict *props);
109 
112 struct pw_thread_loop *
113 pw_thread_loop_new_full(struct pw_loop *loop, const char *name, const struct spa_dict *props);
114 
116 void pw_thread_loop_destroy(struct pw_thread_loop *loop);
117 
120  struct spa_hook *listener,
121  const struct pw_thread_loop_events *events,
122  void *data);
123 
126 
129 
132 
135 
138 
141 
144 int pw_thread_loop_timed_wait(struct pw_thread_loop *loop, int wait_max_sec);
145 
148 int pw_thread_loop_get_time(struct pw_thread_loop *loop, struct timespec *abstime, int64_t timeout);
149 
153 int pw_thread_loop_timed_wait_full(struct pw_thread_loop *loop, struct timespec *abstime);
154 
156 void pw_thread_loop_signal(struct pw_thread_loop *loop, bool wait_for_accept);
157 
160 
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif /* PIPEWIRE_THREAD_LOOP_H */
res
static uint32_t int int res
Definition: core.h:326
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:227
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:227
pw_loop_add_event
#define pw_loop_add_event(l,...)
Definition: loop.h:69
pw_thread_loop_new_full
SPA_EXPORT struct pw_thread_loop * pw_thread_loop_new_full(struct pw_loop *loop, const char *name, const struct spa_dict *props)
Make a new thread loop with the given loop, name and optional properties.
Definition: thread-loop.c:185
pw_loop_signal_event
#define pw_loop_signal_event(l,...)
Definition: loop.h:70
data
Definition: filter.c:71
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:442
pw_loop_leave
#define pw_loop_leave(l)
Definition: loop.h:63
pw_loop
Definition: loop.h:41
pw_thread_loop_events::destroy
void(* destroy)(void *data)
the loop is destroyed
Definition: thread-loop.h:103
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:309
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:456
CHECK
#define CHECK(expression, label)
Definition: thread-loop.c:92
pw_loop_destroy_source
#define pw_loop_destroy_source(l,...)
Definition: loop.h:74
pw_thread_loop::pw_thread_loop_get_time
SPA_EXPORT int pw_thread_loop_get_time(struct pw_thread_loop *loop, struct timespec *abstime, int64_t timeout)
Get the current time of the loop + timeout.
Definition: thread-loop.c:402
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:361
pw_log::pw_log_debug
#define pw_log_debug(...)
pw_log::pw_log_warn
#define pw_log_warn(...)
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:322
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:339
pw_thread_loop_events
Thread loop events.
Definition: thread-loop.h:98
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:217
pw_loop::pw_loop_destroy
SPA_EXPORT void pw_loop_destroy(struct pw_loop *loop)
Destroy a loop.
Definition: loop.c:158
pw_thread_loop::pw_thread_loop_new
SPA_EXPORT struct pw_thread_loop * pw_thread_loop_new(const char *name, const struct spa_dict *props)
Create a new pw_thread_loop.
Definition: thread-loop.c:178
pw_thread_loop
PipeWire threaded loop object.
pw_thread_loop::pw_thread_loop_timed_wait_full
SPA_EXPORT int pw_thread_loop_timed_wait_full(struct pw_thread_loop *loop, struct timespec *abstime)
Wait for the loop thread to call pw_thread_loop_signal() or time out.
Definition: thread-loop.c:426
thread-loop.h
pw_thread_loop_events::version
uint32_t version
Definition: thread-loop.h:100
log.h
pw_log::pw_log_trace
#define pw_log_trace(...)
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:380
pw_loop_enter
#define pw_loop_enter(l)
Definition: loop.h:61
pw_loop::pw_loop_new
SPA_EXPORT struct pw_loop * pw_loop_new(const struct spa_dict *props)
Create a new loop.
Definition: loop.c:55
pw_loop_add_hook
#define pw_loop_add_hook(l,...)
Definition: loop.h:60
pw_thread_loop_events_destroy
#define pw_thread_loop_events_destroy(o)
Definition: thread-loop.c:37
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:217
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:193
pw_loop::loop
struct spa_loop * loop
wrapped loop
Definition: loop.h:43
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:265
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:288
pw_thread_loop_new_full
struct pw_thread_loop * pw_thread_loop_new_full(struct pw_loop *loop, const char *name, const struct spa_dict *props)
Make a new thread loop with the given loop, name and optional properties.
Definition: thread-loop.c:185
NAME
#define NAME
Definition: thread-loop.c:34
pw_loop_iterate
#define pw_loop_iterate(l,...)
Definition: loop.h:62