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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 class OscillatorNode; | 73 class OscillatorNode; |
74 class PannerNode; | 74 class PannerNode; |
75 class PeriodicWave; | 75 class PeriodicWave; |
76 class PeriodicWaveConstraints; | 76 class PeriodicWaveConstraints; |
77 class ScriptProcessorNode; | 77 class ScriptProcessorNode; |
78 class ScriptPromiseResolver; | 78 class ScriptPromiseResolver; |
79 class ScriptState; | 79 class ScriptState; |
80 class SecurityOrigin; | 80 class SecurityOrigin; |
81 class StereoPannerNode; | 81 class StereoPannerNode; |
82 class WaveShaperNode; | 82 class WaveShaperNode; |
| 83 class WebAudioLatencyHint; |
83 | 84 |
84 // BaseAudioContext is the cornerstone of the web audio API and all AudioNodes | 85 // BaseAudioContext is the cornerstone of the web audio API and all AudioNodes |
85 // are created from it. For thread safety between the audio thread and the main | 86 // are created from it. For thread safety between the audio thread and the main |
86 // thread, it has a rendering graph locking mechanism. | 87 // thread, it has a rendering graph locking mechanism. |
87 | 88 |
88 class MODULES_EXPORT BaseAudioContext : public EventTargetWithInlineData, | 89 class MODULES_EXPORT BaseAudioContext : public EventTargetWithInlineData, |
89 public ActiveScriptWrappable, | 90 public ActiveScriptWrappable, |
90 public ActiveDOMObject { | 91 public ActiveDOMObject { |
91 USING_GARBAGE_COLLECTED_MIXIN(BaseAudioContext); | 92 USING_GARBAGE_COLLECTED_MIXIN(BaseAudioContext); |
92 DEFINE_WRAPPERTYPEINFO(); | 93 DEFINE_WRAPPERTYPEINFO(); |
93 | 94 |
94 public: | 95 public: |
95 // The state of an audio context. On creation, the state is Suspended. The | 96 // The state of an audio context. On creation, the state is Suspended. The |
96 // state is Running if audio is being processed (audio graph is being pulled | 97 // state is Running if audio is being processed (audio graph is being pulled |
97 // for data). The state is Closed if the audio context has been closed. The | 98 // for data). The state is Closed if the audio context has been closed. The |
98 // valid transitions are from Suspended to either Running or Closed; Running | 99 // valid transitions are from Suspended to either Running or Closed; Running |
99 // to Suspended or Closed. Once Closed, there are no valid transitions. | 100 // to Suspended or Closed. Once Closed, there are no valid transitions. |
100 enum AudioContextState { Suspended, Running, Closed }; | 101 enum AudioContextState { Suspended, Running, Closed }; |
101 | 102 |
102 // Create an AudioContext for rendering to the audio hardware. | 103 // Create an AudioContext for rendering to the audio hardware. |
103 static BaseAudioContext* create(Document&, ExceptionState&); | 104 static BaseAudioContext* create(Document&, |
| 105 const WebAudioLatencyHint&, |
| 106 ExceptionState&); |
104 | 107 |
105 ~BaseAudioContext() override; | 108 ~BaseAudioContext() override; |
106 | 109 |
107 DECLARE_VIRTUAL_TRACE(); | 110 DECLARE_VIRTUAL_TRACE(); |
108 | 111 |
109 // Is the destination node initialized and ready to handle audio? | 112 // Is the destination node initialized and ready to handle audio? |
110 bool isDestinationInitialized() const { | 113 bool isDestinationInitialized() const { |
111 AudioDestinationNode* dest = destination(); | 114 AudioDestinationNode* dest = destination(); |
112 return dest ? dest->audioDestinationHandler().isInitialized() : false; | 115 return dest ? dest->audioDestinationHandler().isInitialized() : false; |
113 } | 116 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // Get the PeriodicWave for the specified oscillator type. The table is | 301 // Get the PeriodicWave for the specified oscillator type. The table is |
299 // initialized internally if necessary. | 302 // initialized internally if necessary. |
300 PeriodicWave* periodicWave(int type); | 303 PeriodicWave* periodicWave(int type); |
301 | 304 |
302 // For metrics purpose, records when start() is called on a | 305 // For metrics purpose, records when start() is called on a |
303 // AudioScheduledSourceHandler or a AudioBufferSourceHandler without a user | 306 // AudioScheduledSourceHandler or a AudioBufferSourceHandler without a user |
304 // gesture while the AudioContext requires a user gesture. | 307 // gesture while the AudioContext requires a user gesture. |
305 void maybeRecordStartAttempt(); | 308 void maybeRecordStartAttempt(); |
306 | 309 |
307 protected: | 310 protected: |
308 explicit BaseAudioContext(Document*); | 311 explicit BaseAudioContext(Document*, const WebAudioLatencyHint&); |
309 BaseAudioContext(Document*, | 312 BaseAudioContext(Document*, |
310 unsigned numberOfChannels, | 313 unsigned numberOfChannels, |
311 size_t numberOfFrames, | 314 size_t numberOfFrames, |
312 float sampleRate); | 315 float sampleRate); |
313 | 316 |
314 void initialize(); | 317 void initialize(); |
315 void uninitialize(); | 318 void uninitialize(); |
316 | 319 |
317 void setContextState(AudioContextState); | 320 void setContextState(AudioContextState); |
318 | 321 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 // This is considering 32 is large enough for multiple channels audio. | 450 // This is considering 32 is large enough for multiple channels audio. |
448 // It is somewhat arbitrary and could be increased if necessary. | 451 // It is somewhat arbitrary and could be increased if necessary. |
449 enum { MaxNumberOfChannels = 32 }; | 452 enum { MaxNumberOfChannels = 32 }; |
450 | 453 |
451 Optional<AutoplayStatus> m_autoplayStatus; | 454 Optional<AutoplayStatus> m_autoplayStatus; |
452 }; | 455 }; |
453 | 456 |
454 } // namespace blink | 457 } // namespace blink |
455 | 458 |
456 #endif // BaseAudioContext_h | 459 #endif // BaseAudioContext_h |
OLD | NEW |