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

Unified Diff: Source/modules/webaudio/MediaElementAudioSourceNode.cpp

Issue 565643003: Move utility functions for sample rate to AudioUtilities. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add modification in MediaElementSourceNode. Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/webaudio/AudioContext.cpp ('k') | Source/modules/webaudio/OfflineAudioContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/MediaElementAudioSourceNode.cpp
diff --git a/Source/modules/webaudio/MediaElementAudioSourceNode.cpp b/Source/modules/webaudio/MediaElementAudioSourceNode.cpp
index e0812428868b5512fb97840db09ff06ab8a6941e..6d1204232ef01854e36e41ad743c4d2b65ab41d0 100644
--- a/Source/modules/webaudio/MediaElementAudioSourceNode.cpp
+++ b/Source/modules/webaudio/MediaElementAudioSourceNode.cpp
@@ -32,13 +32,10 @@
#include "modules/webaudio/AudioContext.h"
#include "modules/webaudio/AudioNodeOutput.h"
#include "platform/Logging.h"
+#include "platform/audio/AudioUtilities.h"
#include "platform/graphics/media/MediaPlayer.h"
#include "wtf/Locker.h"
-// These are somewhat arbitrary limits, but we need to do some kind of sanity-checking.
-const unsigned minSampleRate = 8000;
-const unsigned maxSampleRate = 192000;
-
namespace blink {
MediaElementAudioSourceNode* MediaElementAudioSourceNode::create(AudioContext* context, HTMLMediaElement* mediaElement)
@@ -76,7 +73,7 @@ void MediaElementAudioSourceNode::dispose()
void MediaElementAudioSourceNode::setFormat(size_t numberOfChannels, float sourceSampleRate)
{
if (numberOfChannels != m_sourceNumberOfChannels || sourceSampleRate != m_sourceSampleRate) {
- if (!numberOfChannels || numberOfChannels > AudioContext::maxNumberOfChannels() || sourceSampleRate < minSampleRate || sourceSampleRate > maxSampleRate) {
+ if (!numberOfChannels || numberOfChannels > AudioContext::maxNumberOfChannels() || !AudioUtilities::isValidAudioBufferSampleRate(sourceSampleRate)) {
// process() will generate silence for these uninitialized values.
WTF_LOG(Media, "MediaElementAudioSourceNode::setFormat(%u, %f) - unhandled format change", static_cast<unsigned>(numberOfChannels), sourceSampleRate);
m_sourceNumberOfChannels = 0;
« no previous file with comments | « Source/modules/webaudio/AudioContext.cpp ('k') | Source/modules/webaudio/OfflineAudioContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698