mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: simplify start/pause
Use the sync option in invoke to implement stop.
This commit is contained in:
parent
67b06d4ad2
commit
155243a27c
6 changed files with 501 additions and 729 deletions
|
|
@ -165,56 +165,10 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int do_send_done(struct spa_loop *loop, bool async, uint32_t seq, const void *data, size_t size, void *user_data)
|
||||
{
|
||||
struct state *this = user_data;
|
||||
|
||||
this->callbacks->done(this->callbacks_data, seq, *(int*)data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_start(struct spa_loop *loop, bool async, uint32_t seq, const void *data, size_t size, void *user_data)
|
||||
{
|
||||
struct state *this = user_data;
|
||||
int res;
|
||||
|
||||
res = spa_alsa_start(this, false);
|
||||
|
||||
if (async) {
|
||||
spa_loop_invoke(this->main_loop,
|
||||
do_send_done,
|
||||
seq,
|
||||
&res,
|
||||
sizeof(res),
|
||||
false,
|
||||
this);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static int do_pause(struct spa_loop *loop, bool async, uint32_t seq, const void *data, size_t size, void *user_data)
|
||||
{
|
||||
struct state *this = user_data;
|
||||
int res;
|
||||
|
||||
res = spa_alsa_pause(this, false);
|
||||
|
||||
if (async) {
|
||||
spa_loop_invoke(this->main_loop,
|
||||
do_send_done,
|
||||
seq,
|
||||
&res,
|
||||
sizeof(res),
|
||||
false,
|
||||
this);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static int impl_node_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
{
|
||||
struct state *this;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(command != NULL, -EINVAL);
|
||||
|
|
@ -227,14 +181,11 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
|
|||
if (this->n_buffers == 0)
|
||||
return -EIO;
|
||||
|
||||
return spa_loop_invoke(this->data_loop, do_start, ++this->seq, NULL, 0, false, this);
|
||||
if ((res = spa_alsa_start(this, false)) < 0)
|
||||
return res;
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return -EIO;
|
||||
if (this->n_buffers == 0)
|
||||
return -EIO;
|
||||
|
||||
return spa_loop_invoke(this->data_loop, do_pause, ++this->seq, NULL, 0, false, this);
|
||||
if ((res = spa_alsa_pause(this, false)) < 0)
|
||||
return res;
|
||||
} else
|
||||
return -ENOTSUP;
|
||||
|
||||
|
|
@ -641,23 +592,8 @@ static int
|
|||
impl_node_port_send_command(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id, const struct spa_command *command)
|
||||
{
|
||||
struct state *this;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(node != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct state, node);
|
||||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), -EINVAL);
|
||||
|
||||
if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
res = spa_alsa_pause(this, false);
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Start) {
|
||||
res = spa_alsa_start(this, false);
|
||||
} else
|
||||
res = -ENOTSUP;
|
||||
|
||||
return res;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue