Bug 1324545 - Implement AudioContext getOutputTimestamp(). r=baku

Differential Revision: https://phabricator.services.mozilla.com/D37281

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Paul Adenot 2019-07-12 11:27:25 +00:00
Родитель 8c692f2f23
Коммит 553f80fde6
5 изменённых файлов: 32 добавлений и 9 удалений

Просмотреть файл

@ -36,6 +36,7 @@
#include "mozilla/dom/OscillatorNodeBinding.h"
#include "mozilla/dom/PannerNodeBinding.h"
#include "mozilla/dom/PeriodicWaveBinding.h"
#include "mozilla/dom/Performance.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/StereoPannerNodeBinding.h"
#include "mozilla/dom/WaveShaperNodeBinding.h"
@ -525,6 +526,28 @@ AudioListener* AudioContext::Listener() {
double AudioContext::OutputLatency() { return Graph()->AudioOutputLatency(); }
void AudioContext::GetOutputTimestamp(AudioTimestamp& aTimeStamp) {
if (!Destination()) {
aTimeStamp.mContextTime.Construct(0.0);
aTimeStamp.mPerformanceTime.Construct(0.0);
return;
}
// The currentTime currently being output is the currentTime minus the audio
// output latency.
aTimeStamp.mContextTime.Construct(
std::max(0.0, CurrentTime() - OutputLatency()));
nsPIDOMWindowInner* parent = GetParentObject();
Performance* perf = parent ? parent->GetPerformance() : nullptr;
if (perf) {
// Convert to milliseconds.
aTimeStamp.mPerformanceTime.Construct(
std::max(0., perf->Now() - (OutputLatency() * 1000.)));
} else {
aTimeStamp.mPerformanceTime.Construct(0.0);
}
}
Worklet* AudioContext::GetAudioWorklet(ErrorResult& aRv) {
if (!mWorklet) {
mWorklet = AudioWorkletImpl::CreateWorklet(this, aRv);

Просмотреть файл

@ -9,6 +9,7 @@
#include "AudioParamDescriptorMap.h"
#include "mozilla/dom/OfflineAudioContextBinding.h"
#include "mozilla/dom/AudioContextBinding.h"
#include "MediaBufferDecoder.h"
#include "mozilla/Attributes.h"
#include "mozilla/DOMEventTargetHelper.h"
@ -200,6 +201,8 @@ class AudioContext final : public DOMEventTargetHelper,
double OutputLatency();
void GetOutputTimestamp(AudioTimestamp& aTimeStamp);
Worklet* GetAudioWorklet(ErrorResult& aRv);
bool IsRunning() const;

Просмотреть файл

@ -14,13 +14,18 @@ dictionary AudioContextOptions {
float sampleRate = 0;
};
dictionary AudioTimestamp {
double contextTime;
DOMHighResTimeStamp performanceTime;
};
[Pref="dom.webaudio.enabled",
Constructor(optional AudioContextOptions contextOptions = {})]
interface AudioContext : BaseAudioContext {
// Bug 1324545: AudioTimestamp getOutputTimestamp ();
readonly attribute double baseLatency;
readonly attribute double outputLatency;
AudioTimestamp getOutputTimestamp();
[Throws]
Promise<void> suspend();

Просмотреть файл

@ -20,9 +20,6 @@
[AudioParam interface: calling cancelAndHoldAtTime(double) on new AudioBufferSourceNode(context).playbackRate with too few arguments must throw TypeError]
expected: FAIL
[AudioContext interface: context must inherit property "getOutputTimestamp()" with the proper type]
expected: FAIL
[AudioListener interface: context.listener must inherit property "forwardX" with the proper type]
expected: FAIL
@ -44,9 +41,6 @@
[MediaElementAudioSourceNode interface: new MediaElementAudioSourceNode(context, {mediaElement: new Audio}) must inherit property "mediaElement" with the proper type]
expected: FAIL
[AudioContext interface: operation getOutputTimestamp()]
expected: FAIL
[Stringification of new AudioProcessingEvent('', {\n playbackTime: 0, inputBuffer: buffer, outputBuffer: buffer\n })]
expected: FAIL

Просмотреть файл

@ -1,2 +0,0 @@
[audiocontext-getoutputtimestamp.html]
expected: ERROR