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

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

Issue 1464673002: Support multichannel audio stream more than 2 in MediaStreamDestinationNode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed intdentation Created 5 years, 1 month 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 | « third_party/WebKit/Source/modules/webaudio/MediaStreamAudioDestinationNode.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 be69b5c8d497a621efd9ceb3b3876068927a129c..ea8874e7ff0145b8d8d03a516001deee7b41966a 100644
--- a/third_party/WebKit/Source/modules/webaudio/MediaStreamAudioDestinationNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/MediaStreamAudioDestinationNode.cpp
@@ -26,6 +26,9 @@
#if ENABLE(WEB_AUDIO)
#include "modules/webaudio/MediaStreamAudioDestinationNode.h"
+#include "bindings/core/v8/ExceptionMessages.h"
+#include "bindings/core/v8/ExceptionState.h"
+#include "core/dom/ExceptionCode.h"
#include "modules/webaudio/AbstractAudioContext.h"
#include "modules/webaudio/AudioNodeInput.h"
#include "platform/UUID.h"
@@ -35,6 +38,10 @@
namespace blink {
+// WebAudioCapturerSource ignores the channel count beyond 8, so we set the
+// block here to avoid anything can cause the crash.
+static unsigned long kMaxChannelCount = 8;
+
MediaStreamAudioDestinationHandler::MediaStreamAudioDestinationHandler(AudioNode& node, size_t numberOfChannels)
: AudioBasicInspectorHandler(NodeTypeMediaStreamAudioDestination, node, node.context()->sampleRate(), numberOfChannels)
, m_mixBus(AudioBus::create(numberOfChannels, ProcessingSizeInFrames))
@@ -63,10 +70,53 @@ MediaStreamAudioDestinationHandler::~MediaStreamAudioDestinationHandler()
void MediaStreamAudioDestinationHandler::process(size_t numberOfFrames)
{
+ // Conform the input bus into the internal mix bus, which represents
+ // MediaStreamDestination's channel count.
m_mixBus->copyFrom(*input(0).bus());
+
m_source->consumeAudio(m_mixBus.get(), numberOfFrames);
}
+void MediaStreamAudioDestinationHandler::setChannelCount(unsigned long channelCount, ExceptionState& exceptionState)
+{
+ ASSERT(isMainThread());
+
+ // Currently the maximum channel count supported for this node is 8,
+ // 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()) {
+ exceptionState.throwDOMException(
+ IndexSizeError,
+ ExceptionMessages::indexOutsideRange<unsigned>("channel count",
+ channelCount,
+ 1,
+ ExceptionMessages::InclusiveBound,
+ maxChannelCount(),
+ ExceptionMessages::InclusiveBound));
+ return;
+ }
+
+ unsigned long oldChannelCount = this->channelCount();
+ AudioHandler::setChannelCount(channelCount, exceptionState);
+
+ // Update the pipeline with the new channel count only if absolutely
+ // necessary. This process requires the graph lock.
+ //
+ // TODO(hongchan): There might be a data race here since both threads
+ // have access to m_mixBus.
+ if (!exceptionState.hadException() && this->channelCount() != oldChannelCount && isInitialized()) {
+ AbstractAudioContext::AutoLocker locker(context());
+ m_mixBus = AudioBus::create(channelCount, ProcessingSizeInFrames);
+ m_source->setAudioFormat(channelCount, context()->sampleRate());
+ }
+}
+
+unsigned long MediaStreamAudioDestinationHandler::maxChannelCount() const
+{
+ return kMaxChannelCount;
+}
+
// ----------------------------------------------------------------
MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(AbstractAudioContext& context, size_t numberOfChannels)
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/MediaStreamAudioDestinationNode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698