1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

FCD: use AudioDeviceManager in place of manupulating AudioInputDevice directly

This commit is contained in:
f4exb 2023-07-10 03:38:40 +02:00
parent e51e8c23b2
commit df917bb489
5 changed files with 18 additions and 20 deletions

View File

@ -176,11 +176,13 @@ bool FCDProInput::openFCDAudio(const char* cardname)
if (itAudio.deviceName().contains(QString(cardname)))
{
int fcdDeviceIndex = audioDeviceManager->getInputDeviceIndex(itAudio.deviceName());
m_fcdAudioInput.start(fcdDeviceIndex, fcd_traits<Pro>::sampleRate);
int fcdSampleRate = m_fcdAudioInput.getRate();
qDebug("FCDProPlusInput::openFCDAudio: %s index %d at %d S/s",
itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex, fcdSampleRate);
m_fcdAudioInput.addFifo(&m_fcdFIFO);
AudioDeviceManager::InputDeviceInfo fcdDeviceInfo;
audioDeviceManager->getInputDeviceInfo(itAudio.deviceName(), fcdDeviceInfo);
fcdDeviceInfo.sampleRate = fcd_traits<Pro>::sampleRate;
audioDeviceManager->setInputDeviceInfo(fcdDeviceIndex, fcdDeviceInfo);
audioDeviceManager->addAudioSource(&m_fcdFIFO, getInputMessageQueue(), fcdDeviceIndex);
qDebug("FCDProPlusInput::openFCDAudio: %s index %d",
itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex);
return true;
}
}
@ -191,8 +193,8 @@ bool FCDProInput::openFCDAudio(const char* cardname)
void FCDProInput::closeFCDAudio()
{
m_fcdAudioInput.removeFifo(&m_fcdFIFO);
m_fcdAudioInput.stop();
AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
audioDeviceManager->removeAudioSource(&m_fcdFIFO);
}
void FCDProInput::stop()

View File

@ -25,7 +25,6 @@
#include <QNetworkRequest>
#include "dsp/devicesamplesource.h"
#include "audio/audioinputdevice.h"
#include "audio/audiofifo.h"
#include "fcdprosettings.h"
@ -158,7 +157,6 @@ public:
private:
DeviceAPI *m_deviceAPI;
hid_device *m_dev;
AudioInputDevice m_fcdAudioInput;
AudioFifo m_fcdFIFO;
QMutex m_mutex;
FCDProSettings m_settings;

View File

@ -178,11 +178,13 @@ bool FCDProPlusInput::openFCDAudio(const char* cardname)
if (itAudio.deviceName().contains(QString(cardname)))
{
int fcdDeviceIndex = audioDeviceManager->getInputDeviceIndex(itAudio.deviceName());
m_fcdAudioInput.start(fcdDeviceIndex, fcd_traits<ProPlus>::sampleRate);
int fcdSampleRate = m_fcdAudioInput.getRate();
qDebug("FCDProPlusInput::openFCDAudio: %s index %d at %d S/s",
itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex, fcdSampleRate);
m_fcdAudioInput.addFifo(&m_fcdFIFO);
AudioDeviceManager::InputDeviceInfo fcdDeviceInfo;
audioDeviceManager->getInputDeviceInfo(itAudio.deviceName(), fcdDeviceInfo);
fcdDeviceInfo.sampleRate = fcd_traits<ProPlus>::sampleRate;
audioDeviceManager->setInputDeviceInfo(fcdDeviceIndex, fcdDeviceInfo);
audioDeviceManager->addAudioSource(&m_fcdFIFO, getInputMessageQueue(), fcdDeviceIndex);
qDebug("FCDProPlusInput::openFCDAudio: %s index %d",
itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex);
return true;
}
}
@ -193,8 +195,8 @@ bool FCDProPlusInput::openFCDAudio(const char* cardname)
void FCDProPlusInput::closeFCDAudio()
{
m_fcdAudioInput.removeFifo(&m_fcdFIFO);
m_fcdAudioInput.stop();
AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
audioDeviceManager->removeAudioSource(&m_fcdFIFO);
}
void FCDProPlusInput::stop()

View File

@ -25,7 +25,6 @@
#include <QNetworkRequest>
#include "dsp/devicesamplesource.h"
#include "audio/audioinputdevice.h"
#include "audio/audiofifo.h"
#include "fcdproplussettings.h"
@ -148,7 +147,6 @@ public:
private:
DeviceAPI *m_deviceAPI;
hid_device *m_dev;
AudioInputDevice m_fcdAudioInput;
AudioFifo m_fcdFIFO;
QMutex m_mutex;
FCDProPlusSettings m_settings;

View File

@ -149,8 +149,6 @@ private:
friend class AudioOutputPipe;
friend class AudioInput;
friend class FCDProInput;
friend class FCDProPlusInput;
private slots:
void handleInputMessages();