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

Unified Diff: third_party/WebKit/Source/modules/webaudio/MediaStreamAudioDestinationNode.cpp

Issue 2578243002: Add constructor for MediaStreamAudioDestinationNode (Closed)
Patch Set: Rebase Created 4 years 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
Index: third_party/WebKit/Source/modules/webaudio/MediaStreamAudioDestinationNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/MediaStreamAudioDestinationNode.cpp b/third_party/WebKit/Source/modules/webaudio/MediaStreamAudioDestinationNode.cpp
index 29fb96a68bbff989771eedb476e651c3f2699bf4..c36de7add71c18a17ea0ee7d5b2afbff35e00fbd 100644
--- a/third_party/WebKit/Source/modules/webaudio/MediaStreamAudioDestinationNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/MediaStreamAudioDestinationNode.cpp
@@ -28,6 +28,7 @@
#include "bindings/core/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "modules/webaudio/AudioNodeInput.h"
+#include "modules/webaudio/AudioNodeOptions.h"
#include "modules/webaudio/BaseAudioContext.h"
#include "platform/UUID.h"
#include "platform/mediastream/MediaStreamCenter.h"
@@ -115,9 +116,9 @@ void MediaStreamAudioDestinationHandler::setChannelCount(
// which is constrained by m_source (WebAudioCapturereSource). Although
// it has its own safety check for the excessive channels, throwing an
// exception here is useful to developers.
- if (channelCount > maxChannelCount()) {
+ if (channelCount < 1 || channelCount > maxChannelCount()) {
exceptionState.throwDOMException(
- IndexSizeError,
+ NotSupportedError,
ExceptionMessages::indexOutsideRange<unsigned>(
"channel count", channelCount, 1, ExceptionMessages::InclusiveBound,
maxChannelCount(), ExceptionMessages::InclusiveBound));
@@ -159,6 +160,28 @@ MediaStreamAudioDestinationNode* MediaStreamAudioDestinationNode::create(
return new MediaStreamAudioDestinationNode(context, numberOfChannels);
}
+MediaStreamAudioDestinationNode* MediaStreamAudioDestinationNode::create(
+ BaseAudioContext* context,
+ const AudioNodeOptions& options,
+ ExceptionState& exceptionState) {
+ DCHECK(isMainThread());
+
+ // Default to stereo; |options| will update it approriately if needed.
+ MediaStreamAudioDestinationNode* node =
+ new MediaStreamAudioDestinationNode(*context, 2);
+
+ // Need to handle channelCount here ourselves because the upper
+ // limit is different from the normal AudioNode::setChannelCount
+ // limit of 32. Error messages will sometimes show the wrong
+ // limits.
+ if (options.hasChannelCount())
+ node->setChannelCount(options.channelCount(), exceptionState);
+
+ node->handleChannelOptions(options, exceptionState);
+
+ return node;
+}
+
MediaStream* MediaStreamAudioDestinationNode::stream() const {
return static_cast<MediaStreamAudioDestinationHandler&>(handler()).stream();
}

Powered by Google App Engine
This is Rietveld 408576698