PipeWire 1.4.1
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
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
39#define SPA_TYPE_INFO_Thread SPA_TYPE_INFO_POINTER_BASE "Thread"
40struct spa_thread;
41
42#define SPA_TYPE_INTERFACE_ThreadUtils SPA_TYPE_INFO_INTERFACE_BASE "ThreadUtils"
43#define SPA_VERSION_THREAD_UTILS 0
44struct spa_thread_utils { struct spa_interface iface; };
45
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
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}
80 struct spa_thread *thread, void **retval)
82 return spa_api_method_r(int, -ENOTSUP,
83 spa_thread_utils, &o->iface, join, 0,
84 thread, retval);
85}
86
90 const struct spa_dict *props, int *min, int *max)
92 return spa_api_method_r(int, -ENOTSUP,
93 spa_thread_utils, &o->iface, get_rt_range, 0,
94 props, min, max);
95}
96
100 struct spa_thread *thread, int priority)
102 return spa_api_method_r(int, -ENOTSUP,
103 spa_thread_utils, &o->iface, acquire_rt, 0,
104 thread, priority);
105}
106
110 struct spa_thread *thread)
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
125#ifdef __cplusplus
126} /* extern "C" */
127#endif
128
129#endif /* SPA_THREAD_H */
spa/utils/defs.h
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
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_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_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_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_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
spa/utils/hook.h
#define SPA_API_THREAD
Definition thread.h:30
spa/utils/string.h
Definition dict.h:51
Definition hook.h:148
thread utils
Definition thread.h:58
int(* drop_rt)(void *object, struct spa_thread *thread)
drop realtime priority
Definition thread.h:76
uint32_t version
Definition thread.h:61
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
int(* join)(void *object, struct spa_thread *thread, void **retval)
stop and join a thread
Definition thread.h:67
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
Definition thread.h:55
struct spa_interface iface
Definition thread.h:55
spa/utils/dict.h