Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AbstractAudioContext.cpp

Issue 2060833002: Implementation of 'AudioContext.getOutputTimestamp' method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implementation of 'AudioContext.getOutputTimestamp' method Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 14 matching lines...) Expand all
25 #include "modules/webaudio/AbstractAudioContext.h" 25 #include "modules/webaudio/AbstractAudioContext.h"
26 #include "bindings/core/v8/Dictionary.h" 26 #include "bindings/core/v8/Dictionary.h"
27 #include "bindings/core/v8/ExceptionMessages.h" 27 #include "bindings/core/v8/ExceptionMessages.h"
28 #include "bindings/core/v8/ExceptionState.h" 28 #include "bindings/core/v8/ExceptionState.h"
29 #include "bindings/core/v8/ScriptPromiseResolver.h" 29 #include "bindings/core/v8/ScriptPromiseResolver.h"
30 #include "bindings/core/v8/ScriptState.h" 30 #include "bindings/core/v8/ScriptState.h"
31 #include "core/dom/DOMException.h" 31 #include "core/dom/DOMException.h"
32 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
33 #include "core/dom/ExceptionCode.h" 33 #include "core/dom/ExceptionCode.h"
34 #include "core/dom/ExecutionContextTask.h" 34 #include "core/dom/ExecutionContextTask.h"
35 #include "core/frame/LocalDOMWindow.h"
35 #include "core/frame/Settings.h" 36 #include "core/frame/Settings.h"
36 #include "core/html/HTMLMediaElement.h" 37 #include "core/html/HTMLMediaElement.h"
38 #include "core/timing/DOMWindowPerformance.h"
39 #include "core/timing/Performance.h"
37 #include "modules/mediastream/MediaStream.h" 40 #include "modules/mediastream/MediaStream.h"
38 #include "modules/webaudio/AnalyserNode.h" 41 #include "modules/webaudio/AnalyserNode.h"
39 #include "modules/webaudio/AudioBuffer.h" 42 #include "modules/webaudio/AudioBuffer.h"
40 #include "modules/webaudio/AudioBufferCallback.h" 43 #include "modules/webaudio/AudioBufferCallback.h"
41 #include "modules/webaudio/AudioBufferSourceNode.h" 44 #include "modules/webaudio/AudioBufferSourceNode.h"
42 #include "modules/webaudio/AudioContext.h" 45 #include "modules/webaudio/AudioContext.h"
43 #include "modules/webaudio/AudioListener.h" 46 #include "modules/webaudio/AudioListener.h"
44 #include "modules/webaudio/AudioNodeInput.h" 47 #include "modules/webaudio/AudioNodeInput.h"
45 #include "modules/webaudio/AudioNodeOutput.h" 48 #include "modules/webaudio/AudioNodeOutput.h"
49 #include "modules/webaudio/AudioTimestamp.h"
46 #include "modules/webaudio/BiquadFilterNode.h" 50 #include "modules/webaudio/BiquadFilterNode.h"
47 #include "modules/webaudio/ChannelMergerNode.h" 51 #include "modules/webaudio/ChannelMergerNode.h"
48 #include "modules/webaudio/ChannelSplitterNode.h" 52 #include "modules/webaudio/ChannelSplitterNode.h"
49 #include "modules/webaudio/ConvolverNode.h" 53 #include "modules/webaudio/ConvolverNode.h"
50 #include "modules/webaudio/DefaultAudioDestinationNode.h" 54 #include "modules/webaudio/DefaultAudioDestinationNode.h"
51 #include "modules/webaudio/DelayNode.h" 55 #include "modules/webaudio/DelayNode.h"
52 #include "modules/webaudio/DynamicsCompressorNode.h" 56 #include "modules/webaudio/DynamicsCompressorNode.h"
53 #include "modules/webaudio/GainNode.h" 57 #include "modules/webaudio/GainNode.h"
54 #include "modules/webaudio/IIRFilterNode.h" 58 #include "modules/webaudio/IIRFilterNode.h"
55 #include "modules/webaudio/MediaElementAudioSourceNode.h" 59 #include "modules/webaudio/MediaElementAudioSourceNode.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 return; 557 return;
554 } 558 }
555 if (!UserGestureIndicator::processingUserGesture()) { 559 if (!UserGestureIndicator::processingUserGesture()) {
556 userGestureHistogram.count(UserGestureRequiredAndNotAvailable); 560 userGestureHistogram.count(UserGestureRequiredAndNotAvailable);
557 return; 561 return;
558 } 562 }
559 userGestureHistogram.count(UserGestureRequiredAndAvailable); 563 userGestureHistogram.count(UserGestureRequiredAndAvailable);
560 m_userGestureRequired = false; 564 m_userGestureRequired = false;
561 } 565 }
562 566
567 static double toPerformanceTime(ExecutionContext* context, double seconds)
568 {
569 LocalDOMWindow* window = context ? context->executingWindow() : nullptr;
Raymond Toy 2016/06/14 16:42:40 Why not just early return with 0.0 if the context
Mikhail 2016/06/17 09:36:57 Done.
570 Performance* performance = window ? DOMWindowPerformance::performance(*windo w) : nullptr;
571 return performance ? performance->monotonicTimeToDOMHighResTimeStamp(seconds ) : 0.0;
572 }
573
574 void AbstractAudioContext::getOutputTimestamp(AudioTimestamp& result)
575 {
576 if (!m_destinationNode) {
577 result.setContextTime(0.0);
578 result.setPerformanceTime(0.0);
579 return;
580 }
581 AudioDestinationHandler& destinationHandler = m_destinationNode->audioDestin ationHandler();
582
583 WebAudioTimestamp outputTimestamp = destinationHandler.outputTimestamp();
584 double contextTime = outputTimestamp.frames / static_cast<double>(destinatio nHandler.sampleRate());
585 double performanceTime = outputTimestamp.seconds ? toPerformanceTime(getExec utionContext(), outputTimestamp.seconds) : 0.0;
586
587 result.setContextTime(contextTime);
588 result.setPerformanceTime(performanceTime);
589 }
590
563 String AbstractAudioContext::state() const 591 String AbstractAudioContext::state() const
564 { 592 {
565 // These strings had better match the strings for AudioContextState in Audio Context.idl. 593 // These strings had better match the strings for AudioContextState in Audio Context.idl.
566 switch (m_contextState) { 594 switch (m_contextState) {
567 case Suspended: 595 case Suspended:
568 return "suspended"; 596 return "suspended";
569 case Running: 597 case Running:
570 return "running"; 598 return "running";
571 case Closed: 599 case Closed:
572 return "closed"; 600 return "closed";
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 858
831 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const 859 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const
832 { 860 {
833 if (getExecutionContext()) 861 if (getExecutionContext())
834 return getExecutionContext()->getSecurityOrigin(); 862 return getExecutionContext()->getSecurityOrigin();
835 863
836 return nullptr; 864 return nullptr;
837 } 865 }
838 866
839 } // namespace blink 867 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698