diff --git a/.vscode/settings.json b/.vscode/settings.json index b1d6a52..bb53364 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -95,6 +95,11 @@ "future": "cpp", "csignal": "cpp", "regex": "cpp", - "variant": "cpp" + "variant": "cpp", + "__std_stream": "cpp", + "any": "cpp", + "format": "cpp", + "ranges": "cpp", + "span": "cpp" } } \ No newline at end of file diff --git a/include/modals/settings.h b/include/modals/settings.h index ecd87e1..b4746e7 100644 --- a/include/modals/settings.h +++ b/include/modals/settings.h @@ -30,11 +30,15 @@ namespace afv_unix::modals { ImGui::Text("Audio configuration"); if (ImGui::BeginCombo("Sound API", afv_unix::shared::configAudioApi.c_str())) { - for (const auto &item: mClient->GetAudioApis()) { + for (const auto &item: afv_unix::shared::availableAudioAPI) { if (ImGui::Selectable(item.second.c_str(), afv_unix::shared::mAudioApi == item.first)) { afv_unix::shared::mAudioApi = item.first; - if (mClient) + if (mClient) { + // set the Audio API and update the available inputs and outputs mClient->SetAudioApi(afv_unix::shared::mAudioApi); + afv_unix::shared::availableInputDevices = mClient->GetAudioInputDevices(afv_unix::shared::mAudioApi); + afv_unix::shared::availableOutputDevices = mClient->GetAudioOutputDevices(afv_unix::shared::mAudioApi); + } afv_unix::shared::configAudioApi = item.second; afv_unix::configuration::config["audio"]["api"] = item.second; } @@ -44,7 +48,7 @@ namespace afv_unix::modals { if (ImGui::BeginCombo("Input Device", afv_unix::shared::configInputDeviceName.c_str())) { - auto m_audioDrivers = mClient->GetAudioInputDevices(afv_unix::shared::mAudioApi); + auto m_audioDrivers = afv_unix::shared::availableInputDevices; for(const auto& driver : m_audioDrivers) { if (ImGui::Selectable(driver.c_str(), afv_unix::shared::configInputDeviceName == driver)) { @@ -58,7 +62,7 @@ namespace afv_unix::modals { if (ImGui::BeginCombo("Output Device", afv_unix::shared::configOutputDeviceName.c_str())) { - auto m_audioDrivers = mClient->GetAudioOutputDevices(afv_unix::shared::mAudioApi); + auto m_audioDrivers = afv_unix::shared::availableOutputDevices; for(const auto& driver : m_audioDrivers) { if (ImGui::Selectable(driver.c_str(), afv_unix::shared::configOutputDeviceName == driver)) { @@ -72,7 +76,7 @@ namespace afv_unix::modals { if (ImGui::BeginCombo("Speaker Device", afv_unix::shared::configSpeakerDeviceName.c_str())) { - auto m_audioDrivers = mClient->GetAudioOutputDevices(afv_unix::shared::mAudioApi); + auto m_audioDrivers = afv_unix::shared::availableOutputDevices; for(const auto& driver : m_audioDrivers) { if (ImGui::Selectable(driver.c_str(), afv_unix::shared::configSpeakerDeviceName == driver)) { diff --git a/include/shared.h b/include/shared.h index 2428f09..0c86cf4 100644 --- a/include/shared.h +++ b/include/shared.h @@ -3,6 +3,7 @@ #include #include #include +#include namespace afv_unix::shared { struct StationElement { @@ -61,6 +62,12 @@ namespace afv_unix::shared { inline float RadioGain = 1.0f; + // Temp settings for config window + inline std::map availableAudioAPI; + inline std::vector availableInputDevices; + inline std::vector availableOutputDevices; + + // Thread unsafe stuff namespace datafile { inline int facility = 0; diff --git a/src/application.cpp b/src/application.cpp index 646aa9f..085842e 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -263,8 +263,14 @@ namespace afv_unix::application { ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); } - if (ImGui::Button("Settings") && !mClient->IsVoiceConnected()) + if (ImGui::Button("Settings") && !mClient->IsVoiceConnected()) { + // Update all available data + afv_unix::shared::availableAudioAPI = mClient->GetAudioApis(); + afv_unix::shared::availableInputDevices = mClient->GetAudioInputDevices(afv_unix::shared::mAudioApi); + afv_unix::shared::availableOutputDevices = mClient->GetAudioOutputDevices(afv_unix::shared::mAudioApi); ImGui::OpenPopup("Settings Panel"); + } + if (mClient->IsVoiceConnected()) { ImGui::PopItemFlag();