comparison audioio/AudioCallbackPlaySource.h @ 366:0876ea394902 warnfix_no_size_t

Remove size_t's, fix compiler warnings
author Chris Cannam
date Tue, 17 Jun 2014 16:23:06 +0100
parents 5e1711be654d
children 1e4fa2007e61
comparison
equal deleted inserted replaced
355:e7a3fa8f4eec 366:0876ea394902
81 /** 81 /**
82 * Start making data available in the ring buffers for playback, 82 * Start making data available in the ring buffers for playback,
83 * from the given frame. If playback is already under way, reseek 83 * from the given frame. If playback is already under way, reseek
84 * to the given frame and continue. 84 * to the given frame and continue.
85 */ 85 */
86 virtual void play(size_t startFrame); 86 virtual void play(int startFrame);
87 87
88 /** 88 /**
89 * Stop playback and ensure that no more data is returned. 89 * Stop playback and ensure that no more data is returned.
90 */ 90 */
91 virtual void stop(); 91 virtual void stop();
97 97
98 /** 98 /**
99 * Return the frame number that is currently expected to be coming 99 * Return the frame number that is currently expected to be coming
100 * out of the speakers. (i.e. compensating for playback latency.) 100 * out of the speakers. (i.e. compensating for playback latency.)
101 */ 101 */
102 virtual size_t getCurrentPlayingFrame(); 102 virtual int getCurrentPlayingFrame();
103 103
104 /** 104 /**
105 * Return the last frame that would come out of the speakers if we 105 * Return the last frame that would come out of the speakers if we
106 * stopped playback right now. 106 * stopped playback right now.
107 */ 107 */
108 virtual size_t getCurrentBufferedFrame(); 108 virtual int getCurrentBufferedFrame();
109 109
110 /** 110 /**
111 * Return the frame at which playback is expected to end (if not looping). 111 * Return the frame at which playback is expected to end (if not looping).
112 */ 112 */
113 virtual size_t getPlayEndFrame() { return m_lastModelEndFrame; } 113 virtual int getPlayEndFrame() { return m_lastModelEndFrame; }
114 114
115 /** 115 /**
116 * Set the target and the block size of the target audio device. 116 * Set the target and the block size of the target audio device.
117 * This should be called by the target class. 117 * This should be called by the target class.
118 */ 118 */
119 void setTarget(AudioCallbackPlayTarget *, size_t blockSize); 119 void setTarget(AudioCallbackPlayTarget *, int blockSize);
120 120
121 /** 121 /**
122 * Get the block size of the target audio device. This may be an 122 * Get the block size of the target audio device. This may be an
123 * estimate or upper bound, if the target has a variable block 123 * estimate or upper bound, if the target has a variable block
124 * size; the source should behave itself even if this value turns 124 * size; the source should behave itself even if this value turns
125 * out to be inaccurate. 125 * out to be inaccurate.
126 */ 126 */
127 size_t getTargetBlockSize() const; 127 int getTargetBlockSize() const;
128 128
129 /** 129 /**
130 * Set the playback latency of the target audio device, in frames 130 * Set the playback latency of the target audio device, in frames
131 * at the target sample rate. This is the difference between the 131 * at the target sample rate. This is the difference between the
132 * frame currently "leaving the speakers" and the last frame (or 132 * frame currently "leaving the speakers" and the last frame (or
133 * highest last frame across all channels) requested via 133 * highest last frame across all channels) requested via
134 * getSamples(). The default is zero. 134 * getSamples(). The default is zero.
135 */ 135 */
136 void setTargetPlayLatency(size_t); 136 void setTargetPlayLatency(int);
137 137
138 /** 138 /**
139 * Get the playback latency of the target audio device. 139 * Get the playback latency of the target audio device.
140 */ 140 */
141 size_t getTargetPlayLatency() const; 141 int getTargetPlayLatency() const;
142 142
143 /** 143 /**
144 * Specify that the target audio device has a fixed sample rate 144 * Specify that the target audio device has a fixed sample rate
145 * (i.e. cannot accommodate arbitrary sample rates based on the 145 * (i.e. cannot accommodate arbitrary sample rates based on the
146 * source). If the target sets this to something other than the 146 * source). If the target sets this to something other than the
147 * source sample rate, this class will resample automatically to 147 * source sample rate, this class will resample automatically to
148 * fit. 148 * fit.
149 */ 149 */
150 void setTargetSampleRate(size_t); 150 void setTargetSampleRate(int);
151 151
152 /** 152 /**
153 * Return the sample rate set by the target audio device (or the 153 * Return the sample rate set by the target audio device (or the
154 * source sample rate if the target hasn't set one). 154 * source sample rate if the target hasn't set one).
155 */ 155 */
156 virtual size_t getTargetSampleRate() const; 156 virtual int getTargetSampleRate() const;
157 157
158 /** 158 /**
159 * Set the current output levels for metering (for call from the 159 * Set the current output levels for metering (for call from the
160 * target) 160 * target)
161 */ 161 */
170 /** 170 /**
171 * Get the number of channels of audio that in the source models. 171 * Get the number of channels of audio that in the source models.
172 * This may safely be called from a realtime thread. Returns 0 if 172 * This may safely be called from a realtime thread. Returns 0 if
173 * there is no source yet available. 173 * there is no source yet available.
174 */ 174 */
175 size_t getSourceChannelCount() const; 175 int getSourceChannelCount() const;
176 176
177 /** 177 /**
178 * Get the number of channels of audio that will be provided 178 * Get the number of channels of audio that will be provided
179 * to the play target. This may be more than the source channel 179 * to the play target. This may be more than the source channel
180 * count: for example, a mono source will provide 2 channels 180 * count: for example, a mono source will provide 2 channels
181 * after pan. 181 * after pan.
182 * This may safely be called from a realtime thread. Returns 0 if 182 * This may safely be called from a realtime thread. Returns 0 if
183 * there is no source yet available. 183 * there is no source yet available.
184 */ 184 */
185 size_t getTargetChannelCount() const; 185 int getTargetChannelCount() const;
186 186
187 /** 187 /**
188 * Get the actual sample rate of the source material. This may 188 * Get the actual sample rate of the source material. This may
189 * safely be called from a realtime thread. Returns 0 if there is 189 * safely be called from a realtime thread. Returns 0 if there is
190 * no source yet available. 190 * no source yet available.
191 */ 191 */
192 virtual size_t getSourceSampleRate() const; 192 virtual int getSourceSampleRate() const;
193 193
194 /** 194 /**
195 * Get "count" samples (at the target sample rate) of the mixed 195 * Get "count" samples (at the target sample rate) of the mixed
196 * audio data, in all channels. This may safely be called from a 196 * audio data, in all channels. This may safely be called from a
197 * realtime thread. 197 * realtime thread.
198 */ 198 */
199 size_t getSourceSamples(size_t count, float **buffer); 199 int getSourceSamples(int count, float **buffer);
200 200
201 /** 201 /**
202 * Set the time stretcher factor (i.e. playback speed). 202 * Set the time stretcher factor (i.e. playback speed).
203 */ 203 */
204 void setTimeStretch(float factor); 204 void setTimeStretch(float factor);
242 signals: 242 signals:
243 void modelReplaced(); 243 void modelReplaced();
244 244
245 void playStatusChanged(bool isPlaying); 245 void playStatusChanged(bool isPlaying);
246 246
247 void sampleRateMismatch(size_t requested, size_t available, bool willResample); 247 void sampleRateMismatch(int requested, int available, bool willResample);
248 248
249 void audioOverloadPluginDisabled(); 249 void audioOverloadPluginDisabled();
250 void audioTimeStretchMultiChannelDisabled(); 250 void audioTimeStretchMultiChannelDisabled();
251 251
252 void activity(QString); 252 void activity(QString);
258 void selectionChanged(); 258 void selectionChanged();
259 void playLoopModeChanged(); 259 void playLoopModeChanged();
260 void playSelectionModeChanged(); 260 void playSelectionModeChanged();
261 void playParametersChanged(PlayParameters *); 261 void playParametersChanged(PlayParameters *);
262 void preferenceChanged(PropertyContainer::PropertyName); 262 void preferenceChanged(PropertyContainer::PropertyName);
263 void modelChanged(size_t startFrame, size_t endFrame); 263 void modelChanged(int startFrame, int endFrame);
264 264
265 protected: 265 protected:
266 ViewManagerBase *m_viewManager; 266 ViewManagerBase *m_viewManager;
267 AudioGenerator *m_audioGenerator; 267 AudioGenerator *m_audioGenerator;
268 QString m_clientName; 268 QString m_clientName;
278 }; 278 };
279 279
280 std::set<Model *> m_models; 280 std::set<Model *> m_models;
281 RingBufferVector *m_readBuffers; 281 RingBufferVector *m_readBuffers;
282 RingBufferVector *m_writeBuffers; 282 RingBufferVector *m_writeBuffers;
283 size_t m_readBufferFill; 283 int m_readBufferFill;
284 size_t m_writeBufferFill; 284 int m_writeBufferFill;
285 Scavenger<RingBufferVector> m_bufferScavenger; 285 Scavenger<RingBufferVector> m_bufferScavenger;
286 size_t m_sourceChannelCount; 286 int m_sourceChannelCount;
287 size_t m_blockSize; 287 int m_blockSize;
288 size_t m_sourceSampleRate; 288 int m_sourceSampleRate;
289 size_t m_targetSampleRate; 289 int m_targetSampleRate;
290 size_t m_playLatency; 290 int m_playLatency;
291 AudioCallbackPlayTarget *m_target; 291 AudioCallbackPlayTarget *m_target;
292 double m_lastRetrievalTimestamp; 292 double m_lastRetrievalTimestamp;
293 size_t m_lastRetrievedBlockSize; 293 int m_lastRetrievedBlockSize;
294 bool m_trustworthyTimestamps; 294 bool m_trustworthyTimestamps;
295 size_t m_lastCurrentFrame; 295 int m_lastCurrentFrame;
296 bool m_playing; 296 bool m_playing;
297 bool m_exiting; 297 bool m_exiting;
298 size_t m_lastModelEndFrame; 298 int m_lastModelEndFrame;
299 size_t m_ringBufferSize; 299 int m_ringBufferSize;
300 float m_outputLeft; 300 float m_outputLeft;
301 float m_outputRight; 301 float m_outputRight;
302 RealTimePluginInstance *m_auditioningPlugin; 302 RealTimePluginInstance *m_auditioningPlugin;
303 bool m_auditioningPluginBypassed; 303 bool m_auditioningPluginBypassed;
304 Scavenger<RealTimePluginInstance> m_pluginScavenger; 304 Scavenger<RealTimePluginInstance> m_pluginScavenger;
305 size_t m_playStartFrame; 305 int m_playStartFrame;
306 bool m_playStartFramePassed; 306 bool m_playStartFramePassed;
307 RealTime m_playStartedAt; 307 RealTime m_playStartedAt;
308 308
309 RingBuffer<float> *getWriteRingBuffer(size_t c) { 309 RingBuffer<float> *getWriteRingBuffer(int c) {
310 if (m_writeBuffers && c < m_writeBuffers->size()) { 310 if (m_writeBuffers && c < (int)m_writeBuffers->size()) {
311 return (*m_writeBuffers)[c]; 311 return (*m_writeBuffers)[c];
312 } else { 312 } else {
313 return 0; 313 return 0;
314 } 314 }
315 } 315 }
316 316
317 RingBuffer<float> *getReadRingBuffer(size_t c) { 317 RingBuffer<float> *getReadRingBuffer(int c) {
318 RingBufferVector *rb = m_readBuffers; 318 RingBufferVector *rb = m_readBuffers;
319 if (rb && c < rb->size()) { 319 if (rb && c < (int)rb->size()) {
320 return (*rb)[c]; 320 return (*rb)[c];
321 } else { 321 } else {
322 return 0; 322 return 0;
323 } 323 }
324 } 324 }
325 325
326 void clearRingBuffers(bool haveLock = false, size_t count = 0); 326 void clearRingBuffers(bool haveLock = false, int count = 0);
327 void unifyRingBuffers(); 327 void unifyRingBuffers();
328 328
329 RubberBand::RubberBandStretcher *m_timeStretcher; 329 RubberBand::RubberBandStretcher *m_timeStretcher;
330 RubberBand::RubberBandStretcher *m_monoStretcher; 330 RubberBand::RubberBandStretcher *m_monoStretcher;
331 float m_stretchRatio; 331 float m_stretchRatio;
332 bool m_stretchMono; 332 bool m_stretchMono;
333 333
334 size_t m_stretcherInputCount; 334 int m_stretcherInputCount;
335 float **m_stretcherInputs; 335 float **m_stretcherInputs;
336 size_t *m_stretcherInputSizes; 336 int *m_stretcherInputSizes;
337 337
338 // Called from fill thread, m_playing true, mutex held 338 // Called from fill thread, m_playing true, mutex held
339 // Return true if work done 339 // Return true if work done
340 bool fillBuffers(); 340 bool fillBuffers();
341 341
342 // Called from fillBuffers. Return the number of frames written, 342 // Called from fillBuffers. Return the number of frames written,
343 // which will be count or fewer. Return in the frame argument the 343 // which will be count or fewer. Return in the frame argument the
344 // new buffered frame position (which may be earlier than the 344 // new buffered frame position (which may be earlier than the
345 // frame argument passed in, in the case of looping). 345 // frame argument passed in, in the case of looping).
346 size_t mixModels(size_t &frame, size_t count, float **buffers); 346 int mixModels(int &frame, int count, float **buffers);
347 347
348 // Called from getSourceSamples. 348 // Called from getSourceSamples.
349 void applyAuditioningEffect(size_t count, float **buffers); 349 void applyAuditioningEffect(int count, float **buffers);
350 350
351 // Ranges of current selections, if play selection is active 351 // Ranges of current selections, if play selection is active
352 std::vector<RealTime> m_rangeStarts; 352 std::vector<RealTime> m_rangeStarts;
353 std::vector<RealTime> m_rangeDurations; 353 std::vector<RealTime> m_rangeDurations;
354 void rebuildRangeLists(); 354 void rebuildRangeLists();
355 355
356 size_t getCurrentFrame(RealTime outputLatency); 356 int getCurrentFrame(RealTime outputLatency);
357 357
358 class FillThread : public Thread 358 class FillThread : public Thread
359 { 359 {
360 public: 360 public:
361 FillThread(AudioCallbackPlaySource &source) : 361 FillThread(AudioCallbackPlaySource &source) :