OLD | NEW |
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 Loading... |
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 Loading... |
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 if (!context) |
| 570 return 0.0; |
| 571 |
| 572 LocalDOMWindow* window = context->executingWindow(); |
| 573 if (!window) |
| 574 return 0.0; |
| 575 |
| 576 Performance* performance = DOMWindowPerformance::performance(*window); |
| 577 if (!performance) |
| 578 return 0.0; |
| 579 |
| 580 return performance->monotonicTimeToDOMHighResTimeStamp(seconds); |
| 581 } |
| 582 |
| 583 void AbstractAudioContext::getOutputTimestamp(AudioTimestamp& result) |
| 584 { |
| 585 DCHECK(isMainThread()); |
| 586 if (!m_destinationNode) { |
| 587 result.setContextTime(0.0); |
| 588 result.setPerformanceTime(0.0); |
| 589 return; |
| 590 } |
| 591 |
| 592 WebAudioTimestamp outputTimestamp; |
| 593 { |
| 594 AutoLocker locker(this); |
| 595 outputTimestamp = m_outputTimestamp; |
| 596 } |
| 597 AudioDestinationHandler& destinationHandler = m_destinationNode->audioDestin
ationHandler(); |
| 598 double contextTime = outputTimestamp.frames / static_cast<double>(destinatio
nHandler.sampleRate()); |
| 599 double performanceTime = outputTimestamp.seconds ? toPerformanceTime(getExec
utionContext(), outputTimestamp.seconds) : 0.0; |
| 600 |
| 601 result.setContextTime(contextTime); |
| 602 result.setPerformanceTime(performanceTime); |
| 603 } |
| 604 |
| 605 void AbstractAudioContext::setWebAudioTimestamp(const WebAudioTimestamp& timesta
mp) |
| 606 { |
| 607 DCHECK(isAudioThread()); |
| 608 if (tryLock()) { |
| 609 m_outputTimestamp = timestamp; |
| 610 unlock(); |
| 611 } |
| 612 } |
| 613 |
563 String AbstractAudioContext::state() const | 614 String AbstractAudioContext::state() const |
564 { | 615 { |
565 // These strings had better match the strings for AudioContextState in Audio
Context.idl. | 616 // These strings had better match the strings for AudioContextState in Audio
Context.idl. |
566 switch (m_contextState) { | 617 switch (m_contextState) { |
567 case Suspended: | 618 case Suspended: |
568 return "suspended"; | 619 return "suspended"; |
569 case Running: | 620 case Running: |
570 return "running"; | 621 return "running"; |
571 case Closed: | 622 case Closed: |
572 return "closed"; | 623 return "closed"; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 | 881 |
831 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const | 882 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const |
832 { | 883 { |
833 if (getExecutionContext()) | 884 if (getExecutionContext()) |
834 return getExecutionContext()->getSecurityOrigin(); | 885 return getExecutionContext()->getSecurityOrigin(); |
835 | 886 |
836 return nullptr; | 887 return nullptr; |
837 } | 888 } |
838 | 889 |
839 } // namespace blink | 890 } // namespace blink |
OLD | NEW |