| 342 | } |
| 343 | |
| 344 | QJsonObject buildAudioStartupSnapshot(const AudioEngine* audio, const QJsonObject& snapshot) |
| 345 | { |
| 346 | const QList<QAudioDevice> inputs = QMediaDevices::audioInputs(); |
| 347 | const QList<QAudioDevice> outputs = QMediaDevices::audioOutputs(); |
| 348 | const QAudioDevice defaultInput = QMediaDevices::defaultAudioInput(); |
| 349 | const QAudioDevice defaultOutput = QMediaDevices::defaultAudioOutput(); |
| 350 | |
| 351 | const QAudioDevice selectedInput = (audio && !audio->inputDevice().isNull()) |
| 352 | ? audio->inputDevice() |
| 353 | : defaultInput; |
| 354 | const QAudioDevice selectedOutput = (audio && !audio->outputDevice().isNull()) |
| 355 | ? audio->outputDevice() |
| 356 | : defaultOutput; |
| 357 | const QByteArray savedInputId = AppSettings::instance() |
| 358 | .value(QStringLiteral("AudioInputDeviceId"), QString()).toByteArray(); |
| 359 | const QByteArray savedOutputId = AppSettings::instance() |
| 360 | .value(QStringLiteral("AudioOutputDeviceId"), QString()).toByteArray(); |
| 361 | |
| 362 | QJsonObject obj; |
| 363 | obj["available"] = audio != nullptr; |
| 364 | obj["qt_multimedia"] = true; |
| 365 | obj["input_device_count"] = inputs.size(); |
| 366 | obj["output_device_count"] = outputs.size(); |
| 367 | obj["saved_input_configured"] = !savedInputId.isEmpty(); |
| 368 | obj["saved_output_configured"] = !savedOutputId.isEmpty(); |
| 369 | obj["saved_input_present"] = deviceIdPresent(inputs, savedInputId); |
| 370 | obj["saved_output_present"] = deviceIdPresent(outputs, savedOutputId); |
| 371 | obj["selected_input_source"] = (audio && !audio->inputDevice().isNull()) ? "saved selection" : "system default"; |
| 372 | obj["selected_output_source"] = (audio && !audio->outputDevice().isNull()) ? "saved selection" : "system default"; |
| 373 | obj["selected_input_present"] = devicePresent(inputs, selectedInput); |
| 374 | obj["selected_output_present"] = devicePresent(outputs, selectedOutput); |
| 375 | obj["selected_input"] = basicDeviceToJson(selectedInput, selectedInput, defaultInput, QStringLiteral("input")); |
| 376 | obj["selected_output"] = basicDeviceToJson(selectedOutput, selectedOutput, defaultOutput, QStringLiteral("output")); |
| 377 | obj["default_input"] = basicDeviceToJson(defaultInput, selectedInput, defaultInput, QStringLiteral("input")); |
| 378 | obj["default_output"] = basicDeviceToJson(defaultOutput, selectedOutput, defaultOutput, QStringLiteral("output")); |
| 379 | |
| 380 | const QJsonObject transmit = snapshot["transmit"].toObject(); |
| 381 | const QJsonObject mic = transmit["mic"].toObject(); |
| 382 | const bool pcAudioEnabled = isSavedTrue(QStringLiteral("PcAudioEnabled"), QStringLiteral("True")); |
| 383 | |
| 384 | QJsonObject rxRoute; |
| 385 | rxRoute["output"] = pcAudioEnabled ? "PC audio" : "Radio audio"; |
| 386 | rxRoute["source"] = "PcAudioEnabled app setting"; |
| 387 | rxRoute["selected_output_device"] = selectedOutput.description(); |
| 388 | obj["rx_route"] = rxRoute; |
| 389 | |
| 390 | QJsonObject txRoute; |
| 391 | txRoute["input"] = micRouteName(mic); |
| 392 | txRoute["source"] = "transmit mic/DAX state"; |
| 393 | if (mic.contains(QStringLiteral("selection"))) |
| 394 | txRoute["mic_selection"] = mic["selection"].toString(); |
| 395 | if (mic.contains(QStringLiteral("dax_on"))) |
| 396 | txRoute["dax_on"] = mic["dax_on"].toBool(); |
| 397 | txRoute["selected_input_device"] = selectedInput.description(); |
| 398 | obj["tx_route"] = txRoute; |
| 399 | |
| 400 | QJsonObject volumes; |
| 401 | volumes["pc_audio_enabled"] = pcAudioEnabled; |
no test coverage detected