PipeWire  0.3.33
data-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_DATA_LOOP_H
26 #define PIPEWIRE_DATA_LOOP_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <spa/utils/hook.h>
33 
44 struct pw_data_loop;
45 
46 #include <pipewire/loop.h>
47 #include <pipewire/properties.h>
48 
51 #define PW_VERSION_DATA_LOOP_EVENTS 0
52  uint32_t version;
54  void (*destroy) (void *data);
55 };
56 
58 struct pw_data_loop *
59 pw_data_loop_new(const struct spa_dict *props);
60 
62 void pw_data_loop_add_listener(struct pw_data_loop *loop,
63  struct spa_hook *listener,
64  const struct pw_data_loop_events *events,
65  void *data);
66 
69 int pw_data_loop_wait(struct pw_data_loop *loop, int timeout);
70 
72 void pw_data_loop_exit(struct pw_data_loop *loop);
73 
75 struct pw_loop *
76 pw_data_loop_get_loop(struct pw_data_loop *loop);
77 
79 void pw_data_loop_destroy(struct pw_data_loop *loop);
80 
82 int pw_data_loop_start(struct pw_data_loop *loop);
83 
85 int pw_data_loop_stop(struct pw_data_loop *loop);
86 
88 bool pw_data_loop_in_thread(struct pw_data_loop *loop);
90 struct spa_thread *pw_data_loop_get_thread(struct pw_data_loop *loop);
91 
94 int pw_data_loop_invoke(struct pw_data_loop *loop,
95  spa_invoke_func_t func, uint32_t seq, const void *data, size_t size,
96  bool block, void *user_data);
97 
102 #ifdef __cplusplus
103 }
104 #endif
105 
106 #endif /* PIPEWIRE_DATA_LOOP_H */
pw_loop_new
struct pw_loop * pw_loop_new(const struct spa_dict *props)
Create a new loop.
Definition: loop.c:54
data-loop.h
pw_data_loop_invoke
int pw_data_loop_invoke(struct pw_data_loop *loop, spa_invoke_func_t func, uint32_t seq, const void *data, size_t size, bool block, void *user_data)
invoke func in the context of the thread or in the caller thread when the loop is not running.
Definition: data-loop.c:272
pw_data_loop_start
int pw_data_loop_start(struct pw_data_loop *loop)
Start a data loop.
Definition: data-loop.c:204
pw_data_loop_in_thread
bool pw_data_loop_in_thread(struct pw_data_loop *loop)
Check if we are inside the data loop.
Definition: data-loop.c:254
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: build-12775836/doc/spa/support/loop.h:67
pw_loop_leave
#define pw_loop_leave(l)
Definition: src/pipewire/loop.h:69
loop.h
pw_data_loop_events
Loop events, use pw_data_loop_add_listener to add a listener.
Definition: data-loop.h:50
data
user data to add to an object
Definition: filter.c:75
pw_loop
Definition: src/pipewire/loop.h:47
SPA_EXPORT
#define SPA_EXPORT
Definition: defs.h:208
pw_data_loop_get_thread
struct spa_thread * pw_data_loop_get_thread(struct pw_data_loop *loop)
Get the thread object.
Definition: data-loop.c:266
thread.h
spa_hook_list_append
void spa_hook_list_append(struct spa_hook_list *list, struct spa_hook *hook, const void *funcs, void *data)
Append a hook.
Definition: hook.h:316
pw_data_loop_new
struct pw_data_loop * pw_data_loop_new(const struct spa_dict *props)
Create a new PipeWire rt-loop object.
Definition: data-loop.c:153
pw_data_loop_events::version
uint32_t version
Definition: data-loop.h:52
props
const char * props
Definition: media-session.c:2382
pw_loop_destroy_source
#define pw_loop_destroy_source(l,...)
Definition: src/pipewire/loop.h:80
pw_data_loop_events::destroy
void(* destroy)(void *data)
The loop is destroyed.
Definition: data-loop.h:54
pw_loop_add_event
#define pw_loop_add_event(l,...)
Definition: src/pipewire/loop.h:75
NAME
#define NAME
Definition: data-loop.c:34
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:295
pw_data_loop_wait
int pw_data_loop_wait(struct pw_data_loop *this, int timeout)
wait for activity on the loop up to timeout milliseconds.
Definition: data-loop.c:37
pw_data_loop_get_loop
struct pw_loop * pw_data_loop_get_loop(struct pw_data_loop *loop)
Get the loop implementation of this data loop.
Definition: data-loop.c:191
pw_thread_utils_join
#define pw_thread_utils_join(...)
Definition: src/pipewire/thread.h:46
spa_dict
Definition: utils/dict.h:48
pw_loop_signal_event
#define pw_loop_signal_event(l,...)
Definition: src/pipewire/loop.h:76
spa_dict_lookup
const char * spa_dict_lookup(const struct spa_dict *dict, const char *key)
Definition: utils/dict.h:99
pw_data_loop_exit
void pw_data_loop_exit(struct pw_data_loop *this)
make sure the thread will exit.
Definition: data-loop.c:56
spa_strerror
#define spa_strerror(err)
Definition: result.h:51
pw_thread_utils_create
#define pw_thread_utils_create(...)
Definition: src/pipewire/thread.h:45
pw_log_debug
#define pw_log_debug(...)
Definition: src/pipewire/log.h:89
pw_loop_enter
#define pw_loop_enter(l)
Definition: src/pipewire/loop.h:67
pw_loop_iterate
#define pw_loop_iterate(l,...)
Definition: src/pipewire/loop.h:68
pw_data_loop_destroy
void pw_data_loop_destroy(struct pw_data_loop *loop)
Destroy a data loop.
Definition: data-loop.c:163
pw_data_loop_stop
int pw_data_loop_stop(struct pw_data_loop *loop)
Stop a data loop.
Definition: data-loop.c:229
pw_loop_destroy
void pw_loop_destroy(struct pw_loop *loop)
Destroy a loop.
Definition: loop.c:156
pw_loop_invoke
#define pw_loop_invoke(l,...)
Definition: src/pipewire/loop.h:63
spa_hook_list_init
void spa_hook_list_init(struct spa_hook_list *list)
Initialize a hook list to the empty list.
Definition: hook.h:305
properties.h
pw_data_loop_add_listener
void pw_data_loop_add_listener(struct pw_data_loop *loop, struct spa_hook *listener, const struct pw_data_loop_events *events, void *data)
Add an event listener to loop.
Definition: data-loop.c:182
pw_loop::loop
struct spa_loop * loop
wrapped loop
Definition: src/pipewire/loop.h:49
hook.h
log.h
spa_hook_list_clean
void spa_hook_list_clean(struct spa_hook_list *list)
Remove all hooks from the list.
Definition: hook.h:344
pw_log_error
#define pw_log_error(...)
Definition: src/pipewire/log.h:86