PipeWire  0.3.31
thread.h
Go to the documentation of this file.
1 /* PipeWire
2  *
3  * Copyright © 2021 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_H
26 #define PIPEWIRE_THREAD_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <string.h>
33 #include <errno.h>
34 
35 #include <spa/utils/dict.h>
36 #include <pipewire/type.h>
37 
43 #define PW_TYPE_INTERFACE_ThreadUtils PW_TYPE_INFO_INTERFACE_BASE "ThreadUtils"
44 
48 struct pw_thread;
49 
50 #define PW_VERSION_THREAD_UTILS 0
51 struct pw_thread_utils { struct spa_interface iface; };
52 
55 #define PW_VERSION_THREAD_UTILS_METHODS 0
56  uint32_t version;
57 
59  struct pw_thread * (*create) (void *data, const struct spa_dict *props,
60  void *(*start)(void*), void *arg);
62  int (*join)(void *data, struct pw_thread *thread, void **retval);
63 
65  int (*get_rt_range) (void *data, const struct spa_dict *props, int *min, int *max);
67  int (*acquire_rt) (void *data, struct pw_thread *thread, int priority);
69  int (*drop_rt) (void *data, struct pw_thread *thread);
70 };
71 
74 
75 static inline struct pw_thread *pw_thread_utils_create(const struct spa_dict *props,
76  void *(*start_routine)(void*), void *arg)
77 {
78  struct pw_thread *res = NULL;
80  struct pw_thread_utils_methods, res, create, 0,
81  props, start_routine, arg);
82  return res;
83 }
84 
85 static inline int pw_thread_utils_join(struct pw_thread *thread, void **retval)
86 {
87  int res = -ENOTSUP;
89  struct pw_thread_utils_methods, res, join, 0,
90  thread, retval);
91  return res;
92 }
93 
94 static inline int pw_thread_utils_get_rt_range(const struct spa_dict *props, int *min, int *max)
95 {
96  int res = -ENOTSUP;
98  struct pw_thread_utils_methods, res, get_rt_range, 0,
99  props, min, max);
100  return res;
101 }
102 
103 static inline int pw_thread_utils_acquire_rt(struct pw_thread *thread, int priority)
104 {
105  int res = -ENOTSUP;
107  struct pw_thread_utils_methods, res, acquire_rt, 0,
108  thread, priority);
109  return res;
110 }
111 
112 static inline int pw_thread_utils_drop_rt(struct pw_thread *thread)
113 {
114  int res = -ENOTSUP;
116  struct pw_thread_utils_methods, res, drop_rt, 0, thread);
117  return res;
118 }
119 
120 #ifdef __cplusplus
121 } /* extern "C" */
122 #endif
123 
124 #endif /* PIPEWIRE_THREAD_H */
spa_interface
Definition: hook.h:65
methods
struct pw_thread_utils_methods methods
Definition: thread.c:69
string.h
data
Definition: filter.c:75
SPA_EXPORT
#define SPA_EXPORT
Definition: defs.h:208
thread
Definition: module-rtkit.c:70
pw_thread_utils_get_impl
struct pw_thread_utils * pw_thread_utils_get_impl(void)
Definition: thread.c:93
spa_interface_call_res
#define spa_interface_call_res(iface, type, res, method, vers,...)
Definition: hook.h:170
impl
Definition: control.c:33
pw_thread_utils_methods::join
int(* join)(void *data, struct pw_thread *thread, void **retval)
stop and join a thread
Definition: thread.h:62
res
static uint32_t int int res
Definition: core.h:329
pw_thread_utils_set_impl
void pw_thread_utils_set_impl(struct pw_thread_utils *impl)
Definition: thread.c:85
pw_thread_utils_get_impl
SPA_EXPORT struct pw_thread_utils * pw_thread_utils_get_impl(void)
Definition: thread.c:93
pw_thread_utils
Definition: thread.h:51
PW_VERSION_THREAD_UTILS
#define PW_VERSION_THREAD_UTILS
Definition: thread.h:50
type.h
PW_VERSION_THREAD_UTILS_METHODS
#define PW_VERSION_THREAD_UTILS_METHODS
Definition: thread.h:55
spa_dict
Definition: utils/dict.h:48
pw_thread_utils::iface
struct spa_interface iface
Definition: thread.h:51
pw_thread_utils_methods::get_rt_range
int(* get_rt_range)(void *data, const struct spa_dict *props, int *min, int *max)
get realtime priority range for threads created with props
Definition: thread.h:65
SPA_CALLBACKS_INIT
#define SPA_CALLBACKS_INIT(_funcs, _data)
Definition: hook.h:63
pw_thread_utils_methods::drop_rt
int(* drop_rt)(void *data, struct pw_thread *thread)
drop realtime priority
Definition: thread.h:69
PW_TYPE_INTERFACE_ThreadUtils
#define PW_TYPE_INTERFACE_ThreadUtils
Definition: thread.h:43
pw_thread_utils_methods::version
uint32_t version
Definition: thread.h:56
utils
struct pw_thread_utils utils
Definition: thread.c:68
defs.h
pw_thread_utils_methods
thread utils
Definition: thread.h:54
list.h
thread.h
pw_thread_utils_methods::acquire_rt
int(* acquire_rt)(void *data, struct pw_thread *thread, int priority)
acquire realtime priority
Definition: thread.h:67
pw_thread_utils_set_impl
SPA_EXPORT void pw_thread_utils_set_impl(struct pw_thread_utils *impl)
Definition: thread.c:85
log.h
dict.h