| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, 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 17 matching lines...) Expand all Loading... |
| 28 #include "bindings/core/v8/ScriptState.h" | 28 #include "bindings/core/v8/ScriptState.h" |
| 29 #include "core/dom/DOMException.h" | 29 #include "core/dom/DOMException.h" |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/dom/ExceptionCode.h" | 31 #include "core/dom/ExceptionCode.h" |
| 32 #include "core/dom/ExecutionContext.h" | 32 #include "core/dom/ExecutionContext.h" |
| 33 #include "modules/webaudio/AudioListener.h" | 33 #include "modules/webaudio/AudioListener.h" |
| 34 #include "modules/webaudio/DeferredTaskHandler.h" | 34 #include "modules/webaudio/DeferredTaskHandler.h" |
| 35 #include "modules/webaudio/OfflineAudioCompletionEvent.h" | 35 #include "modules/webaudio/OfflineAudioCompletionEvent.h" |
| 36 #include "modules/webaudio/OfflineAudioDestinationNode.h" | 36 #include "modules/webaudio/OfflineAudioDestinationNode.h" |
| 37 | 37 |
| 38 #include "platform/Histogram.h" |
| 38 #include "platform/audio/AudioUtilities.h" | 39 #include "platform/audio/AudioUtilities.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 OfflineAudioContext* OfflineAudioContext::create(ExecutionContext* context, unsi
gned numberOfChannels, unsigned numberOfFrames, float sampleRate, ExceptionState
& exceptionState) | 43 OfflineAudioContext* OfflineAudioContext::create(ExecutionContext* context, unsi
gned numberOfChannels, unsigned numberOfFrames, float sampleRate, ExceptionState
& exceptionState) |
| 43 { | 44 { |
| 44 // FIXME: add support for workers. | 45 // FIXME: add support for workers. |
| 45 if (!context || !context->isDocument()) { | 46 if (!context || !context->isDocument()) { |
| 46 exceptionState.throwDOMException( | 47 exceptionState.throwDOMException( |
| 47 NotSupportedError, | 48 NotSupportedError, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 84 |
| 84 if (!audioContext->destination()) { | 85 if (!audioContext->destination()) { |
| 85 exceptionState.throwDOMException( | 86 exceptionState.throwDOMException( |
| 86 NotSupportedError, | 87 NotSupportedError, |
| 87 "OfflineAudioContext(" + String::number(numberOfChannels) | 88 "OfflineAudioContext(" + String::number(numberOfChannels) |
| 88 + ", " + String::number(numberOfFrames) | 89 + ", " + String::number(numberOfFrames) |
| 89 + ", " + String::number(sampleRate) | 90 + ", " + String::number(sampleRate) |
| 90 + ")"); | 91 + ")"); |
| 91 } | 92 } |
| 92 | 93 |
| 94 DEFINE_STATIC_LOCAL(SparseHistogram, offlineContextChannelCountHistogram, |
| 95 ("WebAudio.OfflineAudioContext.ChannelCount")); |
| 96 // Arbitrarly limit the maximum length to 1 million frames (about 20 sec |
| 97 // at 48kHz). The number of buckets is fairly arbitrary. |
| 98 DEFINE_STATIC_LOCAL(CustomCountHistogram, offlineContextLengthHistogram, |
| 99 ("WebAudio.OfflineAudioContext.Length", 1, 1000000, 50)); |
| 100 // The limits are the min and max AudioBuffer sample rates currently |
| 101 // supported. We use explicit values here instead of |
| 102 // AudioUtilities::minAudioBufferSampleRate() and |
| 103 // AudioUtilities::maxAudioBufferSampleRate(). The number of buckets is |
| 104 // fairly arbitrary. |
| 105 DEFINE_STATIC_LOCAL(CustomCountHistogram, offlineContextSampleRateHistogram, |
| 106 ("WebAudio.OfflineAudioContext.SampleRate", 3000, 19200, 50)); |
| 107 |
| 108 offlineContextChannelCountHistogram.sample(numberOfChannels); |
| 109 offlineContextLengthHistogram.count(numberOfFrames); |
| 110 offlineContextSampleRateHistogram.count(sampleRate); |
| 111 |
| 93 audioContext->suspendIfNeeded(); | 112 audioContext->suspendIfNeeded(); |
| 94 return audioContext; | 113 return audioContext; |
| 95 } | 114 } |
| 96 | 115 |
| 97 OfflineAudioContext::OfflineAudioContext(Document* document, unsigned numberOfCh
annels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionState) | 116 OfflineAudioContext::OfflineAudioContext(Document* document, unsigned numberOfCh
annels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionState) |
| 98 : AbstractAudioContext(document, numberOfChannels, numberOfFrames, sampleRat
e) | 117 : AbstractAudioContext(document, numberOfChannels, numberOfFrames, sampleRat
e) |
| 99 , m_isRenderingStarted(false) | 118 , m_isRenderingStarted(false) |
| 100 , m_totalRenderFrames(numberOfFrames) | 119 , m_totalRenderFrames(numberOfFrames) |
| 101 { | 120 { |
| 102 // Create a new destination for offline rendering. | 121 // Create a new destination for offline rendering. |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 // Note that the GraphLock is required before this check. Since this needs | 435 // Note that the GraphLock is required before this check. Since this needs |
| 417 // to run on the audio thread, OfflineGraphAutoLocker must be used. | 436 // to run on the audio thread, OfflineGraphAutoLocker must be used. |
| 418 if (m_scheduledSuspends.contains(currentSampleFrame())) | 437 if (m_scheduledSuspends.contains(currentSampleFrame())) |
| 419 return true; | 438 return true; |
| 420 | 439 |
| 421 return false; | 440 return false; |
| 422 } | 441 } |
| 423 | 442 |
| 424 } // namespace blink | 443 } // namespace blink |
| 425 | 444 |
| OLD | NEW |