diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-10-21 16:24:24 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-10-21 16:24:24 -0400 |
commit | cfe42bc4ea9a5a6234f43c173e14fdd89af39589 (patch) | |
tree | 9af6cd22c43c9e92523e48311499f8bca636f7a7 | |
parent | f1a6735ca4f36b5291b472463b979df01300cbac (diff) |
fix issues with recording while synced to JACK (non-pure-virtual method added to AudioBackend) and remove pause() from AudioEngine/AudioBackend APIs
-rw-r--r-- | libs/ardour/ardour/audio_backend.h | 29 | ||||
-rw-r--r-- | libs/ardour/ardour/audioengine.h | 1 | ||||
-rw-r--r-- | libs/ardour/audioengine.cc | 17 | ||||
-rw-r--r-- | libs/ardour/engine_slave.cc | 26 | ||||
-rw-r--r-- | libs/backends/jack/jack_audiobackend.cc | 55 | ||||
-rw-r--r-- | libs/backends/jack/jack_audiobackend.h | 5 | ||||
-rw-r--r-- | libs/backends/jack/jack_session.cc | 1 |
7 files changed, 70 insertions, 64 deletions
diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h index 21f050afdd..26ced33885 100644 --- a/libs/ardour/ardour/audio_backend.h +++ b/libs/ardour/ardour/audio_backend.h @@ -327,20 +327,6 @@ class AudioBackend : public PortEngine { */ virtual int stop () = 0; - /** Temporarily cease using the device named in the most recent call to set_parameters(). - * - * If the function is successfully called, no subsequent calls to the - * process_callback() of @param engine will be made after the function - * returns, until start() is called again. - * - * The backend will retain its existing parameter configuration after a successful - * return, and does NOT require any calls to set hardware parameters before it can be - * start()-ed again. - * - * Return zero if successful, 1 if the device is not in use, negative values on error - */ - virtual int pause () = 0; - /** While remaining connected to the device, and without changing its * configuration, start (or stop) calling the process_callback() of @param engine * without waiting for the device. Once process_callback() has returned, it @@ -478,6 +464,21 @@ class AudioBackend : public PortEngine { virtual void update_latencies () = 0; + /** Set @param speed and @param position to the current speed and position + * indicated by some transport sync signal. Return whether the current + * transport state is pending, or finalized. + * + * Derived classes only need implement this if they provide some way to + * sync to a transport sync signal (e.g. Sony 9 Pin) that is not + * handled by Ardour itself (LTC and MTC are both handled by Ardour). + * The canonical example is JACK Transport. + */ + virtual bool speed_and_position (double& speed, framepos_t& position) { + speed = 0.0; + position = 0; + return false; + } + protected: AudioEngine& engine; }; diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index d5dcbffe2b..7c05f40b82 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -85,7 +85,6 @@ public: int start (bool for_latency_measurement=false); int stop (bool for_latency_measurement=false); - int pause (); int freewheel (bool start_stop); float get_cpu_load() const ; void transport_start (); diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index c2224a8b5e..45b8bbf757 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -663,23 +663,6 @@ AudioEngine::stop (bool for_latency) } int -AudioEngine::pause () -{ - if (!_backend) { - return 0; - } - - if (_backend->pause ()) { - return -1; - } - - _running = false; - - Stopped(); /* EMIT SIGNAL */ - return 0; -} - -int AudioEngine::freewheel (bool start_stop) { if (!_backend) { diff --git a/libs/ardour/engine_slave.cc b/libs/ardour/engine_slave.cc index eb55c9ba54..849b7320d3 100644 --- a/libs/ardour/engine_slave.cc +++ b/libs/ardour/engine_slave.cc @@ -21,6 +21,7 @@ #include <cerrno> #include "ardour/audioengine.h" +#include "ardour/audio_backend.h" #include "ardour/slave.h" using namespace std; @@ -54,26 +55,13 @@ Engine_Slave::ok() const bool Engine_Slave::speed_and_position (double& sp, framepos_t& position) { - switch (engine.transport_state()) { - case TransportStopped: - speed = 0; - _starting = false; - break; - case TransportRolling: - speed = 1.0; - _starting = false; - break; - case TransportLooping: - speed = 1.0; + boost::shared_ptr<AudioBackend> backend = engine.current_backend(); + + if (backend) { + _starting = backend->speed_and_position (sp, position); + } else { _starting = false; - break; - case TransportStarting: - _starting = true; - // don't adjust speed here, just leave it as it was - break; } - - sp = speed; - position = engine.transport_frame(); + return true; } diff --git a/libs/backends/jack/jack_audiobackend.cc b/libs/backends/jack/jack_audiobackend.cc index ff76486bad..7a9b993251 100644 --- a/libs/backends/jack/jack_audiobackend.cc +++ b/libs/backends/jack/jack_audiobackend.cc @@ -582,18 +582,6 @@ JACKAudioBackend::stop () } int -JACKAudioBackend::pause () -{ - GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1); - - if (_priv_jack) { - jack_deactivate (_priv_jack); - } - - return 0; -} - -int JACKAudioBackend::freewheel (bool onoff) { GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1); @@ -1131,3 +1119,46 @@ JACKAudioBackend::set_midi_option (const string& opt) _target_midi_option = opt; return 0; } + +bool +JACKAudioBackend::speed_and_position (double& speed, framepos_t& position) +{ + jack_position_t pos; + jack_transport_state_t state; + bool starting; + + /* this won't be called if the port engine in use is not JACK, so we do + not have to worry about the type of PortEngine::private_handle() + */ + + speed = 0; + position = 0; + + GET_PRIVATE_JACK_POINTER_RET (_priv_jack, true); + + state = jack_transport_query (_priv_jack, &pos); + + switch (state) { + case JackTransportStopped: + speed = 0; + starting = false; + break; + case JackTransportRolling: + speed = 1.0; + starting = false; + break; + case JackTransportLooping: + speed = 1.0; + starting = false; + break; + case JackTransportStarting: + starting = true; + // don't adjust speed here, just leave it as it was + break; + default: + std::cerr << "WARNING: Unknown JACK transport state: " << state << std::endl; + } + + position = pos.frame; + return starting; +} diff --git a/libs/backends/jack/jack_audiobackend.h b/libs/backends/jack/jack_audiobackend.h index 3c48be5ead..c59ddb5c67 100644 --- a/libs/backends/jack/jack_audiobackend.h +++ b/libs/backends/jack/jack_audiobackend.h @@ -91,7 +91,6 @@ class JACKAudioBackend : public AudioBackend { int _start (bool for_latency_measurement); int stop (); - int pause (); int freewheel (bool); float cpu_load() const; @@ -183,6 +182,10 @@ class JACKAudioBackend : public AudioBackend { void* get_buffer (PortHandle, pframes_t); + /* transport sync */ + + bool speed_and_position (double& sp, framepos_t& pos); + private: boost::shared_ptr<JackConnection> _jack_connection; bool _running; diff --git a/libs/backends/jack/jack_session.cc b/libs/backends/jack/jack_session.cc index ca51dafccc..7cd7f6c62b 100644 --- a/libs/backends/jack/jack_session.cc +++ b/libs/backends/jack/jack_session.cc @@ -23,6 +23,7 @@ #include <glibmm/miscutils.h> #include <jack/jack.h> +#include <jack/transport.h> #include "ardour/audioengine.h" #include "ardour/filename_extensions.h" |