Skip to content

Commit

Permalink
Move AudioDeviceInfo singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
mxi-box committed Mar 30, 2024
1 parent ce3e783 commit 556cc8a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plugins/samplesource/fcdpro/fcdproinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void FCDProInput::closeDevice()
bool FCDProInput::openFCDAudio(const char* cardname)
{
AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
const QList<AudioDeviceInfo>& audioList = audioDeviceManager->getInputDevices();
const QList<AudioDeviceInfo>& audioList = AudioDeviceInfo::availableInputDevices();

for (const auto &itAudio : audioList)
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/samplesource/fcdproplus/fcdproplusinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void FCDProPlusInput::closeDevice()
bool FCDProPlusInput::openFCDAudio(const char* cardname)
{
AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
const QList<AudioDeviceInfo>& audioList = audioDeviceManager->getInputDevices();
const QList<AudioDeviceInfo>& audioList = AudioDeviceInfo::availableInputDevices();

for (const auto &itAudio : audioList)
{
Expand Down
16 changes: 8 additions & 8 deletions sdrbase/audio/audiodeviceinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,28 @@ QString AudioDeviceInfo::realm() const
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const QList<AudioDeviceInfo> &AudioDeviceInfo::availableInputDevices()
{
if (!m_inputDevicesEnumerated) {
if (!inputDevicesEnumerated) {
QList<QAudioDevice> devInfos = QMediaDevices::audioInputs();
for (auto devInfo : devInfos) {
m_inputDevices.append(AudioDeviceInfo(devInfo));
inputDevices.append(AudioDeviceInfo(devInfo));
}
m_inputDevicesEnumerated = true;
inputDevicesEnumerated = true;
}

return m_inputDevices;
return inputDevices;
}

const QList<AudioDeviceInfo> &AudioDeviceInfo::availableOutputDevices()
{
if (!m_outputDevicesEnumerated) {
if (!outputDevicesEnumerated) {
QList<QAudioDevice> devInfos = QMediaDevices::audioOutputs();
for (auto devInfo : devInfos) {
m_outputDevices.append(AudioDeviceInfo(devInfo));
outputDevices.append(AudioDeviceInfo(devInfo));
}
m_outputDevicesEnumerated = true;
outputDevicesEnumerated = true;
}

return m_outputDevices;
return outputDevices;
}
#else
const QList<AudioDeviceInfo> &AudioDeviceInfo::availableInputDevices()
Expand Down
4 changes: 2 additions & 2 deletions sdrbase/webapi/webapiadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ int WebAPIAdapter::instanceAudioGet(
{
(void) error;
DSPEngine *dspEngine = DSPEngine::instance();
const QList<AudioDeviceInfo>& audioInputDevices = dspEngine->getAudioDeviceManager()->getInputDevices();
const QList<AudioDeviceInfo>& audioOutputDevices = dspEngine->getAudioDeviceManager()->getOutputDevices();
const QList<AudioDeviceInfo>& audioInputDevices = AudioDeviceInfo::availableInputDevices();
const QList<AudioDeviceInfo>& audioOutputDevices = AudioDeviceInfo::availableOutputDevices();
int nbInputDevices = audioInputDevices.size();
int nbOutputDevices = audioOutputDevices.size();

Expand Down

0 comments on commit 556cc8a

Please sign in to comment.