mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
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:
parent
4c99611f32
commit
e66a2c4316
@ -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();
|
||||
|
@ -17,9 +17,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
|
||||
|
||||
@ -38,9 +35,6 @@
|
||||
[AudioListener interface: context.listener must inherit property "positionY" 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
|
Loading…
Reference in New Issue
Block a user