stream: implement Flush

Flush out pending samples in the resampler
Set the io area status to _OK so that buffers are recycled and
new buffers produced.
This commit is contained in:
Wim Taymans 2020-11-17 17:15:26 +01:00
parent cd25a1e5e7
commit 79fb95bf90
8 changed files with 36 additions and 6 deletions

View file

@ -388,6 +388,7 @@ static int impl_send_command(void *object, const struct spa_command *command)
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Suspend:
case SPA_NODE_COMMAND_Flush:
case SPA_NODE_COMMAND_Pause:
pw_loop_invoke(impl->context->main_loop,
NULL, 0, NULL, 0, false, impl);
@ -1897,5 +1898,8 @@ int pw_stream_flush(struct pw_stream *stream, bool drain)
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
pw_loop_invoke(impl->context->data_loop,
drain ? do_drain : do_flush, 1, NULL, 0, true, impl);
if (!drain)
spa_node_send_command(impl->node->node,
&SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Flush));
return 0;
}