bluez5: media-sink: keep one more buffer free

We delay the audio a bit to keep packet intervals equal, which keeps
some data in buffers.

In theory the calculation keeps one buffer free, but it doesn't
explicitly keep "extra" buffer space so in theory might flush too late
and next process() might not have free buffers.  However, as we encode
next packet right away this shouldn't really occur...

Try to keep one extra spare buffer free so that the flush time is
certainly early enough.
This commit is contained in:
Pauli Virtanen 2023-12-04 21:32:05 +02:00
parent 513495eaaa
commit 2335657343

View file

@ -53,7 +53,7 @@ struct props {
}; };
#define FILL_FRAMES 4 #define FILL_FRAMES 4
#define MIN_BUFFERS 2 #define MIN_BUFFERS 3
#define MAX_BUFFERS 32 #define MAX_BUFFERS 32
#define BUFFER_SIZE (8192*8) #define BUFFER_SIZE (8192*8)
#define RATE_CTL_DIFF_MAX 0.005 #define RATE_CTL_DIFF_MAX 0.005
@ -888,7 +888,7 @@ again:
*/ */
#if 1 #if 1
this->next_flush_time += SPA_MIN(packet_time, this->next_flush_time += SPA_MIN(packet_time,
duration_ns * (port->n_buffers - 1)); duration_ns * (SPA_MAX(port->n_buffers, 2u) - 2));
#endif #endif
} else { } else {
if (this->next_flush_time == 0) if (this->next_flush_time == 0)