mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
interfaces: improve remote API
Add return values to events and method callbacks. This makes it possible to pass any error or async return value. Add sync/done/error in both directions so that both proxy and resource and perform/reply sync and produce errors. Return a SPA_ASYNC from remote method calls (and events), keep the sequence number in the connection. With the core sync/done we can remove the client-node done method and it's internal sequence number along with the seq number in method calls. We can also use the method/event async return value to perform a sync with as the unique sequence number for this method. Add sync method and done/error event to proxy and resource.
This commit is contained in:
parent
0d8821096a
commit
eea062ee53
41 changed files with 1180 additions and 817 deletions
|
|
@ -184,16 +184,6 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
|
|||
return -EBADF;
|
||||
}
|
||||
|
||||
static void on_sink_done(void *data, int seq, int res)
|
||||
{
|
||||
printf("got done %d %d\n", seq, res);
|
||||
}
|
||||
|
||||
static void on_sink_event(void *data, struct spa_event *event)
|
||||
{
|
||||
printf("got event %d\n", SPA_EVENT_TYPE(event));
|
||||
}
|
||||
|
||||
static void update_props(struct data *data)
|
||||
{
|
||||
struct spa_pod_builder b;
|
||||
|
|
@ -233,7 +223,7 @@ static void update_props(struct data *data)
|
|||
data->volume_accum -= M_PI_M2;
|
||||
}
|
||||
|
||||
static void on_sink_ready(void *_data, int status)
|
||||
static int on_sink_ready(void *_data, int status)
|
||||
{
|
||||
struct data *data = _data;
|
||||
|
||||
|
|
@ -241,20 +231,20 @@ static void on_sink_ready(void *_data, int status)
|
|||
|
||||
spa_graph_node_process(&data->source_node);
|
||||
spa_graph_node_process(&data->sink_node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
on_sink_reuse_buffer(void *_data, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
struct data *data = _data;
|
||||
|
||||
data->source_sink_io[0].buffer_id = buffer_id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_node_callbacks sink_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
.done = on_sink_done,
|
||||
.event = on_sink_event,
|
||||
.ready = on_sink_ready,
|
||||
.reuse_buffer = on_sink_reuse_buffer
|
||||
};
|
||||
|
|
|
|||
|
|
@ -145,21 +145,7 @@ static void handle_events(struct data *data)
|
|||
}
|
||||
}
|
||||
|
||||
static void on_source_done(void *data, int seq, int res)
|
||||
{
|
||||
printf("got done %d %d\n", seq, res);
|
||||
}
|
||||
|
||||
static void on_source_event(void *_data, struct spa_event *event)
|
||||
{
|
||||
struct data *data = _data;
|
||||
|
||||
handle_events(data);
|
||||
|
||||
printf("got event %d\n", SPA_EVENT_TYPE(event));
|
||||
}
|
||||
|
||||
static void on_source_ready(void *_data, int status)
|
||||
static int on_source_ready(void *_data, int status)
|
||||
{
|
||||
struct data *data = _data;
|
||||
int res;
|
||||
|
|
@ -177,7 +163,7 @@ static void on_source_ready(void *_data, int status)
|
|||
printf("got process error %d\n", res);
|
||||
|
||||
if (io->buffer_id > MAX_BUFFERS)
|
||||
return;
|
||||
return -EINVAL;
|
||||
|
||||
b = &data->buffers[io->buffer_id];
|
||||
|
||||
|
|
@ -194,26 +180,28 @@ static void on_source_ready(void *_data, int status)
|
|||
|
||||
if (SDL_LockTexture(texture, NULL, &sdata, &sstride) < 0) {
|
||||
fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError());
|
||||
return;
|
||||
return -EIO;
|
||||
}
|
||||
} else {
|
||||
uint8_t *map;
|
||||
|
||||
if (SDL_LockTexture(data->texture, NULL, &ddata, &dstride) < 0) {
|
||||
fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError());
|
||||
return;
|
||||
return -EIO;
|
||||
}
|
||||
sdata = datas[0].data;
|
||||
if (datas[0].type == SPA_DATA_MemFd ||
|
||||
datas[0].type == SPA_DATA_DmaBuf) {
|
||||
map = mmap(NULL, datas[0].maxsize + datas[0].mapoffset, PROT_READ,
|
||||
MAP_PRIVATE, datas[0].fd, 0);
|
||||
if (map == MAP_FAILED)
|
||||
return -errno;
|
||||
sdata = SPA_MEMBER(map, datas[0].mapoffset, uint8_t);
|
||||
} else if (datas[0].type == SPA_DATA_MemPtr) {
|
||||
map = NULL;
|
||||
sdata = datas[0].data;
|
||||
} else
|
||||
return;
|
||||
return -EIO;
|
||||
|
||||
sstride = datas[0].chunk->stride;
|
||||
|
||||
|
|
@ -233,12 +221,11 @@ static void on_source_ready(void *_data, int status)
|
|||
}
|
||||
|
||||
io->status = SPA_STATUS_NEED_BUFFER;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_node_callbacks source_callbacks = {
|
||||
SPA_VERSION_NODE_CALLBACKS,
|
||||
.done = on_source_done,
|
||||
.event = on_source_event,
|
||||
.ready = on_source_ready
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue