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

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: 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 class SuspendResumeHandler {
245 public:
246 enum ResolverType {
247 ResolverTypeSuspend,
248 ResolverTypeResume
249 };
250
251 static SuspendResumeHandler* createSuspendHandler(PassRefPtrWillBeRawPtr <ScriptPromiseResolver>);
252 static SuspendResumeHandler* createResumeHandler(PassRefPtrWillBeRawPtr< ScriptPromiseResolver>);
253 ResolverType handlerType() { return m_resolverType; }
254 PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver() { return m_reso lver; }
255 ~SuspendResumeHandler();
256 private:
257 SuspendResumeHandler(ResolverType, PassRefPtrWillBeRawPtr<ScriptPromiseR esolver>);
258 ResolverType m_resolverType;
259 RefPtrWillBeRawPtr<ScriptPromiseResolver> m_resolver;
260 };
261
244 void initialize(); 262 void initialize();
245 void uninitialize(); 263 void uninitialize();
246 264
247 // ExecutionContext calls stop twice. 265 // ExecutionContext calls stop twice.
248 // We'd like to schedule only one stop action for them. 266 // We'd like to schedule only one stop action for them.
249 bool m_isStopScheduled; 267 bool m_isStopScheduled;
250 bool m_isCleared; 268 bool m_isCleared;
251 void clear(); 269 void clear();
252 270
253 void throwExceptionForClosedState(ExceptionState&); 271 void throwExceptionForClosedState(ExceptionState&);
(...skipping 17 matching lines...) Expand all
271 // held, or on the main thread when the audio thread has finished. 289 // held, or on the main thread when the audio thread has finished.
272 // Oilpan: This Vector holds connection references. We must call 290 // Oilpan: This Vector holds connection references. We must call
273 // AudioHandler::makeConnection when we add an AudioNode to this, and must 291 // AudioHandler::makeConnection when we add an AudioNode to this, and must
274 // call AudioHandler::breakConnection() when we remove an AudioNode from 292 // call AudioHandler::breakConnection() when we remove an AudioNode from
275 // this. 293 // this.
276 HeapVector<Member<AudioNode>> m_activeSourceNodes; 294 HeapVector<Member<AudioNode>> m_activeSourceNodes;
277 295
278 // Stop rendering the audio graph. 296 // Stop rendering the audio graph.
279 void stopRendering(); 297 void stopRendering();
280 298
281 // Handle Promises for resume() and suspend() 299 void resolvePromisesForSuspendResume();
282 void resolvePromisesForResume(); 300 void resolvePromisesForSuspendResumeOnMainThread();
283 void resolvePromisesForResumeOnMainThread();
284
285 void resolvePromisesForSuspend();
286 void resolvePromisesForSuspendOnMainThread();
287 301
288 // Vector of promises created by resume(). It takes time to handle them, so we collect all of 302 // 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. 303 // the promises here until they can be resolved or rejected.
290 WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_resumeResolver s; 304 Vector<SuspendResumeHandler*> m_suspendResumeHandlers;
291 // Like m_resumeResolvers but for suspend().
292 WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_suspendResolve rs;
293 void rejectPendingResolvers(); 305 void rejectPendingResolvers();
294 306
295 // True if we're in the process of resolving promises for resume(). Resolvi ng can take some 307 // 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 308 // take some time and the audio context process loop is very fast, so we don 't want to call
297 // excessive number of times. 309 // resolve an excessive number of times.
298 bool m_isResolvingResumePromises; 310 bool m_isResolvingSuspendResumePromises;
299 311
300 unsigned m_connectionCount; 312 unsigned m_connectionCount;
301 313
302 // Graph locking. 314 // Graph locking.
303 bool m_didInitializeContextGraphMutex; 315 bool m_didInitializeContextGraphMutex;
304 RefPtr<DeferredTaskHandler> m_deferredTaskHandler; 316 RefPtr<DeferredTaskHandler> m_deferredTaskHandler;
305 317
306 Member<AudioBuffer> m_renderTarget; 318 Member<AudioBuffer> m_renderTarget;
307 319
308 bool m_isOfflineContext; 320 bool m_isOfflineContext;
(...skipping 18 matching lines...) Expand all
327 // This is considering 32 is large enough for multiple channels audio. 339 // This is considering 32 is large enough for multiple channels audio.
328 // It is somewhat arbitrary and could be increased if necessary. 340 // It is somewhat arbitrary and could be increased if necessary.
329 enum { MaxNumberOfChannels = 32 }; 341 enum { MaxNumberOfChannels = 32 };
330 342
331 unsigned m_contextId; 343 unsigned m_contextId;
332 }; 344 };
333 345
334 } // namespace blink 346 } // namespace blink
335 347
336 #endif // AudioContext_h 348 #endif // AudioContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698