Implement restoring hardware<>hardware connections for internal backends

This commit is contained in:
Robin Gareus 2025-10-06 06:15:50 +02:00
parent 4a51f4f350
commit 94a4f6b350
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
14 changed files with 248 additions and 0 deletions

View file

@ -2435,3 +2435,47 @@ AlsaDeviceReservation::reservation_stdout (std::string d, size_t /* s */)
_reservation_succeeded = true;
}
}
/* ****************************************************************************/
XMLNode*
AlsaAudioBackend::get_state () const {
XMLNode* node = PortEngineSharedImpl::get_state ();
node->set_property ("backend", name ());
node->set_property ("driver", driver_name ());
node->set_property ("input-device", input_device_name ());
node->set_property ("output-device", output_device_name ());
return node;
}
int
AlsaAudioBackend::set_state (XMLNode const& node, int version)
{
if (match_state (node, version)) {
return PortEngineSharedImpl::set_state (node, version);
}
return -1;
}
bool
AlsaAudioBackend::match_state (XMLNode const& node, int version)
{
if (node.name() != X_("PortEngine")) {
return false;
}
std::string val;
if (!node.get_property ("backend", val) || val != name ()) {
return false;
}
if (!node.get_property ("driver", val) || val != driver_name ()) {
return false;
}
if (!node.get_property ("input-device", val) || val != input_device_name ()) {
return false;
}
if (!node.get_property ("output-device", val) || val != output_device_name ()) {
return false;
}
return true;
}

View file

@ -245,6 +245,10 @@ class AlsaAudioBackend : public AudioBackend, public PortEngineSharedImpl
bool physically_connected (PortEngine::PortHandle ph, bool process_callback_safe) { return PortEngineSharedImpl::physically_connected (ph, process_callback_safe); }
int get_connections (PortEngine::PortHandle ph, std::vector<std::string>& results, bool process_callback_safe) { return PortEngineSharedImpl::get_connections (ph, results, process_callback_safe); }
XMLNode* get_state () const;
int set_state (XMLNode const& node, int version);
bool match_state (XMLNode const&, int version);
/* MIDI */
int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t const** buf, void* port_buffer, uint32_t event_index);
int midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size);