| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 class AudioNode; | 36 class AudioNode; |
| 37 class AudioNodeOutput; | 37 class AudioNodeOutput; |
| 38 | 38 |
| 39 // An AudioNodeInput represents an input to an AudioNode and can be connected fr
om one or more AudioNodeOutputs. | 39 // An AudioNodeInput represents an input to an AudioNode and can be connected fr
om one or more AudioNodeOutputs. |
| 40 // In the case of multiple connections, the input will act as a unity-gain summi
ng junction, mixing all the outputs. | 40 // In the case of multiple connections, the input will act as a unity-gain summi
ng junction, mixing all the outputs. |
| 41 // The number of channels of the input's bus is the maximum of the number of cha
nnels of all its connections. | 41 // The number of channels of the input's bus is the maximum of the number of cha
nnels of all its connections. |
| 42 | 42 |
| 43 class AudioNodeInput FINAL : public AudioSummingJunction { | 43 class AudioNodeInput FINAL : public AudioSummingJunction { |
| 44 public: | 44 public: |
| 45 static PassOwnPtr<AudioNodeInput> create(AudioNode*); | 45 static PassOwnPtr<AudioNodeInput> create(AudioNode&); |
| 46 | 46 |
| 47 // AudioSummingJunction | 47 // AudioSummingJunction |
| 48 virtual bool canUpdateState() OVERRIDE { return !node()->isMarkedForDeletion
(); } | 48 virtual bool canUpdateState() OVERRIDE { return !node().isMarkedForDeletion(
); } |
| 49 virtual void didUpdate() OVERRIDE; | 49 virtual void didUpdate() OVERRIDE; |
| 50 | 50 |
| 51 // Can be called from any thread. | 51 // Can be called from any thread. |
| 52 AudioNode* node() const { return m_node; } | 52 AudioNode& node() const { return m_node; } |
| 53 | 53 |
| 54 // Must be called with the context's graph lock. | 54 // Must be called with the context's graph lock. |
| 55 void connect(AudioNodeOutput*); | 55 void connect(AudioNodeOutput&); |
| 56 void disconnect(AudioNodeOutput*); | 56 void disconnect(AudioNodeOutput&); |
| 57 | 57 |
| 58 // disable() will take the output out of the active connections list and set
aside in a disabled list. | 58 // disable() will take the output out of the active connections list and set
aside in a disabled list. |
| 59 // enable() will put the output back into the active connections list. | 59 // enable() will put the output back into the active connections list. |
| 60 // Must be called with the context's graph lock. | 60 // Must be called with the context's graph lock. |
| 61 void enable(AudioNodeOutput*); | 61 void enable(AudioNodeOutput&); |
| 62 void disable(AudioNodeOutput*); | 62 void disable(AudioNodeOutput&); |
| 63 | 63 |
| 64 // pull() processes all of the AudioNodes connected to us. | 64 // pull() processes all of the AudioNodes connected to us. |
| 65 // In the case of multiple connections it sums the result into an internal s
umming bus. | 65 // In the case of multiple connections it sums the result into an internal s
umming bus. |
| 66 // In the single connection case, it allows in-place processing where possib
le using inPlaceBus. | 66 // In the single connection case, it allows in-place processing where possib
le using inPlaceBus. |
| 67 // It returns the bus which it rendered into, returning inPlaceBus if in-pla
ce processing was performed. | 67 // It returns the bus which it rendered into, returning inPlaceBus if in-pla
ce processing was performed. |
| 68 // Called from context's audio thread. | 68 // Called from context's audio thread. |
| 69 AudioBus* pull(AudioBus* inPlaceBus, size_t framesToProcess); | 69 AudioBus* pull(AudioBus* inPlaceBus, size_t framesToProcess); |
| 70 | 70 |
| 71 // bus() contains the rendered audio after pull() has been called for each t
ime quantum. | 71 // bus() contains the rendered audio after pull() has been called for each t
ime quantum. |
| 72 // Called from context's audio thread. | 72 // Called from context's audio thread. |
| 73 AudioBus* bus(); | 73 AudioBus* bus(); |
| 74 | 74 |
| 75 // updateInternalBus() updates m_internalSummingBus appropriately for the nu
mber of channels. | 75 // updateInternalBus() updates m_internalSummingBus appropriately for the nu
mber of channels. |
| 76 // This must be called when we own the context's graph lock in the audio thr
ead at the very start or end of the render quantum. | 76 // This must be called when we own the context's graph lock in the audio thr
ead at the very start or end of the render quantum. |
| 77 void updateInternalBus(); | 77 void updateInternalBus(); |
| 78 | 78 |
| 79 // The number of channels of the connection with the largest number of chann
els. | 79 // The number of channels of the connection with the largest number of chann
els. |
| 80 unsigned numberOfChannels() const; | 80 unsigned numberOfChannels() const; |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 explicit AudioNodeInput(AudioNode*); | 83 explicit AudioNodeInput(AudioNode&); |
| 84 | 84 |
| 85 AudioNode* m_node; | 85 AudioNode& m_node; |
| 86 | 86 |
| 87 // m_disabledOutputs contains the AudioNodeOutputs which are disabled (will
not be processed) by the audio graph rendering. | 87 // m_disabledOutputs contains the AudioNodeOutputs which are disabled (will
not be processed) by the audio graph rendering. |
| 88 // But, from JavaScript's perspective, these outputs are still connected to
us. | 88 // But, from JavaScript's perspective, these outputs are still connected to
us. |
| 89 // Generally, these represent disabled connections from "notes" which have f
inished playing but are not yet garbage collected. | 89 // Generally, these represent disabled connections from "notes" which have f
inished playing but are not yet garbage collected. |
| 90 HashSet<AudioNodeOutput*> m_disabledOutputs; | 90 HashSet<AudioNodeOutput*> m_disabledOutputs; |
| 91 | 91 |
| 92 // Called from context's audio thread. | 92 // Called from context's audio thread. |
| 93 AudioBus* internalSummingBus(); | 93 AudioBus* internalSummingBus(); |
| 94 void sumAllConnections(AudioBus* summingBus, size_t framesToProcess); | 94 void sumAllConnections(AudioBus* summingBus, size_t framesToProcess); |
| 95 | 95 |
| 96 RefPtr<AudioBus> m_internalSummingBus; | 96 RefPtr<AudioBus> m_internalSummingBus; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 } // namespace WebCore | 99 } // namespace WebCore |
| 100 | 100 |
| 101 #endif // AudioNodeInput_h | 101 #endif // AudioNodeInput_h |
| OLD | NEW |