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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 // Arbitrarly limit the maximum length to 1 million frames (about 20 sec | 246 // Arbitrarly limit the maximum length to 1 million frames (about 20 sec |
| 247 // at 48kHz). The number of buckets is fairly arbitrary. | 247 // at 48kHz). The number of buckets is fairly arbitrary. |
| 248 DEFINE_STATIC_LOCAL(CustomCountHistogram, audioBufferLengthHistogram, | 248 DEFINE_STATIC_LOCAL(CustomCountHistogram, audioBufferLengthHistogram, |
| 249 ("WebAudio.AudioBuffer.Length", 1, 1000000, 50)); | 249 ("WebAudio.AudioBuffer.Length", 1, 1000000, 50)); |
| 250 // The limits are the min and max AudioBuffer sample rates currently | 250 // The limits are the min and max AudioBuffer sample rates currently |
| 251 // supported. We use explicit values here instead of | 251 // supported. We use explicit values here instead of |
| 252 // AudioUtilities::minAudioBufferSampleRate() and | 252 // AudioUtilities::minAudioBufferSampleRate() and |
| 253 // AudioUtilities::maxAudioBufferSampleRate(). The number of buckets is | 253 // AudioUtilities::maxAudioBufferSampleRate(). The number of buckets is |
| 254 // fairly arbitrary. | 254 // fairly arbitrary. |
| 255 DEFINE_STATIC_LOCAL(CustomCountHistogram, audioBufferSampleRateHistogram , | 255 DEFINE_STATIC_LOCAL(CustomCountHistogram, audioBufferSampleRateHistogram , |
| 256 ("WebAudio.AudioBuffer.SampleRate", 3000, 192000, 60)); | 256 ("WebAudio.AudioBuffer.SampleRate384k", 3000, 384000, 60)); |
| 257 | 257 |
| 258 audioBufferChannelsHistogram.sample(numberOfChannels); | 258 audioBufferChannelsHistogram.sample(numberOfChannels); |
| 259 audioBufferLengthHistogram.count(numberOfFrames); | 259 audioBufferLengthHistogram.count(numberOfFrames); |
| 260 audioBufferSampleRateHistogram.count(sampleRate); | 260 audioBufferSampleRateHistogram.count(sampleRate); |
| 261 | 261 |
| 262 // Compute the ratio of the buffer rate and the context rate so we know | 262 // Compute the ratio of the buffer rate and the context rate so we know |
| 263 // how often the buffer needs to be resampled to match the context. For | 263 // how often the buffer needs to be resampled to match the context. For |
| 264 // the histogram, we multiply the ratio by 100 and round to the nearest | 264 // the histogram, we multiply the ratio by 100 and round to the nearest |
| 265 // integer. If the context is closed, don't record this because we | 265 // integer. If the context is closed, don't record this because we |
| 266 // don't have a sample rate for closed context. | 266 // don't have a sample rate for closed context. |
| 267 if (!isContextClosed()) { | 267 if (!isContextClosed()) { |
| 268 // The limits are choosen from 100*(3000/192000) = 1.5625 and | 268 // The limits are choosen from 100*(3000/384000) = 0.78125 and |
| 269 // 100*(192000/3000) = 6400, where 3000 and 192000 are the current | 269 // 100*(384000/3000) = 12800, where 3000 and 384000 are the current |
| 270 // min and max sample rates possible for an AudioBuffer. The number | 270 // min and max sample rates possible for an AudioBuffer. The number |
| 271 // of buckets is fairly arbitrary. | 271 // of buckets is fairly arbitrary. |
| 272 DEFINE_STATIC_LOCAL(CustomCountHistogram, audioBufferSampleRateRatio Histogram, | 272 DEFINE_STATIC_LOCAL(CustomCountHistogram, audioBufferSampleRateRatio Histogram, |
| 273 ("WebAudio.AudioBuffer.SampleRateRatio", 1, 6400, 50)); | 273 ("WebAudio.AudioBuffer.SampleRateRatio384K", 0, 12800, 50)); |
|
Mark P
2016/09/15 23:16:31
Min of histogram should always be "1". There will
Raymond Toy
2016/10/10 16:28:32
Done.
| |
| 274 float ratio = 100 * sampleRate / this->sampleRate(); | 274 float ratio = 100 * sampleRate / this->sampleRate(); |
| 275 audioBufferSampleRateRatioHistogram.count(static_cast<int>(0.5 + rat io)); | 275 audioBufferSampleRateRatioHistogram.count(static_cast<int>(0.5 + rat io)); |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 | 278 |
| 279 return buffer; | 279 return buffer; |
| 280 } | 280 } |
| 281 | 281 |
| 282 ScriptPromise BaseAudioContext::decodeAudioData(ScriptState* scriptState, DOMArr ayBuffer* audioData, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, ExceptionState& exceptionState) | 282 ScriptPromise BaseAudioContext::decodeAudioData(ScriptState* scriptState, DOMArr ayBuffer* audioData, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, ExceptionState& exceptionState) |
| 283 { | 283 { |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 839 | 839 |
| 840 SecurityOrigin* BaseAudioContext::getSecurityOrigin() const | 840 SecurityOrigin* BaseAudioContext::getSecurityOrigin() const |
| 841 { | 841 { |
| 842 if (getExecutionContext()) | 842 if (getExecutionContext()) |
| 843 return getExecutionContext()->getSecurityOrigin(); | 843 return getExecutionContext()->getSecurityOrigin(); |
| 844 | 844 |
| 845 return nullptr; | 845 return nullptr; |
| 846 } | 846 } |
| 847 | 847 |
| 848 } // namespace blink | 848 } // namespace blink |
| OLD | NEW |