mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-06 21:55:43 +01:00
ALSA & Dummy: implement port [un]registration_callback
This commit is contained in:
parent
7caad67f7f
commit
58a1f32130
4 changed files with 52 additions and 1 deletions
|
|
@ -57,6 +57,7 @@ AlsaAudioBackend::AlsaAudioBackend (AudioEngine& e, AudioBackendInfo& info)
|
|||
, _systemic_input_latency (0)
|
||||
, _systemic_output_latency (0)
|
||||
, _processed_samples (0)
|
||||
, _port_change_flag (false)
|
||||
{
|
||||
_instance_name = s_instance_name;
|
||||
pthread_mutex_init (&_port_callback_mutex, 0);
|
||||
|
|
@ -487,6 +488,7 @@ AlsaAudioBackend::_start (bool for_latency_measurement)
|
|||
|
||||
engine.reconnect_ports ();
|
||||
_run = true;
|
||||
_port_change_flag = false;
|
||||
|
||||
if (_realtime_pthread_create (SCHED_FIFO, -20,
|
||||
&_main_thread, pthread_process, this))
|
||||
|
|
@ -1286,6 +1288,7 @@ AlsaAudioBackend::main_process_thread ()
|
|||
_pcmi->pcm_start ();
|
||||
int no_proc_errors = 0;
|
||||
|
||||
manager.registration_callback();
|
||||
manager.graph_order_callback();
|
||||
|
||||
while (_run) {
|
||||
|
|
@ -1396,7 +1399,16 @@ AlsaAudioBackend::main_process_thread ()
|
|||
Glib::usleep (100); // don't hog cpu
|
||||
}
|
||||
|
||||
bool connections_changed = false;
|
||||
bool ports_changed = false;
|
||||
if (!pthread_mutex_trylock (&_port_callback_mutex)) {
|
||||
if (_port_change_flag) {
|
||||
ports_changed = true;
|
||||
_port_change_flag = false;
|
||||
}
|
||||
if (!_port_connection_queue.empty ()) {
|
||||
connections_changed = true;
|
||||
}
|
||||
while (!_port_connection_queue.empty ()) {
|
||||
PortConnectData *c = _port_connection_queue.back ();
|
||||
manager.connect_callback (c->a, c->b, c->c);
|
||||
|
|
@ -1405,6 +1417,12 @@ AlsaAudioBackend::main_process_thread ()
|
|||
}
|
||||
pthread_mutex_unlock (&_port_callback_mutex);
|
||||
}
|
||||
if (ports_changed) {
|
||||
manager.registration_callback();
|
||||
}
|
||||
if (connections_changed) {
|
||||
manager.graph_order_callback();
|
||||
}
|
||||
|
||||
}
|
||||
_pcmi->pcm_stop ();
|
||||
|
|
|
|||
|
|
@ -352,6 +352,7 @@ class AlsaAudioBackend : public AudioBackend {
|
|||
|
||||
std::vector<PortConnectData *> _port_connection_queue;
|
||||
pthread_mutex_t _port_callback_mutex;
|
||||
bool _port_change_flag;
|
||||
|
||||
void port_connect_callback (const std::string& a, const std::string& b, bool conn) {
|
||||
pthread_mutex_lock (&_port_callback_mutex);
|
||||
|
|
@ -359,6 +360,12 @@ class AlsaAudioBackend : public AudioBackend {
|
|||
pthread_mutex_unlock (&_port_callback_mutex);
|
||||
}
|
||||
|
||||
void port_connect_add_remove_callback () {
|
||||
pthread_mutex_lock (&_port_callback_mutex);
|
||||
_port_change_flag = true;
|
||||
pthread_mutex_unlock (&_port_callback_mutex);
|
||||
}
|
||||
|
||||
bool valid_port (PortHandle port) const {
|
||||
return std::find (_ports.begin (), _ports.end (), (AlsaPort*)port) != _ports.end ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue