| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "wtf/Threading.h" | 45 #include "wtf/Threading.h" |
| 46 #include "wtf/Vector.h" | 46 #include "wtf/Vector.h" |
| 47 #include "wtf/build_config.h" | 47 #include "wtf/build_config.h" |
| 48 | 48 |
| 49 namespace blink { | 49 namespace blink { |
| 50 | 50 |
| 51 class AnalyserNode; | 51 class AnalyserNode; |
| 52 class AudioBuffer; | 52 class AudioBuffer; |
| 53 class AudioBufferCallback; | 53 class AudioBufferCallback; |
| 54 class AudioBufferSourceNode; | 54 class AudioBufferSourceNode; |
| 55 class AudioContextOptions; |
| 55 class AudioListener; | 56 class AudioListener; |
| 56 class BaseAudioContextTest; | 57 class BaseAudioContextTest; |
| 57 class BiquadFilterNode; | 58 class BiquadFilterNode; |
| 58 class ChannelMergerNode; | 59 class ChannelMergerNode; |
| 59 class ChannelSplitterNode; | 60 class ChannelSplitterNode; |
| 60 class ConstantSourceNode; | 61 class ConstantSourceNode; |
| 61 class ConvolverNode; | 62 class ConvolverNode; |
| 62 class DelayNode; | 63 class DelayNode; |
| 63 class Document; | 64 class Document; |
| 64 class DynamicsCompressorNode; | 65 class DynamicsCompressorNode; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 94 | 95 |
| 95 public: | 96 public: |
| 96 // The state of an audio context. On creation, the state is Suspended. The | 97 // The state of an audio context. On creation, the state is Suspended. The |
| 97 // state is Running if audio is being processed (audio graph is being pulled | 98 // state is Running if audio is being processed (audio graph is being pulled |
| 98 // for data). The state is Closed if the audio context has been closed. The | 99 // for data). The state is Closed if the audio context has been closed. The |
| 99 // valid transitions are from Suspended to either Running or Closed; Running | 100 // valid transitions are from Suspended to either Running or Closed; Running |
| 100 // to Suspended or Closed. Once Closed, there are no valid transitions. | 101 // to Suspended or Closed. Once Closed, there are no valid transitions. |
| 101 enum AudioContextState { Suspended, Running, Closed }; | 102 enum AudioContextState { Suspended, Running, Closed }; |
| 102 | 103 |
| 103 // Create an AudioContext for rendering to the audio hardware. | 104 // Create an AudioContext for rendering to the audio hardware. |
| 104 static BaseAudioContext* create(Document&, ExceptionState&); | 105 static BaseAudioContext* create(Document&, |
| 106 const AudioContextOptions&, |
| 107 ExceptionState&); |
| 105 | 108 |
| 106 ~BaseAudioContext() override; | 109 ~BaseAudioContext() override; |
| 107 | 110 |
| 108 DECLARE_VIRTUAL_TRACE(); | 111 DECLARE_VIRTUAL_TRACE(); |
| 109 | 112 |
| 110 // Is the destination node initialized and ready to handle audio? | 113 // Is the destination node initialized and ready to handle audio? |
| 111 bool isDestinationInitialized() const { | 114 bool isDestinationInitialized() const { |
| 112 AudioDestinationNode* dest = destination(); | 115 AudioDestinationNode* dest = destination(); |
| 113 return dest ? dest->audioDestinationHandler().isInitialized() : false; | 116 return dest ? dest->audioDestinationHandler().isInitialized() : false; |
| 114 } | 117 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 131 | 134 |
| 132 double currentTime() const { | 135 double currentTime() const { |
| 133 // TODO: What is the correct value for the current time if the destination | 136 // TODO: What is the correct value for the current time if the destination |
| 134 // node has gone away? 0 is a valid time. | 137 // node has gone away? 0 is a valid time. |
| 135 return m_destinationNode | 138 return m_destinationNode |
| 136 ? m_destinationNode->audioDestinationHandler().currentTime() | 139 ? m_destinationNode->audioDestinationHandler().currentTime() |
| 137 : 0; | 140 : 0; |
| 138 } | 141 } |
| 139 | 142 |
| 140 float sampleRate() const { | 143 float sampleRate() const { |
| 141 return m_destinationNode ? m_destinationNode->handler().sampleRate() : 0; | 144 return m_destinationNode |
| 145 ? m_destinationNode->audioDestinationHandler().sampleRate() |
| 146 : closedContextSampleRate(); |
| 147 } |
| 148 |
| 149 float framesPerBuffer() const { |
| 150 return m_destinationNode |
| 151 ? m_destinationNode->audioDestinationHandler().framesPerBuffer() |
| 152 : 0; |
| 142 } | 153 } |
| 143 | 154 |
| 144 size_t callbackBufferSize() const { | 155 size_t callbackBufferSize() const { |
| 145 return m_destinationNode ? m_destinationNode->handler().callbackBufferSize() | 156 return m_destinationNode ? m_destinationNode->handler().callbackBufferSize() |
| 146 : 0; | 157 : 0; |
| 147 } | 158 } |
| 148 | 159 |
| 149 String state() const; | 160 String state() const; |
| 150 AudioContextState contextState() const { return m_contextState; } | 161 AudioContextState contextState() const { return m_contextState; } |
| 151 void throwExceptionForClosedState(ExceptionState&); | 162 void throwExceptionForClosedState(ExceptionState&); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 // It is somewhat arbitrary and could be increased if necessary. | 476 // It is somewhat arbitrary and could be increased if necessary. |
| 466 enum { MaxNumberOfChannels = 32 }; | 477 enum { MaxNumberOfChannels = 32 }; |
| 467 | 478 |
| 468 Optional<AutoplayStatus> m_autoplayStatus; | 479 Optional<AutoplayStatus> m_autoplayStatus; |
| 469 AudioIOPosition m_outputPosition; | 480 AudioIOPosition m_outputPosition; |
| 470 }; | 481 }; |
| 471 | 482 |
| 472 } // namespace blink | 483 } // namespace blink |
| 473 | 484 |
| 474 #endif // BaseAudioContext_h | 485 #endif // BaseAudioContext_h |
| OLD | NEW |