PipeWire: pipewire/data-loop.h Source File

PipeWire 0.3.51

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
29extern "C" {
30#endif
31
32#include <spa/utils/hook.h>
33#include <spa/support/thread.h>
34
47struct pw_data_loop;
48
49#include <pipewire/loop.h>
50#include <pipewire/properties.h>
51
53struct pw_data_loop_events {
54#define PW_VERSION_DATA_LOOP_EVENTS 0
55 uint32_t version;
57 void (*destroy) (void *data);
58};
59
61 struct pw_data_loop *
62 pw_data_loop_new(const struct spa_dict *props);
63
65void pw_data_loop_add_listener(struct pw_data_loop *loop,
66 struct spa_hook *listener,
67 const struct pw_data_loop_events *events,
68 void *data);
69
72int pw_data_loop_wait(struct pw_data_loop *loop, int timeout);
73
75void pw_data_loop_exit(struct pw_data_loop *loop);
76
78struct pw_loop *
79 pw_data_loop_get_loop(struct pw_data_loop *loop);
80
82void pw_data_loop_destroy(struct pw_data_loop *loop);
83
85int pw_data_loop_start(struct pw_data_loop *loop);
86
88int pw_data_loop_stop(struct pw_data_loop *loop);
89
91bool pw_data_loop_in_thread(struct pw_data_loop *loop);
93struct spa_thread *pw_data_loop_get_thread(struct pw_data_loop *loop);
94
97int pw_data_loop_invoke(struct pw_data_loop *loop,
98 spa_invoke_func_t func, uint32_t seq, const void *data, size_t size,
99 bool block, void *user_data);
100
103void pw_data_loop_set_thread_utils(struct pw_data_loop *loop,
104 struct spa_thread_utils *impl);
109#ifdef __cplusplus
110}
111#endif
112
113#endif /* PIPEWIRE_DATA_LOOP_H */
pw_data_loop_wait
int pw_data_loop_wait(struct pw_data_loop *loop, int timeout)
wait for activity on the loop up to timeout milliseconds.
Definition: data-loop.c:38
pw_data_loop_start
int pw_data_loop_start(struct pw_data_loop *loop)
Start the processing thread.
Definition: data-loop.c:197
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:267
pw_data_loop_set_thread_utils
void pw_data_loop_set_thread_utils(struct pw_data_loop *loop, struct spa_thread_utils *impl)
Set a custom spa_thread_utils for this loop.
Definition: data-loop.c:293
pw_data_loop_stop
int pw_data_loop_stop(struct pw_data_loop *loop)
Stop the processing thread.
Definition: data-loop.c:227
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:174
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:184
pw_data_loop_new
struct pw_data_loop * pw_data_loop_new(const struct spa_dict *props)
Make a new loop.
Definition: data-loop.c:147
pw_data_loop_destroy
void pw_data_loop_destroy(struct pw_data_loop *loop)
Destroy the loop.
Definition: data-loop.c:157
pw_data_loop_in_thread
bool pw_data_loop_in_thread(struct pw_data_loop *loop)
Check if the current thread is the processing thread.
Definition: data-loop.c:255
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:273
pw_data_loop_exit
void pw_data_loop_exit(struct pw_data_loop *loop)
make sure the thread will exit.
Definition: data-loop.c:57
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:86
hook.h
spa/utils/hook.h
properties.h
pipewire/properties.h
thread.h
spa/support/thread.h
loop.h
pipewire/loop.h
pw_data_loop_events
Loop events, use pw_data_loop_add_listener to add a listener.
Definition: data-loop.h:58
pw_data_loop_events::version
uint32_t version
Definition: data-loop.h:61
pw_data_loop_events::destroy
void(* destroy)(void *data)
The loop is destroyed.
Definition: data-loop.h:63
pw_data_loop
pw_loop
Definition: loop.h:51
pw_loop::loop
struct spa_loop * loop
wrapped loop
Definition: loop.h:53
spa_dict
Definition: dict.h:59
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:351
spa_thread_utils
Definition: thread.h:65
spa_thread