Chromium Code Reviews| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 SuspendResumeResolver { | |
|
hongchan
2015/05/04 17:28:38
Should we consider take this definition out of the
Raymond Toy
2015/05/04 17:38:34
It seems natural to keep it here since it's only r
hongchan
2015/05/04 17:41:50
Acknowledged.
| |
| 245 public: | |
| 246 enum ResolverType { | |
| 247 ResolverTypeSuspend, | |
| 248 ResolverTypeResume | |
| 249 }; | |
| 250 | |
| 251 static SuspendResumeResolver* createSuspendHandler(PassRefPtrWillBeRawPt r<ScriptPromiseResolver>); | |
| 252 static SuspendResumeResolver* createResumeHandler(PassRefPtrWillBeRawPtr <ScriptPromiseResolver>); | |
| 253 ResolverType handlerType() { return m_resolverType; } | |
| 254 PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver() { return m_reso lver; } | |
| 255 | |
| 256 private: | |
| 257 SuspendResumeResolver(ResolverType, PassRefPtrWillBeRawPtr<ScriptPromise Resolver>); | |
| 258 ~SuspendResumeResolver(); | |
| 259 ResolverType m_resolverType; | |
| 260 RefPtrWillBeRawPtr<ScriptPromiseResolver> m_resolver; | |
| 261 }; | |
| 262 | |
| 244 void initialize(); | 263 void initialize(); |
| 245 void uninitialize(); | 264 void uninitialize(); |
| 246 | 265 |
| 247 // ExecutionContext calls stop twice. | 266 // ExecutionContext calls stop twice. |
| 248 // We'd like to schedule only one stop action for them. | 267 // We'd like to schedule only one stop action for them. |
| 249 bool m_isStopScheduled; | 268 bool m_isStopScheduled; |
| 250 bool m_isCleared; | 269 bool m_isCleared; |
| 251 void clear(); | 270 void clear(); |
| 252 | 271 |
| 253 void throwExceptionForClosedState(ExceptionState&); | 272 void throwExceptionForClosedState(ExceptionState&); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 272 // Oilpan: This Vector holds connection references. We must call | 291 // Oilpan: This Vector holds connection references. We must call |
| 273 // AudioHandler::makeConnection when we add an AudioNode to this, and must | 292 // AudioHandler::makeConnection when we add an AudioNode to this, and must |
| 274 // call AudioHandler::breakConnection() when we remove an AudioNode from | 293 // call AudioHandler::breakConnection() when we remove an AudioNode from |
| 275 // this. | 294 // this. |
| 276 HeapVector<Member<AudioNode>> m_activeSourceNodes; | 295 HeapVector<Member<AudioNode>> m_activeSourceNodes; |
| 277 | 296 |
| 278 // Stop rendering the audio graph. | 297 // Stop rendering the audio graph. |
| 279 void stopRendering(); | 298 void stopRendering(); |
| 280 | 299 |
| 281 // Handle Promises for resume() and suspend() | 300 // Handle Promises for resume() and suspend() |
| 282 void resolvePromisesForResume(); | 301 void resolvePromisesForSuspendResume(); |
| 283 void resolvePromisesForResumeOnMainThread(); | 302 void resolvePromisesForSuspendResumeOnMainThread(); |
| 284 | 303 |
| 285 void resolvePromisesForSuspend(); | 304 // Vector of promises created by suspend() and resume(). It takes time to h andle them, so we |
| 286 void resolvePromisesForSuspendOnMainThread(); | 305 // collect all of the promises here until they can be resolved or rejected. We can then also |
| 306 // process them in the order in which suspend/resume was called. | |
| 307 Vector<SuspendResumeResolver*> m_suspendResumeResolvers; | |
| 287 | 308 |
| 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(); | 309 void rejectPendingResolvers(); |
| 294 | 310 |
| 295 // True if we're in the process of resolving promises for resume(). Resolvi ng can take some | 311 // 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 | 312 // take some time and the audio context process loop is very fast, so we don 't want to call |
| 297 // excessive number of times. | 313 // resolve an excessive number of times. |
| 298 bool m_isResolvingResumePromises; | 314 bool m_isResolvingSuspendResumePromises; |
| 299 | 315 |
| 300 unsigned m_connectionCount; | 316 unsigned m_connectionCount; |
| 301 | 317 |
| 302 // Graph locking. | 318 // Graph locking. |
| 303 bool m_didInitializeContextGraphMutex; | 319 bool m_didInitializeContextGraphMutex; |
| 304 RefPtr<DeferredTaskHandler> m_deferredTaskHandler; | 320 RefPtr<DeferredTaskHandler> m_deferredTaskHandler; |
| 305 | 321 |
| 306 Member<AudioBuffer> m_renderTarget; | 322 Member<AudioBuffer> m_renderTarget; |
| 307 | 323 |
| 308 bool m_isOfflineContext; | 324 bool m_isOfflineContext; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 327 // This is considering 32 is large enough for multiple channels audio. | 343 // This is considering 32 is large enough for multiple channels audio. |
| 328 // It is somewhat arbitrary and could be increased if necessary. | 344 // It is somewhat arbitrary and could be increased if necessary. |
| 329 enum { MaxNumberOfChannels = 32 }; | 345 enum { MaxNumberOfChannels = 32 }; |
| 330 | 346 |
| 331 unsigned m_contextId; | 347 unsigned m_contextId; |
| 332 }; | 348 }; |
| 333 | 349 |
| 334 } // namespace blink | 350 } // namespace blink |
| 335 | 351 |
| 336 #endif // AudioContext_h | 352 #endif // AudioContext_h |
| OLD | NEW |