diff options
author | David Robillard <d@drobilla.net> | 2007-02-07 03:22:42 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-02-07 03:22:42 +0000 |
commit | b0dda1ccccb53f8bb7ad59c96252647f8e4aa124 (patch) | |
tree | 78a88098a4f73413705141bfe8006373e5671625 /src/JackDriver.cpp | |
parent | 7eb1849da7c9473c5242665b9a28081034ec6876 (diff) | |
download | patchage-b0dda1ccccb53f8bb7ad59c96252647f8e4aa124.tar.gz patchage-b0dda1ccccb53f8bb7ad59c96252647f8e4aa124.tar.bz2 patchage-b0dda1ccccb53f8bb7ad59c96252647f8e4aa124.zip |
Mad sed-fu for consistent private member naming.
git-svn-id: http://svn.drobilla.net/lad/patchage@286 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/JackDriver.cpp')
-rw-r--r-- | src/JackDriver.cpp | 198 |
1 files changed, 99 insertions, 99 deletions
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 77625bc..5d4c139 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -35,15 +35,15 @@ using namespace LibFlowCanvas; JackDriver::JackDriver(Patchage* app) -: m_app(app) -, m_client(NULL) -, m_events(1024) // FIXME: size? -, m_is_activated(false) -, m_xruns(0) -, m_xrun_delay(0) +: _app(app) +, _client(NULL) +, _events(1024) // FIXME: size? +, _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; } @@ -59,34 +59,34 @@ void JackDriver::attach(bool launch_daemon) { // Already connected - if (m_client) + if (_client) return; jack_set_error_function(error_cb); jack_options_t options = (!launch_daemon) ? JackNoStartServer : JackNullOption; - m_client = jack_client_open("Patchage", options, NULL); - if (m_client == NULL) { - m_app->status_message("[JACK] Unable to create client"); - m_is_activated = false; + _client = jack_client_open("Patchage", options, 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; } } } @@ -95,14 +95,14 @@ JackDriver::attach(bool launch_daemon) void JackDriver::detach() { - if (m_client) { - jack_deactivate(m_client); - jack_client_close(m_client); - m_client = NULL; + if (_client) { + jack_deactivate(_client); + jack_client_close(_client); + _client = NULL; destroy_all_ports(); - m_is_activated = false; + _is_activated = false; signal_detached.emit(); - m_app->status_message("[JACK] Detached"); + _app->status_message("[JACK] Detached"); } } @@ -112,7 +112,7 @@ JackDriver::detach() void JackDriver::destroy_all_ports() { - ModuleMap modules = m_app->canvas()->modules(); // copy + ModuleMap modules = _app->canvas()->modules(); // copy for (ModuleMap::iterator m = modules.begin(); m != modules.end(); ++m) { PortVector ports = m->second->ports(); // copy for (PortVector::iterator p = ports.begin(); p != ports.end(); ++p) { @@ -123,7 +123,7 @@ JackDriver::destroy_all_ports() } if (m->second->ports().empty()) - m_app->canvas()->remove_module(m->second->name()); + _app->canvas()->remove_module(m->second->name()); } } @@ -150,7 +150,7 @@ JackDriver::create_port(boost::shared_ptr<PatchageModule> parent, jack_port_t* p boost::shared_ptr<PatchagePort> ret( new PatchagePort(parent, port_type, jack_port_short_name(port), (jack_port_flags(port) & JackPortIsInput), - m_app->state_manager()->get_port_color(port_type))); + _app->state_manager()->get_port_color(port_type))); return ret; } @@ -164,13 +164,13 @@ JackDriver::refresh() { //m_mutex.lock(); - if (m_client == NULL) { + if (_client == NULL) { // Shutdown - if (m_is_dirty) { + if (_is_dirty) { destroy_all_ports(); signal_detached.emit(); } - m_is_dirty = false; + _is_dirty = false; //m_mutex.unlock(); return; } @@ -178,7 +178,7 @@ JackDriver::refresh() const char** ports; jack_port_t* port; - ports = jack_get_ports(m_client, NULL, NULL, 0); // get all existing ports + ports = jack_get_ports(_client, NULL, NULL, 0); // get all existing ports string client1_name; string port1_name; @@ -188,14 +188,14 @@ JackDriver::refresh() // Add all ports if (ports) for (int i=0; ports[i]; ++i) { - port = jack_port_by_name(m_client, ports[i]); + port = jack_port_by_name(_client, ports[i]); client1_name = ports[i]; client1_name = client1_name.substr(0, client1_name.find(":")); ModuleType type = InputOutput; - //if (m_app->state_manager()->get_module_split(client1_name) + //if (_app->state_manager()->get_module_split(client1_name) // || jack_port_flags(port) & JackPortIsTerminal) - if (m_app->state_manager()->get_module_split(client1_name, + if (_app->state_manager()->get_module_split(client1_name, (jack_port_flags(port) & JackPortIsTerminal))) { if (jack_port_flags(port) & JackPortIsInput) { type = Input; @@ -204,13 +204,13 @@ JackDriver::refresh() } } - boost::shared_ptr<PatchageModule> m = m_app->canvas()->find_module(client1_name, type); + boost::shared_ptr<PatchageModule> m = _app->canvas()->find_module(client1_name, type); if (!m) { - m = boost::shared_ptr<PatchageModule>(new PatchageModule(m_app, client1_name, type)); + m = boost::shared_ptr<PatchageModule>(new PatchageModule(_app, client1_name, type)); m->load_location(); m->store_location(); - m_app->canvas()->add_module(m); + _app->canvas()->add_module(m); } // FIXME: leak? jack docs don't say @@ -237,11 +237,11 @@ JackDriver::refresh() // Remove any since-removed ports - /*for (list<string>::iterator i = m_removed_ports.begin(); i != m_removed_ports.end(); ++i) { + /*for (list<string>::iterator i = _removed_ports.begin(); i != _removed_ports.end(); ++i) { const string module_name = (*i).substr(0, i->find(":")); const string port_name = (*i).substr(i->find(":")+1); - for (ModuleMap::iterator m = m_app->canvas()->modules().begin(); m != m_app->canvas()->modules().end(); ++m) { + for (ModuleMap::iterator m = _app->canvas()->modules().begin(); m != _app->canvas()->modules().end(); ++m) { if (m->second->name() == module_name) m->second->remove_port(port_name); } @@ -251,8 +251,8 @@ JackDriver::refresh() // Add all connections if (ports) for (int i=0; ports[i]; ++i) { - port = jack_port_by_name(m_client, ports[i]); - const char** connected_ports = jack_port_get_all_connections(m_client, port); + port = jack_port_by_name(_client, ports[i]); + const char** connected_ports = jack_port_get_all_connections(_client, port); if (connected_ports) { for (int j=0; connected_ports[j]; ++j) { @@ -264,15 +264,15 @@ JackDriver::refresh() port2_name = client2_name.substr(client2_name.find(':')+1); client2_name = client2_name.substr(0, client2_name.find(':')); - boost::shared_ptr<Port> port1 = m_app->canvas()->get_port(client1_name, port1_name); - boost::shared_ptr<Port> port2 = m_app->canvas()->get_port(client2_name, port2_name); + boost::shared_ptr<Port> port1 = _app->canvas()->get_port(client1_name, port1_name); + boost::shared_ptr<Port> port2 = _app->canvas()->get_port(client2_name, port2_name); if (port1 && port2) { - boost::shared_ptr<Connection> existing = m_app->canvas()->get_connection(port1, port2); + boost::shared_ptr<Connection> existing = _app->canvas()->get_connection(port1, port2); if (existing) { existing->set_flagged(false); } else { - m_app->canvas()->add_connection(port1, port2); + _app->canvas()->add_connection(port1, port2); } } } @@ -295,16 +295,16 @@ JackDriver::refresh() bool JackDriver::connect(boost::shared_ptr<PatchagePort> src_port, boost::shared_ptr<PatchagePort> dst_port) { - if (m_client == NULL) + if (_client == NULL) return false; - int result = jack_connect(m_client, src_port->full_name().c_str(), dst_port->full_name().c_str()); + int result = jack_connect(_client, src_port->full_name().c_str(), dst_port->full_name().c_str()); if (result == 0) - m_app->status_message(string("[JACK] Connected ") + _app->status_message(string("[JACK] Connected ") + src_port->full_name() + " -> " + dst_port->full_name()); else - m_app->status_message(string("[JACK] Unable to connect ") + _app->status_message(string("[JACK] Unable to connect ") + src_port->full_name() + " -> " + dst_port->full_name()); return (!result); @@ -318,16 +318,16 @@ JackDriver::connect(boost::shared_ptr<PatchagePort> src_port, boost::shared_ptr< bool JackDriver::disconnect(boost::shared_ptr<PatchagePort> const src_port, boost::shared_ptr<PatchagePort> const dst_port) { - if (m_client == NULL) + if (_client == NULL) return false; - int result = jack_disconnect(m_client, src_port->full_name().c_str(), dst_port->full_name().c_str()); + int result = jack_disconnect(_client, src_port->full_name().c_str(), dst_port->full_name().c_str()); if (result == 0) - m_app->status_message(string("[JACK] Disconnected ") + _app->status_message(string("[JACK] Disconnected ") + src_port->full_name() + " -> " + dst_port->full_name()); else - m_app->status_message(string("[JACK] Unable to disconnect ") + _app->status_message(string("[JACK] Unable to disconnect ") + src_port->full_name() + " -> " + dst_port->full_name()); return (!result); @@ -345,18 +345,18 @@ JackDriver::jack_port_registration_cb(jack_port_id_t port_id, int registered, vo { assert(jack_driver); JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); - assert(me->m_client); + assert(me->_client); - jack_port_t* const port = jack_port_by_id(me->m_client, port_id); + jack_port_t* const port = jack_port_by_id(me->_client, port_id); const string full_name = jack_port_name(port); - jack_reset_max_delayed_usecs(me->m_client); + jack_reset_max_delayed_usecs(me->_client); if (registered) { - me->m_events.push(PatchageEvent(me->m_app, + me->_events.push(PatchageEvent(me->_app, PatchageEvent::PORT_CREATION, port_id)); } else { - me->m_events.push(PatchageEvent(me->m_app, + me->_events.push(PatchageEvent(me->_app, PatchageEvent::PORT_DESTRUCTION, port_id)); } } @@ -367,11 +367,11 @@ JackDriver::jack_graph_order_cb(void* jack_driver) { assert(jack_driver); JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); - assert(me->m_client); + assert(me->_client); - jack_reset_max_delayed_usecs(me->m_client); + jack_reset_max_delayed_usecs(me->_client); - me->m_is_dirty = true; + me->_is_dirty = true; return 0; } @@ -382,15 +382,15 @@ JackDriver::jack_buffer_size_cb(jack_nframes_t buffer_size, void* jack_driver) { assert(jack_driver); JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); - assert(me->m_client); + assert(me->_client); - jack_reset_max_delayed_usecs(me->m_client); + jack_reset_max_delayed_usecs(me->_client); - //(me->m_mutex).lock(); - me->m_buffer_size = buffer_size; + //(me->_mutex).lock(); + me->_buffer_size = buffer_size; me->reset_xruns(); me->reset_delay(); - //(me->m_mutex).unlock(); + //(me->_mutex).unlock(); return 0; } @@ -401,18 +401,18 @@ JackDriver::jack_xrun_cb(void* jack_driver) { assert(jack_driver); JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); - assert(me->m_client); + assert(me->_client); - //(me->m_mutex).lock(); - me->m_xruns++; - me->m_xrun_delay = jack_get_xrun_delayed_usecs(me->m_client); - jack_reset_max_delayed_usecs(me->m_client); + //(me->_mutex).lock(); + me->_xruns++; + me->_xrun_delay = jack_get_xrun_delayed_usecs(me->_client); + jack_reset_max_delayed_usecs(me->_client); - //cerr << "** XRUN Delay = " << me->m_xrun_delay << endl; + //cerr << "** XRUN Delay = " << me->_xrun_delay << endl; - me->m_is_dirty = true; + me->_is_dirty = true; - //(me->m_mutex).unlock(); + //(me->_mutex).unlock(); return 0; } @@ -423,14 +423,14 @@ JackDriver::jack_shutdown_cb(void* jack_driver) { assert(jack_driver); JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver); - assert(me->m_client); + assert(me->_client); - jack_reset_max_delayed_usecs(me->m_client); + jack_reset_max_delayed_usecs(me->_client); - //(me->m_mutex).lock(); - me->m_client = NULL; - me->m_is_dirty = true; - //(me->m_mutex).unlock(); + //(me->_mutex).lock(); + me->_client = NULL; + me->_is_dirty = true; + //(me->_mutex).unlock(); } @@ -444,18 +444,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; } @@ -466,13 +466,13 @@ 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; @@ -483,14 +483,14 @@ void JackDriver::set_realtime(bool /*realtime*/, int /*priority*/) { /* need a jack_set_realtime, this doesn't make sense - pthread_t jack_thread = jack_client_thread_id(m_client); + pthread_t jack_thread = jack_client_thread_id(_client); if (realtime) if (jack_acquire_real_time_scheduling(jack_thread, priority)) - m_app->status_message("[JACK] ERROR: Unable to set real-time priority"); + _app->status_message("[JACK] ERROR: Unable to set real-time priority"); else if (jack_drop_real_time_scheduling(jack_thread)) - m_app->status_message("[JACK] ERROR: Unable to drop real-time priority"); + _app->status_message("[JACK] ERROR: Unable to drop real-time priority"); cerr << "Set Jack realtime: " << realtime << endl; */ |