From 00b234b85cf717fe8b8f36c9d10d25503628c585 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 12 Nov 2020 20:30:34 +0100 Subject: [PATCH] Renamed sdrbase AudioInput to AudioInputDevice --- .../samplesource/audioinput/audioinput.cpp | 8 +--- plugins/samplesource/audioinput/audioinput.h | 9 +--- .../samplesource/audioinput/audioinputgui.cpp | 14 +++---- .../audioinput/audioinputplugin.cpp | 4 +- .../audioinput/audioinputwebapiadapter.cpp | 4 +- plugins/samplesource/fcdpro/fcdproinput.h | 4 +- .../samplesource/fcdproplus/fcdproplusinput.h | 4 +- sdrbase/CMakeLists.txt | 4 +- sdrbase/audio/audiodevicemanager.cpp | 4 +- sdrbase/audio/audiodevicemanager.h | 4 +- .../{audioinput.cpp => audioinputdevice.cpp} | 42 +++++++++---------- .../{audioinput.h => audioinputdevice.h} | 12 +++--- sdrbase/dsp/dspengine.h | 1 - 13 files changed, 52 insertions(+), 62 deletions(-) rename sdrbase/audio/{audioinput.cpp => audioinputdevice.cpp} (75%) rename sdrbase/audio/{audioinput.h => audioinputdevice.h} (90%) diff --git a/plugins/samplesource/audioinput/audioinput.cpp b/plugins/samplesource/audioinput/audioinput.cpp index 80e136090..0ee6efee4 100644 --- a/plugins/samplesource/audioinput/audioinput.cpp +++ b/plugins/samplesource/audioinput/audioinput.cpp @@ -33,10 +33,8 @@ #include "audioinput.h" #include "audioinputthread.h" -MESSAGE_CLASS_DEFINITION(AudioInputSource::AudioInput::MsgConfigureAudioInput, Message) -MESSAGE_CLASS_DEFINITION(AudioInputSource::AudioInput::MsgStartStop, Message) - -namespace AudioInputSource { +MESSAGE_CLASS_DEFINITION(AudioInput::MsgConfigureAudioInput, Message) +MESSAGE_CLASS_DEFINITION(AudioInput::MsgStartStop, Message) AudioInput::AudioInput(DeviceAPI *deviceAPI) : m_deviceAPI(deviceAPI), @@ -521,5 +519,3 @@ void AudioInput::networkManagerFinished(QNetworkReply *reply) reply->deleteLater(); } - -} diff --git a/plugins/samplesource/audioinput/audioinput.h b/plugins/samplesource/audioinput/audioinput.h index 5849f260c..c533503b0 100644 --- a/plugins/samplesource/audioinput/audioinput.h +++ b/plugins/samplesource/audioinput/audioinput.h @@ -26,7 +26,7 @@ #include #include "dsp/devicesamplesource.h" -#include "audio/audioinput.h" +#include "audio/audioinputdevice.h" #include "audio/audiofifo.h" #include "audioinputsettings.h" @@ -36,9 +36,6 @@ class QNetworkReply; class DeviceAPI; class AudioInputThread; -// AudioInput is used in sdrbase/audio/audioinput.h -namespace AudioInputSource { - class AudioInput : public DeviceSampleSource { Q_OBJECT public: @@ -134,7 +131,7 @@ public: private: DeviceAPI *m_deviceAPI; - ::AudioInput m_audioInput; + AudioInputDevice m_audioInput; AudioFifo m_fifo; QMutex m_mutex; AudioInputSettings m_settings; @@ -156,6 +153,4 @@ private slots: void networkManagerFinished(QNetworkReply *reply); }; -} - #endif // INCLUDE_AUDIOINPUT_H diff --git a/plugins/samplesource/audioinput/audioinputgui.cpp b/plugins/samplesource/audioinput/audioinputgui.cpp index 32fdac22c..6c2ae9922 100644 --- a/plugins/samplesource/audioinput/audioinputgui.cpp +++ b/plugins/samplesource/audioinput/audioinputgui.cpp @@ -39,7 +39,7 @@ AudioInputGui::AudioInputGui(DeviceUISet *deviceUISet, QWidget* parent) : m_settings(), m_sampleSource(NULL) { - m_sampleSource = (AudioInputSource::AudioInput*) m_deviceUISet->m_deviceAPI->getSampleSource(); + m_sampleSource = (AudioInput*) m_deviceUISet->m_deviceAPI->getSampleSource(); ui->setupUi(this); @@ -94,18 +94,18 @@ bool AudioInputGui::deserialize(const QByteArray& data) bool AudioInputGui::handleMessage(const Message& message) { - if (AudioInputSource::AudioInput::MsgConfigureAudioInput::match(message)) + if (AudioInput::MsgConfigureAudioInput::match(message)) { - const AudioInputSource::AudioInput::MsgConfigureAudioInput& cfg = (AudioInputSource::AudioInput::MsgConfigureAudioInput&) message; + const AudioInput::MsgConfigureAudioInput& cfg = (AudioInput::MsgConfigureAudioInput&) message; m_settings = cfg.getSettings(); blockApplySettings(true); displaySettings(); blockApplySettings(false); return true; } - else if (AudioInputSource::AudioInput::MsgStartStop::match(message)) + else if (AudioInput::MsgStartStop::match(message)) { - AudioInputSource::AudioInput::MsgStartStop& notif = (AudioInputSource::AudioInput::MsgStartStop&) message; + AudioInput::MsgStartStop& notif = (AudioInput::MsgStartStop&) message; blockApplySettings(true); ui->startStop->setChecked(notif.getStartStop()); blockApplySettings(false); @@ -262,7 +262,7 @@ void AudioInputGui::on_startStop_toggled(bool checked) { if (m_doApplySettings) { - AudioInputSource::AudioInput::MsgStartStop *message = AudioInputSource::AudioInput::MsgStartStop::create(checked); + AudioInput::MsgStartStop *message = AudioInput::MsgStartStop::create(checked); m_sampleSource->getInputMessageQueue()->push(message); } } @@ -277,7 +277,7 @@ void AudioInputGui::updateHardware() { if (m_doApplySettings) { - AudioInputSource::AudioInput::MsgConfigureAudioInput* message = AudioInputSource::AudioInput::MsgConfigureAudioInput::create(m_settings, m_forceSettings); + AudioInput::MsgConfigureAudioInput* message = AudioInput::MsgConfigureAudioInput::create(m_settings, m_forceSettings); m_sampleSource->getInputMessageQueue()->push(message); m_forceSettings = false; m_updateTimer.stop(); diff --git a/plugins/samplesource/audioinput/audioinputplugin.cpp b/plugins/samplesource/audioinput/audioinputplugin.cpp index d55faa3cb..809185020 100644 --- a/plugins/samplesource/audioinput/audioinputplugin.cpp +++ b/plugins/samplesource/audioinput/audioinputplugin.cpp @@ -31,7 +31,7 @@ const PluginDescriptor AudioInputPlugin::m_pluginDescriptor = { QString("AudioInput"), QString("Audio Input"), - QString("4.22.0"), + QString("6.0.0"), QString("(c) Jon Beniston, M7RCE and Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, @@ -136,7 +136,7 @@ DeviceSampleSource *AudioInputPlugin::createSampleSourcePluginInstance(const QSt { if (sourceId == m_deviceTypeID) { - AudioInputSource::AudioInput* input = new AudioInputSource::AudioInput(deviceAPI); + AudioInput* input = new AudioInput(deviceAPI); return input; } else diff --git a/plugins/samplesource/audioinput/audioinputwebapiadapter.cpp b/plugins/samplesource/audioinput/audioinputwebapiadapter.cpp index ae87bbbfc..c88dee9c8 100644 --- a/plugins/samplesource/audioinput/audioinputwebapiadapter.cpp +++ b/plugins/samplesource/audioinput/audioinputwebapiadapter.cpp @@ -33,7 +33,7 @@ int AudioInputWebAPIAdapter::webapiSettingsGet( (void) errorMessage; response.setAirspyHfSettings(new SWGSDRangel::SWGAirspyHFSettings()); response.getAirspyHfSettings()->init(); - AudioInputSource::AudioInput::webapiFormatDeviceSettings(response, m_settings); + AudioInput::webapiFormatDeviceSettings(response, m_settings); return 200; } @@ -44,6 +44,6 @@ int AudioInputWebAPIAdapter::webapiSettingsPutPatch( QString& errorMessage) { (void) errorMessage; - AudioInputSource::AudioInput::webapiUpdateDeviceSettings(m_settings, deviceSettingsKeys, response); + AudioInput::webapiUpdateDeviceSettings(m_settings, deviceSettingsKeys, response); return 200; } diff --git a/plugins/samplesource/fcdpro/fcdproinput.h b/plugins/samplesource/fcdpro/fcdproinput.h index 7ca24c76f..c22d0914a 100644 --- a/plugins/samplesource/fcdpro/fcdproinput.h +++ b/plugins/samplesource/fcdpro/fcdproinput.h @@ -25,7 +25,7 @@ #include #include "dsp/devicesamplesource.h" -#include "audio/audioinput.h" +#include "audio/audioinputdevice.h" #include "audio/audiofifo.h" #include "fcdprosettings.h" @@ -156,7 +156,7 @@ public: private: DeviceAPI *m_deviceAPI; hid_device *m_dev; - AudioInput m_fcdAudioInput; + AudioInputDevice m_fcdAudioInput; AudioFifo m_fcdFIFO; QMutex m_mutex; FCDProSettings m_settings; diff --git a/plugins/samplesource/fcdproplus/fcdproplusinput.h b/plugins/samplesource/fcdproplus/fcdproplusinput.h index 5132056a0..fa7c742cf 100644 --- a/plugins/samplesource/fcdproplus/fcdproplusinput.h +++ b/plugins/samplesource/fcdproplus/fcdproplusinput.h @@ -25,7 +25,7 @@ #include #include "dsp/devicesamplesource.h" -#include "audio/audioinput.h" +#include "audio/audioinputdevice.h" #include "audio/audiofifo.h" #include "fcdproplussettings.h" @@ -145,7 +145,7 @@ public: private: DeviceAPI *m_deviceAPI; hid_device *m_dev; - AudioInput m_fcdAudioInput; + AudioInputDevice m_fcdAudioInput; AudioFifo m_fcdFIFO; QMutex m_mutex; FCDProPlusSettings m_settings; diff --git a/sdrbase/CMakeLists.txt b/sdrbase/CMakeLists.txt index 30cf15cb5..f4ffc730d 100644 --- a/sdrbase/CMakeLists.txt +++ b/sdrbase/CMakeLists.txt @@ -76,7 +76,7 @@ set(sdrbase_SOURCES audio/audiog722.cpp audio/audioopus.cpp audio/audiooutput.cpp - audio/audioinput.cpp + audio/audioinputdevice.cpp audio/audionetsink.cpp audio/audioresampler.cpp @@ -216,7 +216,7 @@ set(sdrbase_HEADERS audio/audiog722.h audio/audiooutput.h audio/audioopus.h - audio/audioinput.h + audio/audioinputdevice.h audio/audionetsink.h audio/audioresampler.h diff --git a/sdrbase/audio/audiodevicemanager.cpp b/sdrbase/audio/audiodevicemanager.cpp index d5fd3aa41..965e24214 100644 --- a/sdrbase/audio/audiodevicemanager.cpp +++ b/sdrbase/audio/audiodevicemanager.cpp @@ -312,7 +312,7 @@ void AudioDeviceManager::addAudioSource(AudioFifo* audioFifo, MessageQueue *samp qDebug("AudioDeviceManager::addAudioSource: %d: %p", inputDeviceIndex, audioFifo); if (m_audioInputs.find(inputDeviceIndex) == m_audioInputs.end()) { - m_audioInputs[inputDeviceIndex] = new AudioInput(); + m_audioInputs[inputDeviceIndex] = new AudioInputDevice(); } if ((m_audioInputs[inputDeviceIndex]->getNbFifos() == 0) && @@ -570,7 +570,7 @@ void AudioDeviceManager::setInputDeviceInfo(int inputDeviceIndex, const InputDev return; } - AudioInput *audioInput = m_audioInputs[inputDeviceIndex]; + AudioInputDevice *audioInput = m_audioInputs[inputDeviceIndex]; if (oldDeviceInfo.sampleRate != deviceInfo.sampleRate) { diff --git a/sdrbase/audio/audiodevicemanager.h b/sdrbase/audio/audiodevicemanager.h index ba11bf4aa..395e5a8fd 100644 --- a/sdrbase/audio/audiodevicemanager.h +++ b/sdrbase/audio/audiodevicemanager.h @@ -24,7 +24,7 @@ #include #include -#include "audio/audioinput.h" +#include "audio/audioinputdevice.h" #include "audio/audiooutput.h" #include "export.h" @@ -133,7 +133,7 @@ private: QMap m_audioSourceFifos; //< audio source FIFO to audio input device index-1 map QMap m_audioFifoToSourceMessageQueues; //!< audio source FIFO to attached source message queue QMap > m_inputDeviceSourceMessageQueues; //!< sink message queues attached to device - QMap m_audioInputs; //!< audio device index to audio input map (index -1 is default device) + QMap m_audioInputs; //!< audio device index to audio input map (index -1 is default device) QMap m_audioInputInfos; //!< audio device name to audio input device info bool m_defaultOutputStarted; //!< True if the default audio output (-1) has already been started diff --git a/sdrbase/audio/audioinput.cpp b/sdrbase/audio/audioinputdevice.cpp similarity index 75% rename from sdrbase/audio/audioinput.cpp rename to sdrbase/audio/audioinputdevice.cpp index 1c8db7838..b62f7c41c 100644 --- a/sdrbase/audio/audioinput.cpp +++ b/sdrbase/audio/audioinputdevice.cpp @@ -19,10 +19,10 @@ #include #include #include -#include "audio/audioinput.h" +#include "audio/audioinputdevice.h" #include "audio/audiofifo.h" -AudioInput::AudioInput() : +AudioInputDevice::AudioInputDevice() : m_mutex(QMutex::Recursive), m_audioInput(0), m_audioUsageCount(0), @@ -32,7 +32,7 @@ AudioInput::AudioInput() : { } -AudioInput::~AudioInput() +AudioInputDevice::~AudioInputDevice() { stop(); @@ -46,7 +46,7 @@ AudioInput::~AudioInput() m_audioFifos.clear(); } -bool AudioInput::start(int device, int rate) +bool AudioInputDevice::start(int device, int rate) { if (m_audioUsageCount == 0) { @@ -56,7 +56,7 @@ bool AudioInput::start(int device, int rate) if (device < 0) { devInfo = QAudioDeviceInfo::defaultInputDevice(); - qWarning("AudioInput::start: using default device %s", qPrintable(devInfo.defaultInputDevice().deviceName())); + qWarning("AudioInputDevice::start: using default device %s", qPrintable(devInfo.defaultInputDevice().deviceName())); } else { @@ -65,12 +65,12 @@ bool AudioInput::start(int device, int rate) if (device < devicesInfo.size()) { devInfo = devicesInfo[device]; - qWarning("AudioInput::start: using audio device #%d: %s", device, qPrintable(devInfo.deviceName())); + qWarning("AudioInputDevice::start: using audio device #%d: %s", device, qPrintable(devInfo.deviceName())); } else { devInfo = QAudioDeviceInfo::defaultInputDevice(); - qWarning("AudioInput::start: audio device #%d does not exist. Using default device %s", device, qPrintable(devInfo.deviceName())); + qWarning("AudioInputDevice::start: audio device #%d does not exist. Using default device %s", device, qPrintable(devInfo.deviceName())); } } @@ -86,17 +86,17 @@ bool AudioInput::start(int device, int rate) if (!devInfo.isFormatSupported(m_audioFormat)) { m_audioFormat = devInfo.nearestFormat(m_audioFormat); - qWarning("AudioInput::start: %d Hz S16_LE audio format not supported. Nearest is sampleRate: %d channelCount: %d sampleSize: %d sampleType: %d", + qWarning("AudioInputDevice::start: %d Hz S16_LE audio format not supported. Nearest is sampleRate: %d channelCount: %d sampleSize: %d sampleType: %d", rate, m_audioFormat.sampleRate(), m_audioFormat.channelCount(), m_audioFormat.sampleSize(), (int) m_audioFormat.sampleType()); } else { - qInfo("AudioInput::start: audio format OK"); + qInfo("AudioInputDevice::start: audio format OK"); } if (m_audioFormat.sampleSize() != 16) { - qWarning("AudioInput::start: Audio device '%s' failed", qPrintable(devInfo.defaultInputDevice().deviceName())); + qWarning("AudioInputDevice::start: Audio device '%s' failed", qPrintable(devInfo.defaultInputDevice().deviceName())); return false; } @@ -109,7 +109,7 @@ bool AudioInput::start(int device, int rate) if (m_audioInput->state() != QAudio::ActiveState) { - qWarning("AudioInput::start: cannot start"); + qWarning("AudioInputDevice::start: cannot start"); } } @@ -118,9 +118,9 @@ bool AudioInput::start(int device, int rate) return true; } -void AudioInput::stop() +void AudioInputDevice::stop() { - qDebug("AudioInput::stop"); + qDebug("AudioInputDevice::stop"); if (m_audioUsageCount > 0) { @@ -128,7 +128,7 @@ void AudioInput::stop() if (m_audioUsageCount == 0) { - qDebug("AudioInput::stop: effectively close QIODevice"); + qDebug("AudioInputDevice::stop: effectively close QIODevice"); QMutexLocker mutexLocker(&m_mutex); QIODevice::close(); @@ -139,28 +139,28 @@ void AudioInput::stop() } } -void AudioInput::addFifo(AudioFifo* audioFifo) +void AudioInputDevice::addFifo(AudioFifo* audioFifo) { QMutexLocker mutexLocker(&m_mutex); m_audioFifos.push_back(audioFifo); } -void AudioInput::removeFifo(AudioFifo* audioFifo) +void AudioInputDevice::removeFifo(AudioFifo* audioFifo) { QMutexLocker mutexLocker(&m_mutex); m_audioFifos.remove(audioFifo); } -qint64 AudioInput::readData(char* data, qint64 maxLen) +qint64 AudioInputDevice::readData(char* data, qint64 maxLen) { Q_UNUSED(data); Q_UNUSED(maxLen); return 0; } -qint64 AudioInput::writeData(const char *data, qint64 len) +qint64 AudioInputDevice::writeData(const char *data, qint64 len) { // Study this mutex on OSX, for now deadlocks possible // Removed as it may indeed cause lockups and is in fact useless. @@ -172,12 +172,12 @@ qint64 AudioInput::writeData(const char *data, qint64 len) || (m_audioFormat.sampleType() != QAudioFormat::SignedInt) || (m_audioFormat.byteOrder() != QAudioFormat::LittleEndian)) { - qCritical("AudioInput::writeData: invalid format not S16LE"); + qCritical("AudioInputDevice::writeData: invalid format not S16LE"); return 0; } if (m_audioFormat.channelCount() != 2) { - qCritical("AudioInput::writeData: invalid format not stereo"); + qCritical("AudioInputDevice::writeData: invalid format not stereo"); return 0; } @@ -189,7 +189,7 @@ qint64 AudioInput::writeData(const char *data, qint64 len) return len; } -void AudioInput::setVolume(float volume) +void AudioInputDevice::setVolume(float volume) { m_volume = volume; if (m_audioInput != nullptr) diff --git a/sdrbase/audio/audioinput.h b/sdrbase/audio/audioinputdevice.h similarity index 90% rename from sdrbase/audio/audioinput.h rename to sdrbase/audio/audioinputdevice.h index 78f706edc..3360a79be 100644 --- a/sdrbase/audio/audioinput.h +++ b/sdrbase/audio/audioinputdevice.h @@ -15,8 +15,8 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// -#ifndef SDRBASE_AUDIO_AUDIOINPUT_H_ -#define SDRBASE_AUDIO_AUDIOINPUT_H_ +#ifndef SDRBASE_AUDIO_AUDIOINPUTDEVICE_H_ +#define SDRBASE_AUDIO_AUDIOINPUTDEVICE_H_ #include #include @@ -30,10 +30,10 @@ class AudioFifo; class AudioOutputPipe; -class SDRBASE_API AudioInput : public QIODevice { +class SDRBASE_API AudioInputDevice : public QIODevice { public: - AudioInput(); - virtual ~AudioInput(); + AudioInputDevice(); + virtual ~AudioInputDevice(); bool start(int device, int rate); void stop(); @@ -67,4 +67,4 @@ private: -#endif /* SDRBASE_AUDIO_AUDIOINPUT_H_ */ +#endif /* SDRBASE_AUDIO_AUDIOINPUTDEVICE_H_ */ diff --git a/sdrbase/dsp/dspengine.h b/sdrbase/dsp/dspengine.h index 8dd95c701..4d0c99fb6 100644 --- a/sdrbase/dsp/dspengine.h +++ b/sdrbase/dsp/dspengine.h @@ -25,7 +25,6 @@ #include "audio/audiodevicemanager.h" #include "audio/audiooutput.h" -#include "audio/audioinput.h" #include "export.h" #include "ambe/ambeengine.h"