Bug 1890689 Change AudioRingBuffer::SetLengthBytes() to EnsureLengthBytes() r=pehrsons
commit6f843408fd241a0ad966009ef64dda249fb3c5e5
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 18 Apr 2024 02:24:04 +0000 (18 02:24 +0000)
committerKarl Tomlinson <karlt+@karlt.net>
Thu, 18 Apr 2024 02:24:04 +0000 (18 02:24 +0000)
treefef397a7ab1e57bccade67f346a60aedccbfc76e
parent9a1ff716234dab3c93c00354ad3d2a60467ec8bd
Bug 1890689 Change AudioRingBuffer::SetLengthBytes() to EnsureLengthBytes() r=pehrsons

This now provides reasonable behavior if shorter lengths should be passed.
SetLengthBytes() did not move buffered data to within a shorter new length and
would not update mWriteIndexhandle.  TestAudioRingBuffer.EnsureLengthShorter
would crash with

Assertion failure:
aStart <= len && (aLength == dynamic_extent || (aStart + aLength <= len)),
at obj/dist/include/mozilla/Span.h:660

SetLengthBytes() was called with shorter lengths only on memory allocation
failure.  This was not necessary.

The warning is adjusted to indicate the size of the allocation attempted.

Depends on D207659

Differential Revision: https://phabricator.services.mozilla.com/D207660
dom/media/AudioRingBuffer.cpp
dom/media/AudioRingBuffer.h
dom/media/driftcontrol/DynamicResampler.h
dom/media/gtest/TestAudioRingBuffer.cpp