move AudioBackend::_start() into protected, and expand a bit on documenting ::start...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 27 Nov 2013 19:27:27 +0000 (14:27 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 27 Nov 2013 19:27:27 +0000 (14:27 -0500)
libs/ardour/ardour/audio_backend.h
libs/backends/jack/jack_audiobackend.h

index 26ced33885b76f69063a0c6681639b51449dbbcc..17d7cd4010413023b8733d336f13348f8f3305bd 100644 (file)
@@ -282,17 +282,7 @@ class AudioBackend : public PortEngine {
     virtual std::string midi_option () const = 0;
     
     /* State Control */
-
-    /* non-virtual method to avoid possible overrides of default
-     * parameters. See Scott Meyers or other books on C++ to
-     * understand this pattern, or possibly just this:
-     *
-     * http://stackoverflow.com/questions/12139786/good-pratice-default-arguments-for-pure-virtual-method
-     */ 
-    int start (bool for_latency_measurement=false) {
-           return _start (for_latency_measurement);
-    }
-
     /** Start using the device named in the most recent call
      * to set_device(), with the parameters set by various
      * the most recent calls to set_sample_rate() etc. etc.
@@ -308,8 +298,24 @@ class AudioBackend : public PortEngine {
      *        any existing systemic latency settings.
      *
      * Return zero if successful, negative values otherwise.
-     */
-    virtual int _start (bool for_latency_measurement) = 0;
+     *
+     *
+     *
+     *
+     * Why is this non-virtual but ::_start() is virtual ?
+     * Virtual methods with default parameters create possible ambiguity
+     * because a derived class may implement the same method with a different
+     * type or value of default parameter.
+     *
+     * So we make this non-virtual method to avoid possible overrides of
+     * default parameters. See Scott Meyers or other books on C++ to understand
+     * this pattern, or possibly just this:
+     *
+     * http://stackoverflow.com/questions/12139786/good-pratice-default-arguments-for-pure-virtual-method
+     */ 
+    int start (bool for_latency_measurement=false) {
+           return _start (for_latency_measurement);
+    }
 
     /** Stop using the device currently in use. 
      *
@@ -481,6 +487,8 @@ class AudioBackend : public PortEngine {
 
   protected:
     AudioEngine&          engine;
+
+    virtual int _start (bool for_latency_measurement) = 0;
 };
 
 struct AudioBackendInfo {
index 2c77e6112b89fb55cdb3daf92c7092cfef8f03eb..299bb1cefd098a9f7b577d68b073f7e7882dafc5 100644 (file)
@@ -89,7 +89,6 @@ class JACKAudioBackend : public AudioBackend {
     std::string control_app_name () const;
     void launch_control_app ();
 
-    int _start (bool for_latency_measurement);
     int stop ();
     int freewheel (bool);
 
@@ -272,6 +271,9 @@ class JACKAudioBackend : public AudioBackend {
     */
 
     JACKSession* _session;
+
+  protected:
+    int _start (bool for_latency_measurement);
 };
 
 } // namespace