using namespace ARDOUR;
using namespace PBD;
-jack_nframes_t Port::_short_over_length = 2;
-jack_nframes_t Port::_long_over_length = 10;
+nframes_t Port::_short_over_length = 2;
+nframes_t Port::_long_over_length = 10;
AudioEngine::AudioEngine (string client_name)
: ports (new Ports)
_buffer_size = 0;
_freewheeling = false;
_freewheel_thread_registered = false;
-
- m_meter_thread = 0;
- m_meter_exit = false;
- start_metering_thread();
-
+ m_meter_thread = 0;
+ m_meter_exit = false;
+
if (connect_to_jack (client_name)) {
throw NoBackendAvailable ();
}
+ start_metering_thread();
+
}
AudioEngine::~AudioEngine ()
jack_client_close (_jack);
}
- if(m_meter_thread) {
- g_atomic_int_inc(&m_meter_exit);
- }
+ if(m_meter_thread) {
+ g_atomic_int_inc(&m_meter_exit);
+ }
}
void
if (!_running) {
if (session) {
- jack_nframes_t blocksize = jack_get_buffer_size (_jack);
+ nframes_t blocksize = jack_get_buffer_size (_jack);
session->set_block_size (blocksize);
session->set_frame_rate (jack_get_sample_rate (_jack));
}
-void
-AudioEngine::_jack_timebase_callback (jack_transport_state_t state, jack_nframes_t nframes,
+
+bool
+AudioEngine::get_sync_offset (nframes_t& offset) const
+{
+
+#ifdef HAVE_JACK_VIDEO_SUPPORT
- jack_position_t* pos, int new_position, void *arg)
+ jack_position_t pos;
+
+ (void) jack_transport_query (_jack, &pos);
+
+ if (pos.valid & JackVideoFrameOffset) {
+ offset = pos.video_offset;
+ return true;
+ }
+
+#endif
+
+ return false;
+}
+
+void
+AudioEngine::_jack_timebase_callback (jack_transport_state_t state, nframes_t nframes,
+ jack_position_t* pos, int new_position, void *arg)
{
static_cast<AudioEngine*> (arg)->jack_timebase_callback (state, nframes, pos, new_position);
}
void
-AudioEngine::jack_timebase_callback (jack_transport_state_t state, jack_nframes_t nframes,
-
- jack_position_t* pos, int new_position)
+AudioEngine::jack_timebase_callback (jack_transport_state_t state, nframes_t nframes,
+ jack_position_t* pos, int new_position)
{
if (session && session->synced_to_jack()) {
session->jack_timebase_callback (state, nframes, pos, new_position);
int
AudioEngine::_graph_order_callback (void *arg)
{
- static_cast<AudioEngine *>(arg)->GraphReordered (); /* EMIT SIGNAL */
+ static_cast<AudioEngine *>(arg)->GraphReordered (); /* EMIT SIGNAL */
return 0;
}
int
-AudioEngine::_process_callback (jack_nframes_t nframes, void *arg)
+AudioEngine::_process_callback (nframes_t nframes, void *arg)
{
return static_cast<AudioEngine *> (arg)->process_callback (nframes);
}
}
int
-AudioEngine::process_callback (jack_nframes_t nframes)
+AudioEngine::process_callback (nframes_t nframes)
{
// CycleTimer ct ("AudioEngine::process");
Glib::Mutex::Lock tm (_process_lock, Glib::TRY_LOCK);
- jack_nframes_t next_processed_frames;
+ nframes_t next_processed_frames;
/* handle wrap around of total frames counter */
}
int
-AudioEngine::_sample_rate_callback (jack_nframes_t nframes, void *arg)
+AudioEngine::_sample_rate_callback (nframes_t nframes, void *arg)
{
return static_cast<AudioEngine *> (arg)->jack_sample_rate_callback (nframes);
}
int
-AudioEngine::jack_sample_rate_callback (jack_nframes_t nframes)
+AudioEngine::jack_sample_rate_callback (nframes_t nframes)
{
_frame_rate = nframes;
_usecs_per_cycle = (int) floor ((((double) frames_per_cycle() / nframes)) * 1000000.0);
}
int
-AudioEngine::_bufsize_callback (jack_nframes_t nframes, void *arg)
+AudioEngine::_bufsize_callback (nframes_t nframes, void *arg)
{
return static_cast<AudioEngine *> (arg)->jack_bufsize_callback (nframes);
}
int
-AudioEngine::jack_bufsize_callback (jack_nframes_t nframes)
+AudioEngine::jack_bufsize_callback (nframes_t nframes)
{
_buffer_size = nframes;
_usecs_per_cycle = (int) floor ((((double) nframes / frame_rate())) * 1000000.0);
void
AudioEngine::start_metering_thread ()
{
- if(m_meter_thread == 0) {
- m_meter_thread = Glib::Thread::create (sigc::mem_fun(this, &AudioEngine::meter_thread), false);
- }
+ if(m_meter_thread == 0) {
+ m_meter_thread = Glib::Thread::create (sigc::mem_fun(this, &AudioEngine::meter_thread), false);
+ }
}
void
}
-jack_nframes_t
+nframes_t
AudioEngine::frame_rate ()
{
if (_jack) {
}
}
-jack_nframes_t
+nframes_t
AudioEngine::frames_per_cycle ()
{
if (_jack) {
for (i = 0; ports[i]; ++i) {
ins.push_back (ports[i]);
}
- cerr << "got " << ins.size() << " physical ins\n";
free (ports);
}
}
for (i = 0; ports[i]; ++i) {
outs.push_back (ports[i]);
}
- cerr << "got " << outs.size() << " physical outs\n";
free (ports);
}
}
return ret;
}
-jack_nframes_t
+nframes_t
AudioEngine::get_port_total_latency (const Port& port)
{
if (!_jack) {
}
void
-AudioEngine::transport_locate (jack_nframes_t where)
+AudioEngine::transport_locate (nframes_t where)
{
// cerr << "tell JACK to locate to " << where << endl;
if (_jack) {
if (session) {
- jack_nframes_t blocksize = jack_get_buffer_size (_jack);
+ nframes_t blocksize = jack_get_buffer_size (_jack);
session->set_block_size (blocksize);
session->set_frame_rate (jack_get_sample_rate (_jack));
}
}
int
-AudioEngine::request_buffer_size (jack_nframes_t nframes)
+AudioEngine::request_buffer_size (nframes_t nframes)
{
if (_jack) {
int ret = jack_set_buffer_size (_jack, nframes);