| 190 | } // namespace |
| 191 | |
| 192 | QJsonObject buildAudioDevicesSnapshot(const AudioEngine* audio, const QJsonObject& snapshot) |
| 193 | { |
| 194 | const QList<QAudioDevice> inputs = QMediaDevices::audioInputs(); |
| 195 | const QList<QAudioDevice> outputs = QMediaDevices::audioOutputs(); |
| 196 | const QAudioDevice defaultInput = QMediaDevices::defaultAudioInput(); |
| 197 | const QAudioDevice defaultOutput = QMediaDevices::defaultAudioOutput(); |
| 198 | |
| 199 | const QAudioDevice selectedInput = (audio && !audio->inputDevice().isNull()) |
| 200 | ? audio->inputDevice() |
| 201 | : defaultInput; |
| 202 | const QAudioDevice selectedOutput = (audio && !audio->outputDevice().isNull()) |
| 203 | ? audio->outputDevice() |
| 204 | : defaultOutput; |
| 205 | const QByteArray savedInputId = AppSettings::instance() |
| 206 | .value(QStringLiteral("AudioInputDeviceId"), QString()).toByteArray(); |
| 207 | const QByteArray savedOutputId = AppSettings::instance() |
| 208 | .value(QStringLiteral("AudioOutputDeviceId"), QString()).toByteArray(); |
| 209 | |
| 210 | QJsonObject obj; |
| 211 | obj["available"] = audio != nullptr; |
| 212 | obj["qt_multimedia"] = true; |
| 213 | obj["input_device_count"] = inputs.size(); |
| 214 | obj["output_device_count"] = outputs.size(); |
| 215 | obj["saved_input_configured"] = !savedInputId.isEmpty(); |
| 216 | obj["saved_output_configured"] = !savedOutputId.isEmpty(); |
| 217 | obj["saved_input_present"] = deviceIdPresent(inputs, savedInputId); |
| 218 | obj["saved_output_present"] = deviceIdPresent(outputs, savedOutputId); |
| 219 | obj["selected_input_source"] = (audio && !audio->inputDevice().isNull()) ? "saved selection" : "system default"; |
| 220 | obj["selected_output_source"] = (audio && !audio->outputDevice().isNull()) ? "saved selection" : "system default"; |
| 221 | obj["selected_input_present"] = devicePresent(inputs, selectedInput); |
| 222 | obj["selected_output_present"] = devicePresent(outputs, selectedOutput); |
| 223 | obj["selected_input"] = deviceToJson(selectedInput, selectedInput, defaultInput, QStringLiteral("input")); |
| 224 | obj["selected_output"] = deviceToJson(selectedOutput, selectedOutput, defaultOutput, QStringLiteral("output")); |
| 225 | obj["default_input"] = deviceToJson(defaultInput, selectedInput, defaultInput, QStringLiteral("input")); |
| 226 | obj["default_output"] = deviceToJson(defaultOutput, selectedOutput, defaultOutput, QStringLiteral("output")); |
| 227 | obj["input_devices"] = deviceListToJson(inputs, selectedInput, defaultInput, QStringLiteral("input")); |
| 228 | obj["output_devices"] = deviceListToJson(outputs, selectedOutput, defaultOutput, QStringLiteral("output")); |
| 229 | |
| 230 | const QJsonObject transmit = snapshot["transmit"].toObject(); |
| 231 | const QJsonObject mic = transmit["mic"].toObject(); |
| 232 | const QJsonObject radio = snapshot["radio"].toObject(); |
| 233 | const QJsonObject remoteAudioRx = radio["remote_audio_rx"].toObject(); |
| 234 | const bool pcAudioEnabled = isSavedTrue(QStringLiteral("PcAudioEnabled"), QStringLiteral("True")); |
| 235 | |
| 236 | QJsonObject rxRoute; |
| 237 | rxRoute["output"] = pcAudioEnabled ? "PC audio" : "Radio audio"; |
| 238 | rxRoute["source"] = "PcAudioEnabled app setting"; |
| 239 | rxRoute["selected_output_device"] = selectedOutput.description(); |
| 240 | rxRoute["actual_sample_rate_hz"] = (audio && audio->isRxStreaming()) |
| 241 | ? QJsonValue(audio->rxBufferSampleRate()) |
| 242 | : QJsonValue(); |
| 243 | rxRoute["actual_channel_count"] = (audio && audio->isRxStreaming()) |
| 244 | ? QJsonValue(2) |
| 245 | : QJsonValue(); |
| 246 | rxRoute["actual_sample_format"] = (audio && audio->isRxStreaming()) |
| 247 | ? QJsonValue(QStringLiteral("Float")) |
| 248 | : QJsonValue(); |
| 249 | rxRoute["resampling_active"] = (audio && audio->isRxStreaming()) |
no test coverage detected