Граф коммитов

496 Коммитов

Автор SHA1 Сообщение Дата
Marian-Vasile Laza 9902932742 Merge autoland to mozilla-central. a=merge 2022-05-25 00:42:50 +03:00
Paul Adenot 0a42587468 Bug 1743834 - Ensure AudioSink are shut down properly when dispatching fails, after they have been initialized. r=alwu
This patch handles this case:
https://searchfox.org/mozilla-central/rev/97c902e8f92b15dc63eb584bfc594ecb041242a4/xpcom/threads/TaskQueue.h#90-93

When the dispatch fails, we can't shutdown the AudioSink properly from the call
site after checking the return value because it's a UniquePtr transferred to the
closure, so we need to do it in the dtor.

Differential Revision: https://phabricator.services.mozilla.com/D146304
2022-05-24 13:09:12 +00:00
Paul Adenot c3ebcd4b77 Bug 1743834 - Handle the fact that it is possible to not have the ended promise on AudioSink shutdown, when muting. r=alwu
It can be resolved from the audio callback thread, which isn't synchronized with
the MDSM thread event loop.

Differential Revision: https://phabricator.services.mozilla.com/D146198
2022-05-24 13:09:11 +00:00
Paul Adenot 8d6098089e Bug 1743834 - Add logging in all branches of AudioSinkWrapper. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D146197
2022-05-24 13:09:11 +00:00
Paul Adenot b495101342 Bug 1743834 - Do not update variable that hold the media time if not playing in OnMuted. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D146196
2022-05-24 13:09:10 +00:00
Paul Adenot 50239a799b Bug 1743834 - Split AudioSink into its own log module. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D146195
2022-05-24 13:09:10 +00:00
Paul Adenot b5ae667a29 Bug 1743834 - Trigger the audibility event at the beginning of the initialization of an audio stream, when un-muting. r=alwu
The initialization itself can take some time and this audibility event is used
to prioritize the process, that will soon become audible, on at least Windows,
so it's better to get prioritized slightly ahead of time.

We should eventually untie audibility from priorities, but this hasn't happened
yet. Instead, we should make it so silent audio for an extended period of time
causes a shutdown of the cubeb stream, it's a lot more efficient.

Differential Revision: https://phabricator.services.mozilla.com/D145328
2022-05-24 13:09:10 +00:00
Paul Adenot 6612306c97 Bug 1743834 - After unmuting, re-initialize the AudioSink asynchronously. r=alwu
On Windows (in particular, but also not quick on other OS, depending on the
hardware being used), opening a system-level audio stream (using cubeb)
can be very long. It's a blocking call from the MDSM thread. The MDSM can't
query the clock and update video frames while the stream is being opened,
resulting in the video freezing.

On the other hand, we don't want the clock starting to increase while first
starting the media, it's better to block the MDSM in this case.

This patch changes `AudioSinkWrapper::StartAudioSink` to have two modes:
- A synchronous mode for the first opening (and therefore for seeking, etc.)
- An asynchronous mode to use when the stream is unmuted: the AudioSinkWrapper
will continue to use a clock based on the system clock, until the system-level
audio stream is effectively opened, at which point it will switch to using it
for the clock.

This new mode does the initialization on a background thread, but starts the
system-level audio stream from the MDSM thread (it's fast enough and simplifies
the code a lot).

The promises are created synchronously, because this is what the MDSM expects,
but they are rejected in case of failure.

Finally, an edge case is handled: if the stream is stopped while it's being
opened asynchronously. This is detected, and instead of starting the
system-level audio stream, the stream is shut down.

Differential Revision: https://phabricator.services.mozilla.com/D145000
2022-05-24 13:09:09 +00:00
Paul Adenot 8e14b4cc53 Bug 1743834 - Split initialization and start in AudioSinkWrapper. r=alwu
No change in functionality, this is to prepare for the next patch that will do
the initialization asynchronously because it's expensing and blocking.

