| OLD | NEW |
| 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 | 87 |
| 88 void AudioHandler::Uninitialize() { | 88 void AudioHandler::Uninitialize() { |
| 89 is_initialized_ = false; | 89 is_initialized_ = false; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void AudioHandler::ClearInternalStateWhenDisabled() {} | 92 void AudioHandler::ClearInternalStateWhenDisabled() {} |
| 93 | 93 |
| 94 void AudioHandler::Dispose() { | 94 void AudioHandler::Dispose() { |
| 95 DCHECK(IsMainThread()); | 95 DCHECK(IsMainThread()); |
| 96 ASSERT(Context()->IsGraphOwner()); | 96 DCHECK(Context()->IsGraphOwner()); |
| 97 | 97 |
| 98 Context()->GetDeferredTaskHandler().RemoveChangedChannelCountMode(this); | 98 Context()->GetDeferredTaskHandler().RemoveChangedChannelCountMode(this); |
| 99 Context()->GetDeferredTaskHandler().RemoveChangedChannelInterpretation(this); | 99 Context()->GetDeferredTaskHandler().RemoveChangedChannelInterpretation(this); |
| 100 Context()->GetDeferredTaskHandler().RemoveAutomaticPullNode(this); | 100 Context()->GetDeferredTaskHandler().RemoveAutomaticPullNode(this); |
| 101 for (auto& output : outputs_) | 101 for (auto& output : outputs_) |
| 102 output->Dispose(); | 102 output->Dispose(); |
| 103 node_ = nullptr; | 103 node_ = nullptr; |
| 104 } | 104 } |
| 105 | 105 |
| 106 AudioNode* AudioHandler::GetNode() const { | 106 AudioNode* AudioHandler::GetNode() const { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return "ChannelMergerNode"; | 146 return "ChannelMergerNode"; |
| 147 case kNodeTypeAnalyser: | 147 case kNodeTypeAnalyser: |
| 148 return "AnalyserNode"; | 148 return "AnalyserNode"; |
| 149 case kNodeTypeDynamicsCompressor: | 149 case kNodeTypeDynamicsCompressor: |
| 150 return "DynamicsCompressorNode"; | 150 return "DynamicsCompressorNode"; |
| 151 case kNodeTypeWaveShaper: | 151 case kNodeTypeWaveShaper: |
| 152 return "WaveShaperNode"; | 152 return "WaveShaperNode"; |
| 153 case kNodeTypeUnknown: | 153 case kNodeTypeUnknown: |
| 154 case kNodeTypeEnd: | 154 case kNodeTypeEnd: |
| 155 default: | 155 default: |
| 156 ASSERT_NOT_REACHED(); | 156 NOTREACHED(); |
| 157 return "UnknownNode"; | 157 return "UnknownNode"; |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 void AudioHandler::SetNodeType(NodeType type) { | 161 void AudioHandler::SetNodeType(NodeType type) { |
| 162 // Don't allow the node type to be changed to a different node type, after | 162 // Don't allow the node type to be changed to a different node type, after |
| 163 // it's already been set. And the new type can't be unknown or end. | 163 // it's already been set. And the new type can't be unknown or end. |
| 164 DCHECK_EQ(node_type_, kNodeTypeUnknown); | 164 DCHECK_EQ(node_type_, kNodeTypeUnknown); |
| 165 DCHECK_NE(type, kNodeTypeUnknown); | 165 DCHECK_NE(type, kNodeTypeUnknown); |
| 166 DCHECK_NE(type, kNodeTypeEnd); | 166 DCHECK_NE(type, kNodeTypeEnd); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // rendering phase, we want to return the value that was set, not the actual | 234 // rendering phase, we want to return the value that was set, not the actual |
| 235 // current mode. | 235 // current mode. |
| 236 switch (new_channel_count_mode_) { | 236 switch (new_channel_count_mode_) { |
| 237 case kMax: | 237 case kMax: |
| 238 return "max"; | 238 return "max"; |
| 239 case kClampedMax: | 239 case kClampedMax: |
| 240 return "clamped-max"; | 240 return "clamped-max"; |
| 241 case kExplicit: | 241 case kExplicit: |
| 242 return "explicit"; | 242 return "explicit"; |
| 243 } | 243 } |
| 244 ASSERT_NOT_REACHED(); | 244 NOTREACHED(); |
| 245 return ""; | 245 return ""; |
| 246 } | 246 } |
| 247 | 247 |
| 248 void AudioHandler::SetChannelCountMode(const String& mode, | 248 void AudioHandler::SetChannelCountMode(const String& mode, |
| 249 ExceptionState& exception_state) { | 249 ExceptionState& exception_state) { |
| 250 DCHECK(IsMainThread()); | 250 DCHECK(IsMainThread()); |
| 251 BaseAudioContext::AutoLocker locker(Context()); | 251 BaseAudioContext::AutoLocker locker(Context()); |
| 252 | 252 |
| 253 ChannelCountMode old_mode = channel_count_mode_; | 253 ChannelCountMode old_mode = channel_count_mode_; |
| 254 | 254 |
| 255 if (mode == "max") { | 255 if (mode == "max") { |
| 256 new_channel_count_mode_ = kMax; | 256 new_channel_count_mode_ = kMax; |
| 257 } else if (mode == "clamped-max") { | 257 } else if (mode == "clamped-max") { |
| 258 new_channel_count_mode_ = kClampedMax; | 258 new_channel_count_mode_ = kClampedMax; |
| 259 } else if (mode == "explicit") { | 259 } else if (mode == "explicit") { |
| 260 new_channel_count_mode_ = kExplicit; | 260 new_channel_count_mode_ = kExplicit; |
| 261 } else { | 261 } else { |
| 262 ASSERT_NOT_REACHED(); | 262 NOTREACHED(); |
| 263 } | 263 } |
| 264 | 264 |
| 265 if (new_channel_count_mode_ != old_mode) | 265 if (new_channel_count_mode_ != old_mode) |
| 266 Context()->GetDeferredTaskHandler().AddChangedChannelCountMode(this); | 266 Context()->GetDeferredTaskHandler().AddChangedChannelCountMode(this); |
| 267 } | 267 } |
| 268 | 268 |
| 269 String AudioHandler::ChannelInterpretation() { | 269 String AudioHandler::ChannelInterpretation() { |
| 270 // Because we delay the actual setting of the interpreation to the pre or | 270 // Because we delay the actual setting of the interpreation to the pre or |
| 271 // post rendering phase, we want to return the value that was set, not the | 271 // post rendering phase, we want to return the value that was set, not the |
| 272 // actual current interpretation. | 272 // actual current interpretation. |
| 273 switch (new_channel_interpretation_) { | 273 switch (new_channel_interpretation_) { |
| 274 case AudioBus::kSpeakers: | 274 case AudioBus::kSpeakers: |
| 275 return "speakers"; | 275 return "speakers"; |
| 276 case AudioBus::kDiscrete: | 276 case AudioBus::kDiscrete: |
| 277 return "discrete"; | 277 return "discrete"; |
| 278 } | 278 } |
| 279 ASSERT_NOT_REACHED(); | 279 NOTREACHED(); |
| 280 return ""; | 280 return ""; |
| 281 } | 281 } |
| 282 | 282 |
| 283 void AudioHandler::SetChannelInterpretation(const String& interpretation, | 283 void AudioHandler::SetChannelInterpretation(const String& interpretation, |
| 284 ExceptionState& exception_state) { | 284 ExceptionState& exception_state) { |
| 285 DCHECK(IsMainThread()); | 285 DCHECK(IsMainThread()); |
| 286 BaseAudioContext::AutoLocker locker(Context()); | 286 BaseAudioContext::AutoLocker locker(Context()); |
| 287 | 287 |
| 288 AudioBus::ChannelInterpretation old_mode = channel_interpretation_; | 288 AudioBus::ChannelInterpretation old_mode = channel_interpretation_; |
| 289 | 289 |
| 290 if (interpretation == "speakers") { | 290 if (interpretation == "speakers") { |
| 291 new_channel_interpretation_ = AudioBus::kSpeakers; | 291 new_channel_interpretation_ = AudioBus::kSpeakers; |
| 292 } else if (interpretation == "discrete") { | 292 } else if (interpretation == "discrete") { |
| 293 new_channel_interpretation_ = AudioBus::kDiscrete; | 293 new_channel_interpretation_ = AudioBus::kDiscrete; |
| 294 } else { | 294 } else { |
| 295 ASSERT_NOT_REACHED(); | 295 NOTREACHED(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 if (new_channel_interpretation_ != old_mode) | 298 if (new_channel_interpretation_ != old_mode) |
| 299 Context()->GetDeferredTaskHandler().AddChangedChannelInterpretation(this); | 299 Context()->GetDeferredTaskHandler().AddChangedChannelInterpretation(this); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void AudioHandler::UpdateChannelsForInputs() { | 302 void AudioHandler::UpdateChannelsForInputs() { |
| 303 for (auto& input : inputs_) | 303 for (auto& input : inputs_) |
| 304 input->ChangedOutputs(); | 304 input->ChangedOutputs(); |
| 305 } | 305 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // the downstream nodes. (For example, a Gain node with a gain of 0 will | 342 // the downstream nodes. (For example, a Gain node with a gain of 0 will |
| 343 // want to silence its output.) | 343 // want to silence its output.) |
| 344 UnsilenceOutputs(); | 344 UnsilenceOutputs(); |
| 345 Process(frames_to_process); | 345 Process(frames_to_process); |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 void AudioHandler::CheckNumberOfChannelsForInput(AudioNodeInput* input) { | 350 void AudioHandler::CheckNumberOfChannelsForInput(AudioNodeInput* input) { |
| 351 DCHECK(Context()->IsAudioThread()); | 351 DCHECK(Context()->IsAudioThread()); |
| 352 ASSERT(Context()->IsGraphOwner()); | 352 DCHECK(Context()->IsGraphOwner()); |
| 353 | 353 |
| 354 DCHECK(inputs_.Contains(input)); | 354 DCHECK(inputs_.Contains(input)); |
| 355 if (!inputs_.Contains(input)) | 355 if (!inputs_.Contains(input)) |
| 356 return; | 356 return; |
| 357 | 357 |
| 358 input->UpdateInternalBus(); | 358 input->UpdateInternalBus(); |
| 359 } | 359 } |
| 360 | 360 |
| 361 double AudioHandler::TailTime() const { | 361 double AudioHandler::TailTime() const { |
| 362 return 0; | 362 return 0; |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 } | 967 } |
| 968 | 968 |
| 969 void AudioNode::DidAddOutput(unsigned number_of_outputs) { | 969 void AudioNode::DidAddOutput(unsigned number_of_outputs) { |
| 970 connected_nodes_.push_back(nullptr); | 970 connected_nodes_.push_back(nullptr); |
| 971 DCHECK_EQ(number_of_outputs, connected_nodes_.size()); | 971 DCHECK_EQ(number_of_outputs, connected_nodes_.size()); |
| 972 connected_params_.push_back(nullptr); | 972 connected_params_.push_back(nullptr); |
| 973 DCHECK_EQ(number_of_outputs, connected_params_.size()); | 973 DCHECK_EQ(number_of_outputs, connected_params_.size()); |
| 974 } | 974 } |
| 975 | 975 |
| 976 } // namespace blink | 976 } // namespace blink |
| OLD | NEW |