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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 bool isInitialized() const { return m_isInitialized; } | 102 bool isInitialized() const { return m_isInitialized; } |
103 bool isOfflineContext() { return m_isOfflineContext; } | 103 bool isOfflineContext() { return m_isOfflineContext; } |
104 | 104 |
105 // Document notification | 105 // Document notification |
106 virtual void stop() override final; | 106 virtual void stop() override final; |
107 virtual bool hasPendingActivity() const override; | 107 virtual bool hasPendingActivity() const override; |
108 | 108 |
109 AudioDestinationNode* destination() { return m_destinationNode.get(); } | 109 AudioDestinationNode* destination() { return m_destinationNode.get(); } |
110 | 110 |
111 // currentSampleFrame() and currentTime() can be called from both the main | 111 size_t currentSampleFrame() const |
112 // thread and the audio thread. Note that, however, they return the cached | 112 { |
113 // value instead of actual current ones when they are accessed from the main | 113 return m_destinationNode ? m_destinationNode->audioDestinationHandler().
currentSampleFrame() : 0; |
114 // thread. See: crbug.com/431874 | 114 } |
115 size_t currentSampleFrame() const; | 115 |
116 double currentTime() const; | 116 double currentTime() const |
| 117 { |
| 118 return m_destinationNode ? m_destinationNode->audioDestinationHandler().
currentTime() : 0; |
| 119 } |
117 | 120 |
118 float sampleRate() const { return m_destinationNode ? m_destinationNode->han
dler().sampleRate() : 0; } | 121 float sampleRate() const { return m_destinationNode ? m_destinationNode->han
dler().sampleRate() : 0; } |
119 | 122 |
120 String state() const; | 123 String state() const; |
121 AudioContextState contextState() const { return m_contextState; } | 124 AudioContextState contextState() const { return m_contextState; } |
122 | 125 |
123 AudioBuffer* createBuffer(unsigned numberOfChannels, size_t numberOfFrames,
float sampleRate, ExceptionState&); | 126 AudioBuffer* createBuffer(unsigned numberOfChannels, size_t numberOfFrames,
float sampleRate, ExceptionState&); |
124 | 127 |
125 // Asynchronous audio file data decoding. | 128 // Asynchronous audio file data decoding. |
126 void decodeAudioData(DOMArrayBuffer*, AudioBufferCallback*, AudioBufferCallb
ack*, ExceptionState&); | 129 void decodeAudioData(DOMArrayBuffer*, AudioBufferCallback*, AudioBufferCallb
ack*, ExceptionState&); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 307 |
305 // The state of the AudioContext. | 308 // The state of the AudioContext. |
306 AudioContextState m_contextState; | 309 AudioContextState m_contextState; |
307 void setContextState(AudioContextState); | 310 void setContextState(AudioContextState); |
308 | 311 |
309 AsyncAudioDecoder m_audioDecoder; | 312 AsyncAudioDecoder m_audioDecoder; |
310 | 313 |
311 // The Promise that is returned by close(); | 314 // The Promise that is returned by close(); |
312 RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver; | 315 RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver; |
313 | 316 |
314 // Follows the destination's currentSampleFrame, but might be slightly behin
d due to locking. | |
315 size_t m_cachedSampleFrame; | |
316 | |
317 // Tries to handle AudioBufferSourceNodes that were started but became disco
nnected or was never | 317 // Tries to handle AudioBufferSourceNodes that were started but became disco
nnected or was never |
318 // connected. Because these never get pulled anymore, they will stay around
forever. So if we | 318 // connected. Because these never get pulled anymore, they will stay around
forever. So if we |
319 // can, try to stop them so they can be collected. | 319 // can, try to stop them so they can be collected. |
320 void handleStoppableSourceNodes(); | 320 void handleStoppableSourceNodes(); |
321 | 321 |
322 // This is considering 32 is large enough for multiple channels audio. | 322 // This is considering 32 is large enough for multiple channels audio. |
323 // It is somewhat arbitrary and could be increased if necessary. | 323 // It is somewhat arbitrary and could be increased if necessary. |
324 enum { MaxNumberOfChannels = 32 }; | 324 enum { MaxNumberOfChannels = 32 }; |
325 | 325 |
326 unsigned m_contextId; | 326 unsigned m_contextId; |
327 }; | 327 }; |
328 | 328 |
329 } // namespace blink | 329 } // namespace blink |
330 | 330 |
331 #endif // AudioContext_h | 331 #endif // AudioContext_h |
OLD | NEW |