PipeWire 1.4.8

Loading...
Searching...
No Matches
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
9 extern "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
19#ifndef SPA_API_THREAD
20 #ifdef SPA_API_IMPL
21 #define SPA_API_THREAD SPA_API_IMPL
22 #else
23 #define SPA_API_THREAD static inline
24 #endif
25#endif
26
30
35
39#define SPA_TYPE_INFO_Thread SPA_TYPE_INFO_POINTER_BASE "Thread"
40 struct spa_thread;
41
42#define SPA_TYPE_INTERFACE_ThreadUtils SPA_TYPE_INFO_INTERFACE_BASE "ThreadUtils"
43#define SPA_VERSION_THREAD_UTILS 0
44 struct spa_thread_utils { struct spa_interface iface; };
45
47 struct spa_thread_utils_methods {
48#define SPA_VERSION_THREAD_UTILS_METHODS 0
49 uint32_t version;
50
52 struct spa_thread * (*create) (void *object, const struct spa_dict *props,
53 void *(*start)(void*), void *arg);
55 int (*join)(void *object, struct spa_thread *thread, void **retval);
56
58 int (*get_rt_range) (void *object, const struct spa_dict *props, int *min, int *max);
62 int (*acquire_rt) (void *object, struct spa_thread *thread, int priority);
64 int (*drop_rt) (void *object, struct spa_thread *thread);
65};
66
69 SPA_API_THREAD struct spa_thread *spa_thread_utils_create(struct spa_thread_utils *o,
70 const struct spa_dict *props, void *(*start_routine)(void*), void *arg)
71{
72 return spa_api_method_r(struct spa_thread *, NULL,
73 spa_thread_utils, &o->iface, create, 0,
74 props, start_routine, arg);
75}
76
78
79 SPA_API_THREAD int spa_thread_utils_join(struct spa_thread_utils *o,
80 struct spa_thread *thread, void **retval)
81{
82 return spa_api_method_r(int, -ENOTSUP,
83 spa_thread_utils, &o->iface, join, 0,
84 thread, retval);
85}
86
88
89 SPA_API_THREAD int spa_thread_utils_get_rt_range(struct spa_thread_utils *o,
90 const struct spa_dict *props, int *min, int *max)
91{
92 return spa_api_method_r(int, -ENOTSUP,
93 spa_thread_utils, &o->iface, get_rt_range, 0,
94 props, min, max);
95}
96
98
99 SPA_API_THREAD int spa_thread_utils_acquire_rt(struct spa_thread_utils *o,
100 struct spa_thread *thread, int priority)
101{
102 return spa_api_method_r(int, -ENOTSUP,
103 spa_thread_utils, &o->iface, acquire_rt, 0,
104 thread, priority);
105}
106
108
109 SPA_API_THREAD int spa_thread_utils_drop_rt(struct spa_thread_utils *o,
110 struct spa_thread *thread)
111{
112 return spa_api_method_r(int, -ENOTSUP,
113 spa_thread_utils, &o->iface, drop_rt, 0, thread);
114}
115
116#define SPA_KEY_THREAD_NAME "thread.name" /* the thread name */
117#define SPA_KEY_THREAD_STACK_SIZE "thread.stack-size" /* the stack size of the thread */
118#define SPA_KEY_THREAD_AFFINITY "thread.affinity" /* array of CPUs for this thread */
119#define SPA_KEY_THREAD_CREATOR "thread.creator" /* platform specific thread creator function */
120
121/**
122 * \}
123 */
124
125#ifdef __cplusplus
126} /* extern "C" */
127#endif
128
129#endif /* SPA_THREAD_H */
defs.h
spa/utils/defs.h
spa_api_method_r
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
spa_thread_utils_drop_rt
SPA_API_THREAD int spa_thread_utils_drop_rt(struct spa_thread_utils *o, struct spa_thread *thread)
drop realtime priority
Definition thread.h:121
spa_thread_utils_acquire_rt
SPA_API_THREAD 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 thread.h:111
spa_thread_utils_get_rt_range
SPA_API_THREAD 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 thread.h:101
spa_thread_utils_create
SPA_API_THREAD 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 thread.h:81
spa_thread_utils_join
SPA_API_THREAD int spa_thread_utils_join(struct spa_thread_utils *o, struct spa_thread *thread, void **retval)
stop and join a thread
Definition thread.h:91
hook.h
spa/utils/hook.h
SPA_API_THREAD
#define SPA_API_THREAD
Definition thread.h:30
string.h
spa/utils/string.h
spa_dict
Definition dict.h:51
spa_interface
Definition hook.h:148
spa_thread_utils_methods
thread utils
Definition thread.h:58
spa_thread_utils_methods::drop_rt
int(* drop_rt)(void *object, struct spa_thread *thread)
drop realtime priority
Definition thread.h:76
spa_thread_utils_methods::version
uint32_t version
Definition thread.h:61
spa_thread_utils_methods::create
struct spa_thread *(* create)(void *object, const struct spa_dict *props, void *(*start)(void *), void *arg)
create a new thread that runs start with arg
Definition thread.h:64
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 thread.h:70
spa_thread_utils_methods::join
int(* join)(void *object, struct spa_thread *thread, void **retval)
stop and join a thread
Definition thread.h:67
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 thread.h:74
spa_thread_utils
Definition thread.h:55
spa_thread_utils::iface
struct spa_interface iface
Definition thread.h:55
spa_thread
dict.h
spa/utils/dict.h