comparison audio/AudioCallbackPlaySource.h @ 595:b23bebfdfaba

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents 298d864113f0
children 163573a73ebe
comparison
equal deleted inserted replaced
594:72b4870f0e6b 595:b23bebfdfaba
56 * per channel, filled during playback by a non-realtime thread, and 56 * per channel, filled during playback by a non-realtime thread, and
57 * provides a method for a realtime thread to pick up the latest 57 * provides a method for a realtime thread to pick up the latest
58 * available sample data from these buffers. 58 * available sample data from these buffers.
59 */ 59 */
60 class AudioCallbackPlaySource : public QObject, 60 class AudioCallbackPlaySource : public QObject,
61 public AudioPlaySource, 61 public AudioPlaySource,
62 public breakfastquay::ApplicationPlaybackSource 62 public breakfastquay::ApplicationPlaybackSource
63 { 63 {
64 Q_OBJECT 64 Q_OBJECT
65 65
66 public: 66 public:
334 AudioGenerator *m_audioGenerator; 334 AudioGenerator *m_audioGenerator;
335 std::string m_clientName; 335 std::string m_clientName;
336 336
337 class RingBufferVector : public std::vector<RingBuffer<float> *> { 337 class RingBufferVector : public std::vector<RingBuffer<float> *> {
338 public: 338 public:
339 virtual ~RingBufferVector() { 339 virtual ~RingBufferVector() {
340 while (!empty()) { 340 while (!empty()) {
341 delete *begin(); 341 delete *begin();
342 erase(begin()); 342 erase(begin());
343 } 343 }
344 } 344 }
345 }; 345 };
346 346
347 std::set<Model *> m_models; 347 std::set<Model *> m_models;
348 RingBufferVector *m_readBuffers; 348 RingBufferVector *m_readBuffers;
349 RingBufferVector *m_writeBuffers; 349 RingBufferVector *m_writeBuffers;
374 sv_frame_t m_playStartFrame; 374 sv_frame_t m_playStartFrame;
375 bool m_playStartFramePassed; 375 bool m_playStartFramePassed;
376 RealTime m_playStartedAt; 376 RealTime m_playStartedAt;
377 377
378 RingBuffer<float> *getWriteRingBuffer(int c) { 378 RingBuffer<float> *getWriteRingBuffer(int c) {
379 if (m_writeBuffers && c < (int)m_writeBuffers->size()) { 379 if (m_writeBuffers && c < (int)m_writeBuffers->size()) {
380 return (*m_writeBuffers)[c]; 380 return (*m_writeBuffers)[c];
381 } else { 381 } else {
382 return 0; 382 return 0;
383 } 383 }
384 } 384 }
385 385
386 RingBuffer<float> *getReadRingBuffer(int c) { 386 RingBuffer<float> *getReadRingBuffer(int c) {
387 RingBufferVector *rb = m_readBuffers; 387 RingBufferVector *rb = m_readBuffers;
388 if (rb && c < (int)rb->size()) { 388 if (rb && c < (int)rb->size()) {
389 return (*rb)[c]; 389 return (*rb)[c];
390 } else { 390 } else {
391 return 0; 391 return 0;
392 } 392 }
393 } 393 }
394 394
395 void clearRingBuffers(bool haveLock = false, int count = 0); 395 void clearRingBuffers(bool haveLock = false, int count = 0);
396 void unifyRingBuffers(); 396 void unifyRingBuffers();
397 397
425 sv_frame_t getCurrentFrame(RealTime outputLatency); 425 sv_frame_t getCurrentFrame(RealTime outputLatency);
426 426
427 class FillThread : public Thread 427 class FillThread : public Thread
428 { 428 {
429 public: 429 public:
430 FillThread(AudioCallbackPlaySource &source) : 430 FillThread(AudioCallbackPlaySource &source) :
431 Thread(Thread::NonRTThread), 431 Thread(Thread::NonRTThread),
432 m_source(source) { } 432 m_source(source) { }
433 433
434 virtual void run(); 434 virtual void run();
435 435
436 protected: 436 protected:
437 AudioCallbackPlaySource &m_source; 437 AudioCallbackPlaySource &m_source;
438 }; 438 };
439 439
440 QMutex m_mutex; 440 QMutex m_mutex;
441 QWaitCondition m_condition; 441 QWaitCondition m_condition;
442 FillThread *m_fillThread; 442 FillThread *m_fillThread;