~aleteoryx/muditaos

e9de840a51149e8f352f9141ba1c7995cf8ed943 — Marcin Smoczyński 5 years ago ac9ab97
[EGD-5290] Fix on audio on voice call

Due to an error in the stream's block reservation, when the stream was
full, SAI was trying to read data to an unitialized data span randomly
disabling audio channel.

Fix the problem by overwriting data after the peek position, always
returning valid data span.

Signed-off-by: Marcin Smoczyński <smoczynski.marcin@gmail.com>
2 files changed, 10 insertions(+), 1 deletions(-)

M module-audio/Audio/Stream.cpp
M module-audio/Audio/test/unittest_stream.cpp
M module-audio/Audio/Stream.cpp => module-audio/Audio/Stream.cpp +9 -0
@@ 137,6 137,15 @@ bool Stream::reserve(Span &span)
        return true;
    }

    // reset data to peek end
    _blocksUsed = 0;
    _dataEnd    = _peekPosition;

    // reserve at peek end
    _reserveCount             = 1;
    _writeReservationPosition = _peekPosition;
    span                      = *++_writeReservationPosition;

    broadcastEvent(Event::StreamOverflow);
    return false;
}

M module-audio/Audio/test/unittest_stream.cpp => module-audio/Audio/test/unittest_stream.cpp +1 -1
@@ 203,7 203,7 @@ TEST(Stream, Reserve)
    EXPECT_FALSE(s.reserve(span));

    s.commit();
    EXPECT_EQ(s.getUsedBlockCount(), s.getBlockCount());
    EXPECT_EQ(s.getUsedBlockCount(), 1);
}

int main(int argc, char **argv)