..and CoreAudio.

This commit is contained in:
Robin Gareus 2016-04-24 20:45:50 +02:00
parent 800c8182c6
commit fde99e68f7
2 changed files with 55 additions and 46 deletions

View file

@ -82,7 +82,7 @@ class CoreBackendPort {
bool is_connected (const CoreBackendPort *port) const;
bool is_physically_connected () const;
const std::vector<CoreBackendPort *>& get_connections () const { return _connections; }
const std::set<CoreBackendPort *>& get_connections () const { return _connections; }
int connect (CoreBackendPort *port);
int disconnect (CoreBackendPort *port);
@ -114,7 +114,7 @@ class CoreBackendPort {
const PortFlags _flags;
LatencyRange _capture_latency_range;
LatencyRange _playback_latency_range;
std::vector<CoreBackendPort*> _connections;
std::set<CoreBackendPort*> _connections;
void _connect (CoreBackendPort* , bool);
void _disconnect (CoreBackendPort* , bool);
@ -461,12 +461,16 @@ class CoreAudioBackend : public AudioBackend {
int register_system_audio_ports ();
void unregister_ports (bool system_only = false);
std::vector<CoreBackendPort *> _ports;
std::vector<CoreBackendPort *> _system_inputs;
std::vector<CoreBackendPort *> _system_outputs;
std::vector<CoreBackendPort *> _system_midi_in;
std::vector<CoreBackendPort *> _system_midi_out;
typedef std::map<std::string, CoreBackendPort *> PortMap; // fast lookup in _ports
typedef std::set<CoreBackendPort *> PortIndex; // fast lookup in _ports
PortMap _portmap;
PortIndex _ports;
struct PortConnectData {
std::string a;
std::string b;
@ -493,16 +497,15 @@ class CoreAudioBackend : public AudioBackend {
}
bool valid_port (PortHandle port) const {
return std::find (_ports.begin (), _ports.end (), (CoreBackendPort*)port) != _ports.end ();
return _ports.find (static_cast<CoreBackendPort*>(port)) != _ports.end ();
}
CoreBackendPort * find_port (const std::string& port_name) const {
for (std::vector<CoreBackendPort*>::const_iterator it = _ports.begin (); it != _ports.end (); ++it) {
if ((*it)->name () == port_name) {
return *it;
}
CoreBackendPort* find_port (const std::string& port_name) const {
PortMap::const_iterator it = _portmap.find (port_name);
if (it == _portmap.end()) {
return NULL;
}
return NULL;
return (*it).second;
}
CoreBackendPort * find_port_in (std::vector<CoreBackendPort *> plist, const std::string& port_name) const {