a2dp-sink: don't accept more data when we need to flush

See #449
This commit is contained in:
Wim Taymans 2020-12-06 15:55:38 +01:00
parent d2ff341263
commit 6566f52a7e

View file

@ -353,6 +353,11 @@ static int send_buffer(struct impl *this)
return written; return written;
} }
static bool need_flush(struct impl *this)
{
return (this->frame_count + 1 >= this->num_blocks);
}
static int encode_buffer(struct impl *this, const void *data, uint32_t size) static int encode_buffer(struct impl *this, const void *data, uint32_t size)
{ {
int processed; int processed;
@ -365,6 +370,9 @@ static int encode_buffer(struct impl *this, const void *data, uint32_t size)
this, size, this->buffer_used, port->frame_size, this->block_size, this, size, this->buffer_used, port->frame_size, this->block_size,
this->frame_count); this->frame_count);
if (need_flush(this))
return 0;
if (this->buffer_used >= sizeof(this->buffer)) if (this->buffer_used >= sizeof(this->buffer))
return -ENOSPC; return -ENOSPC;
@ -401,11 +409,6 @@ static int encode_buffer(struct impl *this, const void *data, uint32_t size)
return processed; return processed;
} }
static bool need_flush(struct impl *this)
{
return (this->frame_count + 1 >= this->num_blocks);
}
static int flush_buffer(struct impl *this, bool force) static int flush_buffer(struct impl *this, bool force)
{ {
spa_log_trace(this->log, NAME" %p: used:%d num_blocks:%d block_size%d", this, spa_log_trace(this->log, NAME" %p: used:%d num_blocks:%d block_size%d", this,