| 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 26 matching lines...) Expand all Loading... |
| 37 // Set to mono by default. | 37 // Set to mono by default. |
| 38 internal_summing_bus_ = | 38 internal_summing_bus_ = |
| 39 AudioBus::Create(1, AudioUtilities::kRenderQuantumFrames); | 39 AudioBus::Create(1, AudioUtilities::kRenderQuantumFrames); |
| 40 } | 40 } |
| 41 | 41 |
| 42 std::unique_ptr<AudioNodeInput> AudioNodeInput::Create(AudioHandler& handler) { | 42 std::unique_ptr<AudioNodeInput> AudioNodeInput::Create(AudioHandler& handler) { |
| 43 return WTF::WrapUnique(new AudioNodeInput(handler)); | 43 return WTF::WrapUnique(new AudioNodeInput(handler)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void AudioNodeInput::Connect(AudioNodeOutput& output) { | 46 void AudioNodeInput::Connect(AudioNodeOutput& output) { |
| 47 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 47 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 48 | 48 |
| 49 // Check if we're already connected to this output. | 49 // Check if we're already connected to this output. |
| 50 if (outputs_.Contains(&output)) | 50 if (outputs_.Contains(&output)) |
| 51 return; | 51 return; |
| 52 | 52 |
| 53 output.AddInput(*this); | 53 output.AddInput(*this); |
| 54 outputs_.insert(&output); | 54 outputs_.insert(&output); |
| 55 ChangedOutputs(); | 55 ChangedOutputs(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void AudioNodeInput::Disconnect(AudioNodeOutput& output) { | 58 void AudioNodeInput::Disconnect(AudioNodeOutput& output) { |
| 59 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 59 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 60 | 60 |
| 61 // First try to disconnect from "active" connections. | 61 // First try to disconnect from "active" connections. |
| 62 if (outputs_.Contains(&output)) { | 62 if (outputs_.Contains(&output)) { |
| 63 outputs_.erase(&output); | 63 outputs_.erase(&output); |
| 64 ChangedOutputs(); | 64 ChangedOutputs(); |
| 65 output.RemoveInput(*this); | 65 output.RemoveInput(*this); |
| 66 // Note: it's important to return immediately after removeInput() calls | 66 // Note: it's important to return immediately after removeInput() calls |
| 67 // since the node may be deleted. | 67 // since the node may be deleted. |
| 68 return; | 68 return; |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Otherwise, try to disconnect from disabled connections. | 71 // Otherwise, try to disconnect from disabled connections. |
| 72 if (disabled_outputs_.Contains(&output)) { | 72 if (disabled_outputs_.Contains(&output)) { |
| 73 disabled_outputs_.erase(&output); | 73 disabled_outputs_.erase(&output); |
| 74 output.RemoveInput(*this); | 74 output.RemoveInput(*this); |
| 75 // Note: it's important to return immediately after all removeInput() calls | 75 // Note: it's important to return immediately after all removeInput() calls |
| 76 // since the node may be deleted. | 76 // since the node may be deleted. |
| 77 return; | 77 return; |
| 78 } | 78 } |
| 79 | 79 |
| 80 ASSERT_NOT_REACHED(); | 80 NOTREACHED(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void AudioNodeInput::Disable(AudioNodeOutput& output) { | 83 void AudioNodeInput::Disable(AudioNodeOutput& output) { |
| 84 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 84 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 85 DCHECK(outputs_.Contains(&output)); | 85 DCHECK(outputs_.Contains(&output)); |
| 86 | 86 |
| 87 disabled_outputs_.insert(&output); | 87 disabled_outputs_.insert(&output); |
| 88 outputs_.erase(&output); | 88 outputs_.erase(&output); |
| 89 ChangedOutputs(); | 89 ChangedOutputs(); |
| 90 | 90 |
| 91 // Propagate disabled state to outputs. | 91 // Propagate disabled state to outputs. |
| 92 Handler().DisableOutputsIfNecessary(); | 92 Handler().DisableOutputsIfNecessary(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void AudioNodeInput::Enable(AudioNodeOutput& output) { | 95 void AudioNodeInput::Enable(AudioNodeOutput& output) { |
| 96 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 96 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 97 | 97 |
| 98 // Move output from disabled list to active list. | 98 // Move output from disabled list to active list. |
| 99 outputs_.insert(&output); | 99 outputs_.insert(&output); |
| 100 if (disabled_outputs_.size() > 0) { | 100 if (disabled_outputs_.size() > 0) { |
| 101 DCHECK(disabled_outputs_.Contains(&output)); | 101 DCHECK(disabled_outputs_.Contains(&output)); |
| 102 disabled_outputs_.erase(&output); | 102 disabled_outputs_.erase(&output); |
| 103 } | 103 } |
| 104 ChangedOutputs(); | 104 ChangedOutputs(); |
| 105 | 105 |
| 106 // Propagate enabled state to outputs. | 106 // Propagate enabled state to outputs. |
| 107 Handler().EnableOutputsIfNecessary(); | 107 Handler().EnableOutputsIfNecessary(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void AudioNodeInput::DidUpdate() { | 110 void AudioNodeInput::DidUpdate() { |
| 111 Handler().CheckNumberOfChannelsForInput(this); | 111 Handler().CheckNumberOfChannelsForInput(this); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void AudioNodeInput::UpdateInternalBus() { | 114 void AudioNodeInput::UpdateInternalBus() { |
| 115 DCHECK(GetDeferredTaskHandler().IsAudioThread()); | 115 DCHECK(GetDeferredTaskHandler().IsAudioThread()); |
| 116 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 116 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 117 | 117 |
| 118 unsigned number_of_input_channels = NumberOfChannels(); | 118 unsigned number_of_input_channels = NumberOfChannels(); |
| 119 | 119 |
| 120 if (number_of_input_channels == internal_summing_bus_->NumberOfChannels()) | 120 if (number_of_input_channels == internal_summing_bus_->NumberOfChannels()) |
| 121 return; | 121 return; |
| 122 | 122 |
| 123 internal_summing_bus_ = AudioBus::Create( | 123 internal_summing_bus_ = AudioBus::Create( |
| 124 number_of_input_channels, AudioUtilities::kRenderQuantumFrames); | 124 number_of_input_channels, AudioUtilities::kRenderQuantumFrames); |
| 125 } | 125 } |
| 126 | 126 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 return internal_summing_bus; | 217 return internal_summing_bus; |
| 218 } | 218 } |
| 219 | 219 |
| 220 // Handle multiple connections case. | 220 // Handle multiple connections case. |
| 221 SumAllConnections(internal_summing_bus, frames_to_process); | 221 SumAllConnections(internal_summing_bus, frames_to_process); |
| 222 | 222 |
| 223 return internal_summing_bus; | 223 return internal_summing_bus; |
| 224 } | 224 } |
| 225 | 225 |
| 226 } // namespace blink | 226 } // namespace blink |
| OLD | NEW |