Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26760d1a authored by Phil Burk's avatar Phil Burk
Browse files

AudioTrackShared: fix min buffer size



Fast Tracks can have very low buffer sizes.

Bug: 27765661
Bug: 27765632
Change-Id: I70262b2a0136aea3c0936aec85f15b0fc78d168f
Signed-off-by: default avatarPhil Burk <philburk@google.com>
parent 02c4f1c0
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -88,13 +88,14 @@ const struct timespec ClientProxy::kNonBlocking = {0 /*tv_sec*/, 0 /*tv_nsec*/};

uint32_t ClientProxy::setBufferSizeInFrames(uint32_t size)
{
    // TODO set minimum to 2X the fast mixer buffer size.
    // The minimum should be  greater than zero and less than the size
    // at which underruns will occur.
    const uint32_t minimum = 128 * 2; // arbitrary
    const uint32_t minimum = 16; // based on AudioMixer::BLOCKSIZE
    const uint32_t maximum = frameCount();
    uint32_t clippedSize = size;
    if (clippedSize < minimum) {
    if (maximum < minimum) {
        clippedSize = maximum;
    } else if (clippedSize < minimum) {
        clippedSize = minimum;
    } else if (clippedSize > maximum) {
        clippedSize = maximum;