This will allow calling those functions properly from an internal thread, and
simplify lock management. This will happen in a subsequent patch.
The initial parameter passed to cubeb_stream_init are now stored on the
cubeb_stream struct to be able to reinitialized properly (again in a subsequent
patch).
Since all those calls need have a lock held, the lock is passed as argument to
ensure thread safety. This ensures the caller of the internal functions has
taken the lock, and at the same time allows not unlocking/relocking the mutex if
a series of call is performed (that will be the case in a subsequent patch,
during reinitialization).
The boolean that marks that a stream is in use is modified in the external
interface, called by the user. A stream is marked as being in use when the user
initialize it, and is marked as not being in use when the user destroys it.
- Converts cubeb_stream into a reference-counted object, and gets rid of
emergency_bailout logic
- When reconfiguring, only restart a stream if it was already started
- Removes timeout inside the render thread, as we can't guarantee events
while a stream is stopped
Subsequently rebased by Paul Adenot <padenot@mozilla.com>
https://bugzilla.mozilla.org/show_bug.cgi?id=1825328 landed in Firefox
without going through upstream. It's necessary to build in an
environment where gtests are all compiled in the same executable.
Original patch by serge-sans-paille <sguelton@mozilla.com>.
Based on examining crash dumps and investigating OpenSL workarounds in
liboboe, there is a potential race between active buffer callbacks and
stream shutdown, resulting in a buffer callback attempting to use a new
buffer after stream destroy has freed the backing allocation.
Ideally there would be a concrete event to watch for to ensure the
last callbacks have completed before destroying the stream, but I'm not
aware of one and the existing workaround in liboboe relies on an
arbitrary ("long enough") sleep between stopping and destroying streams.
A/V sync is now perfect regardless of the output device (bluetooth,
wired, speaker), and client side interpolation provides high accuracy
regardless of the buffer-size that the users decides on.