Because we're generally using high latency on the cubeb stream used by
AudioStream instance, it can take some time for the callbacks to start being
called, and the for the audio clock (cubeb_stream_get_position(...)) to advance.
This waits for the first callback to be called before using the clock of the
audio stream, and the system clock keeps being in use until then.
Differential Revision: https://phabricator.services.mozilla.com/D136235
We're going to shutdown the AudioStream in a subsequent patch, when audio is
muted. This will allow resolving it at the right time when the media ends while
muted.
This also extracts a method to start an AudioSink, because it's going to be
started in multiple locations in a future patch.
Differential Revision: https://phabricator.services.mozilla.com/D136233
The queue directly contains the audio frames, not packets. We'll be able to tune
its size later. `AudioSink::PopFrames` pull from the queue, and is called in the
audio callback. The decoded frame refill logic is adjusted to be simpler.
Signaling the event to refill still takes a lock, that's going to be fixed later.
Ended(), the second member of the interface, is switched to using an atomic.
After this patch, the audio callback doesn't need to take the AudioStream lock.
Differential Revision: https://phabricator.services.mozilla.com/D137303
This changes things so that the time stretcher is only ever touched on the
audio thread. Changes to the playback rate and preserves pitch attribute now
also go through an SPSC queue (but in the other direction).
Locking is made more granular, only around the audio queue now.
Differential Revision: https://phabricator.services.mozilla.com/D137182
This has two parts:
1. Getting the clock is wait-free in cubeb-coreaudio-rs, so we can remove the
lock. This is only on macOS, the lock is still taken on other platforms.
2. The frame history part now uses an SPSCQueue, that sends the callback history
information to the non-realtime thread, that lazily computes the clock the next
time the clock time is requested.
Differential Revision: https://phabricator.services.mozilla.com/D137180
Audio stream is the class which really know about whether the audio playback is completed or not. So it makes more sense to let it return and manage the promise for playback end, not audio sink.
Differential Revision: https://phabricator.services.mozilla.com/D96468
This converts `nsAutoPtr` usage in dom/media to `UniquePtr`. Beyond just a
search and replace we also needed to update assignment and access of the
`UniquePtr`s. This falls into a few categories:
- Assignment from a newly constructed object switches to `MakeUnique`
- Assignment from a raw ptr switches to `UniquePtr::reset`
- Handing out a raw ptr now requires `UniquePtr::get`
- Uses `UniquePtr::release` rather than `nsAutoPtr::forget`
- A few spots are updated to return a `UniquePtr` rather than a raw ptr
Differential Revision: https://phabricator.services.mozilla.com/D60084
--HG--
extra : moz-landing-system : lando
The coming updated libsoundtouch will use ST_THROW_RT_ERROR in several
places built without setting ST_NO_EXCEPTION_HANDLING.
ST_NO_EXCEPTION_HANDLING is only set in libsoundtouch/src/moz.build. To
avoid using `throw`, we should `#define` ST_NO_EXCEPTION_HANDLING before
`#include` soundtouch headers.
Differential Revision: https://phabricator.services.mozilla.com/D52932
--HG--
extra : moz-landing-system : lando
And we add some strong assertions that we never read passed the end of the buffer.
Differential Revision: https://phabricator.services.mozilla.com/D20162
--HG--
extra : moz-landing-system : lando
The VideoSink shares the AudioSink's own EndedPromise to notify its user that it has ended. As such, the MozPromise used must be non-exclusive.
Using the GenericPromise for such purpose only hid that requirement.
We also remove the MediaSink from the media namespace, and clarify the naming of some arguments and class members to accurately describe what they do.
Differential Revision: https://phabricator.services.mozilla.com/D14024
--HG--
extra : moz-landing-system : lando
Channel layout is derived by the content being played. The concept of preferred layout is meaningless. Either we have a layout defined, or we don't. There's no in-between.
So we remove it.
MozReview-Commit-ID: CSCAInNmzMS
AudioStream::DataCallback uses cubeb_get_backend_id to work around a bug in
libcubeb's winmm backend, but calling libcubeb APIs from within libcubeb
callbacks is not safe. Move the query to AudioStream::Init and check a simple
bool from within the callback instead.