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

Commit 5a898236 authored by Phil Burk's avatar Phil Burk Committed by Android (Google) Code Review
Browse files

Merge "AudioTrackShared: fix min buffer size" into nyc-dev

parents 7b5795dc 26760d1a
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line 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)
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
    // The minimum should be  greater than zero and less than the size
    // at which underruns will occur.
    // 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();
    const uint32_t maximum = frameCount();
    uint32_t clippedSize = size;
    uint32_t clippedSize = size;
    if (clippedSize < minimum) {
    if (maximum < minimum) {
        clippedSize = maximum;
    } else if (clippedSize < minimum) {
        clippedSize = minimum;
        clippedSize = minimum;
    } else if (clippedSize > maximum) {
    } else if (clippedSize > maximum) {
        clippedSize = maximum;
        clippedSize = maximum;