| 91 | } |
| 92 | |
| 93 | void Port::setDriverId(int driverId) { |
| 94 | // Unset device and driver |
| 95 | setDeviceId(-1); |
| 96 | driver = NULL; |
| 97 | this->driverId = -1; |
| 98 | |
| 99 | // Find driver by ID |
| 100 | driver = audio::getDriver(driverId); |
| 101 | if (driver) { |
| 102 | this->driverId = driverId; |
| 103 | } |
| 104 | else if (!drivers.empty()) { |
| 105 | // Set first driver as default |
| 106 | driver = drivers[0].second; |
| 107 | this->driverId = drivers[0].first; |
| 108 | } |
| 109 | else { |
| 110 | // No fallback drivers |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | // Set default device if exists |
| 115 | try { |
| 116 | int defaultDeviceId = driver->getDefaultDeviceId(); |
| 117 | if (defaultDeviceId >= 0) |
| 118 | setDeviceId(defaultDeviceId); |
| 119 | } |
| 120 | catch (Exception& e) { |
| 121 | WARN("Audio port could not get default device ID: %s", e.what()); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | std::string Port::getDriverName() { |
| 126 | if (!driver) |
nothing calls this directly
no test coverage detected