PipeWire: pipewire/loop.h Source File

PipeWire 1.6.4

Loading...
Searching...
No Matches
loop.h
Go to the documentation of this file.
1/* PipeWire */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef PIPEWIRE_LOOP_H
6#define PIPEWIRE_LOOP_H
7
8#include <spa/support/loop.h>
9#include <spa/utils/dict.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
23
28
29struct pw_loop {
30 struct spa_system *system;
31 struct spa_loop *loop;
32 struct spa_loop_control *control;
33 struct spa_loop_utils *utils;
34 const char *name;
35};
36
37#ifndef PW_API_LOOP_IMPL
38#define PW_API_LOOP_IMPL static inline
39#endif
40
41struct pw_loop *
42 pw_loop_new(const struct spa_dict *props);
43
44void
45 pw_loop_destroy(struct pw_loop *loop);
46
47int pw_loop_set_name(struct pw_loop *loop, const char *name);
48
49 PW_API_LOOP_IMPL int pw_loop_add_source(struct pw_loop *object, struct spa_source *source)
50{
51 return spa_loop_add_source(object->loop, source);
52}
53 PW_API_LOOP_IMPL int pw_loop_update_source(struct pw_loop *object, struct spa_source *source)
54{
55 return spa_loop_update_source(object->loop, source);
56}
57 PW_API_LOOP_IMPL int pw_loop_remove_source(struct pw_loop *object, struct spa_source *source)
58{
59 return spa_loop_remove_source(object->loop, source);
60}
61 PW_API_LOOP_IMPL int pw_loop_invoke(struct pw_loop *object,
62 spa_invoke_func_t func, uint32_t seq, const void *data,
63 size_t size, bool block, void *user_data)
64{
65 return spa_loop_invoke(object->loop, func, seq, data, size, block, user_data);
66}
67 PW_API_LOOP_IMPL int pw_loop_locked(struct pw_loop *object,
68 spa_invoke_func_t func, uint32_t seq, const void *data,
69 size_t size, void *user_data)
70{
71 return spa_loop_locked(object->loop, func, seq, data, size, user_data);
72}
73
74 PW_API_LOOP_IMPL int pw_loop_get_fd(struct pw_loop *object)
75{
76 return spa_loop_control_get_fd(object->control);
77}
78 PW_API_LOOP_IMPL void pw_loop_add_hook(struct pw_loop *object,
79 struct spa_hook *hook, const struct spa_loop_control_hooks *hooks,
80 void *data)
81{
82 spa_loop_control_add_hook(object->control, hook, hooks, data);
83}
84 PW_API_LOOP_IMPL void pw_loop_enter(struct pw_loop *object)
85{
86 spa_loop_control_enter(object->control);
87}
88 PW_API_LOOP_IMPL void pw_loop_leave(struct pw_loop *object)
89{
90 spa_loop_control_leave(object->control);
91}
92 PW_API_LOOP_IMPL int pw_loop_iterate(struct pw_loop *object,
93 int timeout)
94{
95 return spa_loop_control_iterate_fast(object->control, timeout);
96}
97 PW_API_LOOP_IMPL int pw_loop_check(struct pw_loop *object)
98{
99 return spa_loop_control_check(object->control);
100}
101 PW_API_LOOP_IMPL int pw_loop_lock(struct pw_loop *object)
102{
103 return spa_loop_control_lock(object->control);
104}
105 PW_API_LOOP_IMPL int pw_loop_unlock(struct pw_loop *object)
106{
107 return spa_loop_control_unlock(object->control);
108}
109 PW_API_LOOP_IMPL int pw_loop_get_time(struct pw_loop *object, struct timespec *abstime, int64_t timeout)
110{
111 return spa_loop_control_get_time(object->control, abstime, timeout);
112}
113 PW_API_LOOP_IMPL int pw_loop_wait(struct pw_loop *object, const struct timespec *abstime)
114{
115 return spa_loop_control_wait(object->control, abstime);
116}
117 PW_API_LOOP_IMPL int pw_loop_signal(struct pw_loop *object, bool wait_for_accept)
118{
119 return spa_loop_control_signal(object->control, wait_for_accept);
120}
121 PW_API_LOOP_IMPL int pw_loop_accept(struct pw_loop *object)
122{
123 return spa_loop_control_accept(object->control);
124}
125
126
127
128 PW_API_LOOP_IMPL struct spa_source *
129 pw_loop_add_io(struct pw_loop *object, int fd, uint32_t mask,
130 bool close, spa_source_io_func_t func, void *data)
131{
132 return spa_loop_utils_add_io(object->utils, fd, mask, close, func, data);
133}
134 PW_API_LOOP_IMPL int pw_loop_update_io(struct pw_loop *object,
135 struct spa_source *source, uint32_t mask)
136{
137 return spa_loop_utils_update_io(object->utils, source, mask);
138}
139 PW_API_LOOP_IMPL struct spa_source *
140 pw_loop_add_idle(struct pw_loop *object, bool enabled,
141 spa_source_idle_func_t func, void *data)
142{
143 return spa_loop_utils_add_idle(object->utils, enabled, func, data);
144}
145 PW_API_LOOP_IMPL int pw_loop_enable_idle(struct pw_loop *object,
146 struct spa_source *source, bool enabled)
147{
148 return spa_loop_utils_enable_idle(object->utils, source, enabled);
149}
150 PW_API_LOOP_IMPL struct spa_source *
151 pw_loop_add_event(struct pw_loop *object, spa_source_event_func_t func, void *data)
152{
153 return spa_loop_utils_add_event(object->utils, func, data);
154}
155 PW_API_LOOP_IMPL int pw_loop_signal_event(struct pw_loop *object,
156 struct spa_source *source)
157{
158 return spa_loop_utils_signal_event(object->utils, source);
159}
160 PW_API_LOOP_IMPL struct spa_source *
161 pw_loop_add_timer(struct pw_loop *object, spa_source_timer_func_t func, void *data)
162{
163 return spa_loop_utils_add_timer(object->utils, func, data);
164}
165 PW_API_LOOP_IMPL int pw_loop_update_timer(struct pw_loop *object,
166 struct spa_source *source, struct timespec *value,
167 struct timespec *interval, bool absolute)
168{
169 return spa_loop_utils_update_timer(object->utils, source, value, interval, absolute);
170}
171 PW_API_LOOP_IMPL struct spa_source *
172 pw_loop_add_signal(struct pw_loop *object, int signal_number,
173 spa_source_signal_func_t func, void *data)
174{
175 return spa_loop_utils_add_signal(object->utils, signal_number, func, data);
176}
177 PW_API_LOOP_IMPL void pw_loop_destroy_source(struct pw_loop *object,
178 struct spa_source *source)
179{
180 spa_loop_utils_destroy_source(object->utils, source);
181}
182
186
187#ifdef __cplusplus
188}
189#endif
190
191#endif /* PIPEWIRE_LOOP_H */
seq
uint32_t int seq
Definition core.h:432
pw_loop_signal_event
PW_API_LOOP_IMPL int pw_loop_signal_event(struct pw_loop *object, struct spa_source *source)
Definition loop.h:160
pw_loop_enter
PW_API_LOOP_IMPL void pw_loop_enter(struct pw_loop *object)
Definition loop.h:89
pw_loop_invoke
PW_API_LOOP_IMPL int pw_loop_invoke(struct pw_loop *object, spa_invoke_func_t func, uint32_t seq, const void *data, size_t size, bool block, void *user_data)
Definition loop.h:66
pw_loop_get_time
PW_API_LOOP_IMPL int pw_loop_get_time(struct pw_loop *object, struct timespec *abstime, int64_t timeout)
Definition loop.h:114
pw_loop_destroy_source
PW_API_LOOP_IMPL void pw_loop_destroy_source(struct pw_loop *object, struct spa_source *source)
Definition loop.h:182
pw_loop_add_io
PW_API_LOOP_IMPL struct spa_source * pw_loop_add_io(struct pw_loop *object, int fd, uint32_t mask, bool close, spa_source_io_func_t func, void *data)
Definition loop.h:134
pw_loop_lock
PW_API_LOOP_IMPL int pw_loop_lock(struct pw_loop *object)
Definition loop.h:106
pw_loop_signal
PW_API_LOOP_IMPL int pw_loop_signal(struct pw_loop *object, bool wait_for_accept)
Definition loop.h:122
pw_loop_enable_idle
PW_API_LOOP_IMPL int pw_loop_enable_idle(struct pw_loop *object, struct spa_source *source, bool enabled)
Definition loop.h:150
pw_loop_add_source
PW_API_LOOP_IMPL int pw_loop_add_source(struct pw_loop *object, struct spa_source *source)
Definition loop.h:54
pw_loop_accept
PW_API_LOOP_IMPL int pw_loop_accept(struct pw_loop *object)
Definition loop.h:126
pw_loop_update_timer
PW_API_LOOP_IMPL int pw_loop_update_timer(struct pw_loop *object, struct spa_source *source, struct timespec *value, struct timespec *interval, bool absolute)
Definition loop.h:170
pw_loop_unlock
PW_API_LOOP_IMPL int pw_loop_unlock(struct pw_loop *object)
Definition loop.h:110
pw_loop_add_signal
PW_API_LOOP_IMPL struct spa_source * pw_loop_add_signal(struct pw_loop *object, int signal_number, spa_source_signal_func_t func, void *data)
Definition loop.h:177
pw_loop_add_idle
PW_API_LOOP_IMPL struct spa_source * pw_loop_add_idle(struct pw_loop *object, bool enabled, spa_source_idle_func_t func, void *data)
Definition loop.h:145
pw_loop_remove_source
PW_API_LOOP_IMPL int pw_loop_remove_source(struct pw_loop *object, struct spa_source *source)
Definition loop.h:62
pw_loop_add_timer
PW_API_LOOP_IMPL struct spa_source * pw_loop_add_timer(struct pw_loop *object, spa_source_timer_func_t func, void *data)
Definition loop.h:166
pw_loop_set_name
int pw_loop_set_name(struct pw_loop *loop, const char *name)
Definition loop.c:176
PW_API_LOOP_IMPL
#define PW_API_LOOP_IMPL
Definition loop.h:43
pw_loop_wait
PW_API_LOOP_IMPL int pw_loop_wait(struct pw_loop *object, const struct timespec *abstime)
Definition loop.h:118
pw_loop_leave
PW_API_LOOP_IMPL void pw_loop_leave(struct pw_loop *object)
Definition loop.h:93
pw_loop_locked
PW_API_LOOP_IMPL int pw_loop_locked(struct pw_loop *object, spa_invoke_func_t func, uint32_t seq, const void *data, size_t size, void *user_data)
Definition loop.h:72
pw_loop_add_hook
PW_API_LOOP_IMPL void pw_loop_add_hook(struct pw_loop *object, struct spa_hook *hook, const struct spa_loop_control_hooks *hooks, void *data)
Definition loop.h:83
pw_loop_new
struct pw_loop * pw_loop_new(const struct spa_dict *props)
Create a new loop.
Definition loop.c:41
pw_loop_get_fd
PW_API_LOOP_IMPL int pw_loop_get_fd(struct pw_loop *object)
Definition loop.h:79
pw_loop_check
PW_API_LOOP_IMPL int pw_loop_check(struct pw_loop *object)
Definition loop.h:102
pw_loop_iterate
PW_API_LOOP_IMPL int pw_loop_iterate(struct pw_loop *object, int timeout)
Definition loop.h:97
pw_loop_destroy
void pw_loop_destroy(struct pw_loop *loop)
Destroy a loop.
Definition loop.c:157
pw_loop_update_source
PW_API_LOOP_IMPL int pw_loop_update_source(struct pw_loop *object, struct spa_source *source)
Definition loop.h:58
pw_loop_add_event
PW_API_LOOP_IMPL struct spa_source * pw_loop_add_event(struct pw_loop *object, spa_source_event_func_t func, void *data)
Definition loop.h:156
pw_loop_update_io
PW_API_LOOP_IMPL int pw_loop_update_io(struct pw_loop *object, struct spa_source *source, uint32_t mask)
Definition loop.h:139
spa_loop_invoke
SPA_API_LOOP int spa_loop_invoke(struct spa_loop *object, spa_invoke_func_t func, uint32_t seq, const void *data, size_t size, bool block, void *user_data)
Definition loop.h:191
spa_loop_utils_add_idle
SPA_API_LOOP struct spa_source * spa_loop_utils_add_idle(struct spa_loop_utils *object, bool enabled, spa_source_idle_func_t func, void *data)
Definition loop.h:531
spa_loop_utils_add_signal
SPA_API_LOOP struct spa_source * spa_loop_utils_add_signal(struct spa_loop_utils *object, int signal_number, spa_source_signal_func_t func, void *data)
Definition loop.h:570
spa_loop_control_accept
SPA_API_LOOP int spa_loop_control_accept(struct spa_loop_control *object)
Definition loop.h:461
spa_loop_add_source
SPA_API_LOOP int spa_loop_add_source(struct spa_loop *object, struct spa_source *source)
Definition loop.h:176
spa_source_timer_func_t
void(* spa_source_timer_func_t)(void *data, uint64_t expirations)
Definition loop.h:470
spa_loop_utils_add_timer
SPA_API_LOOP struct spa_source * spa_loop_utils_add_timer(struct spa_loop_utils *object, spa_source_timer_func_t func, void *data)
Definition loop.h:556
spa_loop_control_get_fd
SPA_API_LOOP int spa_loop_control_get_fd(struct spa_loop_control *object)
Definition loop.h:397
spa_loop_control_enter
SPA_API_LOOP void spa_loop_control_enter(struct spa_loop_control *object)
Definition loop.h:409
spa_loop_control_signal
SPA_API_LOOP int spa_loop_control_signal(struct spa_loop_control *object, bool wait_for_accept)
Definition loop.h:456
spa_loop_remove_source
SPA_API_LOOP int spa_loop_remove_source(struct spa_loop *object, struct spa_source *source)
Definition loop.h:186
spa_loop_utils_update_timer
SPA_API_LOOP int spa_loop_utils_update_timer(struct spa_loop_utils *object, struct spa_source *source, struct timespec *value, struct timespec *interval, bool absolute)
Definition loop.h:561
spa_loop_utils_enable_idle
SPA_API_LOOP int spa_loop_utils_enable_idle(struct spa_loop_utils *object, struct spa_source *source, bool enabled)
Definition loop.h:537
spa_source_event_func_t
void(* spa_source_event_func_t)(void *data, uint64_t count)
Definition loop.h:469
spa_source_signal_func_t
void(* spa_source_signal_func_t)(void *data, int signal_number)
Definition loop.h:471
spa_loop_control_iterate_fast
SPA_API_LOOP int spa_loop_control_iterate_fast(struct spa_loop_control *object, int timeout)
Definition loop.h:423
spa_loop_control_add_hook
SPA_API_LOOP void spa_loop_control_add_hook(struct spa_loop_control *object, struct spa_hook *hook, const struct spa_loop_control_hooks *hooks, void *data)
Definition loop.h:402
spa_loop_control_wait
SPA_API_LOOP int spa_loop_control_wait(struct spa_loop_control *object, const struct timespec *abstime)
Definition loop.h:450
spa_source_idle_func_t
void(* spa_source_idle_func_t)(void *data)
Definition loop.h:468
spa_loop_control_unlock
SPA_API_LOOP int spa_loop_control_unlock(struct spa_loop_control *object)
Definition loop.h:439
spa_loop_utils_destroy_source
SPA_API_LOOP void spa_loop_utils_destroy_source(struct spa_loop_utils *object, struct spa_source *source)
Definition loop.h:577
spa_loop_control_check
SPA_API_LOOP int spa_loop_control_check(struct spa_loop_control *object)
Definition loop.h:429
spa_loop_utils_add_event
SPA_API_LOOP struct spa_source * spa_loop_utils_add_event(struct spa_loop_utils *object, spa_source_event_func_t func, void *data)
Definition loop.h:544
spa_loop_control_get_time
SPA_API_LOOP int spa_loop_control_get_time(struct spa_loop_control *object, struct timespec *abstime, int64_t timeout)
Definition loop.h:444
spa_invoke_func_t
int(* spa_invoke_func_t)(struct spa_loop *loop, bool async, uint32_t seq, const void *data, size_t size, void *user_data)
Definition loop.h:78
spa_source_io_func_t
void(* spa_source_io_func_t)(void *data, int fd, uint32_t mask)
Definition loop.h:467
spa_loop_control_lock
SPA_API_LOOP int spa_loop_control_lock(struct spa_loop_control *object)
Definition loop.h:434
spa_loop_utils_signal_event
SPA_API_LOOP int spa_loop_utils_signal_event(struct spa_loop_utils *object, struct spa_source *source)
Definition loop.h:549
spa_loop_utils_update_io
SPA_API_LOOP int spa_loop_utils_update_io(struct spa_loop_utils *object, struct spa_source *source, uint32_t mask)
Definition loop.h:524
spa_loop_control_leave
SPA_API_LOOP void spa_loop_control_leave(struct spa_loop_control *object)
Definition loop.h:413
spa_loop_locked
SPA_API_LOOP int spa_loop_locked(struct spa_loop *object, spa_invoke_func_t func, uint32_t seq, const void *data, size_t size, void *user_data)
Definition loop.h:199
spa_loop_update_source
SPA_API_LOOP int spa_loop_update_source(struct spa_loop *object, struct spa_source *source)
Definition loop.h:181
spa_loop_utils_add_io
SPA_API_LOOP struct spa_source * spa_loop_utils_add_io(struct spa_loop_utils *object, int fd, uint32_t mask, bool close, spa_source_io_func_t func, void *data)
Definition loop.h:518
loop.h
spa/support/loop.h
pw_loop
Definition loop.h:33
pw_loop::loop
struct spa_loop * loop
wrapped loop
Definition loop.h:35
pw_loop::control
struct spa_loop_control * control
loop control
Definition loop.h:36
pw_loop::system
struct spa_system * system
system utils
Definition loop.h:34
spa_dict
Definition dict.h:51
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
spa_loop_control_hooks
Control hooks.
Definition loop.h:212
spa_loop_utils
Definition loop.h:60
spa_source
Definition loop.h:67
spa_source::mask
uint32_t mask
Definition loop.h:72
spa_source::func
spa_source_func_t func
Definition loop.h:69
spa_source::fd
int fd
Definition loop.h:71
dict.h
spa/utils/dict.h