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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 #include "wtf/build_config.h" | 47 #include "wtf/build_config.h" |
| 48 | 48 |
| 49 namespace blink { | 49 namespace blink { |
| 50 | 50 |
| 51 class AnalyserNode; | 51 class AnalyserNode; |
| 52 class AudioBuffer; | 52 class AudioBuffer; |
| 53 class AudioBufferCallback; | 53 class AudioBufferCallback; |
| 54 class AudioBufferSourceNode; | 54 class AudioBufferSourceNode; |
| 55 class AudioListener; | 55 class AudioListener; |
| 56 class AudioSummingJunction; | 56 class AudioSummingJunction; |
| 57 class BaseAudioContextTest; | |
| 57 class BiquadFilterNode; | 58 class BiquadFilterNode; |
| 58 class ChannelMergerNode; | 59 class ChannelMergerNode; |
| 59 class ChannelSplitterNode; | 60 class ChannelSplitterNode; |
| 60 class ConvolverNode; | 61 class ConvolverNode; |
| 61 class DelayNode; | 62 class DelayNode; |
| 62 class Dictionary; | 63 class Dictionary; |
| 63 class Document; | 64 class Document; |
| 64 class DynamicsCompressorNode; | 65 class DynamicsCompressorNode; |
| 65 class ExceptionState; | 66 class ExceptionState; |
| 66 class GainNode; | 67 class GainNode; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 // - it has been stopped by its execution context. | 291 // - it has been stopped by its execution context. |
| 291 virtual bool isContextClosed() const { return m_isCleared; } | 292 virtual bool isContextClosed() const { return m_isCleared; } |
| 292 | 293 |
| 293 // Get the security origin for this audio context. | 294 // Get the security origin for this audio context. |
| 294 SecurityOrigin* getSecurityOrigin() const; | 295 SecurityOrigin* getSecurityOrigin() const; |
| 295 | 296 |
| 296 // Get the PeriodicWave for the specified oscillator type. The table is | 297 // Get the PeriodicWave for the specified oscillator type. The table is |
| 297 // initialized internally if necessary. | 298 // initialized internally if necessary. |
| 298 PeriodicWave* periodicWave(int type); | 299 PeriodicWave* periodicWave(int type); |
| 299 | 300 |
| 301 // For metrics purpose, records when start() is called on a | |
| 302 // AudioScheduledSourceHandler or a AudioBufferSourceHandler without a user | |
| 303 // gesture while the AudioContext is locked. | |
| 304 void maybeRecordStartAttempt(); | |
| 305 | |
| 300 protected: | 306 protected: |
| 301 explicit BaseAudioContext(Document*); | 307 explicit BaseAudioContext(Document*); |
| 302 BaseAudioContext(Document*, | 308 BaseAudioContext(Document*, |
| 303 unsigned numberOfChannels, | 309 unsigned numberOfChannels, |
| 304 size_t numberOfFrames, | 310 size_t numberOfFrames, |
| 305 float sampleRate); | 311 float sampleRate); |
| 306 | 312 |
| 307 void initialize(); | 313 void initialize(); |
| 308 void uninitialize(); | 314 void uninitialize(); |
| 309 | 315 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 333 void rejectPendingDecodeAudioDataResolvers(); | 339 void rejectPendingDecodeAudioDataResolvers(); |
| 334 | 340 |
| 335 // If any, unlock user gesture requirements if a user gesture is being | 341 // If any, unlock user gesture requirements if a user gesture is being |
| 336 // processed. | 342 // processed. |
| 337 void maybeUnlockUserGesture(); | 343 void maybeUnlockUserGesture(); |
| 338 | 344 |
| 339 // Returns whether the AudioContext is allowed to start rendering. | 345 // Returns whether the AudioContext is allowed to start rendering. |
| 340 bool isAllowedToStart() const; | 346 bool isAllowedToStart() const; |
| 341 | 347 |
| 342 private: | 348 private: |
| 349 friend class BaseAudioContextTest; | |
| 350 | |
| 351 // Do not change the order of this enum, it is used for metrics. | |
| 352 enum AutoplayStatus { | |
|
Raymond Toy
2016/10/10 17:05:10
"AutoPlay" or "Autoplay"? If you had written compl
mlamouri (slow - plz ping)
2016/10/10 18:44:40
We use "autoplay" in one word in Chrome (and most
| |
| 353 AutoplayStatusFailed = 0, | |
|
Raymond Toy
2016/10/10 17:05:10
This doesn't seem to quite match the histogram enu
mlamouri (slow - plz ping)
2016/10/10 18:44:40
Sorry about this, I forgot to update the histogram
| |
| 354 AutoplayStatusFailedWithStart = 1, | |
| 355 AutoplayStatusSucceeded = 3, | |
|
Raymond Toy
2016/10/10 17:05:10
Why 3 and not 2?
Plus, this doesn't match the his
mlamouri (slow - plz ping)
2016/10/10 18:44:40
Oups. Same cause, I changed histograms and forgot
| |
| 356 | |
| 357 // Keep at the end. | |
| 358 AutoplayStatusCount | |
| 359 }; | |
| 360 | |
| 343 bool m_isCleared; | 361 bool m_isCleared; |
| 344 void clear(); | 362 void clear(); |
| 345 | 363 |
| 346 // When the context goes away, there might still be some sources which | 364 // When the context goes away, there might still be some sources which |
| 347 // haven't finished playing. Make sure to release them here. | 365 // haven't finished playing. Make sure to release them here. |
| 348 void releaseActiveSourceNodes(); | 366 void releaseActiveSourceNodes(); |
| 349 | 367 |
| 350 void removeFinishedSourceNodes(); | 368 void removeFinishedSourceNodes(); |
| 351 | 369 |
| 352 // Listener for the PannerNodes | 370 // Listener for the PannerNodes |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 374 // FIXME(dominicc): Move these to AudioContext because only | 392 // FIXME(dominicc): Move these to AudioContext because only |
| 375 // it creates these Promises. | 393 // it creates these Promises. |
| 376 // Handle Promises for resume() and suspend() | 394 // Handle Promises for resume() and suspend() |
| 377 void resolvePromisesForResume(); | 395 void resolvePromisesForResume(); |
| 378 void resolvePromisesForResumeOnMainThread(); | 396 void resolvePromisesForResumeOnMainThread(); |
| 379 | 397 |
| 380 // When the context is going away, reject any pending script promise | 398 // When the context is going away, reject any pending script promise |
| 381 // resolvers. | 399 // resolvers. |
| 382 virtual void rejectPendingResolvers(); | 400 virtual void rejectPendingResolvers(); |
| 383 | 401 |
| 402 // Record the current autoplay status and clear it. | |
|
Raymond Toy
2016/10/10 17:05:10
It seems this is intended to be called only when t
| |
| 403 void recordAutoplayStatus(); | |
| 404 | |
| 384 // True if we're in the process of resolving promises for resume(). Resolving | 405 // True if we're in the process of resolving promises for resume(). Resolving |
| 385 // can take some time and the audio context process loop is very fast, so we | 406 // can take some time and the audio context process loop is very fast, so we |
| 386 // don't want to call resolve an excessive number of times. | 407 // don't want to call resolve an excessive number of times. |
| 387 bool m_isResolvingResumePromises; | 408 bool m_isResolvingResumePromises; |
| 388 | 409 |
| 389 // Whether a user gesture is required to start this AudioContext. | 410 // Whether a user gesture is required to start this AudioContext. |
| 390 bool m_userGestureRequired; | 411 bool m_userGestureRequired; |
| 391 | 412 |
| 392 unsigned m_connectionCount; | 413 unsigned m_connectionCount; |
| 393 | 414 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 413 // sample rate. so they can be shared with all OscillatorNodes in the context. | 434 // sample rate. so they can be shared with all OscillatorNodes in the context. |
| 414 // To conserve memory, these are lazily initialized on first use. | 435 // To conserve memory, these are lazily initialized on first use. |
| 415 Member<PeriodicWave> m_periodicWaveSine; | 436 Member<PeriodicWave> m_periodicWaveSine; |
| 416 Member<PeriodicWave> m_periodicWaveSquare; | 437 Member<PeriodicWave> m_periodicWaveSquare; |
| 417 Member<PeriodicWave> m_periodicWaveSawtooth; | 438 Member<PeriodicWave> m_periodicWaveSawtooth; |
| 418 Member<PeriodicWave> m_periodicWaveTriangle; | 439 Member<PeriodicWave> m_periodicWaveTriangle; |
| 419 | 440 |
| 420 // This is considering 32 is large enough for multiple channels audio. | 441 // This is considering 32 is large enough for multiple channels audio. |
| 421 // It is somewhat arbitrary and could be increased if necessary. | 442 // It is somewhat arbitrary and could be increased if necessary. |
| 422 enum { MaxNumberOfChannels = 32 }; | 443 enum { MaxNumberOfChannels = 32 }; |
| 444 | |
| 445 Optional<AutoplayStatus> m_autoplayStatus; | |
| 423 }; | 446 }; |
| 424 | 447 |
| 425 } // namespace blink | 448 } // namespace blink |
| 426 | 449 |
| 427 #endif // BaseAudioContext_h | 450 #endif // BaseAudioContext_h |
| OLD | NEW |