PipeWire  0.3.33
build-12683127/doc/spa/support/thread.h
Go to the documentation of this file.
1 /* Simple Plugin API
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 SPA_THREAD_H
26 #define SPA_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/defs.h>
36 #include <spa/utils/hook.h>
37 #include <spa/utils/dict.h>
38 
47 #define SPA_TYPE_INFO_Thread SPA_TYPE_INFO_POINTER_BASE "Thread"
48 struct spa_thread;
49 
50 #define SPA_TYPE_INTERFACE_ThreadUtils SPA_TYPE_INFO_INTERFACE_BASE "ThreadUtils"
51 #define SPA_VERSION_THREAD_UTILS 0
53 
56 #define SPA_VERSION_THREAD_UTILS_METHODS 0
57  uint32_t version;
58 
60  struct spa_thread * (*create) (void *data, const struct spa_dict *props,
61  void *(*start)(void*), void *arg);
63  int (*join)(void *data, struct spa_thread *thread, void **retval);
64 
66  int (*get_rt_range) (void *data, const struct spa_dict *props, int *min, int *max);
68  int (*acquire_rt) (void *data, struct spa_thread *thread, int priority);
70  int (*drop_rt) (void *data, struct spa_thread *thread);
71 };
72 
73 /* static */ inline struct spa_thread *spa_thread_utils_create(struct spa_thread_utils *o,
74  const struct spa_dict *props, void *(*start_routine)(void*), void *arg)
75 {
76  struct spa_thread *res = NULL;
78  struct spa_thread_utils_methods, res, create, 0,
79  props, start_routine, arg);
80  return res;
81 }
82 
83 /* static */ inline int spa_thread_utils_join(struct spa_thread_utils *o,
84  struct spa_thread *thread, void **retval)
85 {
86  int res = -ENOTSUP;
88  struct spa_thread_utils_methods, res, join, 0,
89  thread, retval);
90  return res;
91 }
92 
93 /* static */ inline int spa_thread_utils_get_rt_range(struct spa_thread_utils *o,
94  const struct spa_dict *props, int *min, int *max)
95 {
96  int res = -ENOTSUP;
98  struct spa_thread_utils_methods, res, get_rt_range, 0,
99  props, min, max);
100  return res;
101 }
102 
103 /* static */ inline int spa_thread_utils_acquire_rt(struct spa_thread_utils *o,
104  struct spa_thread *thread, int priority)
105 {
106  int res = -ENOTSUP;
108  struct spa_thread_utils_methods, res, acquire_rt, 0,
109  thread, priority);
110  return res;
111 }
112 
113 /* static */ inline int spa_thread_utils_drop_rt(struct spa_thread_utils *o,
114  struct spa_thread *thread)
115 {
116  int res = -ENOTSUP;
118  struct spa_thread_utils_methods, res, drop_rt, 0, thread);
119  return res;
120 }
121 
126 #ifdef __cplusplus
127 } /* extern "C" */
128 #endif
129 
130 #endif /* SPA_THREAD_H */
spa_interface_call_res
#define spa_interface_call_res(iface, method_type, res, method, vers,...)
Invoke method named method in the callbacks on the given interface object.
Definition: hook.h:208
spa_thread_utils_create
struct spa_thread * spa_thread_utils_create(struct spa_thread_utils *o, const struct spa_dict *props, void *(*start_routine)(void *), void *arg)
Definition: build-12683127/doc/spa/support/thread.h:73
spa_interface
Definition: hook.h:146
spa_thread_utils_join
int spa_thread_utils_join(struct spa_thread_utils *o, struct spa_thread *thread, void **retval)
Definition: build-12683127/doc/spa/support/thread.h:83
spa_thread_utils_methods::join
int(* join)(void *data, struct spa_thread *thread, void **retval)
stop and join a thread
Definition: build-12683127/doc/spa/support/thread.h:63
string.h
data
user data to add to an object
Definition: filter.c:75
thread
Definition: module-rtkit.c:70
spa_thread_utils
Definition: build-12683127/doc/spa/support/thread.h:52
spa_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: build-12683127/doc/spa/support/thread.h:66
spa_thread_utils_methods
thread utils
Definition: build-12683127/doc/spa/support/thread.h:55
props
const char * props
Definition: media-session.c:2382
spa_thread_utils_drop_rt
int spa_thread_utils_drop_rt(struct spa_thread_utils *o, struct spa_thread *thread)
Definition: build-12683127/doc/spa/support/thread.h:113
spa_thread_utils::iface
struct spa_interface iface
Definition: build-12683127/doc/spa/support/thread.h:52
spa_thread_utils_methods::acquire_rt
int(* acquire_rt)(void *data, struct spa_thread *thread, int priority)
acquire realtime priority
Definition: build-12683127/doc/spa/support/thread.h:68
spa_thread_utils_get_rt_range
int spa_thread_utils_get_rt_range(struct spa_thread_utils *o, const struct spa_dict *props, int *min, int *max)
Definition: build-12683127/doc/spa/support/thread.h:93
spa_dict
Definition: utils/dict.h:48
spa_thread_utils_methods::drop_rt
int(* drop_rt)(void *data, struct spa_thread *thread)
drop realtime priority
Definition: build-12683127/doc/spa/support/thread.h:70
spa_thread_utils_methods::version
uint32_t version
Definition: build-12683127/doc/spa/support/thread.h:57
spa_thread_utils_acquire_rt
int spa_thread_utils_acquire_rt(struct spa_thread_utils *o, struct spa_thread *thread, int priority)
Definition: build-12683127/doc/spa/support/thread.h:103
defs.h
hook.h
dict.h