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

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: Fixed a LO test and minor nits 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();
227 void notifyStateChange(); 225 void notifyStateChange();
228 226
229 // A context is considered closed if: 227 // A context is considered closed if:
230 // - closeContext() has been called, even if the audio HW has not yet been 228 // - closeContext() has been called, even if the audio HW has not yet been
231 // stopped. It will be stopped eventually. 229 // stopped. It will be stopped eventually.
232 // - it has been stopped (or is stopping) by its execution context. 230 // - it has been stopped (or is stopping) by its execution context.
233 bool isContextClosed() const { return m_closeResolver || m_isStopScheduled | | m_isCleared; } 231 bool isContextClosed() const { return m_closeResolver || m_isStopScheduled | | m_isCleared; }
234 232
235 static unsigned s_hardwareContextCount; 233 static unsigned s_hardwareContextCount;
236 static unsigned s_contextId; 234 static unsigned s_contextId;
237 235
238 // Get the security origin for this audio context. 236 // Get the security origin for this audio context.
239 SecurityOrigin* securityOrigin() const; 237 SecurityOrigin* securityOrigin() const;
240 238
239 // FIXME: Refactoring needed. These are OfflineAudioContext-specific tasks.
haraken 2015/06/17 06:46:08 FIXME => TODO
hongchan 2015/06/17 20:10:38 Done.
240 virtual void fireCompletionEvent();
241 virtual bool shouldSuspendNow();
242 virtual void resolvePendingSuspendPromises();
243 Member<AudioBuffer> renderTarget() const { return m_renderTarget; }
haraken 2015/06/17 06:46:08 Member<AudioBuffer> => AudioBuffer* m_renderTarge
hongchan 2015/06/17 20:10:38 Done.
244
241 protected: 245 protected:
242 explicit AudioContext(Document*); 246 explicit AudioContext(Document*);
243 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl oat sampleRate); 247 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl oat sampleRate);
244 248
245 RefPtrWillBeMember<ScriptPromiseResolver> m_offlineResolver; 249 // Shared with OfflineAudioContext.
250 void setContextState(AudioContextState);
251
246 private: 252 private:
247 void initialize(); 253 void initialize();
248 void uninitialize(); 254 void uninitialize();
249 255
250 // ExecutionContext calls stop twice. 256 // ExecutionContext calls stop twice.
251 // We'd like to schedule only one stop action for them. 257 // We'd like to schedule only one stop action for them.
252 bool m_isStopScheduled; 258 bool m_isStopScheduled;
253 bool m_isCleared; 259 bool m_isCleared;
254 void clear(); 260 void clear();
255 261
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // Graph locking. 306 // Graph locking.
301 bool m_didInitializeContextGraphMutex; 307 bool m_didInitializeContextGraphMutex;
302 RefPtr<DeferredTaskHandler> m_deferredTaskHandler; 308 RefPtr<DeferredTaskHandler> m_deferredTaskHandler;
303 309
304 Member<AudioBuffer> m_renderTarget; 310 Member<AudioBuffer> m_renderTarget;
305 311
306 bool m_isOfflineContext; 312 bool m_isOfflineContext;
307 313
308 // The state of the AudioContext. 314 // The state of the AudioContext.
309 AudioContextState m_contextState; 315 AudioContextState m_contextState;
310 void setContextState(AudioContextState);
311 316
312 AsyncAudioDecoder m_audioDecoder; 317 AsyncAudioDecoder m_audioDecoder;
313 318
314 // The Promise that is returned by close(); 319 // The Promise that is returned by close();
315 RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver; 320 RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver;
316 321
317 // Tries to handle AudioBufferSourceNodes that were started but became disco nnected or was never 322 // 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 323 // 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. 324 // can, try to stop them so they can be collected.
320 void handleStoppableSourceNodes(); 325 void handleStoppableSourceNodes();
321 326
327 // Perform common tasks after the render quantum. Called by handlePostRender Tasks().
328 void performPostRenderTasks();
329
322 // This is considering 32 is large enough for multiple channels audio. 330 // This is considering 32 is large enough for multiple channels audio.
323 // It is somewhat arbitrary and could be increased if necessary. 331 // It is somewhat arbitrary and could be increased if necessary.
324 enum { MaxNumberOfChannels = 32 }; 332 enum { MaxNumberOfChannels = 32 };
325 333
326 unsigned m_contextId; 334 unsigned m_contextId;
327 }; 335 };
328 336
329 } // namespace blink 337 } // namespace blink
330 338
331 #endif // AudioContext_h 339 #endif // AudioContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698