PipeWire: pipewire/loop.h Source File

PipeWire 1.4.2 |

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#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <spa/support/loop.h>
13#include <spa/utils/dict.h>
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
68 PW_API_LOOP_IMPL int pw_loop_get_fd(struct pw_loop *object)
69{
70 return spa_loop_control_get_fd(object->control);
71}
72 PW_API_LOOP_IMPL void pw_loop_add_hook(struct pw_loop *object,
73 struct spa_hook *hook, const struct spa_loop_control_hooks *hooks,
74 void *data)
75{
76 spa_loop_control_add_hook(object->control, hook, hooks, data);
77}
78 PW_API_LOOP_IMPL void pw_loop_enter(struct pw_loop *object)
79{
80 spa_loop_control_enter(object->control);
81}
82 PW_API_LOOP_IMPL void pw_loop_leave(struct pw_loop *object)
83{
84 spa_loop_control_leave(object->control);
85}
86 PW_API_LOOP_IMPL int pw_loop_iterate(struct pw_loop *object,
87 int timeout)
88{
89 return spa_loop_control_iterate_fast(object->control, timeout);
90}
91
92 PW_API_LOOP_IMPL struct spa_source *
93 pw_loop_add_io(struct pw_loop *object, int fd, uint32_t mask,
94 bool close, spa_source_io_func_t func, void *data)
95{
96 return spa_loop_utils_add_io(object->utils, fd, mask, close, func, data);
97}
98 PW_API_LOOP_IMPL int pw_loop_update_io(struct pw_loop *object,
99 struct spa_source *source, uint32_t mask)
100{
101 return spa_loop_utils_update_io(object->utils, source, mask);
102}
103 PW_API_LOOP_IMPL struct spa_source *
104 pw_loop_add_idle(struct pw_loop *object, bool enabled,
105 spa_source_idle_func_t func, void *data)
106{
107 return spa_loop_utils_add_idle(object->utils, enabled, func, data);
108}
109 PW_API_LOOP_IMPL int pw_loop_enable_idle(struct pw_loop *object,
110 struct spa_source *source, bool enabled)
111{
112 return spa_loop_utils_enable_idle(object->utils, source, enabled);
113}
114 PW_API_LOOP_IMPL struct spa_source *
115 pw_loop_add_event(struct pw_loop *object, spa_source_event_func_t func, void *data)
116{
117 return spa_loop_utils_add_event(object->utils, func, data);
118}
119 PW_API_LOOP_IMPL int pw_loop_signal_event(struct pw_loop *object,
120 struct spa_source *source)
121{
122 return spa_loop_utils_signal_event(object->utils, source);
123}
124 PW_API_LOOP_IMPL struct spa_source *
125 pw_loop_add_timer(struct pw_loop *object, spa_source_timer_func_t func, void *data)
126{
127 return spa_loop_utils_add_timer(object->utils, func, data);
128}
129 PW_API_LOOP_IMPL int pw_loop_update_timer(struct pw_loop *object,
130 struct spa_source *source, struct timespec *value,
131 struct timespec *interval, bool absolute)
132{
133 return spa_loop_utils_update_timer(object->utils, source, value, interval, absolute);
134}
135 PW_API_LOOP_IMPL struct spa_source *
136 pw_loop_add_signal(struct pw_loop *object, int signal_number,
137 spa_source_signal_func_t func, void *data)
138{
139 return spa_loop_utils_add_signal(object->utils, signal_number, func, data);
140}
141 PW_API_LOOP_IMPL void pw_loop_destroy_source(struct pw_loop *object,
142 struct spa_source *source)
143{
144 spa_loop_utils_destroy_source(object->utils, source);
145}
146
150
151#ifdef __cplusplus
152}
153#endif
154
155#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:124
pw_loop_enter
PW_API_LOOP_IMPL void pw_loop_enter(struct pw_loop *object)
Definition loop.h:83
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_destroy_source
PW_API_LOOP_IMPL void pw_loop_destroy_source(struct pw_loop *object, struct spa_source *source)
Definition loop.h:146
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:98
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:114
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_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:134
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:141
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:109
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:130
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_leave
PW_API_LOOP_IMPL void pw_loop_leave(struct pw_loop *object)
Definition loop.h:87
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:77
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:73
pw_loop_iterate
PW_API_LOOP_IMPL int pw_loop_iterate(struct pw_loop *object, int timeout)
Definition loop.h:91
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:120
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:103
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:169
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:400
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:439
spa_loop_add_source
SPA_API_LOOP int spa_loop_add_source(struct spa_loop *object, struct spa_source *source)
Definition loop.h:154
spa_source_timer_func_t
void(* spa_source_timer_func_t)(void *data, uint64_t expirations)
Definition loop.h:339
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:425
spa_loop_control_get_fd
SPA_API_LOOP int spa_loop_control_get_fd(struct spa_loop_control *object)
Definition loop.h:298
spa_loop_control_enter
SPA_API_LOOP void spa_loop_control_enter(struct spa_loop_control *object)
Definition loop.h:310
spa_loop_remove_source
SPA_API_LOOP int spa_loop_remove_source(struct spa_loop *object, struct spa_source *source)
Definition loop.h:164
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:430
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:406
spa_source_event_func_t
void(* spa_source_event_func_t)(void *data, uint64_t count)
Definition loop.h:338
spa_source_signal_func_t
void(* spa_source_signal_func_t)(void *data, int signal_number)
Definition loop.h:340
spa_loop_control_iterate_fast
SPA_API_LOOP int spa_loop_control_iterate_fast(struct spa_loop_control *object, int timeout)
Definition loop.h:324
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:303
spa_source_idle_func_t
void(* spa_source_idle_func_t)(void *data)
Definition loop.h:337
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:446
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:413
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:336
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:418
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:393
spa_loop_control_leave
SPA_API_LOOP void spa_loop_control_leave(struct spa_loop_control *object)
Definition loop.h:314
spa_loop_update_source
SPA_API_LOOP int spa_loop_update_source(struct spa_loop *object, struct spa_source *source)
Definition loop.h:159
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:387
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:181
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