comparison audioio/AudioCallbackPlaySource.h @ 434:dee4aceb131c cxx11

Fixes to go with latest svcore
author Chris Cannam
date Wed, 04 Mar 2015 13:53:13 +0000
parents 1e4fa2007e61
children 618d5816b04d
comparison
equal deleted inserted replaced
433:720f732e8082 434:dee4aceb131c
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(int startFrame); 86 virtual void play(sv_frame_t 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 int getCurrentPlayingFrame(); 102 virtual sv_frame_t 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 int getCurrentBufferedFrame(); 108 virtual sv_frame_t 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 int getPlayEndFrame() { return m_lastModelEndFrame; } 113 virtual sv_frame_t 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 */
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(int); 136 void setTargetPlayLatency(sv_frame_t);
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 int getTargetPlayLatency() const; 141 sv_frame_t 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(int); 150 void setTargetSampleRate(sv_samplerate_t);
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 int getTargetSampleRate() const; 156 virtual sv_samplerate_t 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 */
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 int getSourceSampleRate() const; 192 virtual sv_samplerate_t 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 int getSourceSamples(int count, float **buffer); 199 sv_frame_t getSourceSamples(sv_frame_t 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);
283 int m_readBufferFill; 283 int m_readBufferFill;
284 int m_writeBufferFill; 284 int m_writeBufferFill;
285 Scavenger<RingBufferVector> m_bufferScavenger; 285 Scavenger<RingBufferVector> m_bufferScavenger;
286 int m_sourceChannelCount; 286 int m_sourceChannelCount;
287 int m_blockSize; 287 int m_blockSize;
288 int m_sourceSampleRate; 288 sv_samplerate_t m_sourceSampleRate;
289 int m_targetSampleRate; 289 sv_samplerate_t m_targetSampleRate;
290 int m_playLatency; 290 int m_playLatency;
291 AudioCallbackPlayTarget *m_target; 291 AudioCallbackPlayTarget *m_target;
292 double m_lastRetrievalTimestamp; 292 double m_lastRetrievalTimestamp;
293 int m_lastRetrievedBlockSize; 293 int m_lastRetrievedBlockSize;
294 bool m_trustworthyTimestamps; 294 bool m_trustworthyTimestamps;
295 int m_lastCurrentFrame; 295 sv_frame_t m_lastCurrentFrame;
296 bool m_playing; 296 bool m_playing;
297 bool m_exiting; 297 bool m_exiting;
298 int m_lastModelEndFrame; 298 sv_frame_t m_lastModelEndFrame;
299 int 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 int m_playStartFrame; 305 sv_frame_t m_playStartFrame;
306 bool m_playStartFramePassed; 306 bool m_playStartFramePassed;
307 RealTime m_playStartedAt; 307 RealTime m_playStartedAt;
308 308
309 RingBuffer<float> *getWriteRingBuffer(int c) { 309 RingBuffer<float> *getWriteRingBuffer(int c) {
310 if (m_writeBuffers && c < (int)m_writeBuffers->size()) { 310 if (m_writeBuffers && c < (int)m_writeBuffers->size()) {
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 int mixModels(int &frame, int count, float **buffers); 346 sv_frame_t mixModels(sv_frame_t &frame, sv_frame_t count, float **buffers);
347 347
348 // Called from getSourceSamples. 348 // Called from getSourceSamples.
349 void applyAuditioningEffect(int count, float **buffers); 349 void applyAuditioningEffect(sv_frame_t 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 int getCurrentFrame(RealTime outputLatency); 356 sv_frame_t 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) :