| 155 | } |
| 156 | |
| 157 | void Port::setDeviceId(int deviceId) { |
| 158 | if (!driver) |
| 159 | return; |
| 160 | if (deviceId == this->deviceId) |
| 161 | return; |
| 162 | // Destroy device |
| 163 | if (this->deviceId >= 0) { |
| 164 | try { |
| 165 | driver->unsubscribe(this->deviceId, this); |
| 166 | onStopStream(); |
| 167 | } |
| 168 | catch (Exception& e) { |
| 169 | WARN("Audio port could not unsubscribe from device: %s", e.what()); |
| 170 | } |
| 171 | } |
| 172 | device = NULL; |
| 173 | this->deviceId = -1; |
| 174 | |
| 175 | // Create device |
| 176 | if (deviceId >= 0) { |
| 177 | try { |
| 178 | device = driver->subscribe(deviceId, this); |
| 179 | if (device) { |
| 180 | this->deviceId = deviceId; |
| 181 | onStartStream(); |
| 182 | } |
| 183 | } |
| 184 | catch (Exception& e) { |
| 185 | WARN("Audio port could not subscribe to device: %s", e.what()); |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | int Port::getDeviceNumInputs(int deviceId) { |
| 191 | if (!driver) |
nothing calls this directly
no test coverage detected