Mercurial > hg > svapp
comparison audio/AudioCallbackPlaySource.h @ 552:8c11ca1ebc39 bqresample
Some fixes to sample rate management
author | Chris Cannam |
---|---|
date | Fri, 09 Dec 2016 13:46:34 +0000 |
parents | b9d8c7a690d6 |
children | 2a1e9e017484 |
comparison
equal
deleted
inserted
replaced
551:b9d8c7a690d6 | 552:8c11ca1ebc39 |
---|---|
201 /** | 201 /** |
202 * Get the number of channels of audio that will be provided | 202 * Get the number of channels of audio that will be provided |
203 * to the play target. This may be more than the source channel | 203 * to the play target. This may be more than the source channel |
204 * count: for example, a mono source will provide 2 channels | 204 * count: for example, a mono source will provide 2 channels |
205 * after pan. | 205 * after pan. |
206 * | |
206 * This may safely be called from a realtime thread. Returns 0 if | 207 * This may safely be called from a realtime thread. Returns 0 if |
207 * there is no source yet available. | 208 * there is no source yet available. |
208 */ | 209 * |
209 int getTargetChannelCount() const; | 210 * override from AudioPlaySource |
211 */ | |
212 virtual int getTargetChannelCount() const override; | |
210 | 213 |
211 /** | 214 /** |
212 * ApplicationPlaybackSource equivalent of the above. | 215 * ApplicationPlaybackSource equivalent of the above. |
213 */ | 216 * |
214 virtual int getApplicationChannelCount() const { | 217 * override from breakfastquay::ApplicationPlaybackSource |
218 */ | |
219 virtual int getApplicationChannelCount() const override { | |
215 return getTargetChannelCount(); | 220 return getTargetChannelCount(); |
216 } | 221 } |
217 | 222 |
218 /** | 223 /** |
219 * Get the actual sample rate of the source material. This may | 224 * Get the actual sample rate of the source material (the main |
220 * safely be called from a realtime thread. Returns 0 if there is | 225 * model). This may safely be called from a realtime thread. |
221 * no source yet available. | 226 * Returns 0 if there is no source yet available. |
222 */ | 227 * |
223 virtual sv_samplerate_t getSourceSampleRate() const; | 228 * When this changes, the AudioCallbackPlaySource notifies its |
224 | 229 * ResamplerWrapper of the new sample rate so that it can resample |
225 /** | 230 * correctly on the way to the device (which is opened at a fixed |
226 * ApplicationPlaybackSource equivalent of the above. | 231 * rate, see getApplicationSampleRate). |
227 */ | 232 */ |
228 virtual int getApplicationSampleRate() const { | 233 virtual sv_samplerate_t getSourceSampleRate() const override; |
229 return int(round(getSourceSampleRate())); | 234 |
235 /** | |
236 * ApplicationPlaybackSource interface method: get the sample rate | |
237 * at which the application wants the device to be opened. We | |
238 * always allow the device to open at its default rate, and then | |
239 * we resample if the audio is at a different rate. This avoids | |
240 * having to close and re-open the device to obtain consistent | |
241 * behaviour for consecutive sessions with different source rates. | |
242 */ | |
243 virtual int getApplicationSampleRate() const override { | |
244 return 0; | |
230 } | 245 } |
231 | 246 |
232 /** | 247 /** |
233 * Get "count" samples (at the target sample rate) of the mixed | 248 * Get "count" samples (at the target sample rate) of the mixed |
234 * audio data, in all channels. This may safely be called from a | 249 * audio data, in all channels. This may safely be called from a |