| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 did_call_dispose_ = true; | 58 did_call_dispose_ = true; |
| 59 | 59 |
| 60 GetDeferredTaskHandler().RemoveMarkedAudioNodeOutput(this); | 60 GetDeferredTaskHandler().RemoveMarkedAudioNodeOutput(this); |
| 61 DisconnectAll(); | 61 DisconnectAll(); |
| 62 DCHECK(inputs_.IsEmpty()); | 62 DCHECK(inputs_.IsEmpty()); |
| 63 DCHECK(params_.IsEmpty()); | 63 DCHECK(params_.IsEmpty()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void AudioNodeOutput::SetNumberOfChannels(unsigned number_of_channels) { | 66 void AudioNodeOutput::SetNumberOfChannels(unsigned number_of_channels) { |
| 67 DCHECK_LE(number_of_channels, BaseAudioContext::MaxNumberOfChannels()); | 67 DCHECK_LE(number_of_channels, BaseAudioContext::MaxNumberOfChannels()); |
| 68 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 68 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 69 | 69 |
| 70 desired_number_of_channels_ = number_of_channels; | 70 desired_number_of_channels_ = number_of_channels; |
| 71 | 71 |
| 72 if (GetDeferredTaskHandler().IsAudioThread()) { | 72 if (GetDeferredTaskHandler().IsAudioThread()) { |
| 73 // If we're in the audio thread then we can take care of it right away (we | 73 // If we're in the audio thread then we can take care of it right away (we |
| 74 // should be at the very start or end of a rendering quantum). | 74 // should be at the very start or end of a rendering quantum). |
| 75 UpdateNumberOfChannels(); | 75 UpdateNumberOfChannels(); |
| 76 } else { | 76 } else { |
| 77 DCHECK(!did_call_dispose_); | 77 DCHECK(!did_call_dispose_); |
| 78 // Let the context take care of it in the audio thread in the pre and post | 78 // Let the context take care of it in the audio thread in the pre and post |
| (...skipping 11 matching lines...) Expand all Loading... |
| 90 } | 90 } |
| 91 | 91 |
| 92 void AudioNodeOutput::UpdateRenderingState() { | 92 void AudioNodeOutput::UpdateRenderingState() { |
| 93 UpdateNumberOfChannels(); | 93 UpdateNumberOfChannels(); |
| 94 rendering_fan_out_count_ = FanOutCount(); | 94 rendering_fan_out_count_ = FanOutCount(); |
| 95 rendering_param_fan_out_count_ = ParamFanOutCount(); | 95 rendering_param_fan_out_count_ = ParamFanOutCount(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void AudioNodeOutput::UpdateNumberOfChannels() { | 98 void AudioNodeOutput::UpdateNumberOfChannels() { |
| 99 DCHECK(GetDeferredTaskHandler().IsAudioThread()); | 99 DCHECK(GetDeferredTaskHandler().IsAudioThread()); |
| 100 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 100 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 101 | 101 |
| 102 if (number_of_channels_ != desired_number_of_channels_) { | 102 if (number_of_channels_ != desired_number_of_channels_) { |
| 103 number_of_channels_ = desired_number_of_channels_; | 103 number_of_channels_ = desired_number_of_channels_; |
| 104 UpdateInternalBus(); | 104 UpdateInternalBus(); |
| 105 PropagateChannelCount(); | 105 PropagateChannelCount(); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 void AudioNodeOutput::PropagateChannelCount() { | 109 void AudioNodeOutput::PropagateChannelCount() { |
| 110 DCHECK(GetDeferredTaskHandler().IsAudioThread()); | 110 DCHECK(GetDeferredTaskHandler().IsAudioThread()); |
| 111 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 111 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 112 | 112 |
| 113 if (IsChannelCountKnown()) { | 113 if (IsChannelCountKnown()) { |
| 114 // Announce to any nodes we're connected to that we changed our channel | 114 // Announce to any nodes we're connected to that we changed our channel |
| 115 // count for its input. | 115 // count for its input. |
| 116 for (AudioNodeInput* i : inputs_) | 116 for (AudioNodeInput* i : inputs_) |
| 117 i->Handler().CheckNumberOfChannelsForInput(i); | 117 i->Handler().CheckNumberOfChannelsForInput(i); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 AudioBus* AudioNodeOutput::Pull(AudioBus* in_place_bus, | 121 AudioBus* AudioNodeOutput::Pull(AudioBus* in_place_bus, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 140 Handler().ProcessIfNecessary(frames_to_process); | 140 Handler().ProcessIfNecessary(frames_to_process); |
| 141 return Bus(); | 141 return Bus(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 AudioBus* AudioNodeOutput::Bus() const { | 144 AudioBus* AudioNodeOutput::Bus() const { |
| 145 DCHECK(GetDeferredTaskHandler().IsAudioThread()); | 145 DCHECK(GetDeferredTaskHandler().IsAudioThread()); |
| 146 return is_in_place_ ? in_place_bus_.Get() : internal_bus_.Get(); | 146 return is_in_place_ ? in_place_bus_.Get() : internal_bus_.Get(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 unsigned AudioNodeOutput::FanOutCount() { | 149 unsigned AudioNodeOutput::FanOutCount() { |
| 150 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 150 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 151 return inputs_.size(); | 151 return inputs_.size(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 unsigned AudioNodeOutput::ParamFanOutCount() { | 154 unsigned AudioNodeOutput::ParamFanOutCount() { |
| 155 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 155 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 156 return params_.size(); | 156 return params_.size(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 unsigned AudioNodeOutput::RenderingFanOutCount() const { | 159 unsigned AudioNodeOutput::RenderingFanOutCount() const { |
| 160 return rendering_fan_out_count_; | 160 return rendering_fan_out_count_; |
| 161 } | 161 } |
| 162 | 162 |
| 163 void AudioNodeOutput::AddInput(AudioNodeInput& input) { | 163 void AudioNodeOutput::AddInput(AudioNodeInput& input) { |
| 164 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 164 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 165 inputs_.insert(&input); | 165 inputs_.insert(&input); |
| 166 input.Handler().MakeConnection(); | 166 input.Handler().MakeConnection(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void AudioNodeOutput::RemoveInput(AudioNodeInput& input) { | 169 void AudioNodeOutput::RemoveInput(AudioNodeInput& input) { |
| 170 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 170 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 171 input.Handler().BreakConnection(); | 171 input.Handler().BreakConnection(); |
| 172 inputs_.erase(&input); | 172 inputs_.erase(&input); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void AudioNodeOutput::DisconnectAllInputs() { | 175 void AudioNodeOutput::DisconnectAllInputs() { |
| 176 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 176 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 177 | 177 |
| 178 // AudioNodeInput::disconnect() changes m_inputs by calling removeInput(). | 178 // AudioNodeInput::disconnect() changes m_inputs by calling removeInput(). |
| 179 while (!inputs_.IsEmpty()) | 179 while (!inputs_.IsEmpty()) |
| 180 (*inputs_.begin())->Disconnect(*this); | 180 (*inputs_.begin())->Disconnect(*this); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void AudioNodeOutput::DisconnectInput(AudioNodeInput& input) { | 183 void AudioNodeOutput::DisconnectInput(AudioNodeInput& input) { |
| 184 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 184 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 185 DCHECK(IsConnectedToInput(input)); | 185 DCHECK(IsConnectedToInput(input)); |
| 186 input.Disconnect(*this); | 186 input.Disconnect(*this); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void AudioNodeOutput::DisconnectAudioParam(AudioParamHandler& param) { | 189 void AudioNodeOutput::DisconnectAudioParam(AudioParamHandler& param) { |
| 190 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 190 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 191 DCHECK(IsConnectedToAudioParam(param)); | 191 DCHECK(IsConnectedToAudioParam(param)); |
| 192 param.Disconnect(*this); | 192 param.Disconnect(*this); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void AudioNodeOutput::AddParam(AudioParamHandler& param) { | 195 void AudioNodeOutput::AddParam(AudioParamHandler& param) { |
| 196 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 196 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 197 params_.insert(¶m); | 197 params_.insert(¶m); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void AudioNodeOutput::RemoveParam(AudioParamHandler& param) { | 200 void AudioNodeOutput::RemoveParam(AudioParamHandler& param) { |
| 201 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 201 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 202 params_.erase(¶m); | 202 params_.erase(¶m); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void AudioNodeOutput::DisconnectAllParams() { | 205 void AudioNodeOutput::DisconnectAllParams() { |
| 206 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 206 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 207 | 207 |
| 208 // AudioParam::disconnect() changes m_params by calling removeParam(). | 208 // AudioParam::disconnect() changes m_params by calling removeParam(). |
| 209 while (!params_.IsEmpty()) | 209 while (!params_.IsEmpty()) |
| 210 (*params_.begin())->Disconnect(*this); | 210 (*params_.begin())->Disconnect(*this); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void AudioNodeOutput::DisconnectAll() { | 213 void AudioNodeOutput::DisconnectAll() { |
| 214 DisconnectAllInputs(); | 214 DisconnectAllInputs(); |
| 215 DisconnectAllParams(); | 215 DisconnectAllParams(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool AudioNodeOutput::IsConnectedToInput(AudioNodeInput& input) { | 218 bool AudioNodeOutput::IsConnectedToInput(AudioNodeInput& input) { |
| 219 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 219 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 220 return inputs_.Contains(&input); | 220 return inputs_.Contains(&input); |
| 221 } | 221 } |
| 222 | 222 |
| 223 bool AudioNodeOutput::IsConnectedToAudioParam(AudioParamHandler& param) { | 223 bool AudioNodeOutput::IsConnectedToAudioParam(AudioParamHandler& param) { |
| 224 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 224 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 225 return params_.Contains(¶m); | 225 return params_.Contains(¶m); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void AudioNodeOutput::Disable() { | 228 void AudioNodeOutput::Disable() { |
| 229 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 229 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 230 | 230 |
| 231 if (is_enabled_) { | 231 if (is_enabled_) { |
| 232 is_enabled_ = false; | 232 is_enabled_ = false; |
| 233 for (AudioNodeInput* i : inputs_) | 233 for (AudioNodeInput* i : inputs_) |
| 234 i->Disable(*this); | 234 i->Disable(*this); |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 void AudioNodeOutput::Enable() { | 238 void AudioNodeOutput::Enable() { |
| 239 ASSERT(GetDeferredTaskHandler().IsGraphOwner()); | 239 DCHECK(GetDeferredTaskHandler().IsGraphOwner()); |
| 240 | 240 |
| 241 if (!is_enabled_) { | 241 if (!is_enabled_) { |
| 242 is_enabled_ = true; | 242 is_enabled_ = true; |
| 243 for (AudioNodeInput* i : inputs_) | 243 for (AudioNodeInput* i : inputs_) |
| 244 i->Enable(*this); | 244 i->Enable(*this); |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 } // namespace blink | 248 } // namespace blink |
| OLD | NEW |