зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1754006 - Add profiler markers in push/pop operations on the AudioSink ring buffer. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D138048
This commit is contained in:
Родитель
7a98b07c0b
Коммит
b679353753
|
@ -16,6 +16,7 @@
|
||||||
#include "mozilla/StaticPrefs_media.h"
|
#include "mozilla/StaticPrefs_media.h"
|
||||||
#include "mozilla/StaticPrefs_dom.h"
|
#include "mozilla/StaticPrefs_dom.h"
|
||||||
#include "nsPrintfCString.h"
|
#include "nsPrintfCString.h"
|
||||||
|
#include "Tracing.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
@ -215,6 +216,11 @@ uint32_t AudioSink::PopFrames(AudioDataValue* aBuffer, uint32_t aFrames,
|
||||||
if (aAudioThreadChanged) {
|
if (aAudioThreadChanged) {
|
||||||
mProcessedSPSCQueue->ResetThreadIds();
|
mProcessedSPSCQueue->ResetThreadIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACE_COMMENT("AudioSink::PopFrames", "%u frames (ringbuffer: %u/%u)",
|
||||||
|
aFrames, SampleToFrame(mProcessedSPSCQueue->AvailableRead()),
|
||||||
|
SampleToFrame(mProcessedSPSCQueue->Capacity()));
|
||||||
|
|
||||||
const int samplesToPop = static_cast<int>(aFrames * mOutputChannels);
|
const int samplesToPop = static_cast<int>(aFrames * mOutputChannels);
|
||||||
const int samplesRead = mProcessedSPSCQueue->Dequeue(aBuffer, samplesToPop);
|
const int samplesRead = mProcessedSPSCQueue->Dequeue(aBuffer, samplesToPop);
|
||||||
MOZ_ASSERT(samplesRead % mOutputChannels == 0);
|
MOZ_ASSERT(samplesRead % mOutputChannels == 0);
|
||||||
|
@ -224,6 +230,8 @@ uint32_t AudioSink::PopFrames(AudioDataValue* aBuffer, uint32_t aFrames,
|
||||||
SINK_LOG("Last PopFrames -- Source ended.");
|
SINK_LOG("Last PopFrames -- Source ended.");
|
||||||
} else {
|
} else {
|
||||||
NS_WARNING("Underrun when popping samples from audiosink ring buffer.");
|
NS_WARNING("Underrun when popping samples from audiosink ring buffer.");
|
||||||
|
TRACE_COMMENT("AudioSink::PopFrames", "Underrun %u frames missing",
|
||||||
|
SampleToFrame(samplesToPop - samplesRead));
|
||||||
}
|
}
|
||||||
// silence the rest
|
// silence the rest
|
||||||
PodZero(aBuffer + samplesRead, samplesToPop - samplesRead);
|
PodZero(aBuffer + samplesRead, samplesToPop - samplesRead);
|
||||||
|
@ -390,6 +398,7 @@ void AudioSink::NotifyAudioNeeded() {
|
||||||
} else {
|
} else {
|
||||||
silenceData = CreateAudioFromBuffer(std::move(silenceBuffer), data);
|
silenceData = CreateAudioFromBuffer(std::move(silenceBuffer), data);
|
||||||
}
|
}
|
||||||
|
TRACE("Pushing silence");
|
||||||
PushProcessedAudio(silenceData);
|
PushProcessedAudio(silenceData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,6 +428,10 @@ uint32_t AudioSink::PushProcessedAudio(AudioData* aData) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int framesToEnqueue = static_cast<int>(aData->Frames() * aData->mChannels);
|
int framesToEnqueue = static_cast<int>(aData->Frames() * aData->mChannels);
|
||||||
|
TRACE_COMMENT("AudioSink::PushProcessedAudio", "%u frames (%u/%u)",
|
||||||
|
framesToEnqueue,
|
||||||
|
SampleToFrame(mProcessedSPSCQueue->AvailableWrite()),
|
||||||
|
SampleToFrame(mProcessedSPSCQueue->Capacity()));
|
||||||
DebugOnly<int> rv =
|
DebugOnly<int> rv =
|
||||||
mProcessedSPSCQueue->Enqueue(aData->Data().Elements(), framesToEnqueue);
|
mProcessedSPSCQueue->Enqueue(aData->Data().Elements(), framesToEnqueue);
|
||||||
NS_WARNING_ASSERTION(
|
NS_WARNING_ASSERTION(
|
||||||
|
|
Загрузка…
Ссылка в новой задаче