2 Copyright (C) 2002 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <glibmm/timer.h>
28 #include <pbd/pthread_utils.h>
29 #include <pbd/stacktrace.h>
30 #include <pbd/unknown_type.h>
32 #include <midi++/jack.h>
34 #include <ardour/audioengine.h>
35 #include <ardour/buffer.h>
36 #include <ardour/port.h>
37 #include <ardour/audio_port.h>
38 #include <ardour/midi_port.h>
39 #include <ardour/session.h>
40 #include <ardour/cycle_timer.h>
41 #include <ardour/utils.h>
42 #include <ardour/event_type_map.h>
43 #include <ardour/io.h>
48 #include <ardour/timestamps.h>
53 using namespace ARDOUR;
56 gint AudioEngine::m_meter_exit;
59 ardour_jack_error (const char* msg)
61 error << "JACK: " << msg << endmsg;
64 AudioEngine::AudioEngine (string client_name)
68 session_remove_pending = false;
71 last_monitor_check = 0;
72 monitor_check_interval = max_frames;
73 _processed_frames = 0;
78 _freewheel_thread_registered = false;
79 _freewheeling = false;
82 g_atomic_int_set (&m_meter_exit, 0);
84 if (connect_to_jack (client_name)) {
85 throw NoBackendAvailable ();
88 Port::set_engine (this);
90 // Initialize parameter metadata (e.g. ranges)
91 Evoral::Parameter p(NullAutomation);
92 p = EventTypeMap::instance().new_parameter(NullAutomation);
93 p = EventTypeMap::instance().new_parameter(GainAutomation);
94 p = EventTypeMap::instance().new_parameter(PanAutomation);
95 p = EventTypeMap::instance().new_parameter(PluginAutomation);
96 p = EventTypeMap::instance().new_parameter(SoloAutomation);
97 p = EventTypeMap::instance().new_parameter(MuteAutomation);
98 p = EventTypeMap::instance().new_parameter(MidiCCAutomation);
99 p = EventTypeMap::instance().new_parameter(MidiPgmChangeAutomation);
100 p = EventTypeMap::instance().new_parameter(MidiPitchBenderAutomation);
101 p = EventTypeMap::instance().new_parameter(MidiChannelPressureAutomation);
102 p = EventTypeMap::instance().new_parameter(FadeInAutomation);
103 p = EventTypeMap::instance().new_parameter(FadeOutAutomation);
104 p = EventTypeMap::instance().new_parameter(EnvelopeAutomation);
105 p = EventTypeMap::instance().new_parameter(MidiCCAutomation);
108 AudioEngine::~AudioEngine ()
111 Glib::Mutex::Lock tm (_process_lock);
112 session_removed.signal ();
115 jack_client_close (_jack);
119 stop_metering_thread ();
124 AudioEngine::jack() const
130 _thread_init_callback (void *arg)
132 /* make sure that anybody who needs to know about this thread
136 PBD::notify_gui_about_thread_creation (pthread_self(), X_("Audioengine"), 4096);
137 #ifdef WITH_JACK_MIDI
138 MIDI::JACK_MidiPort::set_process_thread (pthread_self());
139 #endif // WITH_JACK_MIDI
143 AudioEngine::start ()
146 error << _("AudioEngine::start() called while disconnected from JACK") << endmsg;
153 nframes_t blocksize = jack_get_buffer_size (_jack);
155 BootMessage (_("Connect session to engine"));
157 session->set_block_size (blocksize);
158 session->set_frame_rate (jack_get_sample_rate (_jack));
160 /* page in as much of the session process code as we
161 can before we really start running.
164 session->process (blocksize);
165 session->process (blocksize);
166 session->process (blocksize);
167 session->process (blocksize);
168 session->process (blocksize);
169 session->process (blocksize);
170 session->process (blocksize);
171 session->process (blocksize);
174 _processed_frames = 0;
175 last_monitor_check = 0;
177 jack_on_shutdown (_jack, halted, this);
178 jack_set_graph_order_callback (_jack, _graph_order_callback, this);
179 jack_set_thread_init_callback (_jack, _thread_init_callback, this);
180 jack_set_process_callback (_jack, _process_callback, this);
181 jack_set_sample_rate_callback (_jack, _sample_rate_callback, this);
182 jack_set_buffer_size_callback (_jack, _bufsize_callback, this);
183 jack_set_xrun_callback (_jack, _xrun_callback, this);
184 jack_set_sync_callback (_jack, _jack_sync_callback, this);
185 jack_set_freewheel_callback (_jack, _freewheel_callback, this);
187 if (Config->get_jack_time_master()) {
188 jack_set_timebase_callback (_jack, 0, _jack_timebase_callback, this);
191 if (jack_activate (_jack) == 0) {
194 Running(); /* EMIT SIGNAL */
196 // error << _("cannot activate JACK client") << endmsg;
199 start_metering_thread();
202 return _running ? 0 : -1;
206 AudioEngine::stop (bool forever)
210 disconnect_from_jack ();
212 jack_deactivate (_jack);
213 Stopped(); /* EMIT SIGNAL */
217 return _running ? -1 : 0;
222 AudioEngine::get_sync_offset (nframes_t& offset) const
225 #ifdef HAVE_JACK_VIDEO_SUPPORT
230 (void) jack_transport_query (_jack, &pos);
232 if (pos.valid & JackVideoFrameOffset) {
233 offset = pos.video_offset;
244 AudioEngine::_jack_timebase_callback (jack_transport_state_t state, nframes_t nframes,
245 jack_position_t* pos, int new_position, void *arg)
247 static_cast<AudioEngine*> (arg)->jack_timebase_callback (state, nframes, pos, new_position);
251 AudioEngine::jack_timebase_callback (jack_transport_state_t state, nframes_t nframes,
252 jack_position_t* pos, int new_position)
254 if (_jack && session && session->synced_to_jack()) {
255 session->jack_timebase_callback (state, nframes, pos, new_position);
260 AudioEngine::_jack_sync_callback (jack_transport_state_t state, jack_position_t* pos, void* arg)
262 return static_cast<AudioEngine*> (arg)->jack_sync_callback (state, pos);
266 AudioEngine::jack_sync_callback (jack_transport_state_t state, jack_position_t* pos)
268 if (_jack && session) {
269 return session->jack_sync_callback (state, pos);
276 AudioEngine::_xrun_callback (void *arg)
278 AudioEngine* ae = static_cast<AudioEngine*> (arg);
279 if (ae->connected()) {
280 ae->Xrun (); /* EMIT SIGNAL */
286 AudioEngine::_graph_order_callback (void *arg)
288 AudioEngine* ae = static_cast<AudioEngine*> (arg);
289 if (ae->connected()) {
290 ae->GraphReordered (); /* EMIT SIGNAL */
295 /** Wrapped which is called by JACK as its process callback. It is just
296 * here to get us back into C++ land by calling AudioEngine::process_callback()
297 * @param nframes Number of frames passed by JACK.
298 * @param arg User argument passed by JACK, which will be the AudioEngine*.
301 AudioEngine::_process_callback (nframes_t nframes, void *arg)
303 return static_cast<AudioEngine *> (arg)->process_callback (nframes);
307 AudioEngine::_freewheel_callback (int onoff, void *arg)
309 static_cast<AudioEngine*>(arg)->_freewheeling = onoff;
312 /** Method called by JACK (via _process_callback) which says that there
313 * is work to be done.
314 * @param nframes Number of frames to process.
317 AudioEngine::process_callback (nframes_t nframes)
319 // CycleTimer ct ("AudioEngine::process");
320 Glib::Mutex::Lock tm (_process_lock, Glib::TRY_LOCK);
322 /// The number of frames that will have been processed when we've finished
323 nframes_t next_processed_frames;
325 /* handle wrap around of total frames counter */
327 if (max_frames - _processed_frames < nframes) {
328 next_processed_frames = nframes - (max_frames - _processed_frames);
330 next_processed_frames = _processed_frames + nframes;
333 if (!tm.locked() || session == 0) {
334 /* return having done nothing */
335 _processed_frames = next_processed_frames;
339 if (session_remove_pending) {
340 /* perform the actual session removal */
342 session_remove_pending = false;
343 session_removed.signal();
344 _processed_frames = next_processed_frames;
348 boost::shared_ptr<Ports> p = ports.reader();
350 for (Ports::iterator i = p->begin(); i != p->end(); ++i) {
351 (*i)->cycle_start (nframes, 0);
355 /* emit the Freewheel signal and stop freewheeling in the event of trouble */
356 if (Freewheel (nframes)) {
357 jack_set_freewheel (_jack, false);
362 session->process (nframes);
371 _processed_frames = next_processed_frames;
375 if (last_monitor_check + monitor_check_interval < next_processed_frames) {
377 boost::shared_ptr<Ports> p = ports.reader();
379 for (Ports::iterator i = p->begin(); i != p->end(); ++i) {
384 if (port->_last_monitor != (x = port->monitoring_input ())) {
385 port->_last_monitor = x;
386 /* XXX I think this is dangerous, due to
387 a likely mutex in the signal handlers ...
389 port->MonitorInputChanged (x); /* EMIT SIGNAL */
392 last_monitor_check = next_processed_frames;
395 if (session->silent()) {
397 boost::shared_ptr<Ports> p = ports.reader();
399 for (Ports::iterator i = p->begin(); i != p->end(); ++i) {
403 if (port->sends_output()) {
404 port->get_buffer(nframes, 0 ).silence(nframes);
409 // Finalize ports (ie write data if necessary)
411 for (Ports::iterator i = p->begin(); i != p->end(); ++i) {
412 (*i)->cycle_end (nframes, 0);
414 _processed_frames = next_processed_frames;
419 AudioEngine::_sample_rate_callback (nframes_t nframes, void *arg)
421 return static_cast<AudioEngine *> (arg)->jack_sample_rate_callback (nframes);
425 AudioEngine::jack_sample_rate_callback (nframes_t nframes)
427 _frame_rate = nframes;
428 _usecs_per_cycle = (int) floor ((((double) frames_per_cycle() / nframes)) * 1000000.0);
430 /* check for monitor input change every 1/10th of second */
432 monitor_check_interval = nframes / 10;
433 last_monitor_check = 0;
436 session->set_frame_rate (nframes);
439 SampleRateChanged (nframes); /* EMIT SIGNAL */
445 AudioEngine::_bufsize_callback (nframes_t nframes, void *arg)
447 return static_cast<AudioEngine *> (arg)->jack_bufsize_callback (nframes);
451 AudioEngine::jack_bufsize_callback (nframes_t nframes)
453 _buffer_size = nframes;
454 _usecs_per_cycle = (int) floor ((((double) nframes / frame_rate())) * 1000000.0);
455 last_monitor_check = 0;
457 boost::shared_ptr<Ports> p = ports.reader();
459 for (Ports::iterator i = p->begin(); i != p->end(); ++i) {
464 session->set_block_size (_buffer_size);
471 AudioEngine::stop_metering_thread ()
473 if (m_meter_thread) {
474 g_atomic_int_set (&m_meter_exit, 1);
475 m_meter_thread->join ();
481 AudioEngine::start_metering_thread ()
483 if (m_meter_thread == 0) {
484 g_atomic_int_set (&m_meter_exit, 0);
485 m_meter_thread = Glib::Thread::create (sigc::mem_fun(this, &AudioEngine::meter_thread),
486 500000, true, true, Glib::THREAD_PRIORITY_NORMAL);
491 AudioEngine::meter_thread ()
494 Glib::usleep (10000); /* 1/100th sec interval */
495 if (g_atomic_int_get(&m_meter_exit)) {
498 IO::update_meters ();
503 AudioEngine::set_session (Session *s)
505 Glib::Mutex::Lock pl (_process_lock);
511 nframes_t blocksize = jack_get_buffer_size (_jack);
513 /* page in as much of the session process code as we
514 can before we really start running.
517 boost::shared_ptr<Ports> p = ports.reader();
519 for (Ports::iterator i = p->begin(); i != p->end(); ++i) {
520 (*i)->cycle_start (blocksize, 0);
523 s->process (blocksize);
524 s->process (blocksize);
525 s->process (blocksize);
526 s->process (blocksize);
527 s->process (blocksize);
528 s->process (blocksize);
529 s->process (blocksize);
530 s->process (blocksize);
532 for (Ports::iterator i = p->begin(); i != p->end(); ++i) {
533 (*i)->cycle_end (blocksize, 0);
539 AudioEngine::remove_session ()
541 Glib::Mutex::Lock lm (_process_lock);
546 session_remove_pending = true;
547 session_removed.wait(_process_lock);
554 //FIXME: Preliminary bugfix for http://tracker.ardour.org/view.php?id=1985
555 //remove_all_ports ();
559 AudioEngine::port_registration_failure (const std::string& portname)
561 string full_portname = jack_client_name;
562 full_portname += ':';
563 full_portname += portname;
566 jack_port_t* p = jack_port_by_name (_jack, full_portname.c_str());
570 reason = _("a port with this name already exists: check for duplicated track/bus names");
572 reason = _("unknown error");
575 throw PortRegistrationFailure (string_compose (_("AudioEngine: cannot register port \"%1\": %2"), portname, reason).c_str());
579 AudioEngine::register_port (DataType dtype, const string& portname, bool input)
584 if (dtype == DataType::AUDIO) {
585 newport = new AudioPort (portname, (input ? Port::IsInput : Port::IsOutput));
586 } else if (dtype == DataType::MIDI) {
587 newport = new MidiPort (portname, (input ? Port::IsInput : Port::IsOutput));
589 throw unknown_type();
593 RCUWriter<Ports> writer (ports);
594 boost::shared_ptr<Ports> ps = writer.get_copy ();
595 ps->insert (ps->begin(), newport);
597 /* writer goes out of scope, forces update */
603 throw PortRegistrationFailure("unable to create port (unknown type?)");
608 AudioEngine::register_input_port (DataType type, const string& portname)
610 return register_port (type, portname, true);
614 AudioEngine::register_output_port (DataType type, const string& portname)
616 return register_port (type, portname, false);
620 AudioEngine::unregister_port (Port& port)
622 /* caller must hold process lock */
625 /* probably happening when the engine has been halted by JACK,
626 in which case, there is nothing we can do here.
632 RCUWriter<Ports> writer (ports);
633 boost::shared_ptr<Ports> ps = writer.get_copy ();
635 for (Ports::iterator i = ps->begin(); i != ps->end(); ++i) {
643 /* writer goes out of scope, forces update */
646 remove_connections_for (port);
652 AudioEngine::connect (const string& source, const string& destination)
654 /* caller must hold process lock */
660 fatal << _("connect called before engine was started") << endmsg;
667 string s = make_port_name_non_relative (source);
668 string d = make_port_name_non_relative (destination);
670 Port* src = get_port_by_name_locked (s);
671 Port* dst = get_port_by_name_locked (d);
674 ret = src->connect (d);
676 ret = dst->connect (s);
678 /* neither port is known to us, and this API isn't intended for use as a general patch bay */
683 error << string_compose(_("AudioEngine: connection already exists: %1 (%2) to %3 (%4)"),
684 source, s, destination, d)
686 } else if (ret < 0) {
687 error << string_compose(_("AudioEngine: cannot connect %1 (%2) to %3 (%4)"),
688 source, s, destination, d)
696 AudioEngine::disconnect (const string& source, const string& destination)
698 /* caller must hold process lock */
704 fatal << _("disconnect called before engine was started") << endmsg;
711 string s = make_port_name_non_relative (source);
712 string d = make_port_name_non_relative (destination);
714 Port* src = get_port_by_name_locked (s);
715 Port* dst = get_port_by_name_locked (d);
718 ret = src->disconnect (d);
720 ret = dst->disconnect (s);
722 /* neither port is known to us, and this API isn't intended for use as a general patch bay */
729 AudioEngine::disconnect (Port& port)
733 fatal << _("disconnect called before engine was started") << endmsg;
740 return port.disconnect_all ();
744 AudioEngine::frame_rate ()
747 if (_frame_rate == 0) {
748 return (_frame_rate = jack_get_sample_rate (_jack));
753 fatal << X_("programming error: AudioEngine::frame_rate() called while disconnected from JACK")
761 AudioEngine::frames_per_cycle ()
764 if (_buffer_size == 0) {
765 return (_buffer_size = jack_get_buffer_size (_jack));
770 fatal << X_("programming error: AudioEngine::frame_rate() called while disconnected from JACK")
777 /** @param name Full name of port (including prefix:)
778 * @return Corresponding Port*, or 0. This object remains the property of the AudioEngine
779 * so must not be deleted.
782 AudioEngine::get_port_by_name (const string& portname)
784 assert (portname.find_first_of (':') != string::npos);
786 Glib::Mutex::Lock lm (_process_lock);
787 return get_port_by_name_locked (portname);
791 AudioEngine::get_port_by_name_locked (const string& portname)
793 /* caller must hold process lock */
797 fatal << _("get_port_by_name_locked() called before engine was started") << endmsg;
804 if (portname.substr (0, jack_client_name.length ()) != jack_client_name) {
805 /* not an ardour: port */
809 std::string const rel = make_port_name_relative (portname);
811 boost::shared_ptr<Ports> pr = ports.reader();
813 for (Ports::iterator i = pr->begin(); i != pr->end(); ++i) {
814 if (rel == (*i)->name()) {
827 AudioEngine::get_ports (const string& port_name_pattern, const string& type_name_pattern, uint32_t flags)
831 fatal << _("get_ports called before engine was started") << endmsg;
837 return jack_get_ports (_jack, port_name_pattern.c_str(), type_name_pattern.c_str(), flags);
841 AudioEngine::halted (void *arg)
843 AudioEngine* ae = static_cast<AudioEngine *> (arg);
844 bool was_running = ae->_running;
846 ae->stop_metering_thread ();
848 ae->_running = false;
849 ae->_buffer_size = 0;
853 ae->Halted(); /* EMIT SIGNAL */
858 AudioEngine::can_request_hardware_monitoring ()
866 if ((ports = jack_get_ports (_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortCanMonitor)) == 0) {
877 AudioEngine::n_physical_outputs (DataType type) const
886 if ((ports = jack_get_ports (_jack, NULL, type.to_jack_type(), JackPortIsPhysical|JackPortIsInput)) == 0) {
890 for (i = 0; ports[i]; ++i);
897 AudioEngine::n_physical_inputs (DataType type) const
906 if ((ports = jack_get_ports (_jack, NULL, type.to_jack_type(), JackPortIsPhysical|JackPortIsOutput)) == 0) {
911 for (i = 0; ports[i]; ++i);
918 AudioEngine::get_physical_inputs (DataType type, vector<string>& ins)
927 if ((ports = jack_get_ports (_jack, NULL, type.to_jack_type(), JackPortIsPhysical|JackPortIsOutput)) == 0) {
932 for (i = 0; ports[i]; ++i) {
933 ins.push_back (ports[i]);
940 AudioEngine::get_physical_outputs (DataType type, vector<string>& outs)
949 if ((ports = jack_get_ports (_jack, NULL, type.to_jack_type(), JackPortIsPhysical|JackPortIsInput)) == 0) {
954 for (i = 0; ports[i]; ++i) {
955 outs.push_back (ports[i]);
962 AudioEngine::get_nth_physical (DataType type, uint32_t n, int flag)
968 assert(type != DataType::NIL);
970 if (!_running || !_jack) {
972 fatal << _("get_nth_physical called before engine was started") << endmsg;
979 ports = jack_get_ports (_jack, NULL, type.to_jack_type(), JackPortIsPhysical|flag);
985 for (i = 0; i < n && ports[i]; ++i);
991 free ((char *) ports);
997 AudioEngine::update_total_latency (const Port& port)
1000 fatal << _("update_total_latency() called with no JACK client connection") << endmsg;
1006 fatal << _("update_total_latency() called before engine was started") << endmsg;
1011 port.recompute_total_latency ();
1015 AudioEngine::transport_stop ()
1018 jack_transport_stop (_jack);
1023 AudioEngine::transport_start ()
1026 jack_transport_start (_jack);
1031 AudioEngine::transport_locate (nframes_t where)
1033 // cerr << "tell JACK to locate to " << where << endl;
1035 jack_transport_locate (_jack, where);
1039 AudioEngine::TransportState
1040 AudioEngine::transport_state ()
1043 jack_position_t pos;
1044 return (TransportState) jack_transport_query (_jack, &pos);
1046 return (TransportState) JackTransportStopped;
1051 AudioEngine::reset_timebase ()
1054 if (Config->get_jack_time_master()) {
1055 return jack_set_timebase_callback (_jack, 0, _jack_timebase_callback, this);
1057 return jack_release_timebase (_jack);
1065 AudioEngine::freewheel (bool onoff)
1069 if (onoff != _freewheeling) {
1072 _freewheel_thread_registered = false;
1075 return jack_set_freewheel (_jack, onoff);
1078 /* already doing what has been asked for */
1088 AudioEngine::remove_all_ports ()
1090 /* process lock MUST be held */
1093 RCUWriter<Ports> writer (ports);
1094 boost::shared_ptr<Ports> ps = writer.get_copy ();
1100 AudioEngine::remove_connections_for (Port& port)
1102 for (PortConnections::iterator i = port_connections.begin(); i != port_connections.end(); ) {
1103 PortConnections::iterator tmp;
1108 if ((*i).first == port.name()) {
1109 port_connections.erase (i);
1117 #ifdef HAVE_JACK_CLIENT_OPEN
1120 AudioEngine::connect_to_jack (string client_name)
1122 jack_options_t options = JackNullOption;
1123 jack_status_t status;
1124 const char *server_name = NULL;
1126 jack_client_name = client_name; /* might be reset below */
1127 _jack = jack_client_open (jack_client_name.c_str(), options, &status, server_name);
1129 if (_jack == NULL) {
1130 // error message is not useful here
1134 if (status & JackNameNotUnique) {
1135 jack_client_name = jack_get_client_name (_jack);
1138 jack_set_error_function (ardour_jack_error);
1146 AudioEngine::connect_to_jack (string client_name)
1148 jack_client_name = client_name;
1150 if ((_jack = jack_client_new (client_name.c_str())) == 0) {
1157 #endif /* HAVE_JACK_CLIENT_OPEN */
1160 AudioEngine::disconnect_from_jack ()
1168 stop_metering_thread ();
1172 Glib::Mutex::Lock lm (_process_lock);
1173 jack_client_close (_jack);
1182 Stopped(); /* EMIT SIGNAL */
1189 AudioEngine::reconnect_to_jack ()
1192 disconnect_from_jack ();
1193 /* XXX give jackd a chance */
1194 Glib::usleep (250000);
1197 if (connect_to_jack (jack_client_name)) {
1198 error << _("failed to connect to JACK") << endmsg;
1204 boost::shared_ptr<Ports> p = ports.reader ();
1206 for (i = p->begin(); i != p->end(); ++i) {
1207 if ((*i)->reestablish ()) {
1212 if (i != p->end()) {
1214 remove_all_ports ();
1220 session->reset_jack_connection (_jack);
1221 nframes_t blocksize = jack_get_buffer_size (_jack);
1222 session->set_block_size (blocksize);
1223 session->set_frame_rate (jack_get_sample_rate (_jack));
1226 last_monitor_check = 0;
1228 jack_on_shutdown (_jack, halted, this);
1229 jack_set_graph_order_callback (_jack, _graph_order_callback, this);
1230 jack_set_thread_init_callback (_jack, _thread_init_callback, this);
1231 jack_set_process_callback (_jack, _process_callback, this);
1232 jack_set_sample_rate_callback (_jack, _sample_rate_callback, this);
1233 jack_set_buffer_size_callback (_jack, _bufsize_callback, this);
1234 jack_set_xrun_callback (_jack, _xrun_callback, this);
1235 jack_set_sync_callback (_jack, _jack_sync_callback, this);
1236 jack_set_freewheel_callback (_jack, _freewheel_callback, this);
1238 if (Config->get_jack_time_master()) {
1239 jack_set_timebase_callback (_jack, 0, _jack_timebase_callback, this);
1242 if (jack_activate (_jack) == 0) {
1249 /* re-establish connections */
1251 for (i = p->begin(); i != p->end(); ++i) {
1255 Running (); /* EMIT SIGNAL*/
1257 start_metering_thread ();
1263 AudioEngine::request_buffer_size (nframes_t nframes)
1267 if (nframes == jack_get_buffer_size (_jack)) {
1271 return jack_set_buffer_size (_jack, nframes);
1279 AudioEngine::update_total_latencies ()
1281 #ifdef HAVE_JACK_RECOMPUTE_LATENCIES
1283 jack_recompute_total_latencies (_jack);
1289 AudioEngine::make_port_name_relative (string portname)
1291 string::size_type len;
1292 string::size_type n;
1294 len = portname.length();
1296 for (n = 0; n < len; ++n) {
1297 if (portname[n] == ':') {
1302 if ((n != len) && (portname.substr (0, n) == jack_client_name)) {
1303 return portname.substr (n+1);
1310 AudioEngine::make_port_name_non_relative (string portname)
1314 if (portname.find_first_of (':') != string::npos) {
1318 str = jack_client_name;
1326 AudioEngine::is_realtime () const
1329 return jack_is_realtime (_jack);