| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 if (!output || !node()) | 55 if (!output || !node()) |
| 56 return; | 56 return; |
| 57 | 57 |
| 58 // Check if we're already connected to this output. | 58 // Check if we're already connected to this output. |
| 59 if (m_outputs.contains(output)) | 59 if (m_outputs.contains(output)) |
| 60 return; | 60 return; |
| 61 | 61 |
| 62 output->addInput(this); | 62 output->addInput(this); |
| 63 m_outputs.add(output); | 63 m_outputs.add(output); |
| 64 changedOutputs(); | 64 changedOutputs(); |
| 65 |
| 66 // Sombody has just connected to us, so count it as a reference. |
| 67 node()->ref(AudioNode::RefTypeConnection); |
| 65 } | 68 } |
| 66 | 69 |
| 67 void AudioNodeInput::disconnect(AudioNodeOutput* output) | 70 void AudioNodeInput::disconnect(AudioNodeOutput* output) |
| 68 { | 71 { |
| 69 ASSERT(context()->isGraphOwner()); | 72 ASSERT(context()->isGraphOwner()); |
| 70 | 73 |
| 71 ASSERT(output && node()); | 74 ASSERT(output && node()); |
| 72 if (!output || !node()) | 75 if (!output || !node()) |
| 73 return; | 76 return; |
| 74 | 77 |
| 75 // First try to disconnect from "active" connections. | 78 // First try to disconnect from "active" connections. |
| 76 if (m_outputs.contains(output)) { | 79 if (m_outputs.contains(output)) { |
| 77 m_outputs.remove(output); | 80 m_outputs.remove(output); |
| 78 changedOutputs(); | 81 changedOutputs(); |
| 79 output->removeInput(this); | 82 output->removeInput(this); |
| 80 // Note: it's important to return immediately after removeInput() calls | 83 node()->deref(AudioNode::RefTypeConnection); // Note: it's important to
return immediately after all deref() calls since the node may be deleted. |
| 81 // since the node may be deleted. | |
| 82 return; | 84 return; |
| 83 } | 85 } |
| 84 | 86 |
| 85 // Otherwise, try to disconnect from disabled connections. | 87 // Otherwise, try to disconnect from disabled connections. |
| 86 if (m_disabledOutputs.contains(output)) { | 88 if (m_disabledOutputs.contains(output)) { |
| 87 m_disabledOutputs.remove(output); | 89 m_disabledOutputs.remove(output); |
| 88 output->removeInput(this); | 90 output->removeInput(this); |
| 89 // Note: it's important to return immediately after all removeInput() ca
lls | 91 node()->deref(AudioNode::RefTypeConnection); // Note: it's important to
return immediately after all deref() calls since the node may be deleted. |
| 90 // since the node may be deleted. | |
| 91 return; | 92 return; |
| 92 } | 93 } |
| 93 | 94 |
| 94 ASSERT_NOT_REACHED(); | 95 ASSERT_NOT_REACHED(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 void AudioNodeInput::disable(AudioNodeOutput* output) | 98 void AudioNodeInput::disable(AudioNodeOutput* output) |
| 98 { | 99 { |
| 99 ASSERT(context()->isGraphOwner()); | 100 ASSERT(context()->isGraphOwner()); |
| 100 | 101 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 239 |
| 239 // Handle multiple connections case. | 240 // Handle multiple connections case. |
| 240 sumAllConnections(internalSummingBus, framesToProcess); | 241 sumAllConnections(internalSummingBus, framesToProcess); |
| 241 | 242 |
| 242 return internalSummingBus; | 243 return internalSummingBus; |
| 243 } | 244 } |
| 244 | 245 |
| 245 } // namespace WebCore | 246 } // namespace WebCore |
| 246 | 247 |
| 247 #endif // ENABLE(WEB_AUDIO) | 248 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |