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

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

Issue 1123603002: Process suspend() and resume() in call order (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update according to review. Created 5 years, 7 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 | Annotate | Revision Log
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 // Get the security origin for this audio context. 235 // Get the security origin for this audio context.
236 SecurityOrigin* securityOrigin() const; 236 SecurityOrigin* securityOrigin() const;
237 237
238 protected: 238 protected:
239 explicit AudioContext(Document*); 239 explicit AudioContext(Document*);
240 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl oat sampleRate); 240 AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, fl oat sampleRate);
241 241
242 RefPtrWillBeMember<ScriptPromiseResolver> m_offlineResolver; 242 RefPtrWillBeMember<ScriptPromiseResolver> m_offlineResolver;
243 private: 243 private:
244 // Helper class to wrap a ScriptPromiseResolver to include information on wh ether the resolver
245 // was created by suspend() or resume() so that we can process them correctl y.
246 class SuspendResumeResolver {
haraken 2015/05/04 23:24:41 This needs to be: class SuspendResumeResolver :
Raymond Toy 2015/05/14 21:26:05 When I do this and make m_resolver be a RefPtrWill
haraken 2015/05/14 21:28:27 You'll need to use NoBaseWillBeGarbageCollected.
247 public:
248 enum ResolverType {
249 ResolverTypeSuspend,
250 ResolverTypeResume
251 };
252
253 static SuspendResumeResolver* createSuspendResolver(PassRefPtrWillBeRawP tr<ScriptPromiseResolver>);
254 static SuspendResumeResolver* createResumeResolver(PassRefPtrWillBeRawPt r<ScriptPromiseResolver>);
255 ResolverType handlerType() const { return m_resolverType; }
256 PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver() { return m_reso lver; }
257
258 private:
259 SuspendResumeResolver(ResolverType, PassRefPtrWillBeRawPtr<ScriptPromise Resolver>);
260 ~SuspendResumeResolver();
261 ResolverType m_resolverType;
262 RefPtrWillBeRawPtr<ScriptPromiseResolver> m_resolver;
haraken 2015/05/04 23:24:41 RefPtrWillBeMember<ScriptPromiseResolver> Also yo
263 };
264
244 void initialize(); 265 void initialize();
245 void uninitialize(); 266 void uninitialize();
246 267
247 // ExecutionContext calls stop twice. 268 // ExecutionContext calls stop twice.
248 // We'd like to schedule only one stop action for them. 269 // We'd like to schedule only one stop action for them.
249 bool m_isStopScheduled; 270 bool m_isStopScheduled;
250 bool m_isCleared; 271 bool m_isCleared;
251 void clear(); 272 void clear();
252 273
253 void throwExceptionForClosedState(ExceptionState&); 274 void throwExceptionForClosedState(ExceptionState&);
(...skipping 18 matching lines...) Expand all
272 // Oilpan: This Vector holds connection references. We must call 293 // Oilpan: This Vector holds connection references. We must call
273 // AudioHandler::makeConnection when we add an AudioNode to this, and must 294 // AudioHandler::makeConnection when we add an AudioNode to this, and must
274 // call AudioHandler::breakConnection() when we remove an AudioNode from 295 // call AudioHandler::breakConnection() when we remove an AudioNode from
275 // this. 296 // this.
276 HeapVector<Member<AudioNode>> m_activeSourceNodes; 297 HeapVector<Member<AudioNode>> m_activeSourceNodes;
277 298
278 // Stop rendering the audio graph. 299 // Stop rendering the audio graph.
279 void stopRendering(); 300 void stopRendering();
280 301
281 // Handle Promises for resume() and suspend() 302 // Handle Promises for resume() and suspend()
282 void resolvePromisesForResume(); 303 void resolvePromisesForSuspendResume();
283 void resolvePromisesForResumeOnMainThread(); 304 void resolvePromisesForSuspendResumeOnMainThread();
284 305
285 void resolvePromisesForSuspend(); 306 // Vector of promises created by suspend() and resume(). It takes time to h andle them, so we
286 void resolvePromisesForSuspendOnMainThread(); 307 // collect all of the promises here until they can be resolved or rejected. We can then also
308 // process them in the order in which suspend/resume was called.
309 Vector<SuspendResumeResolver*> m_suspendResumeResolvers;
haraken 2015/05/04 23:24:40 WillBeHeapVector<OwnPtrWillBeMember<SuspendResumeR
287 310
288 // Vector of promises created by resume(). It takes time to handle them, so we collect all of
289 // the promises here until they can be resolved or rejected.
290 WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_resumeResolver s;
291 // Like m_resumeResolvers but for suspend().
292 WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_suspendResolve rs;
293 void rejectPendingResolvers(); 311 void rejectPendingResolvers();
294 312
295 // True if we're in the process of resolving promises for resume(). Resolvi ng can take some 313 // True if we're in the process of resolving promises for suspend()/resume() . Resolving can
296 // time and the audio context process loop is very fast, so we don't want to call resolve an 314 // take some time and the audio context process loop is very fast, so we don 't want to call
297 // excessive number of times. 315 // resolve an excessive number of times.
298 bool m_isResolvingResumePromises; 316 bool m_isResolvingSuspendResumePromises;
299 317
300 unsigned m_connectionCount; 318 unsigned m_connectionCount;
301 319
302 // Graph locking. 320 // Graph locking.
303 bool m_didInitializeContextGraphMutex; 321 bool m_didInitializeContextGraphMutex;
304 RefPtr<DeferredTaskHandler> m_deferredTaskHandler; 322 RefPtr<DeferredTaskHandler> m_deferredTaskHandler;
305 323
306 Member<AudioBuffer> m_renderTarget; 324 Member<AudioBuffer> m_renderTarget;
307 325
308 bool m_isOfflineContext; 326 bool m_isOfflineContext;
(...skipping 18 matching lines...) Expand all
327 // This is considering 32 is large enough for multiple channels audio. 345 // This is considering 32 is large enough for multiple channels audio.
328 // It is somewhat arbitrary and could be increased if necessary. 346 // It is somewhat arbitrary and could be increased if necessary.
329 enum { MaxNumberOfChannels = 32 }; 347 enum { MaxNumberOfChannels = 32 };
330 348
331 unsigned m_contextId; 349 unsigned m_contextId;
332 }; 350 };
333 351
334 } // namespace blink 352 } // namespace blink
335 353
336 #endif // AudioContext_h 354 #endif // AudioContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698