stream: clear buffer when format is cleared

Setting the format to NULL should clear the buffers.
This commit is contained in:
Wim Taymans 2020-03-02 16:27:18 +01:00
parent 6b06341b14
commit 4c2954b7a9
2 changed files with 77 additions and 74 deletions

View file

@ -518,49 +518,6 @@ static int update_params(struct filter *impl, struct port *port, uint32_t id,
return res;
}
static int port_set_param(struct filter *impl, struct port *port,
uint32_t id, uint32_t flags, const struct spa_pod *param)
{
struct pw_filter *filter = &impl->this;
int res;
pw_log_debug(NAME" %p: param changed: %p %d", impl, param, impl->disconnecting);
if (param && pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
spa_debug_pod(2, NULL, param);
if ((res = update_params(impl, port, id, &param, param ? 1 : 0)) < 0)
return res;
pw_filter_emit_param_changed(filter, port->user_data, id, param);
if (filter->state == PW_FILTER_STATE_ERROR)
return -EIO;
if (port)
emit_port_info(impl, port, false);
else
emit_node_info(impl, false);
return res;
}
static int impl_port_set_param(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
struct filter *impl = object;
struct port *port;
if (impl->disconnecting)
return param == NULL ? 0 : -EIO;
if ((port = get_port(impl, direction, port_id)) == NULL)
return -EINVAL;
return port_set_param(impl, port, id, flags, param);
}
static int map_data(struct filter *impl, struct spa_data *data, int prot)
{
void *ptr;
@ -626,6 +583,46 @@ static void clear_buffers(struct port *port)
clear_queue(port, &port->queued);
}
static int impl_port_set_param(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
struct filter *impl = object;
struct pw_filter *filter = &impl->this;
struct port *port;
int res;
if (impl->disconnecting)
return param == NULL ? 0 : -EIO;
pw_log_debug(NAME" %p: param changed: %p %d", impl, param, impl->disconnecting);
if ((port = get_port(impl, direction, port_id)) == NULL)
return -EINVAL;
if (param && pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
spa_debug_pod(2, NULL, param);
if ((res = update_params(impl, port, id, &param, param ? 1 : 0)) < 0)
return res;
if (id == SPA_PARAM_Format && param == NULL)
clear_buffers(port);
pw_filter_emit_param_changed(filter, port->user_data, id, param);
if (filter->state == PW_FILTER_STATE_ERROR)
return -EIO;
if (port)
emit_port_info(impl, port, false);
else
emit_node_info(impl, false);
return res;
}
static int impl_port_use_buffers(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t flags,

View file

@ -343,7 +343,8 @@ static int impl_set_io(void *object, uint32_t id, void *data, size_t size)
struct stream *impl = object;
struct pw_stream *stream = &impl->this;
pw_log_debug(NAME" %p: io %d %p/%zd", impl, id, data, size);
pw_log_debug(NAME" %p: set io id %d (%s) %p %zd", impl, id,
spa_debug_type_find_name(spa_type_io, id), data, size);
switch(id) {
case SPA_IO_Position:
@ -455,7 +456,7 @@ static int impl_port_set_io(void *object, enum spa_direction direction, uint32_t
{
struct stream *impl = object;
pw_log_debug(NAME" %p: set io %s %p %zd", impl,
pw_log_debug(NAME" %p: set io id %d (%s) %p %zd", impl, id,
spa_debug_type_find_name(spa_type_io, id), data, size);
switch (id) {
@ -516,35 +517,6 @@ static int impl_port_enum_params(void *object, int seq,
return 0;
}
static int impl_port_set_param(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
struct stream *impl = object;
struct pw_stream *stream = &impl->this;
int res;
if (impl->disconnecting)
return param == NULL ? 0 : -EIO;
pw_log_debug(NAME" %p: param changed: %p %d", impl, param, impl->disconnecting);
if (param && pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
spa_debug_pod(2, NULL, param);
if ((res = update_params(impl, id, &param, param ? 1 : 0)) < 0)
return res;
pw_stream_emit_param_changed(stream, id, param);
if (stream->state == PW_STREAM_STATE_ERROR)
return -EIO;
emit_port_info(impl, false);
return 0;
}
static int map_data(struct stream *impl, struct spa_data *data, int prot)
{
void *ptr;
@ -611,6 +583,40 @@ static void clear_buffers(struct pw_stream *stream)
clear_queue(impl, &impl->queued);
}
static int impl_port_set_param(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
struct stream *impl = object;
struct pw_stream *stream = &impl->this;
int res;
if (impl->disconnecting)
return param == NULL ? 0 : -EIO;
pw_log_debug(NAME" %p: param id %d (%s) changed: %p", impl, id,
spa_debug_type_find_name(spa_type_param, id), param);
if (param && pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG))
spa_debug_pod(2, NULL, param);
if ((res = update_params(impl, id, &param, param ? 1 : 0)) < 0)
return res;
if (id == SPA_PARAM_Format && param == NULL)
clear_buffers(stream);
pw_stream_emit_param_changed(stream, id, param);
if (stream->state == PW_STREAM_STATE_ERROR)
return -EIO;
emit_port_info(impl, false);
return 0;
}
static int impl_port_use_buffers(void *object,
enum spa_direction direction, uint32_t port_id,
uint32_t flags,