mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
bluez5: a2dp-sink: Fail flush on EAGAIN instead of delaying it
If we get an EAGAIN, the device has started lagging in processing its packets. We should not try to stuff the same packet in again, because the device will just lag more. Instead, just drop current data, and hope bitpool reduction takes care of it. Also increase bitpool only if the socket buffer is empty.
This commit is contained in:
parent
734470f0cd
commit
f6a83a91e0
1 changed files with 17 additions and 5 deletions
|
|
@ -650,16 +650,25 @@ again:
|
|||
}
|
||||
|
||||
written = flush_buffer(this);
|
||||
|
||||
if (written == -EAGAIN) {
|
||||
spa_log_trace(this->log, "%p: delay flush", this);
|
||||
spa_log_trace(this->log, "%p: fail flush", this);
|
||||
if (now_time - this->last_error > SPA_NSEC_PER_SEC / 2) {
|
||||
spa_log_trace(this->log, "%p: reduce bitpool", this);
|
||||
this->codec->reduce_bitpool(this->codec_data);
|
||||
this->last_error = now_time;
|
||||
}
|
||||
this->need_flush = true;
|
||||
enable_flush(this, true);
|
||||
|
||||
/*
|
||||
* The socket buffer is full, and the device is not processing data
|
||||
* fast enough, so should just skip this packet. There will be a sound
|
||||
* glitch in any case.
|
||||
*/
|
||||
written = this->buffer_used;
|
||||
reset_buffer(this);
|
||||
}
|
||||
else if (written < 0) {
|
||||
|
||||
if (written < 0) {
|
||||
spa_log_trace(this->log, "%p: error flushing %s", this,
|
||||
spa_strerror(written));
|
||||
reset_buffer(this);
|
||||
|
|
@ -669,7 +678,10 @@ again:
|
|||
else if (written > 0) {
|
||||
reset_buffer(this);
|
||||
if (now_time - this->last_error > SPA_NSEC_PER_SEC) {
|
||||
this->codec->increase_bitpool(this->codec_data);
|
||||
if (get_transport_unused_size(this) == (int)this->fd_buffer_size) {
|
||||
spa_log_trace(this->log, "%p: increase bitpool", this);
|
||||
this->codec->increase_bitpool(this->codec_data);
|
||||
}
|
||||
this->last_error = now_time;
|
||||
}
|
||||
if (!spa_list_is_empty(&port->ready))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue