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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // AudioScheduledSourceNode | 91 // AudioScheduledSourceNode |
92 virtual void finish() override; | 92 virtual void finish() override; |
93 | 93 |
94 void handleStoppableSourceNode(); | 94 void handleStoppableSourceNode(); |
95 | 95 |
96 DECLARE_VIRTUAL_TRACE(); | 96 DECLARE_VIRTUAL_TRACE(); |
97 | 97 |
98 private: | 98 private: |
99 AudioBufferSourceNode(AudioContext*, float sampleRate); | 99 AudioBufferSourceNode(AudioContext*, float sampleRate); |
100 | 100 |
| 101 void startSource(double when, double grainOffset, double grainDuration, bool
isDurationGiven, ExceptionState&); |
| 102 |
101 // Returns true on success. | 103 // Returns true on success. |
102 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num
berOfFrames); | 104 bool renderFromBuffer(AudioBus*, unsigned destinationFrameOffset, size_t num
berOfFrames); |
103 | 105 |
104 // Render silence starting from "index" frame in AudioBus. | 106 // Render silence starting from "index" frame in AudioBus. |
105 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si
ze_t framesToProcess); | 107 inline bool renderSilenceAndFinishIfNotLooping(AudioBus*, unsigned index, si
ze_t framesToProcess); |
106 | 108 |
107 // Clamps grain parameters to the duration of the given AudioBuffer. | 109 // Clamps grain parameters to the duration of the given AudioBuffer. |
108 void clampGrainParameters(const AudioBuffer*); | 110 void clampGrainParameters(const AudioBuffer*); |
109 | 111 |
110 // m_buffer holds the sample data which this node outputs. | 112 // m_buffer holds the sample data which this node outputs. |
(...skipping 14 matching lines...) Expand all Loading... |
125 double m_loopEnd; | 127 double m_loopEnd; |
126 | 128 |
127 // m_virtualReadIndex is a sample-frame index into our buffer representing t
he current playback position. | 129 // m_virtualReadIndex is a sample-frame index into our buffer representing t
he current playback position. |
128 // Since it's floating-point, it has sub-sample accuracy. | 130 // Since it's floating-point, it has sub-sample accuracy. |
129 double m_virtualReadIndex; | 131 double m_virtualReadIndex; |
130 | 132 |
131 // Granular playback | 133 // Granular playback |
132 bool m_isGrain; | 134 bool m_isGrain; |
133 double m_grainOffset; // in seconds | 135 double m_grainOffset; // in seconds |
134 double m_grainDuration; // in seconds | 136 double m_grainDuration; // in seconds |
135 | 137 // True if grainDuration is given explicitly (via 3 arg start method). |
| 138 bool m_isDurationGiven; |
136 // totalPitchRate() returns the instantaneous pitch rate (non-time preservin
g). | 139 // totalPitchRate() returns the instantaneous pitch rate (non-time preservin
g). |
137 // It incorporates the base pitch rate, any sample-rate conversion factor fr
om the buffer, and any doppler shift from an associated panner node. | 140 // It incorporates the base pitch rate, any sample-rate conversion factor fr
om the buffer, and any doppler shift from an associated panner node. |
138 double totalPitchRate(); | 141 double totalPitchRate(); |
139 | 142 |
140 // We optionally keep track of a panner node which has a doppler shift that | 143 // We optionally keep track of a panner node which has a doppler shift that |
141 // is incorporated into the pitch rate. | 144 // is incorporated into the pitch rate. |
142 // This RefPtr is connection reference. We must call AudioNode:: | 145 // This RefPtr is connection reference. We must call AudioNode:: |
143 // makeConnection() after ref(), and call AudioNode::breakConnection() | 146 // makeConnection() after ref(), and call AudioNode::breakConnection() |
144 // before deref(). | 147 // before deref(). |
145 // Oilpan: This holds connection references. We must call | 148 // Oilpan: This holds connection references. We must call |
146 // AudioNode::makeConnection when we add an AudioNode to this, and must call | 149 // AudioNode::makeConnection when we add an AudioNode to this, and must call |
147 // AudioNode::breakConnection() when we remove an AudioNode from this. | 150 // AudioNode::breakConnection() when we remove an AudioNode from this. |
148 Member<PannerNode> m_pannerNode; | 151 Member<PannerNode> m_pannerNode; |
149 | 152 |
150 // This synchronizes process() with setBuffer() which can cause dynamic chan
nel count changes. | 153 // This synchronizes process() with setBuffer() which can cause dynamic chan
nel count changes. |
151 mutable Mutex m_processLock; | 154 mutable Mutex m_processLock; |
152 }; | 155 }; |
153 | 156 |
154 } // namespace blink | 157 } // namespace blink |
155 | 158 |
156 #endif // AudioBufferSourceNode_h | 159 #endif // AudioBufferSourceNode_h |
OLD | NEW |