Differential Revision: https://phabricator.services.mozilla.com/D144999
2022-05-24 13:09:09 +00:00
Paul Adenot 1f44d7e428 Bug 1743834 - When no packet are in the queue when shutting down the AudioStream, try our best to provide timing data. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D141992
2022-05-24 13:09:08 +00:00
Paul Adenot 0eebe8ba74 Bug 1743834 - Fix static-analysis warning. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D141991
2022-05-24 13:09:08 +00:00
Paul Adenot 880373650f Bug 1743834 - Don't start with an AudioSink if muted from the start. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D141990
2022-05-24 13:09:07 +00:00
Paul Adenot f390de1f06 Bug 1743834 - Correctly set the start time when the audio callbacks actually are called, the first time audio audio clock starts to be in use. r=alwu,media-playback-reviewers
The base clock for the new audio stream is precisely the time when the clock
source changes from the system clock to the audio clock, accounting for the time
it takes to actually starts the stream. This allows avoiding discontinuities
when switching clocks.

Differential Revision: https://phabricator.services.mozilla.com/D136237
2022-05-24 13:09:07 +00:00
Paul Adenot a6e5c1f4ff Bug 1743834 - Detect when switching clock provider in AudioSinkWrapper. r=alwu,media-playback-reviewers
This will allow detecting the first time the AudioSinkWrapper starts using the
clock from an audio stream after having been muted (=using the system clock) for
some time, to correct the timing.

Differential Revision: https://phabricator.services.mozilla.com/D136236
2022-05-24 13:09:06 +00:00
Paul Adenot f048891e77 Bug 1743834 - Wait for the audio callbacks to start being called before using the audio clock. r=alwu,media-playback-reviewers
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
2022-05-24 13:09:06 +00:00
Paul Adenot 024b4fe28b Bug 1743834 - Shut down the AudioSink when audio is muted. r=alwu,media-playback-reviewers
This does the following:
- When the media is muted, shut down and release the AudioSink ;
- While the media is muted, use the system clock to make video advance ;
- Each time the clock is queried, check if some audio packets should be
discarded because they are in the past, compared to the media time ;
- While muted, if the audio finished, resolve the EndedPromise ;
- When the media is un-muted, a new AudioSink is created, and its clock starts
to be in use.

This works well and A/V sync is correct, but a micro-stuttering is perceptible
on the video when looking carefully, because of the time it takes to open the
audio stream. This is fixed in subsequent patches.

Differential Revision: https://phabricator.services.mozilla.com/D136234
2022-05-24 13:09:06 +00:00
Paul Adenot 017bb613c7 Bug 1743834 - Create and manage the lifetime of the AudioStream EndedPromise in AudioSinkWrapper. r=alwu,media-playback-reviewers
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
2022-05-24 13:09:05 +00:00
Paul Adenot 5ac8c5f580 Bug 1743834 - Add a logging module for AudioSink. r=alwu,media-playback-reviewers
Depends on D133642

Differential Revision: https://phabricator.services.mozilla.com/D133643
2022-05-24 13:09:05 +00:00
Paul Adenot 8b1e4a744d Bug 1743834 - Make GetClock() non-const on MediaSink, and allow the AudioSink to modify the AudioQueue. r=alwu,media-playback-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D133642
2022-05-24 13:09:04 +00:00
Norisz Fay 3ab130ec64 Backed out 15 changesets (bug 1743834, bug 1765554) for causing bug 1768473
Backed out changeset 41d154330f7f (bug 1743834)
Backed out changeset f09bb9e00c17 (bug 1743834)
Backed out changeset 569b8d3a9fcd (bug 1743834)
Backed out changeset 9c37cd8faac3 (bug 1765554)
Backed out changeset 4c12bdcae40a (bug 1743834)
Backed out changeset 1155d1d6db79 (bug 1743834)
Backed out changeset ee700aa90a1b (bug 1743834)
Backed out changeset 150ecd10e53a (bug 1743834)
Backed out changeset 4076e2055960 (bug 1743834)
Backed out changeset 966ceb9947fa (bug 1743834)
Backed out changeset f604fe0f8d02 (bug 1743834)
Backed out changeset 61ec6368ddcd (bug 1743834)
Backed out changeset c0a1eaca1d90 (bug 1743834)
Backed out changeset 798e05478220 (bug 1743834)
Backed out changeset b92a638392da (bug 1743834)
2022-05-09 19:39:59 +03:00
Paul Adenot 8573aebfe4 Bug 1743834 - Trigger the audibility event at the beginning of the initialization of an audio stream, when un-muting. r=alwu
The initialization itself can take some time and this audibility event is used
to prioritize the process, that will soon become audible, on at least Windows,
so it's better to get prioritized slightly ahead of time.

We should eventually untie audibility from priorities, but this hasn't happened
yet. Instead, we should make it so silent audio for an extended period of time
causes a shutdown of the cubeb stream, it's a lot more efficient.

Differential Revision: https://phabricator.services.mozilla.com/D145328
2022-05-09 13:20:54 +00:00
Paul Adenot 6900b5e9d0 Bug 1743834 - After unmuting, re-initialize the AudioSink asynchronously. r=alwu
On Windows (in particular, but also not quick on other OS, depending on the
hardware being used), opening a system-level audio stream (using cubeb)
can be very long. It's a blocking call from the MDSM thread. The MDSM can't
query the clock and update video frames while the stream is being opened,
resulting in the video freezing.

On the other hand, we don't want the clock starting to increase while first
starting the media, it's better to block the MDSM in this case.

This patch changes `AudioSinkWrapper::StartAudioSink` to have two modes:
- A synchronous mode for the first opening (and therefore for seeking, etc.)
- An asynchronous mode to use when the stream is unmuted: the AudioSinkWrapper
will continue to use a clock based on the system clock, until the system-level
audio stream is effectively opened, at which point it will switch to using it
for the clock.

This new mode does the initialization on a background thread, but starts the
system-level audio stream from the MDSM thread (it's fast enough and simplifies
the code a lot).

The promises are created synchronously, because this is what the MDSM expects,
but they are rejected in case of failure.

Finally, an edge case is handled: if the stream is stopped while it's being
opened asynchronously. This is detected, and instead of starting the
system-level audio stream, the stream is shut down.

Differential Revision: https://phabricator.services.mozilla.com/D145000
2022-05-09 13:20:54 +00:00
Paul Adenot e2faa2f92c Bug 1743834 - Split initialization and start in AudioSinkWrapper. r=alwu
No change in functionality, this is to prepare for the next patch that will do
the initialization asynchronously because it's expensing and blocking.

Differential Revision: https://phabricator.services.mozilla.com/D144999
2022-05-09 13:20:53 +00:00
Paul Adenot db8b7abf47 Bug 1743834 - When no packet are in the queue when shutting down the AudioStream, try our best to provide timing data. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D141992
2022-05-09 13:20:52 +00:00
Paul Adenot 9840a23c31 Bug 1743834 - Fix static-analysis warning. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D141991
2022-05-09 13:20:51 +00:00
Paul Adenot f8ef45ed87 Bug 1743834 - Don't start with an AudioSink if muted from the start. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D141990
2022-05-09 13:20:51 +00:00
Paul Adenot 68188c63fa Bug 1743834 - Correctly set the start time when the audio callbacks actually are called, the first time audio audio clock starts to be in use. r=alwu,media-playback-reviewers
The base clock for the new audio stream is precisely the time when the clock
source changes from the system clock to the audio clock, accounting for the time
it takes to actually starts the stream. This allows avoiding discontinuities
when switching clocks.

Differential Revision: https://phabricator.services.mozilla.com/D136237
2022-05-09 13:20:51 +00:00
Paul Adenot 8a10c3c36c Bug 1743834 - Detect when switching clock provider in AudioSinkWrapper. r=alwu,media-playback-reviewers
This will allow detecting the first time the AudioSinkWrapper starts using the
clock from an audio stream after having been muted (=using the system clock) for
some time, to correct the timing.

Differential Revision: https://phabricator.services.mozilla.com/D136236
2022-05-09 13:20:50 +00:00
Paul Adenot b42e188e30 Bug 1743834 - Wait for the audio callbacks to start being called before using the audio clock. r=alwu,media-playback-reviewers
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
2022-05-09 13:20:50 +00:00
Paul Adenot 7bf06a2b04 Bug 1743834 - Shut down the AudioSink when audio is muted. r=alwu,media-playback-reviewers
This does the following:
- When the media is muted, shut down and release the AudioSink ;
- While the media is muted, use the system clock to make video advance ;
- Each time the clock is queried, check if some audio packets should be
discarded because they are in the past, compared to the media time ;
- While muted, if the audio finished, resolve the EndedPromise ;
- When the media is un-muted, a new AudioSink is created, and its clock starts
to be in use.

This works well and A/V sync is correct, but a micro-stuttering is perceptible
on the video when looking carefully, because of the time it takes to open the
audio stream. This is fixed in subsequent patches.

Differential Revision: https://phabricator.services.mozilla.com/D136234
2022-05-09 13:20:50 +00:00
Paul Adenot 0795585040 Bug 1743834 - Create and manage the lifetime of the AudioStream EndedPromise in AudioSinkWrapper. r=alwu,media-playback-reviewers
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
2022-05-09 13:20:49 +00:00
Paul Adenot 7b56cea329 Bug 1743834 - Add a logging module for AudioSink. r=alwu,media-playback-reviewers
Depends on D133642

Differential Revision: https://phabricator.services.mozilla.com/D133643
2022-05-09 13:20:49 +00:00
Paul Adenot 8709902435 Bug 1743834 - Make GetClock() non-const on MediaSink, and allow the AudioSink to modify the AudioQueue. r=alwu,media-playback-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D133642
2022-05-09 13:20:48 +00:00
Cristian Tuns 8cf35d7033 Backed out 12 changesets (bug 1743834, bug 1765554) for causing reftest failures CLOSED TREE
Backed out changeset e4045f9906cf (bug 1765554)
Backed out changeset e2e3a95faccd (bug 1743834)
Backed out changeset 06a4c7ba1807 (bug 1743834)
Backed out changeset 322ac397ad9c (bug 1743834)
Backed out changeset f1aaa967ed6d (bug 1743834)
Backed out changeset 3728fcbd5753 (bug 1743834)
Backed out changeset 4d427e0ca400 (bug 1743834)
Backed out changeset 3000680ad5f4 (bug 1743834)
Backed out changeset 048e93d0a274 (bug 1743834)
Backed out changeset 32210507c793 (bug 1743834)
Backed out changeset b15369c023af (bug 1743834)
Backed out changeset b03a509cbe7e (bug 1743834)
2022-04-20 13:30:30 -04:00
Paul Adenot d52cb6068e Bug 1743834 - When no packet are in the queue when shutting down the AudioStream, try our best to provide timing data. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D141992
2022-04-20 12:07:11 +00:00
Paul Adenot 5249ed3026 Bug 1743834 - Fix static-analysis warning. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D141991
2022-04-20 12:07:11 +00:00
Paul Adenot 4ee13d5c53 Bug 1743834 - Don't start with an AudioSink if muted from the start. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D141990
2022-04-20 12:07:11 +00:00
Paul Adenot 3e3fffb168 Bug 1743834 - Correctly set the start time when the audio callbacks actually are called, the first time audio audio clock starts to be in use. r=alwu,media-playback-reviewers
The base clock for the new audio stream is precisely the time when the clock
source changes from the system clock to the audio clock, accounting for the time
it takes to actually starts the stream. This allows avoiding discontinuities
when switching clocks.

Differential Revision: https://phabricator.services.mozilla.com/D136237
2022-04-20 12:07:10 +00:00
Paul Adenot abe34cfe43 Bug 1743834 - Detect when switching clock provider in AudioSinkWrapper. r=alwu,media-playback-reviewers
This will allow detecting the first time the AudioSinkWrapper starts using the
clock from an audio stream after having been muted (=using the system clock) for
some time, to correct the timing.

Differential Revision: https://phabricator.services.mozilla.com/D136236
2022-04-20 12:07:10 +00:00
Paul Adenot 92868004aa Bug 1743834 - Wait for the audio callbacks to start being called before using the audio clock. r=alwu,media-playback-reviewers
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
2022-04-20 12:07:10 +00:00
Paul Adenot 5112586411 Bug 1743834 - Shut down the AudioSink when audio is muted. r=alwu,media-playback-reviewers
This does the following:
- When the media is muted, shut down and release the AudioSink ;
- While the media is muted, use the system clock to make video advance ;
- Each time the clock is queried, check if some audio packets should be
discarded because they are in the past, compared to the media time ;
- While muted, if the audio finished, resolve the EndedPromise ;
- When the media is un-muted, a new AudioSink is created, and its clock starts
to be in use.

This works well and A/V sync is correct, but a micro-stuttering is perceptible
on the video when looking carefully, because of the time it takes to open the
audio stream. This is fixed in subsequent patches.

Differential Revision: https://phabricator.services.mozilla.com/D136234
2022-04-20 12:07:09 +00:00
Paul Adenot c06f4b14cf Bug 1743834 - Create and manage the lifetime of the AudioStream EndedPromise in AudioSinkWrapper. r=alwu,media-playback-reviewers
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
2022-04-20 12:07:09 +00:00
Paul Adenot 2ca6ca1b09 Bug 1743834 - Add a logging module for AudioSink. r=alwu,media-playback-reviewers
Depends on D133642

Differential Revision: https://phabricator.services.mozilla.com/D133643
2022-04-20 12:07:08 +00:00
Paul Adenot 2c96668e6e Bug 1743834 - Make GetClock() non-const on MediaSink, and allow the AudioSink to modify the AudioQueue. r=alwu,media-playback-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D133642
2022-04-20 12:07:08 +00:00
Jeff Muizelaar 44e031f1b3 Bug 1762455 - Redo VideoSink dropped frame profiler marker. r=alwu
This gives it an elaborated name and includes the current clock time.

Differential Revision: https://phabricator.services.mozilla.com/D142595
2022-04-01 00:29:08 +00:00
Randell Jesup b7a9cfb40a Bug 1747178: dom/media Audio thread-safety cleanup r=padenot
Differential Revision: https://phabricator.services.mozilla.com/D134469
2022-03-30 18:04:32 +00:00
Paul Adenot 50a93923a0 Bug 1759325 - Only drain the converter at the end of the queue. r=alwu
Before this change, the converter would be drained after each packet would be
pushed to the queue, introducing discontinuities in the audio, at the end, after
all the decoding operations were finished, but before all the audio packets were
pushed to the queue.

This went unnoticed because there is no converter most of the time, with audio
that has a sample-rate higher or equal to the common 44100Hz value.

Depends on D141356

Differential Revision: https://phabricator.services.mozilla.com/D141357
2022-03-22 11:43:45 +00:00
Paul Adenot 6ce58a96c5 Bug 1759325 - Use PushProcessedAudio in DrainConverter instead of having almost the same code written twice. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D141356
2022-03-22 11:43:45 +00:00
Lee Salzman 6f0be8c19f Bug 1757067 - Explicitly specify chroma subsampling scheme for YCbCr data. r=jgilbert,jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D139656
2022-03-10 09:24:15 +00:00
smolnar 97f77f8381 Backed out changeset 36c6350bc7d1 (bug 1757067) for causing build bustages in gfx/gl/GLBlitHelperD3D.cpp CLOSED TREE 2022-03-10 10:10:10 +02:00