diff options
Diffstat (limited to 'src/JackDriver.cpp')
-rw-r--r-- | src/JackDriver.cpp | 88 |
1 files changed, 46 insertions, 42 deletions
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index cd96ab7..a8ece4a 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -26,16 +26,17 @@ using std::cerr; using std::endl; using std::string; +namespace Raul { + JackDriver::JackDriver() -//: m_app(app) -: m_client(NULL) -, m_is_activated(false) -, m_xruns(0) -, m_xrun_delay(0) +: _client(NULL) +, _is_activated(false) +, _xruns(0) +, _xrun_delay(0) { - m_last_pos.frame = 0; - m_last_pos.valid = (jack_position_bits_t)0; + _last_pos.frame = 0; + _last_pos.valid = (jack_position_bits_t)0; } @@ -51,33 +52,33 @@ void JackDriver::attach(const string& client_name) { // Already connected - if (m_client) + if (_client) return; jack_set_error_function(error_cb); - m_client = jack_client_open(client_name.c_str(), JackNullOption, NULL); - if (m_client == NULL) { - //m_app->status_message("[JACK] Unable to create client"); - m_is_activated = false; + _client = jack_client_open(client_name.c_str(), JackNullOption, NULL); + if (_client == NULL) { + //_app->status_message("[JACK] Unable to create client"); + _is_activated = false; } else { jack_set_error_function(error_cb); - jack_on_shutdown(m_client, jack_shutdown_cb, this); - jack_set_port_registration_callback(m_client, jack_port_registration_cb, this); - jack_set_graph_order_callback(m_client, jack_graph_order_cb, this); - jack_set_buffer_size_callback(m_client, jack_buffer_size_cb, this); - jack_set_xrun_callback(m_client, jack_xrun_cb, this); + jack_on_shutdown(_client, jack_shutdown_cb, this); + jack_set_port_registration_callback(_client, jack_port_registration_cb, this); + jack_set_graph_order_callback(_client, jack_graph_order_cb, this); + jack_set_buffer_size_callback(_client, jack_buffer_size_cb, this); + jack_set_xrun_callback(_client, jack_xrun_cb, this); - //m_is_dirty = true; - m_buffer_size = jack_get_buffer_size(m_client); + //_is_dirty = true; + _buffer_size = jack_get_buffer_size(_client); - if (!jack_activate(m_client)) { - m_is_activated = true; + if (!jack_activate(_client)) { + _is_activated = true; //signal_attached.emit(); - //m_app->status_message("[JACK] Attached"); + //_app->status_message("[JACK] Attached"); } else { - //m_app->status_message("[JACK] ERROR: Failed to attach"); - m_is_activated = false; + //_app->status_message("[JACK] ERROR: Failed to attach"); + _is_activated = false; } } } @@ -86,11 +87,11 @@ JackDriver::attach(const string& client_name) void JackDriver::detach() { - if (m_client) { - jack_deactivate(m_client); - jack_client_close(m_client); - m_client = NULL; - m_is_activated = false; + if (_client) { + jack_deactivate(_client); + jack_client_close(_client); + _client = NULL; + _is_activated = false; //signal_detached.emit(); } } @@ -124,7 +125,7 @@ JackDriver::jack_buffer_size_cb(jack_nframes_t buffer_size, void* jack_driver) me->reset_xruns(); me->reset_delay(); me->on_buffer_size_changed(buffer_size); - me->m_buffer_size = buffer_size; + me->_buffer_size = buffer_size; return 0; } @@ -137,8 +138,8 @@ JackDriver::jack_xrun_cb(void* jack_driver) assert(me); - me->m_xruns++; - me->m_xrun_delay = jack_get_xrun_delayed_usecs(me->m_client); + me->_xruns++; + me->_xrun_delay = jack_get_xrun_delayed_usecs(me->_client); me->reset_delay(); me->on_xrun(); @@ -158,7 +159,7 @@ JackDriver::jack_shutdown_cb(void* jack_driver) me->on_shutdown(); - me->m_client = NULL; + me->_client = NULL; } @@ -172,18 +173,18 @@ JackDriver::error_cb(const char* msg) jack_nframes_t JackDriver::buffer_size() { - if (m_is_activated) - return m_buffer_size; + if (_is_activated) + return _buffer_size; else - return jack_get_buffer_size(m_client); + return jack_get_buffer_size(_client); } void JackDriver::reset_xruns() { - m_xruns = 0; - m_xrun_delay = 0; + _xruns = 0; + _xrun_delay = 0; } @@ -194,16 +195,19 @@ JackDriver::set_buffer_size(jack_nframes_t size) return true; } - if (!m_client) { - m_buffer_size = size; + if (!_client) { + _buffer_size = size; return true; } - if (jack_set_buffer_size(m_client, size)) { - //m_app->status_message("[JACK] ERROR: Unable to set buffer size"); + if (jack_set_buffer_size(_client, size)) { + //_app->status_message("[JACK] ERROR: Unable to set buffer size"); return false; } else { return true; } } + +} // namespace Raul + |