mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: add operation with custom callback
Add an operation with a custom callback when the roundtrip completed.
This commit is contained in:
parent
ae14ef7a49
commit
7ddcc91461
2 changed files with 19 additions and 2 deletions
|
|
@ -33,7 +33,9 @@
|
|||
#include "operation.h"
|
||||
#include "reply.h"
|
||||
|
||||
int operation_new(struct client *client, uint32_t tag)
|
||||
int operation_new_cb(struct client *client, uint32_t tag,
|
||||
void (*callback)(void *data, struct client *client, uint32_t tag),
|
||||
void *data)
|
||||
{
|
||||
struct operation *o;
|
||||
|
||||
|
|
@ -42,6 +44,8 @@ int operation_new(struct client *client, uint32_t tag)
|
|||
|
||||
o->client = client;
|
||||
o->tag = tag;
|
||||
o->callback = callback;
|
||||
o->data = data;
|
||||
|
||||
spa_list_append(&client->operations, &o->link);
|
||||
pw_manager_sync(client->manager);
|
||||
|
|
@ -51,6 +55,11 @@ int operation_new(struct client *client, uint32_t tag)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int operation_new(struct client *client, uint32_t tag)
|
||||
{
|
||||
return operation_new_cb(client, tag, NULL, NULL);
|
||||
}
|
||||
|
||||
void operation_free(struct operation *o)
|
||||
{
|
||||
spa_list_remove(&o->link);
|
||||
|
|
@ -63,6 +72,9 @@ void operation_complete(struct operation *o)
|
|||
|
||||
pw_log_info("[%s]: tag:%u complete", client->name, o->tag);
|
||||
|
||||
if (o->callback)
|
||||
o->callback(o->data, client, o->tag);
|
||||
else
|
||||
reply_simple_ack(client, o->tag);
|
||||
operation_free(o);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,9 +35,14 @@ struct operation {
|
|||
struct spa_list link;
|
||||
struct client *client;
|
||||
uint32_t tag;
|
||||
void (*callback) (void *data, struct client *client, uint32_t tag);
|
||||
void *data;
|
||||
};
|
||||
|
||||
int operation_new(struct client *client, uint32_t tag);
|
||||
int operation_new_cb(struct client *client, uint32_t tag,
|
||||
void (*callback) (void *data, struct client *client, uint32_t tag),
|
||||
void *data);
|
||||
void operation_free(struct operation *o);
|
||||
void operation_complete(struct operation *o);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue