зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1754006 - Increase the processed media queue size and threshold in AudioSink. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D138028
This commit is contained in:
Родитель
001c77587c
Коммит
0630b647a3
|
@ -30,9 +30,6 @@ extern LazyLogModule gMediaDecoderLog;
|
|||
// The amount of audio frames that is used to fuzz rounding errors.
|
||||
static const int64_t AUDIO_FUZZ_FRAMES = 1;
|
||||
|
||||
// Amount of audio frames we will be processing ahead of use
|
||||
static const int32_t LOW_AUDIO_USECS = 300000;
|
||||
|
||||
using media::TimeUnit;
|
||||
|
||||
AudioSink::AudioSink(AbstractThread* aThread,
|
||||
|
@ -54,9 +51,11 @@ AudioSink::AudioSink(AbstractThread* aThread,
|
|||
StaticPrefs::dom_media_silence_duration_for_audibility()),
|
||||
mIsAudioDataAudible(false),
|
||||
mProcessedQueueFinished(false),
|
||||
mAudioQueue(aAudioQueue) {
|
||||
mAudioQueue(aAudioQueue),
|
||||
mProcessedQueueThresholdMS(
|
||||
StaticPrefs::media_audio_audiosink_threshold_ms()) {
|
||||
// Twice the limit that trigger a refill.
|
||||
float capacitySeconds = LOW_AUDIO_USECS / 1000. / 1000. * 2;
|
||||
float capacitySeconds = mProcessedQueueThresholdMS / 1000.f * 2;
|
||||
mProcessedSPSCQueue =
|
||||
MakeUnique<SPSCQueue<AudioDataValue>>(static_cast<uint32_t>(
|
||||
capacitySeconds * static_cast<float>(mOutputChannels * mOutputRate)));
|
||||
|
@ -268,10 +267,9 @@ void AudioSink::OnAudioPushed(const RefPtr<AudioData>& aSample) {
|
|||
NotifyAudioNeeded();
|
||||
}
|
||||
|
||||
uint32_t AudioSink::AudioQueuedInRingBufferUs() const {
|
||||
uint32_t AudioSink::AudioQueuedInRingBufferMS() const {
|
||||
return static_cast<uint32_t>(
|
||||
1000. * 1000 * SampleToFrame(mProcessedSPSCQueue->AvailableRead()) /
|
||||
mOutputRate);
|
||||
1000 * SampleToFrame(mProcessedSPSCQueue->AvailableRead()) / mOutputRate);
|
||||
}
|
||||
|
||||
uint32_t AudioSink::SampleToFrame(uint32_t aSamples) const {
|
||||
|
@ -283,7 +281,7 @@ void AudioSink::NotifyAudioNeeded() {
|
|||
"Not called from the owner's thread");
|
||||
|
||||
while (mAudioQueue.GetSize() &&
|
||||
AudioQueuedInRingBufferUs() < LOW_AUDIO_USECS) {
|
||||
AudioQueuedInRingBufferMS() < mProcessedQueueThresholdMS) {
|
||||
// Check if there's room in our ring buffer.
|
||||
if (mAudioQueue.PeekFront()->Frames() >
|
||||
SampleToFrame(mProcessedSPSCQueue->AvailableWrite())) {
|
||||
|
|
|
@ -129,7 +129,7 @@ class AudioSink : private AudioStream::DataSource {
|
|||
AlignedAudioBuffer&& aBuffer, AudioData* aReference);
|
||||
// Add data to the processsed queue return the number of frames added.
|
||||
uint32_t PushProcessedAudio(AudioData* aData);
|
||||
uint32_t AudioQueuedInRingBufferUs() const;
|
||||
uint32_t AudioQueuedInRingBufferMS() const;
|
||||
uint32_t SampleToFrame(uint32_t aSamples) const;
|
||||
UniquePtr<AudioConverter> mConverter;
|
||||
UniquePtr<SPSCQueue<AudioDataValue>> mProcessedSPSCQueue;
|
||||
|
@ -153,6 +153,7 @@ class AudioSink : private AudioStream::DataSource {
|
|||
|
||||
Atomic<bool> mProcessedQueueFinished;
|
||||
MediaQueue<AudioData>& mAudioQueue;
|
||||
const float mProcessedQueueThresholdMS;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -9517,6 +9517,14 @@
|
|||
value: 8
|
||||
mirror: always
|
||||
|
||||
# The duration, in milliseconds, of decoded audio to keep around in the
|
||||
# AudioSink ring-buffer. New decoding operations are started when this limit is
|
||||
# reached. The total size of the ring-buffer is slightly bigger than this.
|
||||
- name: media.audio.audiosink.threshold_ms
|
||||
type: AtomicFloat
|
||||
value: 1000.0
|
||||
mirror: always
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Prefs starting with "midi."
|
||||
|
|
Загрузка…
Ссылка в новой задаче