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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/ChannelMergerNode.cpp

Issue 1865583002: Implement BaseAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 13 matching lines...) Expand all
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "modules/webaudio/ChannelMergerNode.h" 29 #include "modules/webaudio/ChannelMergerNode.h"
30 #include "bindings/core/v8/ExceptionMessages.h" 30 #include "bindings/core/v8/ExceptionMessages.h"
31 #include "bindings/core/v8/ExceptionState.h" 31 #include "bindings/core/v8/ExceptionState.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "core/dom/ExecutionContext.h" 33 #include "core/dom/ExecutionContext.h"
34 #include "modules/webaudio/AbstractAudioContext.h"
35 #include "modules/webaudio/AudioNodeInput.h" 34 #include "modules/webaudio/AudioNodeInput.h"
36 #include "modules/webaudio/AudioNodeOutput.h" 35 #include "modules/webaudio/AudioNodeOutput.h"
36 #include "modules/webaudio/BaseAudioContext.h"
37 37
38 38
39 namespace blink { 39 namespace blink {
40 40
41 ChannelMergerHandler::ChannelMergerHandler(AudioNode& node, float sampleRate, un signed numberOfInputs) 41 ChannelMergerHandler::ChannelMergerHandler(AudioNode& node, float sampleRate, un signed numberOfInputs)
42 : AudioHandler(NodeTypeChannelMerger, node, sampleRate) 42 : AudioHandler(NodeTypeChannelMerger, node, sampleRate)
43 { 43 {
44 // These properties are fixed for the node and cannot be changed by user. 44 // These properties are fixed for the node and cannot be changed by user.
45 m_channelCount = 1; 45 m_channelCount = 1;
46 m_channelCountMode = Explicit; 46 m_channelCountMode = Explicit;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } else { 87 } else {
88 // If input is unconnected, fill zeros in the channel. 88 // If input is unconnected, fill zeros in the channel.
89 outputChannel->zero(); 89 outputChannel->zero();
90 } 90 }
91 } 91 }
92 } 92 }
93 93
94 void ChannelMergerHandler::setChannelCount(unsigned long channelCount, Exception State& exceptionState) 94 void ChannelMergerHandler::setChannelCount(unsigned long channelCount, Exception State& exceptionState)
95 { 95 {
96 ASSERT(isMainThread()); 96 ASSERT(isMainThread());
97 AbstractAudioContext::AutoLocker locker(context()); 97 BaseAudioContext::AutoLocker locker(context());
98 98
99 // channelCount must be 1. 99 // channelCount must be 1.
100 if (channelCount != 1) { 100 if (channelCount != 1) {
101 exceptionState.throwDOMException( 101 exceptionState.throwDOMException(
102 InvalidStateError, 102 InvalidStateError,
103 "ChannelMerger: channelCount cannot be changed from 1"); 103 "ChannelMerger: channelCount cannot be changed from 1");
104 } 104 }
105 } 105 }
106 106
107 void ChannelMergerHandler::setChannelCountMode(const String& mode, ExceptionStat e& exceptionState) 107 void ChannelMergerHandler::setChannelCountMode(const String& mode, ExceptionStat e& exceptionState)
108 { 108 {
109 ASSERT(isMainThread()); 109 ASSERT(isMainThread());
110 AbstractAudioContext::AutoLocker locker(context()); 110 BaseAudioContext::AutoLocker locker(context());
111 111
112 // channcelCountMode must be 'explicit'. 112 // channcelCountMode must be 'explicit'.
113 if (mode != "explicit") { 113 if (mode != "explicit") {
114 exceptionState.throwDOMException( 114 exceptionState.throwDOMException(
115 InvalidStateError, 115 InvalidStateError,
116 "ChannelMerger: channelCountMode cannot be changed from 'explicit'") ; 116 "ChannelMerger: channelCountMode cannot be changed from 'explicit'") ;
117 } 117 }
118 } 118 }
119 119
120 // ---------------------------------------------------------------- 120 // ----------------------------------------------------------------
121 121
122 ChannelMergerNode::ChannelMergerNode(AbstractAudioContext& context, float sample Rate, unsigned numberOfInputs) 122 ChannelMergerNode::ChannelMergerNode(BaseAudioContext& context, float sampleRate , unsigned numberOfInputs)
123 : AudioNode(context) 123 : AudioNode(context)
124 { 124 {
125 setHandler(ChannelMergerHandler::create(*this, sampleRate, numberOfInputs)); 125 setHandler(ChannelMergerHandler::create(*this, sampleRate, numberOfInputs));
126 } 126 }
127 127
128 ChannelMergerNode* ChannelMergerNode::create(AbstractAudioContext& context, floa t sampleRate, unsigned numberOfInputs) 128 ChannelMergerNode* ChannelMergerNode::create(BaseAudioContext& context, float sa mpleRate, unsigned numberOfInputs)
129 { 129 {
130 if (!numberOfInputs || numberOfInputs > AbstractAudioContext::maxNumberOfCha nnels()) 130 if (!numberOfInputs || numberOfInputs > BaseAudioContext::maxNumberOfChannel s())
131 return nullptr; 131 return nullptr;
132 return new ChannelMergerNode(context, sampleRate, numberOfInputs); 132 return new ChannelMergerNode(context, sampleRate, numberOfInputs);
133 } 133 }
134 134
135 } // namespace blink 135 } // namespace blink
136 136
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698