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

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

Issue 2159403002: Replace ASSERT with DCHECK in WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 PassRefPtr<ChannelMergerHandler> ChannelMergerHandler::create(AudioNode& node, f loat sampleRate, unsigned numberOfInputs) 58 PassRefPtr<ChannelMergerHandler> ChannelMergerHandler::create(AudioNode& node, f loat sampleRate, unsigned numberOfInputs)
59 { 59 {
60 return adoptRef(new ChannelMergerHandler(node, sampleRate, numberOfInputs)); 60 return adoptRef(new ChannelMergerHandler(node, sampleRate, numberOfInputs));
61 } 61 }
62 62
63 void ChannelMergerHandler::process(size_t framesToProcess) 63 void ChannelMergerHandler::process(size_t framesToProcess)
64 { 64 {
65 AudioNodeOutput& output = this->output(0); 65 AudioNodeOutput& output = this->output(0);
66 ASSERT_UNUSED(framesToProcess, framesToProcess == output.bus()->length()); 66 DCHECK_EQ(framesToProcess, output.bus()->length());
67 67
68 unsigned numberOfOutputChannels = output.numberOfChannels(); 68 unsigned numberOfOutputChannels = output.numberOfChannels();
69 ASSERT(numberOfInputs() == numberOfOutputChannels); 69 DCHECK_EQ(numberOfInputs(), numberOfOutputChannels);
70 70
71 // Merge multiple inputs into one output. 71 // Merge multiple inputs into one output.
72 for (unsigned i = 0; i < numberOfOutputChannels; ++i) { 72 for (unsigned i = 0; i < numberOfOutputChannels; ++i) {
73 AudioNodeInput& input = this->input(i); 73 AudioNodeInput& input = this->input(i);
74 ASSERT(input.numberOfChannels() == 1); 74 DCHECK_EQ(input.numberOfChannels(), 1u);
75 AudioChannel* outputChannel = output.bus()->channel(i); 75 AudioChannel* outputChannel = output.bus()->channel(i);
76 if (input.isConnected()) { 76 if (input.isConnected()) {
77 77
78 // The mixing rules will be applied so multiple channels are down- 78 // The mixing rules will be applied so multiple channels are down-
79 // mixed to mono (when the mixing rule is defined). Note that only 79 // mixed to mono (when the mixing rule is defined). Note that only
80 // the first channel will be taken for the undefined input channel 80 // the first channel will be taken for the undefined input channel
81 // layout. 81 // layout.
82 // 82 //
83 // See: http://webaudio.github.io/web-audio-api/#channel-up-mixing-a nd-down-mixing 83 // See: http://webaudio.github.io/web-audio-api/#channel-up-mixing-a nd-down-mixing
84 AudioChannel* inputChannel = input.bus()->channel(0); 84 AudioChannel* inputChannel = input.bus()->channel(0);
85 outputChannel->copyFrom(inputChannel); 85 outputChannel->copyFrom(inputChannel);
86 86
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 DCHECK(isMainThread());
97 BaseAudioContext::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 DCHECK(isMainThread());
110 BaseAudioContext::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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 BaseAudioContext::maxNumberOfChannels(), 153 BaseAudioContext::maxNumberOfChannels(),
154 ExceptionMessages::InclusiveBound)); 154 ExceptionMessages::InclusiveBound));
155 return nullptr; 155 return nullptr;
156 } 156 }
157 157
158 return new ChannelMergerNode(context, numberOfInputs); 158 return new ChannelMergerNode(context, numberOfInputs);
159 } 159 }
160 160
161 } // namespace blink 161 } // namespace blink
162 162
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698