changeset 741:6508d9d216c7 audio-source-refactor

Comments & tidying
author Chris Cannam
date Mon, 23 Mar 2020 14:14:20 +0000
parents 846970dbef17
children 1c6c10cc5f73
files audio/AudioCallbackPlaySource.cpp audio/AudioCallbackPlaySource.h
diffstat 2 files changed, 14 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/audio/AudioCallbackPlaySource.cpp	Fri Mar 20 16:31:58 2020 +0000
+++ b/audio/AudioCallbackPlaySource.cpp	Mon Mar 23 14:14:20 2020 +0000
@@ -612,8 +612,6 @@
 void
 AudioCallbackPlaySource::setSystemPlaybackTarget(breakfastquay::SystemPlaybackTarget *target)
 {
-    //!!! This should go, we should be using the ApplicationPlaybackSource callbacks
-    
     if (target == nullptr) {
         // reset target-related facts and figures
         m_deviceSampleRate = 0;
@@ -625,16 +623,16 @@
 void
 AudioCallbackPlaySource::setSystemPlaybackBlockSize(int size)
 {
-    cout << "AudioCallbackPlaySource::setTarget: Block size -> " << size << endl;
+    SVDEBUG << "AudioCallbackPlaySource::setTarget: Block size -> " << size << endl;
     if (size != 0) {
         m_blockSize = size;
     }
     if (size * 4 > m_ringBufferSize) {
 #ifdef DEBUG_AUDIO_PLAY_SOURCE
-        cout << "AudioCallbackPlaySource::setTarget: Buffer size "
-             << size << " > a quarter of ring buffer size "
-             << m_ringBufferSize << ", calling for more ring buffer"
-             << endl;
+        SVCERR << "AudioCallbackPlaySource::setTarget: Buffer size "
+               << size << " > a quarter of ring buffer size "
+               << m_ringBufferSize << ", calling for more ring buffer"
+               << endl;
 #endif
         m_ringBufferSize = size * 4;
         if (m_writeBuffers && !m_writeBuffers->empty()) {
@@ -721,17 +719,6 @@
 
     RealTime inbuffer_t = RealTime::frame2RealTime(inbuffer, rate);
 
-    /*!!!
-    sv_frame_t stretchlat = 0;
-    double timeRatio = 1.0;
-
-    if (m_timeStretcher) {
-        stretchlat = m_timeStretcher->getLatency();
-        timeRatio = m_timeStretcher->getTimeRatio();
-    }
-
-    RealTime stretchlat_t = RealTime::frame2RealTime(stretchlat, rate);
-    */
     // When the target has just requested a block from us, the last
     // sample it obtained was our buffer fill frame count minus the
     // amount of read space (converted back to source sample rate)
@@ -785,7 +772,6 @@
     if (m_rangeStarts.empty()) {
         // this code is only used in case of error in rebuildRangeLists
         RealTime playing_t = bufferedto_t
-//!!!            - latency_t - stretchlat_t - lastretrieved_t - inbuffer_t
             - latency_t - lastretrieved_t - inbuffer_t
             + sincerequest_t;
         if (playing_t < RealTime::zeroTime) playing_t = RealTime::zeroTime;
@@ -812,7 +798,6 @@
     RealTime playing_t = bufferedto_t;
 
     playing_t = playing_t
-//!!!        - latency_t - stretchlat_t - lastretrieved_t - inbuffer_t
         - latency_t - lastretrieved_t - inbuffer_t
         + sincerequest_t;
 
@@ -831,9 +816,7 @@
         if (playing_t < playstart_t) {
 //            cout << "playing_t " << playing_t << " < playstart_t " 
 //                      << playstart_t << endl;
-            if (/*!!! sincerequest_t > RealTime::zeroTime && */
-//!!!                m_playStartedAt + latency_t + stretchlat_t <
-                m_playStartedAt + latency_t <
+            if (m_playStartedAt + latency_t <
                 RealTime::fromSeconds(currentTime)) {
 //                cout << "but we've been playing for long enough that I think we should disregard it (it probably results from loop wrapping)" << endl;
                 m_playStartFramePassed = true;
--- a/audio/AudioCallbackPlaySource.h	Fri Mar 20 16:31:58 2020 +0000
+++ b/audio/AudioCallbackPlaySource.h	Mon Mar 23 14:14:20 2020 +0000
@@ -58,7 +58,6 @@
  */
 class AudioCallbackPlaySource : public QObject,
                                 public AudioPlaySource,
-                                //!!! to remove:
                                 public breakfastquay::ApplicationPlaybackSource
 {
     Q_OBJECT
@@ -68,11 +67,14 @@
     virtual ~AudioCallbackPlaySource();
 
     /**
-     * Return an ApplicationPlaybackSource interface to this class.
-     * The returned pointer is only borrowed, and the object continues
-     * to be owned by us. Caller must ensure the lifetime of the
-     * AudioCallbackPlaySource exceeds the scope in which the pointer
-     * is retained.
+     * Return an ApplicationPlaybackSource interface to this
+     * class. Although this class implements ApplicationPlaybackSource
+     * itself, the object returned here may be a wrapper which
+     * provides facilities not implemented in this class, such as
+     * time-stretching, resampling, and an auditioning effect.  The
+     * returned pointer points to an object which is owned by this
+     * object. Caller must ensure the lifetime of this object exceeds
+     * the scope which the returned pointer is retained.
      */
     breakfastquay::ApplicationPlaybackSource *getApplicationPlaybackSource();