PipeWire: thread.h Source File

PipeWire 0.3.67

Loading...
Searching...
No Matches
spa/include/spa/support/thread.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2021 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_THREAD_H
6#define SPA_THREAD_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <string.h>
13#include <errno.h>
14
15#include <spa/utils/defs.h>
16#include <spa/utils/hook.h>
17#include <spa/utils/dict.h>
18
31#define SPA_TYPE_INFO_Thread SPA_TYPE_INFO_POINTER_BASE "Thread"
32struct spa_thread;
33
34#define SPA_TYPE_INTERFACE_ThreadUtils SPA_TYPE_INFO_INTERFACE_BASE "ThreadUtils"
35#define SPA_VERSION_THREAD_UTILS 0
36struct spa_thread_utils { struct spa_interface iface; };
37
39struct spa_thread_utils_methods {
40#define SPA_VERSION_THREAD_UTILS_METHODS 0
41 uint32_t version;
42
44 struct spa_thread * (*create) (void *object, const struct spa_dict *props,
45 void *(*start)(void*), void *arg);
47 int (*join)(void *object, struct spa_thread *thread, void **retval);
48
50 int (*get_rt_range) (void *object, const struct spa_dict *props, int *min, int *max);
54 int (*acquire_rt) (void *object, struct spa_thread *thread, int priority);
56 int (*drop_rt) (void *object, struct spa_thread *thread);
57};
58
61static inline struct spa_thread *spa_thread_utils_create(struct spa_thread_utils *o,
62 const struct spa_dict *props, void *(*start_routine)(void*), void *arg)
63{
64 struct spa_thread *res = NULL;
65 spa_interface_call_res(&o->iface,
66 struct spa_thread_utils_methods, res, create, 0,
67 props, start_routine, arg);
68 return res;
69}
70
73static inline int spa_thread_utils_join(struct spa_thread_utils *o,
74 struct spa_thread *thread, void **retval)
75{
76 int res = -ENOTSUP;
77 spa_interface_call_res(&o->iface,
78 struct spa_thread_utils_methods, res, join, 0,
79 thread, retval);
80 return res;
81}
82
85static inline int spa_thread_utils_get_rt_range(struct spa_thread_utils *o,
86 const struct spa_dict *props, int *min, int *max)
87{
88 int res = -ENOTSUP;
89 spa_interface_call_res(&o->iface,
90 struct spa_thread_utils_methods, res, get_rt_range, 0,
91 props, min, max);
92 return res;
93}
94
97static inline int spa_thread_utils_acquire_rt(struct spa_thread_utils *o,
98 struct spa_thread *thread, int priority)
99{
100 int res = -ENOTSUP;
101 spa_interface_call_res(&o->iface,
102 struct spa_thread_utils_methods, res, acquire_rt, 0,
103 thread, priority);
104 return res;
105}
106
109static inline int spa_thread_utils_drop_rt(struct spa_thread_utils *o,
110 struct spa_thread *thread)
111{
112 int res = -ENOTSUP;
113 spa_interface_call_res(&o->iface,
114 struct spa_thread_utils_methods, res, drop_rt, 0, thread);
115 return res;
116}
117
118#define SPA_KEY_THREAD_NAME "thread.name" /* the thread name */
119#define SPA_KEY_THREAD_STACK_SIZE "thread.stack-size" /* the stack size of the thread */
120
125#ifdef __cplusplus
126} /* extern "C" */
127#endif
128
129#endif /* SPA_THREAD_H */
defs.h
spa/utils/defs.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:235
spa_thread_utils_acquire_rt
static int spa_thread_utils_acquire_rt(struct spa_thread_utils *o, struct spa_thread *thread, int priority)
acquire realtime priority, a priority of -1 refers to the priority configured in the realtime module
Definition: spa/include/spa/support/thread.h:107
spa_thread_utils_get_rt_range
static int spa_thread_utils_get_rt_range(struct spa_thread_utils *o, const struct spa_dict *props, int *min, int *max)
get realtime priority range for threads created with props
Definition: spa/include/spa/support/thread.h:95
spa_thread_utils_create
static struct spa_thread * spa_thread_utils_create(struct spa_thread_utils *o, const struct spa_dict *props, void *(*start_routine)(void *), void *arg)
create a new thread that runs start with arg
Definition: spa/include/spa/support/thread.h:71
spa_thread_utils_join
static int spa_thread_utils_join(struct spa_thread_utils *o, struct spa_thread *thread, void **retval)
stop and join a thread
Definition: spa/include/spa/support/thread.h:83
spa_thread_utils_drop_rt
static int spa_thread_utils_drop_rt(struct spa_thread_utils *o, struct spa_thread *thread)
drop realtime priority
Definition: spa/include/spa/support/thread.h:119
hook.h
spa/utils/hook.h
string.h
spa/utils/string.h
spa_dict
Definition: utils/dict.h:39
spa_interface
Definition: hook.h:138
spa_thread_utils_methods
thread utils
Definition: spa/include/spa/support/thread.h:48
spa_thread_utils_methods::drop_rt
int(* drop_rt)(void *object, struct spa_thread *thread)
drop realtime priority
Definition: spa/include/spa/support/thread.h:66
spa_thread_utils_methods::version
uint32_t version
Definition: spa/include/spa/support/thread.h:51
spa_thread_utils_methods::get_rt_range
int(* get_rt_range)(void *object, const struct spa_dict *props, int *min, int *max)
get realtime priority range for threads created with props
Definition: spa/include/spa/support/thread.h:60
spa_thread_utils_methods::join
int(* join)(void *object, struct spa_thread *thread, void **retval)
stop and join a thread
Definition: spa/include/spa/support/thread.h:57
spa_thread_utils_methods::acquire_rt
int(* acquire_rt)(void *object, struct spa_thread *thread, int priority)
acquire realtime priority, a priority of -1 refers to the priority configured in the realtime module
Definition: spa/include/spa/support/thread.h:64
spa_thread_utils
Definition: spa/include/spa/support/thread.h:45
spa_thread_utils::iface
struct spa_interface iface
Definition: spa/include/spa/support/thread.h:45
spa_thread
dict.h
spa/utils/dict.h