1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 08:04:49 -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))) if (itAudio.deviceName().contains(QString(cardname)))
{ {
int fcdDeviceIndex = audioDeviceManager->getInputDeviceIndex(itAudio.deviceName()); int fcdDeviceIndex = audioDeviceManager->getInputDeviceIndex(itAudio.deviceName());
m_fcdAudioInput.start(fcdDeviceIndex, fcd_traits<Pro>::sampleRate); AudioDeviceManager::InputDeviceInfo fcdDeviceInfo;
int fcdSampleRate = m_fcdAudioInput.getRate(); audioDeviceManager->getInputDeviceInfo(itAudio.deviceName(), fcdDeviceInfo);
qDebug("FCDProPlusInput::openFCDAudio: %s index %d at %d S/s", fcdDeviceInfo.sampleRate = fcd_traits<Pro>::sampleRate;
itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex, fcdSampleRate); audioDeviceManager->setInputDeviceInfo(fcdDeviceIndex, fcdDeviceInfo);
m_fcdAudioInput.addFifo(&m_fcdFIFO); audioDeviceManager->addAudioSource(&m_fcdFIFO, getInputMessageQueue(), fcdDeviceIndex);
qDebug("FCDProPlusInput::openFCDAudio: %s index %d",
itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex);
return true; return true;
} }
} }
@ -191,8 +193,8 @@ bool FCDProInput::openFCDAudio(const char* cardname)
void FCDProInput::closeFCDAudio() void FCDProInput::closeFCDAudio()
{ {
m_fcdAudioInput.removeFifo(&m_fcdFIFO); AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
m_fcdAudioInput.stop(); audioDeviceManager->removeAudioSource(&m_fcdFIFO);
} }
void FCDProInput::stop() void FCDProInput::stop()

View File

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

View File

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

View File

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

View File

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