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

Side by Side Diff: Source/modules/webaudio/AudioContext.h

Issue 1140723003: Implement suspend() and resume() for OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Restructured the resolution of suspend promise Created 5 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 #endif 212 #endif
213 using AutoLocker = DeferredTaskHandler::AutoLocker; 213 using AutoLocker = DeferredTaskHandler::AutoLocker;
214 214
215 // Returns the maximum numuber of channels we can support. 215 // Returns the maximum numuber of channels we can support.
216 static unsigned maxNumberOfChannels() { return MaxNumberOfChannels;} 216 static unsigned maxNumberOfChannels() { return MaxNumberOfChannels;}
217 217
218 // EventTarget 218 // EventTarget
219 virtual const AtomicString& interfaceName() const override final; 219 virtual const AtomicString& interfaceName() const override final;
220 virtual ExecutionContext* executionContext() const override final; 220 virtual ExecutionContext* executionContext() const override final;
221 221
222 DEFINE_ATTRIBUTE_EVENT_LISTENER(complete);
223 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); 222 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange);
224 223
225 void startRendering(); 224 void startRendering();
226 void fireCompletionEvent(); 225 virtual void fireCompletionEvent();
227 void notifyStateChange(); 226 void notifyStateChange();
228 227
228 // For OfflineAudioContext-specific tasks.
229 virtual bool shouldSuspendNow();
230 virtual void resolvePendingSuspendPromises();
231
229 // A context is considered closed if: 232 // A context is considered closed if:
230 // - closeContext() has been called, even if the audio HW has not yet been 233 // - closeContext() has been called, even if the audio HW has not yet been
231 // stopped. It will be stopped eventually. 234 // stopped. It will be stopped eventually.
232 // - it has been stopped (or is stopping) by its execution context. 235 // - it has been stopped (or is stopping) by its execution context.
233 bool isContextClosed() const { return m_closeResolver || m_isStopScheduled | | m_isCleared; } 236 bool isContextClosed() const { return m_closeResolver || m_isStopScheduled | | m_isCleared; }
234 237
235 static unsigned s_hardwareContextCount; 238 static unsigned s_hardwareContextCount;
236 static unsigned s_contextId; 239 static unsigned s_contextId;
237 240
238 // Get the security origin for this audio context. 241 // Get the security origin for this audio context.
239 SecurityOrigin* securityOrigin() const; 242 SecurityOrigin* securityOrigin() const;
240 243
244 Member<AudioBuffer> renderTarget() const { return m_renderTarget; }
245 AudioDestinationNode* destination() const { return m_destinationNode; }
246
241 protected: 247 protected:
242 explicit AudioContext(Document*); 248 explicit AudioContext(Document*);
243 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl oat sampleRate); 249 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl oat sampleRate);
244 250
245 RefPtrWillBeMember<ScriptPromiseResolver> m_offlineResolver; 251 // Shared with OfflineAudioContext.
252 void setContextState(AudioContextState);
253
246 private: 254 private:
247 void initialize(); 255 void initialize();
248 void uninitialize(); 256 void uninitialize();
249 257
250 // ExecutionContext calls stop twice. 258 // ExecutionContext calls stop twice.
251 // We'd like to schedule only one stop action for them. 259 // We'd like to schedule only one stop action for them.
252 bool m_isStopScheduled; 260 bool m_isStopScheduled;
253 bool m_isCleared; 261 bool m_isCleared;
254 void clear(); 262 void clear();
255 263
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // Graph locking. 308 // Graph locking.
301 bool m_didInitializeContextGraphMutex; 309 bool m_didInitializeContextGraphMutex;
302 RefPtr<DeferredTaskHandler> m_deferredTaskHandler; 310 RefPtr<DeferredTaskHandler> m_deferredTaskHandler;
303 311
304 Member<AudioBuffer> m_renderTarget; 312 Member<AudioBuffer> m_renderTarget;
305 313
306 bool m_isOfflineContext; 314 bool m_isOfflineContext;
307 315
308 // The state of the AudioContext. 316 // The state of the AudioContext.
309 AudioContextState m_contextState; 317 AudioContextState m_contextState;
310 void setContextState(AudioContextState);
311 318
312 AsyncAudioDecoder m_audioDecoder; 319 AsyncAudioDecoder m_audioDecoder;
313 320
314 // The Promise that is returned by close(); 321 // The Promise that is returned by close();
315 RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver; 322 RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver;
316 323
317 // Tries to handle AudioBufferSourceNodes that were started but became disco nnected or was never 324 // 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 325 // 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. 326 // can, try to stop them so they can be collected.
320 void handleStoppableSourceNodes(); 327 void handleStoppableSourceNodes();
321 328
322 // This is considering 32 is large enough for multiple channels audio. 329 // This is considering 32 is large enough for multiple channels audio.
323 // It is somewhat arbitrary and could be increased if necessary. 330 // It is somewhat arbitrary and could be increased if necessary.
324 enum { MaxNumberOfChannels = 32 }; 331 enum { MaxNumberOfChannels = 32 };
325 332
326 unsigned m_contextId; 333 unsigned m_contextId;
327 }; 334 };
328 335
329 } // namespace blink 336 } // namespace blink
330 337
331 #endif // AudioContext_h 338 #endif // AudioContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698