mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
context: add method to get a work_queue
Make a method to get a work-queue from the context. There is one work-queue to use and the context will allocate it when requested and free when destroyed. The work queue is handy to delay execution of some logic for later, either in the next iteration of the main-loop or when an async operation completed. Export some work-queue methods.
This commit is contained in:
parent
bf5d40434d
commit
0a3d44ac53
4 changed files with 22 additions and 4 deletions
|
|
@ -433,6 +433,9 @@ void pw_context_destroy(struct pw_context *context)
|
||||||
|
|
||||||
pw_data_loop_destroy(context->data_loop_impl);
|
pw_data_loop_destroy(context->data_loop_impl);
|
||||||
|
|
||||||
|
if (context->work_queue)
|
||||||
|
pw_work_queue_destroy(context->work_queue);
|
||||||
|
|
||||||
pw_properties_free(context->properties);
|
pw_properties_free(context->properties);
|
||||||
pw_properties_free(context->conf);
|
pw_properties_free(context->conf);
|
||||||
|
|
||||||
|
|
@ -483,6 +486,14 @@ struct pw_loop *pw_context_get_main_loop(struct pw_context *context)
|
||||||
return context->main_loop;
|
return context->main_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPA_EXPORT
|
||||||
|
struct pw_work_queue *pw_context_get_work_queue(struct pw_context *context)
|
||||||
|
{
|
||||||
|
if (context->work_queue == NULL)
|
||||||
|
context->work_queue = pw_work_queue_new(context->main_loop);
|
||||||
|
return context->work_queue;
|
||||||
|
}
|
||||||
|
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
const struct pw_properties *pw_context_get_properties(struct pw_context *context)
|
const struct pw_properties *pw_context_get_properties(struct pw_context *context)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,9 @@ const struct spa_support *pw_context_get_support(struct pw_context *context, uin
|
||||||
/** get the context main loop */
|
/** get the context main loop */
|
||||||
struct pw_loop *pw_context_get_main_loop(struct pw_context *context);
|
struct pw_loop *pw_context_get_main_loop(struct pw_context *context);
|
||||||
|
|
||||||
|
/** Get the work queue from the context: Since 0.3.26 */
|
||||||
|
struct pw_work_queue *pw_context_get_work_queue(struct pw_context *context);
|
||||||
|
|
||||||
/** Iterate the globals of the context. The callback should return
|
/** Iterate the globals of the context. The callback should return
|
||||||
* 0 to fetch the next item, any other value stops the iteration and returns
|
* 0 to fetch the next item, any other value stops the iteration and returns
|
||||||
* the value. When all callbacks return 0, this function returns 0 when all
|
* the value. When all callbacks return 0, this function returns 0 when all
|
||||||
|
|
|
||||||
|
|
@ -405,6 +405,7 @@ struct pw_context {
|
||||||
struct pw_loop *data_loop; /**< data loop for data passing */
|
struct pw_loop *data_loop; /**< data loop for data passing */
|
||||||
struct pw_data_loop *data_loop_impl;
|
struct pw_data_loop *data_loop_impl;
|
||||||
struct spa_system *data_system; /**< data system for data passing */
|
struct spa_system *data_system; /**< data system for data passing */
|
||||||
|
struct pw_work_queue *work_queue; /**< work queue */
|
||||||
|
|
||||||
struct spa_support support[16]; /**< support for spa plugins */
|
struct spa_support support[16]; /**< support for spa plugins */
|
||||||
uint32_t n_support; /**< number of support items */
|
uint32_t n_support; /**< number of support items */
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,7 @@ void pw_work_queue_destroy(struct pw_work_queue *queue)
|
||||||
*
|
*
|
||||||
* \memberof pw_work_queue
|
* \memberof pw_work_queue
|
||||||
*/
|
*/
|
||||||
|
SPA_EXPORT
|
||||||
uint32_t
|
uint32_t
|
||||||
pw_work_queue_add(struct pw_work_queue *queue, void *obj, int res, pw_work_func_t func, void *data)
|
pw_work_queue_add(struct pw_work_queue *queue, void *obj, int res, pw_work_func_t func, void *data)
|
||||||
{
|
{
|
||||||
|
|
@ -215,6 +216,7 @@ pw_work_queue_add(struct pw_work_queue *queue, void *obj, int res, pw_work_func_
|
||||||
*
|
*
|
||||||
* \memberof pw_work_queue
|
* \memberof pw_work_queue
|
||||||
*/
|
*/
|
||||||
|
SPA_EXPORT
|
||||||
int pw_work_queue_cancel(struct pw_work_queue *queue, void *obj, uint32_t id)
|
int pw_work_queue_cancel(struct pw_work_queue *queue, void *obj, uint32_t id)
|
||||||
{
|
{
|
||||||
bool have_work = false;
|
bool have_work = false;
|
||||||
|
|
@ -246,6 +248,7 @@ int pw_work_queue_cancel(struct pw_work_queue *queue, void *obj, uint32_t id)
|
||||||
*
|
*
|
||||||
* \memberof pw_work_queue
|
* \memberof pw_work_queue
|
||||||
*/
|
*/
|
||||||
|
SPA_EXPORT
|
||||||
int pw_work_queue_complete(struct pw_work_queue *queue, void *obj, uint32_t seq, int res)
|
int pw_work_queue_complete(struct pw_work_queue *queue, void *obj, uint32_t seq, int res)
|
||||||
{
|
{
|
||||||
struct work_item *item;
|
struct work_item *item;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue