diff --git a/src/audio/AudioDeviceSpecification.h b/src/audio/AudioDeviceSpecification.h index 68d85b0e..ab83157c 100644 --- a/src/audio/AudioDeviceSpecification.h +++ b/src/audio/AudioDeviceSpecification.h @@ -33,6 +33,7 @@ struct AudioDeviceSpecification wxString cardName; // Name of the audio device wxString portName; // Name of the port from the above audio device (e.g. "Speakers" on Windows). Optional. wxString apiName; // Name of the active audio API + int defaultSampleRate; int maxChannels; int minChannels; diff --git a/src/audio/PulseAudioEngine.cpp b/src/audio/PulseAudioEngine.cpp index fa96f365..51963630 100644 --- a/src/audio/PulseAudioEngine.cpp +++ b/src/audio/PulseAudioEngine.cpp @@ -23,6 +23,8 @@ #include "PulseAudioDevice.h" #include "PulseAudioEngine.h" +#include + PulseAudioEngine::PulseAudioEngine() : initialized_(false) { @@ -140,6 +142,7 @@ void PulseAudioEngine::stop() struct PulseAudioDeviceListTemp { std::vector result; + std::map cardResult; PulseAudioEngine* thisPtr; }; @@ -207,10 +210,9 @@ std::vector PulseAudioEngine::getAudioDeviceList(Audio pa_operation_unref(op); // Get list of cards - std::map cards; op = pa_context_get_card_info_list(context_, [](pa_context *c, const pa_card_info *i, int eol, void *userdata) { - std::map* tempObj = static_cast*>(userdata); + PulseAudioDeviceListTemp* tempObj = static_cast(userdata); if (eol) { @@ -218,8 +220,8 @@ std::vector PulseAudioEngine::getAudioDeviceList(Audio return; } - (*tempObj)[i->index] = i->name; - }, &cards); + tempObj->cardResult[i->index] = i->name; + }, &tempObj); // Wait for the operation to complete for(;;) @@ -235,9 +237,9 @@ std::vector PulseAudioEngine::getAudioDeviceList(Audio // Iterate over result and populate cardName for (auto& obj : tempObj.result) { - if (cards.find(obj.deviceId) != cards.end()) + if (tempObj.cardResult.find(obj.deviceId) != tempObj.cardResult.end()) { - obj.cardName = wxString::FromUTF8(cards[obj.deviceId].c_str()); + obj.cardName = wxString::FromUTF8(tempObj.cardResult[obj.deviceId].c_str()); } }