PipeWire 0.3.38
redhat-linux-build/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
29extern "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"
48struct 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 */
#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:226
int spa_thread_utils_get_rt_range(struct spa_thread_utils *o, const struct spa_dict *props, int *min, int *max)
Definition: redhat-linux-build/doc/spa/support/thread.h:93
struct spa_thread * spa_thread_utils_create(struct spa_thread_utils *o, const struct spa_dict *props, void *(*start_routine)(void *), void *arg)
Definition: redhat-linux-build/doc/spa/support/thread.h:73
int spa_thread_utils_drop_rt(struct spa_thread_utils *o, struct spa_thread *thread)
Definition: redhat-linux-build/doc/spa/support/thread.h:113
int spa_thread_utils_join(struct spa_thread_utils *o, struct spa_thread *thread, void **retval)
Definition: redhat-linux-build/doc/spa/support/thread.h:83
int spa_thread_utils_acquire_rt(struct spa_thread_utils *o, struct spa_thread *thread, int priority)
Definition: redhat-linux-build/doc/spa/support/thread.h:103
const char * props
Definition: media-session.c:2397
user data to add to an object
Definition: media-session.c:113
Definition: utils/dict.h:48
Definition: hook.h:149
thread utils
Definition: redhat-linux-build/doc/spa/support/thread.h:55
int(* join)(void *data, struct spa_thread *thread, void **retval)
stop and join a thread
Definition: redhat-linux-build/doc/spa/support/thread.h:63
int(* acquire_rt)(void *data, struct spa_thread *thread, int priority)
acquire realtime priority
Definition: redhat-linux-build/doc/spa/support/thread.h:68
int(* drop_rt)(void *data, struct spa_thread *thread)
drop realtime priority
Definition: redhat-linux-build/doc/spa/support/thread.h:70
uint32_t version
Definition: redhat-linux-build/doc/spa/support/thread.h:57
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: redhat-linux-build/doc/spa/support/thread.h:66
Definition: redhat-linux-build/doc/spa/support/thread.h:52
struct spa_interface iface
Definition: redhat-linux-build/doc/spa/support/thread.h:52
Definition: module-rtkit.c:75