Mercurial > hg > svapp
comparison audio/AudioCallbackPlaySource.h @ 559:7b115a6505b8 3.0-integration
Handle increases in the overall channel count by closing and reopening the audio device.
author | Chris Cannam |
---|---|
date | Tue, 13 Dec 2016 12:03:48 +0000 |
parents | 206d65e2b69a |
children | fc70aa31d8c5 |
comparison
equal
deleted
inserted
replaced
558:206d65e2b69a | 559:7b115a6505b8 |
---|---|
88 /** | 88 /** |
89 * Start making data available in the ring buffers for playback, | 89 * Start making data available in the ring buffers for playback, |
90 * from the given frame. If playback is already under way, reseek | 90 * from the given frame. If playback is already under way, reseek |
91 * to the given frame and continue. | 91 * to the given frame and continue. |
92 */ | 92 */ |
93 virtual void play(sv_frame_t startFrame); | 93 virtual void play(sv_frame_t startFrame) override; |
94 | 94 |
95 /** | 95 /** |
96 * Stop playback and ensure that no more data is returned. | 96 * Stop playback and ensure that no more data is returned. |
97 */ | 97 */ |
98 virtual void stop(); | 98 virtual void stop() override; |
99 | 99 |
100 /** | 100 /** |
101 * Return whether playback is currently supposed to be happening. | 101 * Return whether playback is currently supposed to be happening. |
102 */ | 102 */ |
103 virtual bool isPlaying() const { return m_playing; } | 103 virtual bool isPlaying() const override { return m_playing; } |
104 | 104 |
105 /** | 105 /** |
106 * Return the frame number that is currently expected to be coming | 106 * Return the frame number that is currently expected to be coming |
107 * out of the speakers. (i.e. compensating for playback latency.) | 107 * out of the speakers. (i.e. compensating for playback latency.) |
108 */ | 108 */ |
109 virtual sv_frame_t getCurrentPlayingFrame(); | 109 virtual sv_frame_t getCurrentPlayingFrame() override; |
110 | 110 |
111 /** | 111 /** |
112 * Return the last frame that would come out of the speakers if we | 112 * Return the last frame that would come out of the speakers if we |
113 * stopped playback right now. | 113 * stopped playback right now. |
114 */ | 114 */ |
131 | 131 |
132 /** | 132 /** |
133 * Set the block size of the target audio device. This should be | 133 * Set the block size of the target audio device. This should be |
134 * called by the target class. | 134 * called by the target class. |
135 */ | 135 */ |
136 virtual void setSystemPlaybackBlockSize(int blockSize); | 136 virtual void setSystemPlaybackBlockSize(int blockSize) override; |
137 | 137 |
138 /** | 138 /** |
139 * Get the block size of the target audio device. This may be an | 139 * Get the block size of the target audio device. This may be an |
140 * estimate or upper bound, if the target has a variable block | 140 * estimate or upper bound, if the target has a variable block |
141 * size; the source should behave itself even if this value turns | 141 * size; the source should behave itself even if this value turns |
148 * at the device sample rate. This is the difference between the | 148 * at the device sample rate. This is the difference between the |
149 * frame currently "leaving the speakers" and the last frame (or | 149 * frame currently "leaving the speakers" and the last frame (or |
150 * highest last frame across all channels) requested via | 150 * highest last frame across all channels) requested via |
151 * getSamples(). The default is zero. | 151 * getSamples(). The default is zero. |
152 */ | 152 */ |
153 void setSystemPlaybackLatency(int); | 153 virtual void setSystemPlaybackLatency(int) override; |
154 | 154 |
155 /** | 155 /** |
156 * Get the playback latency of the target audio device. | 156 * Get the playback latency of the target audio device. |
157 */ | 157 */ |
158 sv_frame_t getTargetPlayLatency() const; | 158 sv_frame_t getTargetPlayLatency() const; |
162 * (i.e. cannot accommodate arbitrary sample rates based on the | 162 * (i.e. cannot accommodate arbitrary sample rates based on the |
163 * source). If the target sets this to something other than the | 163 * source). If the target sets this to something other than the |
164 * source sample rate, this class will resample automatically to | 164 * source sample rate, this class will resample automatically to |
165 * fit. | 165 * fit. |
166 */ | 166 */ |
167 void setSystemPlaybackSampleRate(int); | 167 virtual void setSystemPlaybackSampleRate(int) override; |
168 | 168 |
169 /** | 169 /** |
170 * Return the sample rate set by the target audio device (or the | 170 * Return the sample rate set by the target audio device (or the |
171 * source sample rate if the target hasn't set one). | 171 * source sample rate if the target hasn't set one). |
172 */ | 172 */ |
173 sv_samplerate_t getDeviceSampleRate() const; | 173 sv_samplerate_t getDeviceSampleRate() const; |
174 | 174 |
175 /** | 175 /** |
176 * Indicate how many channels the target audio device was opened | 176 * Indicate how many channels the target audio device was opened |
177 * with. Note that the target device does channel mixing in the | 177 * with. Note that the target device does channel mixing in the |
178 * case where our requested channel count does not match its. | 178 * case where our requested channel count does not match its, so |
179 */ | 179 * long as we provide the number of channels we specified when the |
180 void setSystemPlaybackChannelCount(int); | 180 * target was started in getApplicationChannelCount(). |
181 */ | |
182 virtual void setSystemPlaybackChannelCount(int) override; | |
181 | 183 |
182 /** | 184 /** |
183 * Set the current output levels for metering (for call from the | 185 * Set the current output levels for metering (for call from the |
184 * target) | 186 * target) |
185 */ | 187 */ |
209 * | 211 * |
210 * override from AudioPlaySource | 212 * override from AudioPlaySource |
211 */ | 213 */ |
212 virtual int getTargetChannelCount() const override; | 214 virtual int getTargetChannelCount() const override; |
213 | 215 |
216 /** | |
217 * Get the number of channels of audio the device is | |
218 * expecting. Equal to whatever getTargetChannelCount() was | |
219 * returning at the time the device was initialised. | |
220 */ | |
221 int getDeviceChannelCount() const; | |
222 | |
214 /** | 223 /** |
215 * ApplicationPlaybackSource equivalent of the above. | 224 * ApplicationPlaybackSource equivalent of the above. |
216 * | 225 * |
217 * override from breakfastquay::ApplicationPlaybackSource | 226 * override from breakfastquay::ApplicationPlaybackSource |
218 */ | 227 */ |
247 /** | 256 /** |
248 * Get "count" samples (at the target sample rate) of the mixed | 257 * Get "count" samples (at the target sample rate) of the mixed |
249 * audio data, in all channels. This may safely be called from a | 258 * audio data, in all channels. This may safely be called from a |
250 * realtime thread. | 259 * realtime thread. |
251 */ | 260 */ |
252 virtual int getSourceSamples(int count, float **buffer); | 261 virtual int getSourceSamples(float *const *buffer, int nchannels, int count) override; |
253 | 262 |
254 /** | 263 /** |
255 * Set the time stretcher factor (i.e. playback speed). | 264 * Set the time stretcher factor (i.e. playback speed). |
256 */ | 265 */ |
257 void setTimeStretch(double factor); | 266 void setTimeStretch(double factor); |
290 void playStatusChanged(bool isPlaying); | 299 void playStatusChanged(bool isPlaying); |
291 | 300 |
292 void sampleRateMismatch(sv_samplerate_t requested, | 301 void sampleRateMismatch(sv_samplerate_t requested, |
293 sv_samplerate_t available, | 302 sv_samplerate_t available, |
294 bool willResample); | 303 bool willResample); |
304 | |
305 void channelCountIncreased(); | |
295 | 306 |
296 void audioOverloadPluginDisabled(); | 307 void audioOverloadPluginDisabled(); |
297 void audioTimeStretchMultiChannelDisabled(); | 308 void audioTimeStretchMultiChannelDisabled(); |
298 | 309 |
299 void activity(QString); | 310 void activity(QString); |
332 Scavenger<RingBufferVector> m_bufferScavenger; | 343 Scavenger<RingBufferVector> m_bufferScavenger; |
333 int m_sourceChannelCount; | 344 int m_sourceChannelCount; |
334 sv_frame_t m_blockSize; | 345 sv_frame_t m_blockSize; |
335 sv_samplerate_t m_sourceSampleRate; | 346 sv_samplerate_t m_sourceSampleRate; |
336 sv_samplerate_t m_deviceSampleRate; | 347 sv_samplerate_t m_deviceSampleRate; |
348 int m_deviceChannelCount; | |
337 sv_frame_t m_playLatency; | 349 sv_frame_t m_playLatency; |
338 breakfastquay::SystemPlaybackTarget *m_target; | 350 breakfastquay::SystemPlaybackTarget *m_target; |
339 double m_lastRetrievalTimestamp; | 351 double m_lastRetrievalTimestamp; |
340 sv_frame_t m_lastRetrievedBlockSize; | 352 sv_frame_t m_lastRetrievedBlockSize; |
341 bool m_trustworthyTimestamps; | 353 bool m_trustworthyTimestamps; |
391 // new buffered frame position (which may be earlier than the | 403 // new buffered frame position (which may be earlier than the |
392 // frame argument passed in, in the case of looping). | 404 // frame argument passed in, in the case of looping). |
393 sv_frame_t mixModels(sv_frame_t &frame, sv_frame_t count, float **buffers); | 405 sv_frame_t mixModels(sv_frame_t &frame, sv_frame_t count, float **buffers); |
394 | 406 |
395 // Called from getSourceSamples. | 407 // Called from getSourceSamples. |
396 void applyAuditioningEffect(sv_frame_t count, float **buffers); | 408 void applyAuditioningEffect(sv_frame_t count, float *const *buffers); |
397 | 409 |
398 // Ranges of current selections, if play selection is active | 410 // Ranges of current selections, if play selection is active |
399 std::vector<RealTime> m_rangeStarts; | 411 std::vector<RealTime> m_rangeStarts; |
400 std::vector<RealTime> m_rangeDurations; | 412 std::vector<RealTime> m_rangeDurations; |
401 void rebuildRangeLists(); | 413 void rebuildRangeLists(); |