summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/SConscript2
-rw-r--r--libs/ardour/ardour/audioengine.h34
-rw-r--r--libs/ardour/ardour/sndfile_helpers.h2
-rw-r--r--libs/ardour/audioengine.cc360
-rw-r--r--libs/ardour/audiofilesource.cc3
-rw-r--r--libs/ardour/session_export.cc5
-rw-r--r--libs/ardour/sndfile_helpers.cc6
7 files changed, 199 insertions, 213 deletions
diff --git a/libs/ardour/SConscript b/libs/ardour/SConscript
index 100986b5db..6dfc62ecbc 100644
--- a/libs/ardour/SConscript
+++ b/libs/ardour/SConscript
@@ -281,7 +281,7 @@ ardour.Merge ([
libraries['raptor'],
libraries['samplerate'],
libraries['sigc2'],
- libraries['sndfile-ardour'],
+ libraries['sndfile'],
libraries['vamp'],
libraries['vamphost'],
libraries['xml']
diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h
index 6ba141248c..2d2acfed27 100644
--- a/libs/ardour/ardour/audioengine.h
+++ b/libs/ardour/ardour/audioengine.h
@@ -76,26 +76,31 @@ class AudioEngine : public sigc::trackable
bool get_sync_offset (nframes_t& offset) const;
nframes_t frames_since_cycle_start () {
- if (!_running || !_jack) return 0;
- return jack_frames_since_cycle_start (_jack);
+ jack_client_t* _priv_jack = _jack;
+ if (!_running || !_priv_jack) return 0;
+ return jack_frames_since_cycle_start (_priv_jack);
}
nframes_t frame_time () {
- if (!_running || !_jack) return 0;
- return jack_frame_time (_jack);
+ jack_client_t* _priv_jack = _jack;
+ if (!_running || !_priv_jack) return 0;
+ return jack_frame_time (_priv_jack);
}
nframes_t transport_frame () const {
- if (!_running || !_jack) return 0;
- return jack_get_current_transport_frame (_jack);
+ const jack_client_t* _priv_jack = _jack;
+ if (!_running || !_priv_jack) return 0;
+ return jack_get_current_transport_frame (_priv_jack);
}
int request_buffer_size (nframes_t);
nframes_t set_monitor_check_interval (nframes_t);
+ nframes_t processed_frames() const { return _processed_frames; }
float get_cpu_load() {
- if (!_running || !_jack) return 0;
- return jack_cpu_load (_jack);
+ jack_client_t* _priv_jack = _jack;
+ if (!_running || !_priv_jack) return 0;
+ return jack_cpu_load (_priv_jack);
}
void set_session (Session *);
@@ -172,7 +177,7 @@ class AudioEngine : public sigc::trackable
bool freewheeling() const { return _freewheeling; }
/* this signal is sent for every process() cycle while freewheeling.
- the regular process() call to session->process() is not made.
+_ the regular process() call to session->process() is not made.
*/
sigc::signal<int,nframes_t> Freewheel;
@@ -201,9 +206,14 @@ class AudioEngine : public sigc::trackable
std::string make_port_name_relative (std::string);
std::string make_port_name_non_relative (std::string);
+ static AudioEngine* instance() { return _instance; }
+ void died ();
+
private:
+ static AudioEngine* _instance;
+
ARDOUR::Session* session;
- jack_client_t* _jack;
+ jack_client_t* volatile _jack; /* could be reset to null by SIGPIPE or another thread */
std::string jack_client_name;
Glib::Mutex _process_lock;
Glib::Cond session_removed;
@@ -252,10 +262,10 @@ class AudioEngine : public sigc::trackable
int jack_bufsize_callback (nframes_t);
int jack_sample_rate_callback (nframes_t);
- static void halted (void *);
-
int connect_to_jack (std::string client_name);
+ static void halted (void *);
+
void meter_thread ();
void start_metering_thread ();
void stop_metering_thread ();
diff --git a/libs/ardour/ardour/sndfile_helpers.h b/libs/ardour/ardour/sndfile_helpers.h
index cf6b15f3a4..26a93ad124 100644
--- a/libs/ardour/ardour/sndfile_helpers.h
+++ b/libs/ardour/ardour/sndfile_helpers.h
@@ -28,7 +28,7 @@ using std::string;
// Use this define when initializing arrarys for use in sndfile_*_format()
#define SNDFILE_STR_LENGTH 32
-#define SNDFILE_HEADER_FORMATS 5
+#define SNDFILE_HEADER_FORMATS 7
extern const char * const sndfile_header_formats_strings[SNDFILE_HEADER_FORMATS+1];
extern const char * const sndfile_file_endings_strings[SNDFILE_HEADER_FORMATS+1];
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc
index 4e9960c7bd..bc528b2146 100644
--- a/libs/ardour/audioengine.cc
+++ b/libs/ardour/audioengine.cc
@@ -43,6 +43,10 @@ using namespace ARDOUR;
using namespace PBD;
gint AudioEngine::m_meter_exit;
+AudioEngine* AudioEngine::_instance = 0;
+
+#define GET_PRIVATE_JACK_POINTER(j) jack_client_t* _priv_jack = (jack_client_t*) (j); if (!_priv_jack) { return; }
+#define GET_PRIVATE_JACK_POINTER_RET(j,r) jack_client_t* _priv_jack = (jack_client_t*) (j); if (!_priv_jack) { return r; }
static void
ardour_jack_error (const char* msg)
@@ -54,6 +58,8 @@ ardour_jack_error (const char* msg)
AudioEngine::AudioEngine (string client_name)
: ports (new Ports)
{
+ _instance = this; /* singleton */
+
session = 0;
session_remove_pending = false;
_running = false;
@@ -104,14 +110,11 @@ _thread_init_callback (void *arg)
int
AudioEngine::start ()
{
- if (!_jack) {
- error << _("AudioEngine::start() called while disconnected from JACK") << endmsg;
- return -1;
- }
+ GET_PRIVATE_JACK_POINTER_RET (_jack, -1);
if (!_running) {
- nframes_t blocksize = jack_get_buffer_size (_jack);
+ nframes_t blocksize = jack_get_buffer_size (_priv_jack);
Port::set_buffer_size (blocksize);
if (session) {
@@ -119,7 +122,7 @@ AudioEngine::start ()
BootMessage (_("Connect session to engine"));
session->set_block_size (blocksize);
- session->set_frame_rate (jack_get_sample_rate (_jack));
+ session->set_frame_rate (jack_get_sample_rate (_priv_jack));
/* page in as much of the session process code as we
can before we really start running.
@@ -138,21 +141,21 @@ AudioEngine::start ()
_processed_frames = 0;
last_monitor_check = 0;
- jack_on_shutdown (_jack, halted, this);
- jack_set_graph_order_callback (_jack, _graph_order_callback, this);
- jack_set_thread_init_callback (_jack, _thread_init_callback, this);
- jack_set_process_callback (_jack, _process_callback, this);
- jack_set_sample_rate_callback (_jack, _sample_rate_callback, this);
- jack_set_buffer_size_callback (_jack, _bufsize_callback, this);
- jack_set_xrun_callback (_jack, _xrun_callback, this);
- jack_set_sync_callback (_jack, _jack_sync_callback, this);
- jack_set_freewheel_callback (_jack, _freewheel_callback, this);
+ jack_on_shutdown (_priv_jack, halted, this);
+ jack_set_graph_order_callback (_priv_jack, _graph_order_callback, this);
+ jack_set_thread_init_callback (_priv_jack, _thread_init_callback, this);
+ jack_set_process_callback (_priv_jack, _process_callback, this);
+ jack_set_sample_rate_callback (_priv_jack, _sample_rate_callback, this);
+ jack_set_buffer_size_callback (_priv_jack, _bufsize_callback, this);
+ jack_set_xrun_callback (_priv_jack, _xrun_callback, this);
+ jack_set_sync_callback (_priv_jack, _jack_sync_callback, this);
+ jack_set_freewheel_callback (_priv_jack, _freewheel_callback, this);
if (Config->get_jack_time_master()) {
- jack_set_timebase_callback (_jack, 0, _jack_timebase_callback, this);
+ jack_set_timebase_callback (_priv_jack, 0, _jack_timebase_callback, this);
}
- if (jack_activate (_jack) == 0) {
+ if (jack_activate (_priv_jack) == 0) {
_running = true;
_has_run = true;
Running(); /* EMIT SIGNAL */
@@ -169,11 +172,13 @@ AudioEngine::start ()
int
AudioEngine::stop (bool forever)
{
- if (_jack) {
+ GET_PRIVATE_JACK_POINTER_RET (_jack, -1);
+
+ if (_priv_jack) {
if (forever) {
disconnect_from_jack ();
} else {
- jack_deactivate (_jack);
+ jack_deactivate (_priv_jack);
Stopped(); /* EMIT SIGNAL */
}
}
@@ -188,10 +193,12 @@ AudioEngine::get_sync_offset (nframes_t& offset) const
#ifdef HAVE_JACK_VIDEO_SUPPORT
+ GET_PRIVATE_JACK_POINTER_RET (_jack, false);
+
jack_position_t pos;
- if (_jack) {
- (void) jack_transport_query (_jack, &pos);
+ if (_priv_jack) {
+ (void) jack_transport_query (_priv_jack, &pos);
if (pos.valid & JackVideoFrameOffset) {
offset = pos.video_offset;
@@ -272,6 +279,7 @@ int
AudioEngine::process_callback (nframes_t nframes)
{
// CycleTimer ct ("AudioEngine::process");
+ GET_PRIVATE_JACK_POINTER_RET (_jack, -1);
Glib::Mutex::Lock tm (_process_lock, Glib::TRY_LOCK);
nframes_t next_processed_frames;
@@ -306,7 +314,7 @@ AudioEngine::process_callback (nframes_t nframes)
if (_freewheeling) {
if (Freewheel (nframes)) {
- jack_set_freewheel (_jack, false);
+ jack_set_freewheel (_priv_jack, false);
}
return 0;
}
@@ -498,12 +506,13 @@ AudioEngine::remove_session ()
void
AudioEngine::port_registration_failure (const std::string& portname)
{
+ GET_PRIVATE_JACK_POINTER (_jack);
string full_portname = jack_client_name;
full_portname += ':';
full_portname += portname;
- jack_port_t* p = jack_port_by_name (_jack, full_portname.c_str());
+ jack_port_t* p = jack_port_by_name (_priv_jack, full_portname.c_str());
string reason;
if (p) {
@@ -518,6 +527,7 @@ AudioEngine::port_registration_failure (const std::string& portname)
Port *
AudioEngine::register_input_port (DataType type, const string& portname)
{
+ GET_PRIVATE_JACK_POINTER_RET (_jack, 0);
if (!_running) {
if (!_has_run) {
fatal << _("register input port called before engine was started") << endmsg;
@@ -527,7 +537,7 @@ AudioEngine::register_input_port (DataType type, const string& portname)
}
}
- jack_port_t *p = jack_port_register (_jack, portname.c_str(), type.to_jack_type(), JackPortIsInput, 0);
+ jack_port_t *p = jack_port_register (_priv_jack, portname.c_str(), type.to_jack_type(), JackPortIsInput, 0);
if (p) {
@@ -552,6 +562,8 @@ AudioEngine::register_input_port (DataType type, const string& portname)
Port *
AudioEngine::register_output_port (DataType type, const string& portname)
{
+ GET_PRIVATE_JACK_POINTER_RET (_jack, 0);
+
if (!_running) {
if (!_has_run) {
fatal << _("register output port called before engine was started") << endmsg;
@@ -563,7 +575,7 @@ AudioEngine::register_output_port (DataType type, const string& portname)
jack_port_t *p;
- if ((p = jack_port_register (_jack, portname.c_str(),
+ if ((p = jack_port_register (_priv_jack, portname.c_str(),
type.to_jack_type(), JackPortIsOutput, 0)) != 0) {
Port *newport = 0;
@@ -591,6 +603,8 @@ AudioEngine::register_output_port (DataType type, const string& portname)
int
AudioEngine::unregister_port (Port *port)
{
+ GET_PRIVATE_JACK_POINTER_RET (_jack,-1);
+
if (!_running) {
/* probably happening when the engine has been halted by JACK,
in which case, there is nothing we can do here.
@@ -600,7 +614,7 @@ AudioEngine::unregister_port (Port *port)
if (port) {
- int ret = jack_port_unregister (_jack, port->_port);
+ int ret = jack_port_unregister (_priv_jack, port->_port);
if (ret == 0) {
@@ -632,19 +646,12 @@ AudioEngine::unregister_port (Port *port)
int
AudioEngine::connect (const string& source, const string& destination)
{
- if (!_running) {
- if (!_has_run) {
- fatal << _("connect called before engine was started") << endmsg;
- /*NOTREACHED*/
- } else {
- return -1;
- }
- }
+ GET_PRIVATE_JACK_POINTER_RET (_jack, -1);
string s = make_port_name_non_relative (source);
string d = make_port_name_non_relative (destination);
- int ret = jack_connect (_jack, s.c_str(), d.c_str());
+ int ret = jack_connect (_priv_jack, s.c_str(), d.c_str());
if (ret == 0) {
pair<string,string> c (s, d);
@@ -665,6 +672,8 @@ AudioEngine::connect (const string& source, const string& destination)
int
AudioEngine::disconnect (const string& source, const string& destination)
{
+ GET_PRIVATE_JACK_POINTER_RET (_jack,-1);
+
if (!_running) {
if (!_has_run) {
fatal << _("disconnect called before engine was started") << endmsg;
@@ -677,7 +686,7 @@ AudioEngine::disconnect (const string& source, const string& destination)
string s = make_port_name_non_relative (source);
string d = make_port_name_non_relative (destination);
- int ret = jack_disconnect (_jack, s.c_str(), d.c_str());
+ int ret = jack_disconnect (_priv_jack, s.c_str(), d.c_str());
if (ret == 0) {
pair<string,string> c (s, d);
@@ -694,6 +703,8 @@ AudioEngine::disconnect (const string& source, const string& destination)
int
AudioEngine::disconnect (Port *port)
{
+ GET_PRIVATE_JACK_POINTER_RET (_jack,-1);
+
if (!_running) {
if (!_has_run) {
fatal << _("disconnect called before engine was started") << endmsg;
@@ -703,7 +714,7 @@ AudioEngine::disconnect (Port *port)
}
}
- int ret = jack_port_disconnect (_jack, port->_port);
+ int ret = jack_port_disconnect (_priv_jack, port->_port);
if (ret == 0) {
remove_connections_for (port);
@@ -716,34 +727,22 @@ AudioEngine::disconnect (Port *port)
nframes_t
AudioEngine::frame_rate ()
{
- if (_jack) {
- if (_frame_rate == 0) {
- return (_frame_rate = jack_get_sample_rate (_jack));
- } else {
- return _frame_rate;
- }
+ GET_PRIVATE_JACK_POINTER_RET (_jack,0);
+ if (_frame_rate == 0) {
+ return (_frame_rate = jack_get_sample_rate (_priv_jack));
} else {
- fatal << X_("programming error: AudioEngine::frame_rate() called while disconnected from JACK")
- << endmsg;
- /*NOTREACHED*/
- return 0;
+ return _frame_rate;
}
}
nframes_t
AudioEngine::frames_per_cycle ()
{
- if (_jack) {
- if (_buffer_size == 0) {
- return (_buffer_size = jack_get_buffer_size (_jack));
- } else {
- return _buffer_size;
- }
+ GET_PRIVATE_JACK_POINTER_RET (_jack,0);
+ if (_buffer_size == 0) {
+ return (_buffer_size = jack_get_buffer_size (_jack));
} else {
- fatal << X_("programming error: AudioEngine::frame_rate() called while disconnected from JACK")
- << endmsg;
- /*NOTREACHED*/
- return 0;
+ return _buffer_size;
}
}
@@ -751,6 +750,7 @@ Port *
AudioEngine::get_port_by_name (const string& portname, bool keep)
{
Glib::Mutex::Lock lm (_process_lock);
+ GET_PRIVATE_JACK_POINTER_RET (_jack,0);
if (!_running) {
if (!_has_run) {
@@ -773,7 +773,7 @@ AudioEngine::get_port_by_name (const string& portname, bool keep)
jack_port_t *p;
- if ((p = jack_port_by_name (_jack, portname.c_str())) != 0) {
+ if ((p = jack_port_by_name (_priv_jack, portname.c_str())) != 0) {
Port *newport = new Port (p);
{
@@ -796,6 +796,7 @@ AudioEngine::get_port_by_name (const string& portname, bool keep)
const char **
AudioEngine::get_ports (const string& port_name_pattern, const string& type_name_pattern, uint32_t flags)
{
+ GET_PRIVATE_JACK_POINTER_RET (_jack,0);
if (!_running) {
if (!_has_run) {
fatal << _("get_ports called before engine was started") << endmsg;
@@ -804,12 +805,14 @@ AudioEngine::get_ports (const string& port_name_pattern, const string& type_name
return 0;
}
}
- return jack_get_ports (_jack, port_name_pattern.c_str(), type_name_pattern.c_str(), flags);
+ return jack_get_ports (_priv_jack, port_name_pattern.c_str(), type_name_pattern.c_str(), flags);
}
void
AudioEngine::halted (void *arg)
{
+ /* called from jack shutdown handler */
+
AudioEngine* ae = static_cast<AudioEngine *> (arg);
bool was_running = ae->_running;
@@ -825,16 +828,26 @@ AudioEngine::halted (void *arg)
}
}
+void
+AudioEngine::died ()
+{
+ /* called from a signal handler for SIGPIPE */
+
+ stop_metering_thread ();
+
+ _running = false;
+ _buffer_size = 0;
+ _frame_rate = 0;
+ _jack = 0;
+}
+
bool
AudioEngine::can_request_hardware_monitoring ()
{
+ GET_PRIVATE_JACK_POINTER_RET (_jack,false);
const char ** ports;
- if (!_jack) {
- return 0;
- }
-
- if ((ports = jack_get_ports (_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortCanMonitor)) == 0) {
+ if ((ports = jack_get_ports (_priv_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortCanMonitor)) == 0) {
return false;
}
@@ -847,14 +860,11 @@ AudioEngine::can_request_hardware_monitoring ()
uint32_t
AudioEngine::n_physical_audio_outputs () const
{
+ GET_PRIVATE_JACK_POINTER_RET (_jack,0);
const char ** ports;
uint32_t i = 0;
- if (!_jack) {
- return 0;
- }
-
- if ((ports = jack_get_ports (_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|JackPortIsInput)) == 0) {
+ if ((ports = jack_get_ports (_priv_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|JackPortIsInput)) == 0) {
return 0;
}
@@ -867,14 +877,11 @@ AudioEngine::n_physical_audio_outputs () const
uint32_t
AudioEngine::n_physical_audio_inputs () const
{
+ GET_PRIVATE_JACK_POINTER_RET (_jack,0);
const char ** ports;
uint32_t i = 0;
- if (!_jack) {
- return 0;
- }
-
- if ((ports = jack_get_ports (_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|JackPortIsOutput)) == 0) {
+ if ((ports = jack_get_ports (_priv_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|JackPortIsOutput)) == 0) {
return 0;
}
@@ -888,14 +895,11 @@ AudioEngine::n_physical_audio_inputs () const
void
AudioEngine::get_physical_audio_inputs (vector<string>& ins)
{
+ GET_PRIVATE_JACK_POINTER (_jack);
const char ** ports;
uint32_t i = 0;
- if (!_jack) {
- return;
- }
-
- if ((ports = jack_get_ports (_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|JackPortIsOutput)) == 0) {
+ if ((ports = jack_get_ports (_priv_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|JackPortIsOutput)) == 0) {
return;
}
@@ -910,14 +914,11 @@ AudioEngine::get_physical_audio_inputs (vector<string>& ins)
void
AudioEngine::get_physical_audio_outputs (vector<string>& outs)
{
+ GET_PRIVATE_JACK_POINTER (_jack);
const char ** ports;
uint32_t i = 0;
- if (!_jack) {
- return;
- }
-
- if ((ports = jack_get_ports (_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|JackPortIsInput)) == 0) {
+ if ((ports = jack_get_ports (_priv_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|JackPortIsInput)) == 0) {
return;
}
@@ -932,21 +933,13 @@ AudioEngine::get_physical_audio_outputs (vector<string>& outs)
string
AudioEngine::get_nth_physical_audio (uint32_t n, int flag)
{
+ GET_PRIVATE_JACK_POINTER_RET (_jack,"");
const char ** ports;
uint32_t i;
string ret;
- if (!_jack) {
- fatal << _("get_nth_physical called before engine was connected") << endmsg;
- /*NOTREACHED*/
- }
-
- ports = jack_get_ports (_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|flag);
+ ports = jack_get_ports (_priv_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|flag);
- if (ports == 0) {
- return "";
- }
-
for (i = 0; i < n && ports[i]; ++i);
if (ports[i]) {
@@ -961,106 +954,93 @@ AudioEngine::get_nth_physical_audio (uint32_t n, int flag)
nframes_t
AudioEngine::get_port_total_latency (const Port& port)
{
- if (!_jack) {
- return 0;
- }
+ GET_PRIVATE_JACK_POINTER_RET (_jack,0);
- return jack_port_get_total_latency (_jack, port._port);
+ return jack_port_get_total_latency (_priv_jack, port._port);
}
void
AudioEngine::transport_stop ()
{
- if (_jack) {
- jack_transport_stop (_jack);
- }
+ GET_PRIVATE_JACK_POINTER (_jack);
+ jack_transport_stop (_priv_jack);
}
void
AudioEngine::transport_start ()
{
- if (_jack) {
- jack_transport_start (_jack);
- }
+ GET_PRIVATE_JACK_POINTER (_jack);
+ jack_transport_start (_priv_jack);
}
void
AudioEngine::transport_locate (nframes_t where)
{
+ GET_PRIVATE_JACK_POINTER (_jack);
// cerr << "tell JACK to locate to " << where << endl;
- if (_jack) {
- jack_transport_locate (_jack, where);
- }
+ jack_transport_locate (_priv_jack, where);
}
AudioEngine::TransportState
AudioEngine::transport_state ()
{
- if (_jack) {
- jack_position_t pos;
- return (TransportState) jack_transport_query (_jack, &pos);
- } else {
- return (TransportState) JackTransportStopped;
- }
+ GET_PRIVATE_JACK_POINTER_RET (_jack, ((TransportState) JackTransportStopped));
+ jack_position_t pos;
+ return (TransportState) jack_transport_query (_priv_jack, &pos);
}
int
AudioEngine::reset_timebase ()
{
- if (_jack) {
- if (Config->get_jack_time_master()) {
- return jack_set_timebase_callback (_jack, 0, _jack_timebase_callback, this);
- } else {
- return jack_release_timebase (_jack);
- }
+ GET_PRIVATE_JACK_POINTER_RET (_jack, -1);
+ if (Config->get_jack_time_master()) {
+ return jack_set_timebase_callback (_priv_jack, 0, _jack_timebase_callback, this);
} else {
- return -1;
+ return jack_release_timebase (_jack);
}
}
int
AudioEngine::freewheel (bool onoff)
{
- if (_jack) {
-
- if (onoff != _freewheeling) {
-
- if (onoff) {
- _freewheel_thread_registered = false;
- }
-
- return jack_set_freewheel (_jack, onoff);
-
- } else {
- /* already doing what has been asked for */
- return 0;
- }
-
+ GET_PRIVATE_JACK_POINTER_RET (_jack, -1);
+
+ if (onoff != _freewheeling) {
+
+ if (onoff) {
+ _freewheel_thread_registered = false;
+ }
+
+ return jack_set_freewheel (_priv_jack, onoff);
+
} else {
- return -1;
+ /* already doing what has been asked for */
+ return 0;
}
}
void
AudioEngine::remove_all_ports ()
{
- /* process lock MUST be held */
-
- if (_jack) {
- boost::shared_ptr<Ports> p = ports.reader();
+ jack_client_t* _priv_jack = _jack;
- for (Ports::iterator i = p->begin(); i != p->end(); ++i) {
- jack_port_unregister (_jack, (*i)->_port);
- }
- }
+ /* process lock MUST be held */
- {
- RCUWriter<Ports> writer (ports);
- boost::shared_ptr<Ports> ps = writer.get_copy ();
- ps->clear ();
- }
+ if (_priv_jack) {
- port_connections.clear ();
+ boost::shared_ptr<Ports> p = ports.reader();
+
+ for (Ports::iterator i = p->begin(); i != p->end(); ++i) {
+ jack_port_unregister (_priv_jack, (*i)->_port);
+ }
+ }
+ {
+ RCUWriter<Ports> writer (ports);
+ boost::shared_ptr<Ports> ps = writer.get_copy ();
+ ps->clear ();
+ }
+
+ port_connections.clear ();
}
void
@@ -1097,8 +1077,10 @@ AudioEngine::connect_to_jack (string client_name)
return -1;
}
+ GET_PRIVATE_JACK_POINTER_RET (_jack, -1);
+
if (status & JackNameNotUnique) {
- jack_client_name = jack_get_client_name (_jack);
+ jack_client_name = jack_get_client_name (_priv_jack);
}
jack_set_error_function (ardour_jack_error);
@@ -1125,10 +1107,7 @@ AudioEngine::connect_to_jack (string client_name)
int
AudioEngine::disconnect_from_jack ()
{
- if (!_jack) {
- return 0;
- }
-
+ GET_PRIVATE_JACK_POINTER_RET (_jack, 0);
if (_running) {
stop_metering_thread ();
@@ -1136,7 +1115,7 @@ AudioEngine::disconnect_from_jack ()
{
Glib::Mutex::Lock lm (_process_lock);
- jack_client_close (_jack);
+ jack_client_close (_priv_jack);
_jack = 0;
}
@@ -1154,6 +1133,8 @@ AudioEngine::disconnect_from_jack ()
int
AudioEngine::reconnect_to_jack ()
{
+ GET_PRIVATE_JACK_POINTER_RET (_jack,-1);
+
if (_running) {
disconnect_from_jack ();
/* XXX give jackd a chance */
@@ -1178,7 +1159,7 @@ AudioEngine::reconnect_to_jack ()
short_name = long_name.substr (long_name.find_last_of (':') + 1);
- if (((*i)->_port = jack_port_register (_jack, short_name.c_str(), (*i)->type(), (*i)->flags(), 0)) == 0) {
+ if (((*i)->_port = jack_port_register (_priv_jack, short_name.c_str(), (*i)->type(), (*i)->flags(), 0)) == 0) {
error << string_compose (_("could not reregister %1"), (*i)->name()) << endmsg;
break;
} else {
@@ -1187,44 +1168,44 @@ AudioEngine::reconnect_to_jack ()
(*i)->reset ();
if ((*i)->flags() & JackPortIsOutput) {
- (*i)->silence (jack_get_buffer_size (_jack));
+ (*i)->silence (jack_get_buffer_size (_priv_jack));
}
}
if (i != p->end()) {
/* failed */
for (Ports::iterator i = p->begin(); i != p->end(); ++i) {
- jack_port_unregister (_jack, (*i)->_port);
+ jack_port_unregister (_priv_jack, (*i)->_port);
}
return -1;
}
if (session) {
- session->reset_jack_connection (_jack);
- nframes_t blocksize = jack_get_buffer_size (_jack);
+ session->reset_jack_connection (_priv_jack);
+ nframes_t blocksize = jack_get_buffer_size (_priv_jack);
Port::set_buffer_size (blocksize);
session->set_block_size (blocksize);
- session->set_frame_rate (jack_get_sample_rate (_jack));
+ session->set_frame_rate (jack_get_sample_rate (_priv_jack));
}
last_monitor_check = 0;
- jack_on_shutdown (_jack, halted, this);
- jack_set_graph_order_callback (_jack, _graph_order_callback, this);
- jack_set_thread_init_callback (_jack, _thread_init_callback, this);
- jack_set_process_callback (_jack, _process_callback, this);
- jack_set_sample_rate_callback (_jack, _sample_rate_callback, this);
- jack_set_buffer_size_callback (_jack, _bufsize_callback, this);
- jack_set_xrun_callback (_jack, _xrun_callback, this);
- jack_set_sync_callback (_jack, _jack_sync_callback, this);
- jack_set_freewheel_callback (_jack, _freewheel_callback, this);
+ jack_on_shutdown (_priv_jack, halted, this);
+ jack_set_graph_order_callback (_priv_jack, _graph_order_callback, this);
+ jack_set_thread_init_callback (_priv_jack, _thread_init_callback, this);
+ jack_set_process_callback (_priv_jack, _process_callback, this);
+ jack_set_sample_rate_callback (_priv_jack, _sample_rate_callback, this);
+ jack_set_buffer_size_callback (_priv_jack, _bufsize_callback, this);
+ jack_set_xrun_callback (_priv_jack, _xrun_callback, this);
+ jack_set_sync_callback (_priv_jack, _jack_sync_callback, this);
+ jack_set_freewheel_callback (_priv_jack, _freewheel_callback, this);
if (Config->get_jack_time_master()) {
- jack_set_timebase_callback (_jack, 0, _jack_timebase_callback, this);
+ jack_set_timebase_callback (_priv_jack, 0, _jack_timebase_callback, this);
}
- if (jack_activate (_jack) == 0) {
+ if (jack_activate (_priv_jack) == 0) {
_running = true;
_has_run = true;
} else {
@@ -1236,16 +1217,13 @@ AudioEngine::reconnect_to_jack ()
for (PortConnections::iterator i = port_connections.begin(); i != port_connections.end(); ++i) {
int err;
- jack_client_t* j = _jack;
-
- /* JACK could have zombified us. */
- if (!j) {
+ if (!_jack) {
error << _("Disconnected from JACK while reconnecting. You should quit Ardour now.") << endmsg;
return -1;
}
- if ((err = jack_connect (j, (*i).first.c_str(), (*i).second.c_str())) != 0) {
+ if ((err = jack_connect (_priv_jack, (*i).first.c_str(), (*i).second.c_str())) != 0) {
if (err != EEXIST) {
error << string_compose (_("could not reconnect %1 and %2 (err = %3)"),
(*i).first, (*i).second, err)
@@ -1264,26 +1242,21 @@ AudioEngine::reconnect_to_jack ()
int
AudioEngine::request_buffer_size (nframes_t nframes)
{
- if (_jack) {
+ GET_PRIVATE_JACK_POINTER_RET (_jack, -1);
- if (nframes == jack_get_buffer_size (_jack)) {
- return 0;
- }
-
- return jack_set_buffer_size (_jack, nframes);
-
- } else {
- return -1;
+ if (nframes == jack_get_buffer_size (_priv_jack)) {
+ return 0;
}
+
+ return jack_set_buffer_size (_priv_jack, nframes);
}
void
AudioEngine::update_total_latencies ()
{
#ifdef HAVE_JACK_RECOMPUTE_LATENCIES
- if (_jack) {
- jack_recompute_total_latencies (_jack);
- }
+ GET_PRIVATE_JACK_POINTER (_jack);
+ jack_recompute_total_latencies (_priv_jack);
#endif
}
@@ -1327,9 +1300,6 @@ AudioEngine::make_port_name_non_relative (string portname)
bool
AudioEngine::is_realtime () const
{
- if (_jack) {
- return jack_is_realtime (_jack);
- } else {
- return false;
- }
+ GET_PRIVATE_JACK_POINTER_RET (_jack,false);
+ return jack_is_realtime (_priv_jack);
}
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc
index ad132f219f..b1ec8a3baa 100644
--- a/libs/ardour/audiofilesource.cc
+++ b/libs/ardour/audiofilesource.cc
@@ -734,9 +734,8 @@ AudioFileSource::safe_file_extension(ustring file)
".maud", ".MAUD",
".vwe", ".VWE",
".paf",
-#ifdef HAVE_FLAC
".flac", ".FLAC",
-#endif // HAVE_FLAC
+ ".ogg", ".OGG",
#ifdef HAVE_COREAUDIO
".mp3", ".MP3",
".aac", ".AAC",
diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc
index db11c61276..e7c2596fe1 100644
--- a/libs/ardour/session_export.cc
+++ b/libs/ardour/session_export.cc
@@ -88,6 +88,7 @@ AudioExportSpecification::~AudioExportSpecification ()
void
AudioExportSpecification::init ()
{
+ memset (&sfinfo, 0, sizeof (sfinfo));
src_state = 0;
pos = 0;
total_frames = 0;
@@ -169,7 +170,7 @@ AudioExportSpecification::prepare (nframes_t blocksize, nframes_t frate)
return -1;
}
- if ((data_width = sndfile_data_width(format)) == 0) {
+ if (((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_OGG) && (data_width = sndfile_data_width(format)) == 0) {
error << _("Bad data width size. Report me!") << endmsg;
return -1;
}
@@ -197,7 +198,7 @@ AudioExportSpecification::prepare (nframes_t blocksize, nframes_t frate)
}
/* XXX make sure we have enough disk space for the output */
-
+
if ((out = sf_open (path.c_str(), SFM_WRITE, &sfinfo)) == 0) {
sf_error_str (0, errbuf, sizeof (errbuf) - 1);
error << string_compose(_("Export: cannot open output file \"%1\" (%2)"), path, errbuf) << endmsg;
diff --git a/libs/ardour/sndfile_helpers.cc b/libs/ardour/sndfile_helpers.cc
index 22a1b3555e..4a85b712f1 100644
--- a/libs/ardour/sndfile_helpers.cc
+++ b/libs/ardour/sndfile_helpers.cc
@@ -35,6 +35,8 @@ const char * const sndfile_header_formats_strings[SNDFILE_HEADER_FORMATS+1] = {
N_("AIFF"),
N_("CAF"),
N_("W64 (64 bit WAV)"),
+ N_("FLAC"),
+ N_("Ogg/Vorbis"),
N_("raw (no header)"),
0
};
@@ -44,6 +46,8 @@ const char* const sndfile_file_endings_strings[SNDFILE_HEADER_FORMATS+1] = {
N_(".aiff"),
N_(".caf"),
N_(".w64"),
+ N_(".flac"),
+ N_(".ogg"),
N_(".raw"),
0
};
@@ -53,6 +57,8 @@ int sndfile_header_formats[SNDFILE_HEADER_FORMATS] = {
SF_FORMAT_AIFF,
SF_FORMAT_CAF,
SF_FORMAT_W64,
+ SF_FORMAT_FLAC,
+ SF_FORMAT_OGG,
SF_FORMAT_RAW
};