stream: only unmap data that was mapped and mappable.

This commit is contained in:
Wim Taymans 2024-04-01 16:28:43 +02:00
parent 0b42ec714d
commit 45984fef77
2 changed files with 14 additions and 7 deletions

View file

@ -780,12 +780,15 @@ static void clear_buffers(struct port *port)
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_MAPPED)) {
for (j = 0; j < b->this.buffer->n_datas; j++) {
struct spa_data *d = &b->this.buffer->datas[j];
if (SPA_FLAG_IS_SET(d->flags, SPA_DATA_FLAG_MAPPABLE) ||
(mappable_dataTypes & (1<<d->type)) > 0) {
pw_log_debug("%p: clear buffer %d mem",
impl, b->id);
unmap_data(impl, d);
}
}
}
}
port->n_buffers = 0;
clear_queue(port, &port->dequeued);
clear_queue(port, &port->queued);
@ -945,7 +948,8 @@ static int impl_port_use_buffers(void *object,
if (SPA_FLAG_IS_SET(impl_flags, PW_FILTER_PORT_FLAG_MAP_BUFFERS)) {
for (j = 0; j < buffers[i]->n_datas; j++) {
struct spa_data *d = &buffers[i]->datas[j];
if ((mappable_dataTypes & (1<<d->type)) > 0) {
if (SPA_FLAG_IS_SET(d->flags, SPA_DATA_FLAG_MAPPABLE) ||
(mappable_dataTypes & (1<<d->type)) > 0) {
if ((res = map_data(impl, d, prot)) < 0)
return res;
SPA_FLAG_SET(b->flags, BUFFER_FLAG_MAPPED);

View file

@ -865,12 +865,15 @@ static void clear_buffers(struct pw_stream *stream)
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_MAPPED)) {
for (j = 0; j < b->this.buffer->n_datas; j++) {
struct spa_data *d = &b->this.buffer->datas[j];
if (SPA_FLAG_IS_SET(d->flags, SPA_DATA_FLAG_MAPPABLE) ||
(mappable_dataTypes & (1<<d->type)) > 0) {
pw_log_debug("%p: clear buffer %d mem",
stream, b->id);
unmap_data(impl, d);
}
}
}
}
impl->n_buffers = 0;
if (impl->direction == SPA_DIRECTION_INPUT) {
struct buffer *b;