mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
NO-OP: Consolidate PortConnect code into shared parent class
This commit is contained in:
parent
17ab174277
commit
a80064981e
12 changed files with 33 additions and 170 deletions
|
|
@ -154,10 +154,8 @@ public:
|
||||||
bool physically_connected (PortEngine::PortHandle, bool process_callback_safe);
|
bool physically_connected (PortEngine::PortHandle, bool process_callback_safe);
|
||||||
int get_connections (PortEngine::PortHandle, std::vector<std::string>&, bool process_callback_safe);
|
int get_connections (PortEngine::PortHandle, std::vector<std::string>&, bool process_callback_safe);
|
||||||
|
|
||||||
virtual void port_connect_callback (const std::string& a, const std::string& b, bool conn) = 0;
|
|
||||||
virtual void port_connect_add_remove_callback () = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
friend class BackendPort;
|
||||||
std::string _instance_name;
|
std::string _instance_name;
|
||||||
|
|
||||||
std::vector<BackendPortPtr> _system_inputs;
|
std::vector<BackendPortPtr> _system_inputs;
|
||||||
|
|
@ -165,6 +163,31 @@ protected:
|
||||||
std::vector<BackendPortPtr> _system_midi_in;
|
std::vector<BackendPortPtr> _system_midi_in;
|
||||||
std::vector<BackendPortPtr> _system_midi_out;
|
std::vector<BackendPortPtr> _system_midi_out;
|
||||||
|
|
||||||
|
struct PortConnectData {
|
||||||
|
std::string a;
|
||||||
|
std::string b;
|
||||||
|
bool c;
|
||||||
|
|
||||||
|
PortConnectData (const std::string& a, const std::string& b, bool c)
|
||||||
|
: a (a) , b (b) , c (c) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
_port_connection_queue.push_back(new PortConnectData(a, b, conn));
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void update_system_port_latencies ();
|
virtual void update_system_port_latencies ();
|
||||||
|
|
||||||
void clear_ports ();
|
void clear_ports ();
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,13 @@ BackendPort::BackendPort (PortEngineSharedImpl &b, const std::string& name, Port
|
||||||
_capture_latency_range.max = 0;
|
_capture_latency_range.max = 0;
|
||||||
_playback_latency_range.min = 0;
|
_playback_latency_range.min = 0;
|
||||||
_playback_latency_range.max = 0;
|
_playback_latency_range.max = 0;
|
||||||
|
|
||||||
|
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
||||||
}
|
}
|
||||||
|
|
||||||
BackendPort::~BackendPort ()
|
BackendPort::~BackendPort ()
|
||||||
{
|
{
|
||||||
|
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
||||||
assert (_connections.empty());
|
assert (_connections.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,14 +189,17 @@ BackendPort::update_connected_latency (bool for_playback)
|
||||||
|
|
||||||
|
|
||||||
PortEngineSharedImpl::PortEngineSharedImpl (PortManager& mgr, std::string const & str)
|
PortEngineSharedImpl::PortEngineSharedImpl (PortManager& mgr, std::string const & str)
|
||||||
: _instance_name (str)
|
: _instance_name (str)
|
||||||
|
, _port_change_flag (false)
|
||||||
, _portmap (new PortMap)
|
, _portmap (new PortMap)
|
||||||
, _ports (new PortIndex)
|
, _ports (new PortIndex)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_init (&_port_callback_mutex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
PortEngineSharedImpl::~PortEngineSharedImpl ()
|
PortEngineSharedImpl::~PortEngineSharedImpl ()
|
||||||
{
|
{
|
||||||
|
pthread_mutex_destroy (&_port_callback_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
||||||
|
|
@ -76,10 +76,8 @@ AlsaAudioBackend::AlsaAudioBackend (AudioEngine& e, AudioBackendInfo& info)
|
||||||
, _midi_device_thread_active (false)
|
, _midi_device_thread_active (false)
|
||||||
, _dsp_load (0)
|
, _dsp_load (0)
|
||||||
, _processed_samples (0)
|
, _processed_samples (0)
|
||||||
, _port_change_flag (false)
|
|
||||||
{
|
{
|
||||||
_instance_name = s_instance_name;
|
_instance_name = s_instance_name;
|
||||||
pthread_mutex_init (&_port_callback_mutex, 0);
|
|
||||||
pthread_mutex_init (&_device_port_mutex, 0);
|
pthread_mutex_init (&_device_port_mutex, 0);
|
||||||
_input_audio_device_info.valid = false;
|
_input_audio_device_info.valid = false;
|
||||||
_output_audio_device_info.valid = false;
|
_output_audio_device_info.valid = false;
|
||||||
|
|
@ -91,7 +89,6 @@ AlsaAudioBackend::~AlsaAudioBackend ()
|
||||||
{
|
{
|
||||||
clear_ports ();
|
clear_ports ();
|
||||||
|
|
||||||
pthread_mutex_destroy (&_port_callback_mutex);
|
|
||||||
pthread_mutex_destroy (&_device_port_mutex);
|
pthread_mutex_destroy (&_device_port_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2230,12 +2227,10 @@ AlsaAudioPort::AlsaAudioPort (AlsaAudioBackend &b, const std::string& name, Port
|
||||||
{
|
{
|
||||||
memset (_buffer, 0, sizeof (_buffer));
|
memset (_buffer, 0, sizeof (_buffer));
|
||||||
mlock (_buffer, sizeof (_buffer));
|
mlock (_buffer, sizeof (_buffer));
|
||||||
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AlsaAudioPort::~AlsaAudioPort ()
|
AlsaAudioPort::~AlsaAudioPort ()
|
||||||
{
|
{
|
||||||
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
|
|
@ -2277,13 +2272,10 @@ AlsaMidiPort::AlsaMidiPort (AlsaAudioBackend &b, const std::string& name, PortFl
|
||||||
_buffer[0].reserve(256);
|
_buffer[0].reserve(256);
|
||||||
_buffer[1].reserve(256);
|
_buffer[1].reserve(256);
|
||||||
_buffer[2].reserve(256);
|
_buffer[2].reserve(256);
|
||||||
|
|
||||||
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AlsaMidiPort::~AlsaMidiPort ()
|
AlsaMidiPort::~AlsaMidiPort ()
|
||||||
{
|
{
|
||||||
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MidiEventSorter {
|
struct MidiEventSorter {
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,6 @@ class AlsaDeviceReservation
|
||||||
|
|
||||||
class AlsaAudioBackend : public AudioBackend, public PortEngineSharedImpl
|
class AlsaAudioBackend : public AudioBackend, public PortEngineSharedImpl
|
||||||
{
|
{
|
||||||
friend class AlsaPort;
|
|
||||||
public:
|
public:
|
||||||
AlsaAudioBackend (AudioEngine& e, AudioBackendInfo& info);
|
AlsaAudioBackend (AudioEngine& e, AudioBackendInfo& info);
|
||||||
~AlsaAudioBackend ();
|
~AlsaAudioBackend ();
|
||||||
|
|
@ -375,31 +374,6 @@ class AlsaAudioBackend : public AudioBackend, public PortEngineSharedImpl
|
||||||
std::vector<AlsaMidiOut *> _rmidi_out;
|
std::vector<AlsaMidiOut *> _rmidi_out;
|
||||||
std::vector<AlsaMidiIn *> _rmidi_in;
|
std::vector<AlsaMidiIn *> _rmidi_in;
|
||||||
|
|
||||||
struct PortConnectData {
|
|
||||||
std::string a;
|
|
||||||
std::string b;
|
|
||||||
bool c;
|
|
||||||
|
|
||||||
PortConnectData (const std::string& a, const std::string& b, bool c)
|
|
||||||
: a (a) , b (b) , c (c) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
_port_connection_queue.push_back(new PortConnectData(a, b, conn));
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void update_systemic_audio_latencies ();
|
void update_systemic_audio_latencies ();
|
||||||
void update_systemic_midi_latencies ();
|
void update_systemic_midi_latencies ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,10 +107,8 @@ CoreAudioBackend::CoreAudioBackend (AudioEngine& e, AudioBackendInfo& info)
|
||||||
, _systemic_audio_output_latency (0)
|
, _systemic_audio_output_latency (0)
|
||||||
, _dsp_load (0)
|
, _dsp_load (0)
|
||||||
, _processed_samples (0)
|
, _processed_samples (0)
|
||||||
, _port_change_flag (false)
|
|
||||||
{
|
{
|
||||||
_instance_name = s_instance_name;
|
_instance_name = s_instance_name;
|
||||||
pthread_mutex_init (&_port_callback_mutex, 0);
|
|
||||||
pthread_mutex_init (&_port_registration_mutex, 0);
|
pthread_mutex_init (&_port_registration_mutex, 0);
|
||||||
pthread_mutex_init (&_process_callback_mutex, 0);
|
pthread_mutex_init (&_process_callback_mutex, 0);
|
||||||
pthread_mutex_init (&_freewheel_mutex, 0);
|
pthread_mutex_init (&_freewheel_mutex, 0);
|
||||||
|
|
@ -132,7 +130,6 @@ CoreAudioBackend::~CoreAudioBackend ()
|
||||||
|
|
||||||
clear_ports ();
|
clear_ports ();
|
||||||
|
|
||||||
pthread_mutex_destroy (&_port_callback_mutex);
|
|
||||||
pthread_mutex_destroy (&_port_registration_mutex);
|
pthread_mutex_destroy (&_port_registration_mutex);
|
||||||
pthread_mutex_destroy (&_process_callback_mutex);
|
pthread_mutex_destroy (&_process_callback_mutex);
|
||||||
pthread_mutex_destroy (&_freewheel_mutex);
|
pthread_mutex_destroy (&_freewheel_mutex);
|
||||||
|
|
@ -1605,13 +1602,10 @@ CoreAudioPort::CoreAudioPort (CoreAudioBackend &b, const std::string& name, Port
|
||||||
memset (_buffer, 0, sizeof (_buffer));
|
memset (_buffer, 0, sizeof (_buffer));
|
||||||
mlock (_buffer, sizeof (_buffer));
|
mlock (_buffer, sizeof (_buffer));
|
||||||
|
|
||||||
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreAudioPort::~CoreAudioPort ()
|
CoreAudioPort::~CoreAudioPort ()
|
||||||
{
|
{
|
||||||
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,6 @@ class CoreMidiPort : public BackendPort {
|
||||||
}; // class CoreMidiPort
|
}; // class CoreMidiPort
|
||||||
|
|
||||||
class CoreAudioBackend : public AudioBackend, public PortEngineSharedImpl {
|
class CoreAudioBackend : public AudioBackend, public PortEngineSharedImpl {
|
||||||
friend class CoreBackendPort;
|
|
||||||
public:
|
public:
|
||||||
CoreAudioBackend (AudioEngine& e, AudioBackendInfo& info);
|
CoreAudioBackend (AudioEngine& e, AudioBackendInfo& info);
|
||||||
~CoreAudioBackend ();
|
~CoreAudioBackend ();
|
||||||
|
|
@ -398,32 +397,6 @@ class CoreAudioBackend : public AudioBackend, public PortEngineSharedImpl {
|
||||||
/* port engine */
|
/* port engine */
|
||||||
int register_system_audio_ports ();
|
int register_system_audio_ports ();
|
||||||
|
|
||||||
struct PortConnectData {
|
|
||||||
std::string a;
|
|
||||||
std::string b;
|
|
||||||
bool c;
|
|
||||||
|
|
||||||
PortConnectData (const std::string& a, const std::string& b, bool c)
|
|
||||||
: a (a) , b (b) , c (c) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<PortConnectData *> _port_connection_queue;
|
|
||||||
pthread_mutex_t _port_callback_mutex;
|
|
||||||
pthread_mutex_t _port_registration_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);
|
|
||||||
_port_connection_queue.push_back(new PortConnectData(a, b, conn));
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
BackendPortPtr find_port_in (std::vector<BackendPortPtr> const & plist, const std::string& port_name) const {
|
BackendPortPtr find_port_in (std::vector<BackendPortPtr> const & plist, const std::string& port_name) const {
|
||||||
for (std::vector<BackendPortPtr>::const_iterator it = plist.begin (); it != plist.end (); ++it) {
|
for (std::vector<BackendPortPtr>::const_iterator it = plist.begin (); it != plist.end (); ++it) {
|
||||||
if ((*it)->name () == port_name) {
|
if ((*it)->name () == port_name) {
|
||||||
|
|
|
||||||
|
|
@ -77,11 +77,9 @@ DummyAudioBackend::DummyAudioBackend (AudioEngine& e, AudioBackendInfo& info)
|
||||||
, _systemic_input_latency (0)
|
, _systemic_input_latency (0)
|
||||||
, _systemic_output_latency (0)
|
, _systemic_output_latency (0)
|
||||||
, _processed_samples (0)
|
, _processed_samples (0)
|
||||||
, _port_change_flag (false)
|
|
||||||
{
|
{
|
||||||
_instance_name = s_instance_name;
|
_instance_name = s_instance_name;
|
||||||
_device = _("Silence");
|
_device = _("Silence");
|
||||||
pthread_mutex_init (&_port_callback_mutex, 0);
|
|
||||||
|
|
||||||
if (_driver_speed.empty()) {
|
if (_driver_speed.empty()) {
|
||||||
_driver_speed.push_back (DriverSpeed (_("Half Speed"), 2.0f));
|
_driver_speed.push_back (DriverSpeed (_("Half Speed"), 2.0f));
|
||||||
|
|
@ -99,7 +97,6 @@ DummyAudioBackend::DummyAudioBackend (AudioEngine& e, AudioBackendInfo& info)
|
||||||
DummyAudioBackend::~DummyAudioBackend ()
|
DummyAudioBackend::~DummyAudioBackend ()
|
||||||
{
|
{
|
||||||
clear_ports ();
|
clear_ports ();
|
||||||
pthread_mutex_destroy (&_port_callback_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AUDIOBACKEND API */
|
/* AUDIOBACKEND API */
|
||||||
|
|
@ -1113,12 +1110,10 @@ DummyPort::DummyPort (DummyAudioBackend &b, const std::string& name, PortFlags f
|
||||||
, _gen_cycle (false)
|
, _gen_cycle (false)
|
||||||
, _engine (b)
|
, _engine (b)
|
||||||
{
|
{
|
||||||
_backend.port_connect_add_remove_callback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DummyPort::~DummyPort ()
|
DummyPort::~DummyPort ()
|
||||||
{
|
{
|
||||||
_backend.port_connect_add_remove_callback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DummyPort::setup_random_number_generator ()
|
void DummyPort::setup_random_number_generator ()
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,6 @@ class DummyMidiPort : public DummyPort {
|
||||||
}; // class DummyMidiPort
|
}; // class DummyMidiPort
|
||||||
|
|
||||||
class DummyAudioBackend : public AudioBackend, public PortEngineSharedImpl {
|
class DummyAudioBackend : public AudioBackend, public PortEngineSharedImpl {
|
||||||
friend class DummyPort;
|
|
||||||
public:
|
public:
|
||||||
DummyAudioBackend (AudioEngine& e, AudioBackendInfo& info);
|
DummyAudioBackend (AudioEngine& e, AudioBackendInfo& info);
|
||||||
~DummyAudioBackend ();
|
~DummyAudioBackend ();
|
||||||
|
|
@ -405,31 +404,6 @@ class DummyAudioBackend : public AudioBackend, public PortEngineSharedImpl {
|
||||||
/* port engine */
|
/* port engine */
|
||||||
int register_system_ports ();
|
int register_system_ports ();
|
||||||
|
|
||||||
struct PortConnectData {
|
|
||||||
std::string a;
|
|
||||||
std::string b;
|
|
||||||
bool c;
|
|
||||||
|
|
||||||
PortConnectData (const std::string& a, const std::string& b, bool c)
|
|
||||||
: a (a) , b (b) , c (c) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
_port_connection_queue.push_back(new PortConnectData(a, b, conn));
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
BackendPort* port_factory (std::string const & name, ARDOUR::DataType type, ARDOUR::PortFlags);
|
BackendPort* port_factory (std::string const & name, ARDOUR::DataType type, ARDOUR::PortFlags);
|
||||||
|
|
||||||
}; // class DummyAudioBackend
|
}; // class DummyAudioBackend
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,8 @@ PortAudioBackend::PortAudioBackend (AudioEngine& e, AudioBackendInfo& info)
|
||||||
, _systemic_audio_output_latency (0)
|
, _systemic_audio_output_latency (0)
|
||||||
, _dsp_load (0)
|
, _dsp_load (0)
|
||||||
, _processed_samples (0)
|
, _processed_samples (0)
|
||||||
, _port_change_flag (false)
|
|
||||||
{
|
{
|
||||||
_instance_name = s_instance_name;
|
_instance_name = s_instance_name;
|
||||||
pthread_mutex_init (&_port_callback_mutex, 0);
|
|
||||||
pthread_mutex_init (&_freewheel_mutex, 0);
|
pthread_mutex_init (&_freewheel_mutex, 0);
|
||||||
pthread_cond_init (&_freewheel_signal, 0);
|
pthread_cond_init (&_freewheel_signal, 0);
|
||||||
|
|
||||||
|
|
@ -108,7 +106,6 @@ PortAudioBackend::~PortAudioBackend ()
|
||||||
|
|
||||||
clear_ports ();
|
clear_ports ();
|
||||||
|
|
||||||
pthread_mutex_destroy (&_port_callback_mutex);
|
|
||||||
pthread_mutex_destroy (&_freewheel_mutex);
|
pthread_mutex_destroy (&_freewheel_mutex);
|
||||||
pthread_cond_destroy (&_freewheel_signal);
|
pthread_cond_destroy (&_freewheel_signal);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,6 @@ class PortMidiPort : public BackendPort {
|
||||||
}; // class PortMidiPort
|
}; // class PortMidiPort
|
||||||
|
|
||||||
class PortAudioBackend : public AudioBackend, public PortEngineSharedImpl {
|
class PortAudioBackend : public AudioBackend, public PortEngineSharedImpl {
|
||||||
friend class PamPort;
|
|
||||||
public:
|
public:
|
||||||
PortAudioBackend (AudioEngine& e, AudioBackendInfo& info);
|
PortAudioBackend (AudioEngine& e, AudioBackendInfo& info);
|
||||||
~PortAudioBackend ();
|
~PortAudioBackend ();
|
||||||
|
|
@ -373,31 +372,6 @@ class PortAudioBackend : public AudioBackend, public PortEngineSharedImpl {
|
||||||
int register_system_audio_ports ();
|
int register_system_audio_ports ();
|
||||||
int register_system_midi_ports ();
|
int register_system_midi_ports ();
|
||||||
|
|
||||||
struct PortConnectData {
|
|
||||||
std::string a;
|
|
||||||
std::string b;
|
|
||||||
bool c;
|
|
||||||
|
|
||||||
PortConnectData (const std::string& a, const std::string& b, bool c)
|
|
||||||
: a (a) , b (b) , c (c) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
_port_connection_queue.push_back(new PortConnectData(a, b, conn));
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // class PortAudioBackend
|
}; // class PortAudioBackend
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
||||||
|
|
@ -61,17 +61,13 @@ PulseAudioBackend::PulseAudioBackend (AudioEngine& e, AudioBackendInfo& info)
|
||||||
, _systemic_audio_output_latency (0)
|
, _systemic_audio_output_latency (0)
|
||||||
, _dsp_load (0)
|
, _dsp_load (0)
|
||||||
, _processed_samples (0)
|
, _processed_samples (0)
|
||||||
, _port_change_flag (false)
|
|
||||||
{
|
{
|
||||||
_instance_name = s_instance_name;
|
_instance_name = s_instance_name;
|
||||||
pthread_mutex_init (&_port_callback_mutex, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PulseAudioBackend::~PulseAudioBackend ()
|
PulseAudioBackend::~PulseAudioBackend ()
|
||||||
{
|
{
|
||||||
clear_ports ();
|
clear_ports ();
|
||||||
|
|
||||||
pthread_mutex_destroy (&_port_callback_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pulseaudio */
|
/* Pulseaudio */
|
||||||
|
|
@ -1214,12 +1210,10 @@ PulseAudioPort::PulseAudioPort (PulseAudioBackend& b, const std::string& name, P
|
||||||
{
|
{
|
||||||
memset (_buffer, 0, sizeof (_buffer));
|
memset (_buffer, 0, sizeof (_buffer));
|
||||||
mlock (_buffer, sizeof (_buffer));
|
mlock (_buffer, sizeof (_buffer));
|
||||||
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PulseAudioPort::~PulseAudioPort ()
|
PulseAudioPort::~PulseAudioPort ()
|
||||||
{
|
{
|
||||||
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
|
|
@ -1254,12 +1248,10 @@ PulseMidiPort::PulseMidiPort (PulseAudioBackend& b, const std::string& name, Por
|
||||||
{
|
{
|
||||||
_buffer.clear ();
|
_buffer.clear ();
|
||||||
_buffer.reserve (256);
|
_buffer.reserve (256);
|
||||||
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PulseMidiPort::~PulseMidiPort ()
|
PulseMidiPort::~PulseMidiPort ()
|
||||||
{
|
{
|
||||||
_backend.port_connect_add_remove_callback (); // XXX -> RT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MidiEventSorter {
|
struct MidiEventSorter {
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,6 @@ private:
|
||||||
|
|
||||||
class PulseAudioBackend : public AudioBackend, public PortEngineSharedImpl
|
class PulseAudioBackend : public AudioBackend, public PortEngineSharedImpl
|
||||||
{
|
{
|
||||||
friend class PulsePort;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PulseAudioBackend (AudioEngine& e, AudioBackendInfo& info);
|
PulseAudioBackend (AudioEngine& e, AudioBackendInfo& info);
|
||||||
~PulseAudioBackend ();
|
~PulseAudioBackend ();
|
||||||
|
|
@ -296,35 +294,6 @@ private:
|
||||||
BackendPort* port_factory (std::string const & name, ARDOUR::DataType dt, ARDOUR::PortFlags flags);
|
BackendPort* port_factory (std::string const & name, ARDOUR::DataType dt, ARDOUR::PortFlags flags);
|
||||||
int register_system_ports ();
|
int register_system_ports ();
|
||||||
|
|
||||||
struct PortConnectData {
|
|
||||||
std::string a;
|
|
||||||
std::string b;
|
|
||||||
bool c;
|
|
||||||
|
|
||||||
PortConnectData (const std::string& a, const std::string& b, bool c)
|
|
||||||
: a (a), b (b), c (c) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
_port_connection_queue.push_back (new PortConnectData (a, b, conn));
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // class PulseAudioBackend
|
}; // class PulseAudioBackend
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue