@@ -43,14 +43,15 @@ struct pw_context;
4343
4444struct pw_global ;
4545struct pw_impl_client ;
46+ struct pw_impl_node ;
4647
4748#include <pipewire/core.h>
4849#include <pipewire/loop.h>
4950#include <pipewire/properties.h>
5051
5152/** context events emitted by the context object added with \ref pw_context_add_listener */
5253struct pw_context_events {
53- #define PW_VERSION_CONTEXT_EVENTS 0
54+ #define PW_VERSION_CONTEXT_EVENTS 1
5455 uint32_t version ;
5556
5657 /** The context is being destroyed */
@@ -63,12 +64,24 @@ struct pw_context_events {
6364 void (* global_added ) (void * data , struct pw_global * global );
6465 /** a global object was removed */
6566 void (* global_removed ) (void * data , struct pw_global * global );
67+
68+ /** a driver was added, since 0.3.75 version:1 */
69+ void (* driver_added ) (void * data , struct pw_impl_node * node );
70+ /** a driver was removed, since 0.3.75 version:1 */
71+ void (* driver_removed ) (void * data , struct pw_impl_node * node );
6672};
6773
68- /** Make a new context object for a given main_loop. Ownership of the properties is taken */
69- struct pw_context * pw_context_new (struct pw_loop * main_loop , /**< a main loop to run in */
70- struct pw_properties * props , /**< extra properties */
71- size_t user_data_size /**< extra user data size */ );
74+ /** Make a new context object for a given main_loop. Ownership of the properties is taken, even
75+ * if the function returns NULL.
76+ *
77+ * \param main_loop A main loop to run in. This must stay alive unil pw_context_destroy() is called.
78+ * \param props extra properties
79+ * \param user_data_size extra user data size
80+ * \return The context object on success, or NULL on failure, in which case errno is set.
81+ * */
82+ struct pw_context * pw_context_new (struct pw_loop * main_loop ,
83+ struct pw_properties * props ,
84+ size_t user_data_size );
7285
7386/** destroy a context object, all resources except the main_loop will be destroyed */
7487void pw_context_destroy (struct pw_context * context );
@@ -113,15 +126,27 @@ int pw_context_conf_section_match_rules(struct pw_context *context, const char *
113126/** Get the context support objects */
114127const struct spa_support * pw_context_get_support (struct pw_context * context , uint32_t * n_support );
115128
116- /** get the context main loop */
129+ /** Get the context main loop. Returns the value passed to pw_context_new(). */
117130struct pw_loop * pw_context_get_main_loop (struct pw_context * context );
118131
119- /** get the context data loop. Since 0.3.56 */
132+ /** Get the context data loop. This loop runs on the realtime thread. This
133+ * acquires a loop from the generic data.rt class. Use pw_context_acquire_loop() instead.
134+ * Since 0.3.56 */
120135struct pw_data_loop * pw_context_get_data_loop (struct pw_context * context );
121136
137+ /** Get a data-loop.
138+ * Since 1.1.0 */
139+ struct pw_loop * pw_context_acquire_loop (struct pw_context * context , const struct spa_dict * props );
140+ /** Release a data-loop.
141+ * Since 1.1.0 */
142+ void pw_context_release_loop (struct pw_context * context , struct pw_loop * loop );
143+
122144/** Get the work queue from the context: Since 0.3.26 */
123145struct pw_work_queue * pw_context_get_work_queue (struct pw_context * context );
124146
147+ /** Get the memory pool from the context: Since 0.3.74 */
148+ struct pw_mempool * pw_context_get_mempool (struct pw_context * context );
149+
125150/** Iterate the globals of the context. The callback should return
126151 * 0 to fetch the next item, any other value stops the iteration and returns
127152 * the value. When all callbacks return 0, this function returns 0 when all
@@ -130,7 +155,10 @@ int pw_context_for_each_global(struct pw_context *context,
130155 int (* callback ) (void * data , struct pw_global * global ),
131156 void * data );
132157
133- /** Find a context global by id */
158+ /** Find a context global by id.
159+ *
160+ * \return The global on success, or NULL on failure. If id is \ref PW_ID_CORE,
161+ * this function will always return a non-NULL value. */
134162struct pw_global * pw_context_find_global (struct pw_context * context , /**< the context */
135163 uint32_t id /**< the global id */ );
136164
@@ -140,6 +168,7 @@ int pw_context_add_spa_lib(struct pw_context *context, const char *factory_regex
140168/** find the library name for a spa factory */
141169const char * pw_context_find_spa_lib (struct pw_context * context , const char * factory_name );
142170
171+ /** Load a SPA handle from a context. On failure returns NULL and sets errno. */
143172struct spa_handle * pw_context_load_spa_handle (struct pw_context * context ,
144173 const char * factory_name ,
145174 const struct spa_dict * info );
@@ -160,9 +189,21 @@ int pw_context_register_export_type(struct pw_context *context, struct pw_export
160189/** find information about registered export type */
161190const struct pw_export_type * pw_context_find_export_type (struct pw_context * context , const char * type );
162191
163- /** add an object to the context */
192+ /** add an object to the context
193+ *
194+ * \param context The context.
195+ * \param type The type of the object, usually a `TYPE_INTERFACE_` value.
196+ * \param value The object value. Must last as long as the context and must
197+ * be of the type corresponding to the type.
198+ * \return A negative number on failure (out of memory).
199+ * */
164200int pw_context_set_object (struct pw_context * context , const char * type , void * value );
165- /** get an object from the context */
201+ /** get an object from the context
202+ *
203+ * \param context The context.
204+ * \param type The string corresponding to the object's interface.
205+ * \return The object, or NULL if the object does not exist.
206+ * */
166207void * pw_context_get_object (struct pw_context * context , const char * type );
167208
168209/**
0 commit comments