From 111c539e890c237ebc518ebca6f74f4cbe295ea5 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Thu, 25 Dec 2014 16:19:22 +0100 Subject: [PATCH] refs #320 Remove deprecated code * Mic and squelch tests * VoiceVatlib threading * Exception handling --- samples/voiceclient/client.cpp | 33 --- samples/voiceclient/client.h | 6 - src/blackcore/context_audio_impl.cpp | 25 +- src/blackcore/context_audio_impl.h | 1 - src/blackcore/voice.h | 54 ----- src/blackcore/voice_channel.h | 3 - src/blackcore/voice_channel_vatlib.cpp | 7 - src/blackcore/voice_channel_vatlib.h | 3 - src/blackcore/voice_vatlib.cpp | 318 +------------------------ src/blackcore/voice_vatlib.h | 62 ----- 10 files changed, 9 insertions(+), 503 deletions(-) diff --git a/samples/voiceclient/client.cpp b/samples/voiceclient/client.cpp index 9ce9c8f9b..cd8b6ba61 100644 --- a/samples/voiceclient/client.cpp +++ b/samples/voiceclient/client.cpp @@ -19,13 +19,9 @@ Client::Client(QObject *parent) : QObject(parent), m_voice(new BlackCore::CVoiceVatlib()) { - m_voice->moveToThread(&m_threadVoice); - m_threadVoice.start(); m_channelCom1 = m_voice->getVoiceChannel(0); using namespace BlackCore; - connect(m_voice, &IVoice::squelchTestFinished, this, &Client::onSquelchTestFinished); - connect(m_voice, &IVoice::micTestFinished, this, &Client::onMicTestFinished); connect(m_channelCom1.data(), &IVoiceChannel::connectionStatusChanged, this, &Client::connectionStatusChanged); connect(m_channelCom1.data(), &IVoiceChannel::audioStarted, this, &Client::audioStartedStream); connect(m_channelCom1.data(), &IVoiceChannel::audioStopped, this, &Client::audioStoppedStream); @@ -36,8 +32,6 @@ Client::Client(QObject *parent) : m_commands["help"] = std::bind(&Client::help, this, _1); m_commands["echo"] = std::bind(&Client::echo, this, _1); m_commands["exit"] = std::bind(&Client::exit, this, _1); - m_commands["squelchtest"] = std::bind(&Client::squelchTestCmd, this, _1); - m_commands["mictest"] = std::bind(&Client::micTestCmd, this, _1); m_commands["setcallsign"] = std::bind(&Client::setCallsignCmd, this, _1); m_commands["initconnect"] = std::bind(&Client::initiateConnectionCmd, this, _1); m_commands["termconnect"] = std::bind(&Client::terminateConnectionCmd, this, _1); @@ -97,25 +91,9 @@ void Client::echo(QTextStream &line) void Client::exit(QTextStream &) { qDebug() << "Shutting down..."; - m_threadVoice.quit(); - m_threadVoice.wait(5000); emit quit(); } -void Client::squelchTestCmd(QTextStream & /** args **/) -{ - std::cout << "Running squelch test. Please be quiet for 5 seconds..." << std::endl; - printLinePrefix(); - m_voice->runSquelchTest(); -} - -void Client::micTestCmd(QTextStream & /** args **/) -{ - std::cout << "Running mic test. Speak normally for 5 seconds..." << std::endl; - printLinePrefix(); - m_voice->runMicrophoneTest(); -} - void Client::setCallsignCmd(QTextStream &args) { QString callsign; @@ -187,17 +165,6 @@ void Client::disableLoopbackCmd(QTextStream &/*args*/) std::cout << "Disabling audio loopback." << std::endl; m_voice->enableAudioLoopback(false); printLinePrefix(); -} - -void Client::onSquelchTestFinished() -{ - std::cout << "Input squelch: " << m_voice->inputSquelch() << std::endl; - printLinePrefix(); -} - -void Client::onMicTestFinished() -{ - std::cout << "Mic test result: " << (int)m_voice->micTestResult() << std::endl; printLinePrefix(); } diff --git a/samples/voiceclient/client.h b/samples/voiceclient/client.h index 709e4dae2..bc8444533 100644 --- a/samples/voiceclient/client.h +++ b/samples/voiceclient/client.h @@ -33,8 +33,6 @@ private: //commands void help(QTextStream &args); void echo(QTextStream &args); void exit(QTextStream &args); - void squelchTestCmd(QTextStream &args); - void micTestCmd(QTextStream &args); void setCallsignCmd(QTextStream &args); void initiateConnectionCmd(QTextStream &args); void terminateConnectionCmd(QTextStream &args); @@ -46,9 +44,6 @@ private: //commands void printLinePrefix(); -public slots: - void onSquelchTestFinished(); - void onMicTestFinished(); private slots: void connectionStatusChanged(BlackCore::IVoiceChannel::ConnectionStatus oldStatus, @@ -61,7 +56,6 @@ private slots: private: QMap> m_commands; BlackCore::IVoice *m_voice; - QThread m_threadVoice; QPointer m_channelCom1; }; diff --git a/src/blackcore/context_audio_impl.cpp b/src/blackcore/context_audio_impl.cpp index 4707c5676..c2deea033 100644 --- a/src/blackcore/context_audio_impl.cpp +++ b/src/blackcore/context_audio_impl.cpp @@ -35,18 +35,11 @@ namespace BlackCore m_voice(new CVoiceVatlib()) { // 1. Init by "voice driver" - m_voice->moveToThread(&m_threadVoice); - m_threadVoice.start(); // 2. Register PTT hotkey function - CVoiceVatlib *voice = m_voice.data(); m_inputManager = CInputManager::getInstance(); m_handlePtt = m_inputManager->registerHotkeyFunc(CHotkeyFunction::Ptt(), voice, &CVoiceVatlib::handlePushToTalk); - // 3. Signal / slots - connect(voice, &CVoiceVatlib::micTestFinished, this, &CContextAudio::audioTestCompleted); - connect(voice, &CVoiceVatlib::squelchTestFinished, this, &CContextAudio::audioTestCompleted); - m_channelCom1 = m_voice->getVoiceChannel(0); m_channelCom1->setMyAircraftCallsign(getIContextOwnAircraft()->getOwnAircraft().getCallsign()); connect(m_channelCom1.data(), &IVoiceChannel::connectionStatusChanged, this, &CContextAudio::ps_com1ConnectionStatusChanged); @@ -64,8 +57,6 @@ namespace BlackCore CContextAudio::~CContextAudio() { this->leaveAllVoiceRooms(); - m_threadVoice.quit(); - m_threadVoice.wait(1000); } /* @@ -380,7 +371,7 @@ namespace BlackCore { Q_ASSERT(this->m_voice); CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; - this->m_voice->runMicrophoneTest(); + // Deprecated } /* @@ -388,9 +379,7 @@ namespace BlackCore */ void CContextAudio::runSquelchTest() { - Q_ASSERT(this->m_voice); - CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; - this->m_voice->runSquelchTest(); + CLogMessage(this).warning("This method is deprecated and will be removed soon"); } /* @@ -398,9 +387,8 @@ namespace BlackCore */ QString CContextAudio::getMicrophoneTestResult() const { - Q_ASSERT(this->m_voice); - CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; - return this->m_voice->micTestResultAsString(); + CLogMessage(this).warning("This method is deprecated and will be removed soon"); + return QString(); } /* @@ -408,9 +396,8 @@ namespace BlackCore */ double CContextAudio::getSquelchValue() const { - Q_ASSERT(this->m_voice); - CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; - return static_cast(this->m_voice->inputSquelch()); + CLogMessage(this).warning("This method is deprecated and will be removed soon"); + return 0.0; } /* diff --git a/src/blackcore/context_audio_impl.h b/src/blackcore/context_audio_impl.h index b4a6bf9b4..ff77256ea 100644 --- a/src/blackcore/context_audio_impl.h +++ b/src/blackcore/context_audio_impl.h @@ -168,7 +168,6 @@ namespace BlackCore CInputManager *m_inputManager = nullptr; CInputManager::RegistrationHandle m_handlePtt; - QThread m_threadVoice; QPointer m_channelCom1; QPointer m_channelCom2; }; diff --git a/src/blackcore/voice.h b/src/blackcore/voice.h index ea1c90af3..ec3254f41 100644 --- a/src/blackcore/voice.h +++ b/src/blackcore/voice.h @@ -71,43 +71,9 @@ namespace BlackCore */ virtual const BlackMisc::Audio::CAudioDeviceInfo defaultAudioOutputDevice() const = 0; - /************************************************ - * SETUP TESTS - ***********************************************/ - - /*! - * \brief Runs a 5 seconds test, measuring your background noise. - */ - virtual void runSquelchTest() = 0; - - /*! - * \brief Runs a 5 seconds test, measuring the qualitiy of your mic input - */ - virtual void runMicrophoneTest() = 0; - - /*! - * \brief Value of the measured squelch - * \return - */ - virtual float inputSquelch() const = 0; - - /*! - * \brief Result of the mic test. - * \return - */ - virtual qint32 micTestResult() const = 0; - - /*! - * \brief Result of the mic test as human readable string - * \return - */ - virtual QString micTestResultAsString() const = 0; - //! Get voice channel object virtual IVoiceChannel *getVoiceChannel(qint32 channelIndex) const = 0; - public slots: - /*! * \brief Current input device */ @@ -133,26 +99,6 @@ namespace BlackCore * \param enable (default true) */ virtual void enableAudioLoopback(bool enable = true) = 0; - - signals: - - // Test signals - /*! - * \brief Squelch test completed - */ - void squelchTestFinished(); - - /*! - * \brief Microphone test completed - */ - void micTestFinished(); - - // non protocol related signals - - /*! - * We sent a message about the status of the network connection, for the attention of the user. - */ - void statusMessage(const BlackMisc::CStatusMessage &message); }; } // namespace BlackCore diff --git a/src/blackcore/voice_channel.h b/src/blackcore/voice_channel.h index cea769abe..42e6e650a 100644 --- a/src/blackcore/voice_channel.h +++ b/src/blackcore/voice_channel.h @@ -46,9 +46,6 @@ namespace BlackCore //! Leave voice room virtual void leaveVoiceRoom() = 0; - //! Set room output volume - virtual void setRoomOutputVolume(const qint32 volume) = 0; - //! Start transmitting virtual void startTransmitting() = 0; diff --git a/src/blackcore/voice_channel_vatlib.cpp b/src/blackcore/voice_channel_vatlib.cpp index e6102ae69..81b39719e 100644 --- a/src/blackcore/voice_channel_vatlib.cpp +++ b/src/blackcore/voice_channel_vatlib.cpp @@ -36,7 +36,6 @@ namespace BlackCore q_ptr(parent) { m_roomIndex.store(InvalidRoomIndex); - m_volume.store(100); m_connectionRefCount.store(0); m_outputEnabled.store(true); m_roomStatus.store(IVoiceChannel::Disconnected); @@ -367,12 +366,6 @@ namespace BlackCore } } - // Set room volume - void CVoiceChannelVatlib::setRoomOutputVolume(const qint32 volume) - { - d_ptr->setRoomOutputVolume(volume); - } - void CVoiceChannelVatlib::startTransmitting() { d_ptr->startTransmitting(); diff --git a/src/blackcore/voice_channel_vatlib.h b/src/blackcore/voice_channel_vatlib.h index 58e4afe5a..aebf99990 100644 --- a/src/blackcore/voice_channel_vatlib.h +++ b/src/blackcore/voice_channel_vatlib.h @@ -43,9 +43,6 @@ namespace BlackCore //! \copydoc IVoiceChannel::leaveVoiceRoom virtual void leaveVoiceRoom() override; - //! \copydoc IVoiceChannel::setRoomOutputVolume - virtual void setRoomOutputVolume(const qint32 volume) override; - //! \copydoc IVoiceChannel::startTransmitting virtual void startTransmitting() override; diff --git a/src/blackcore/voice_vatlib.cpp b/src/blackcore/voice_vatlib.cpp index 8d17238f5..303dfbe74 100644 --- a/src/blackcore/voice_vatlib.cpp +++ b/src/blackcore/voice_vatlib.cpp @@ -21,41 +21,10 @@ namespace BlackCore * Constructor */ CVoiceVatlib::CVoiceVatlib(QObject *parent) : - IVoice(parent), - m_vatlib(Cvatlib_Voice_Simple::Create(), Cvatlib_Voice_Simple_Deleter::cleanup), - // m_audioOutput(nullptr), // removed #227 - m_inputSquelch(-1), - m_micTestResult(Cvatlib_Voice_Simple::agc_Ok), - m_lockCurrentOutputDevice(QMutex::Recursive), - m_lockCurrentInputDevice(QMutex::Recursive), - m_lockDeviceList(QMutex::Recursive) + IVoice(parent) { - try - { - // we use reset here until issue #277 is resolved - // easier to find root cause - // m_audioOutput.reset(new QAudioOutput()); - m_vatlib->Setup(true, 3290, 2, 1, onRoomStatusUpdate, this); - m_vatlib->GetInputDevices(onInputHardwareDeviceReceived, this); - m_vatlib->GetOutputDevices(onOutputHardwareDeviceReceived, this); - - this->m_currentInputDevice = this->defaultAudioInputDevice(); - this->m_currentOutputDevice = this->defaultAudioOutputDevice(); - - for (int ii = 0; ii < 2; ++ii) - { - IVoiceChannel *channel = new CVoiceChannelVatlib(m_vatlib, this); - Q_ASSERT(channel); - m_hashChannelIndex.insert(ii, channel); - } - - // do processing - this->startTimer(10); - } - catch (...) - { - this->exceptionDispatcher(Q_FUNC_INFO); - } + this->m_currentInputDevice = this->defaultAudioInputDevice(); + this->m_currentOutputDevice = this->defaultAudioOutputDevice(); } /* @@ -68,7 +37,6 @@ namespace BlackCore */ const BlackMisc::Audio::CAudioDeviceInfoList &CVoiceVatlib::audioDevices() const { - QMutexLocker lockForReading(&m_lockDeviceList); return m_devices; } @@ -95,7 +63,6 @@ namespace BlackCore */ CAudioDeviceInfo CVoiceVatlib::getCurrentOutputDevice() const { - QMutexLocker locker(&m_lockCurrentOutputDevice); return m_currentOutputDevice; } @@ -104,7 +71,6 @@ namespace BlackCore */ CAudioDeviceInfo CVoiceVatlib::getCurrentInputDevice() const { - QMutexLocker locker(&m_lockCurrentInputDevice); return m_currentInputDevice; } @@ -113,31 +79,6 @@ namespace BlackCore */ void CVoiceVatlib::setInputDevice(const BlackMisc::Audio::CAudioDeviceInfo &device) { - std::lock_guard locker(m_vatlib); - Q_ASSERT_X(m_vatlib->IsValid() && m_vatlib->IsSetup(), "CVoiceVatlib", "Cvatlib_Voice_Simple invalid or not setup!"); - if (!device.isValid()) - { - qWarning() << "Cannot set invalid input device!"; - return; - } - - try - { - if (!m_vatlib->SetInputDevice(device.getIndex())) - { - qWarning() << "Setting input device failed"; - } - if (!m_vatlib->IsInputDeviceAlive()) - { - qWarning() << "Input device hit a fatal error"; - } - QMutexLocker writeLocker(&m_lockCurrentInputDevice); - this->m_currentInputDevice = device; - } - catch (...) - { - exceptionDispatcher(Q_FUNC_INFO); - } } /* @@ -145,143 +86,6 @@ namespace BlackCore */ void CVoiceVatlib::setOutputDevice(const BlackMisc::Audio::CAudioDeviceInfo &device) { - std::lock_guard locker(m_vatlib); - Q_ASSERT_X(m_vatlib->IsValid() && m_vatlib->IsSetup(), "CVoiceVatlib", "Cvatlib_Voice_Simple invalid or not setup!"); - if (!device.isValid()) - { - qWarning() << "Cannot set invalid output device!"; - return; - } - - try - { - // there is no return value here: https://dev.vatsim-germany.org/issues/115 - m_vatlib->SetOutputDevice(0, device.getIndex()); - if (!m_vatlib->IsOutputDeviceAlive(0)) - { - qWarning() << "Output device hit a fatal error"; - } - QMutexLocker writeLocker(&m_lockCurrentOutputDevice); - this->m_currentOutputDevice = device; - } - catch (...) - { - exceptionDispatcher(Q_FUNC_INFO); - } - } - - void CVoiceVatlib::enableAudioLoopback(bool enable) - { - if (enable == m_isAudioLoopbackEnabled) - return; - - std::lock_guard locker(m_vatlib); - Q_ASSERT_X(m_vatlib->IsValid() && m_vatlib->IsSetup(), "CVoiceVatlib", "Cvatlib_Voice_Simple invalid or not setup!"); - try - { - m_vatlib->SetAudioLoopback(0, enable); - } - catch (...) - { - this->exceptionDispatcher(Q_FUNC_INFO); - } - - // bools are atomic. No need to protect it with a mutex - m_isAudioLoopbackEnabled = enable; - } - - /* - * Squelch test - */ - void CVoiceVatlib::runSquelchTest() - { - std::lock_guard locker(m_vatlib); - Q_ASSERT_X(m_vatlib->IsValid() && m_vatlib->IsSetup(), "CVoiceVatlib", "Cvatlib_Voice_Simple invalid or not setup!"); - - try - { - m_vatlib->BeginFindSquelch(); - } - catch (...) - { - this->exceptionDispatcher(Q_FUNC_INFO); - } - - // Start the timer only if no exception was thrown before - QTimer::singleShot(5000, this, SLOT(onEndFindSquelch())); - } - - /* - * Start microphone test - */ - void CVoiceVatlib::runMicrophoneTest() - { - std::lock_guard locker(m_vatlib); - Q_ASSERT_X(m_vatlib->IsValid() && m_vatlib->IsSetup(), "CVoiceVatlib", "Cvatlib_Voice_Simple invalid or not setup!"); - - try - { - m_vatlib->BeginMicTest(); - // Start the timer only if no exception was thrown before - QTimer::singleShot(5000, this, SLOT(onEndMicTest())); - } - catch (...) - { - this->exceptionDispatcher(Q_FUNC_INFO); - } - } - - /* - * Input squelch volume - */ - float CVoiceVatlib::inputSquelch() const - { - return m_inputSquelch; - } - - /* - * Mic test - */ - qint32 CVoiceVatlib::micTestResult() const - { - return m_micTestResult; - } - - /* - * Mic test, result as string - */ - QString CVoiceVatlib::micTestResultAsString() const - { - QString result; - - // Due to a standard defect, some compilers do not accept two consecutive implicit conversions. - // Hence calling load() here. - // References: - // http://stackoverflow.com/questions/25143860/implicit-convertion-from-class-to-enumeration-type-in-switch-conditional - // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3323.pdf - switch (m_micTestResult.load()) - { - case Cvatlib_Voice_Simple::agc_Ok: - result = "The test went ok"; - break; - case Cvatlib_Voice_Simple::agc_BkgndNoiseLoud: - result = "The overall background noise is very loud and may be a nuisance to others"; - break; - case Cvatlib_Voice_Simple::agc_TalkDrownedOut: - result = "The overall background noise is loud enough that others probably wont be able to distinguish speech from it"; - break; - case Cvatlib_Voice_Simple::agc_TalkMicHot: - result = "The overall mic volume is too hot, you should lower the volume in the windows volume control panel"; - break; - case Cvatlib_Voice_Simple::agc_TalkMicCold: - result = "The overall mic volume is too cold, you should raise the volume in the windows control panel and enable mic boost if needed"; - break; - default: - result = "Unknown result."; - break; - } - - return result; } IVoiceChannel *CVoiceVatlib::getVoiceChannel(qint32 channelIndex) const @@ -321,67 +125,6 @@ namespace BlackCore */ void CVoiceVatlib::timerEvent(QTimerEvent *) { - std::lock_guard locker(m_vatlib); - Q_ASSERT_X(m_vatlib->IsValid() && m_vatlib->IsSetup(), "CVoiceVatlib", "Cvatlib_Voice_Simple invalid or not setup!"); - - try - { - this->m_vatlib->DoProcessing(); - } - catch (...) - { - this->exceptionDispatcher(Q_FUNC_INFO); - } - } - - /* - * Find squelch - */ - void CVoiceVatlib::onEndFindSquelch() - { - std::lock_guard locker(m_vatlib); - Q_ASSERT_X(m_vatlib->IsValid() && m_vatlib->IsSetup(), "CVoiceVatlib", "Cvatlib_Voice_Simple invalid or not setup!"); - - try - { - m_vatlib->EndFindSquelch(); - m_inputSquelch = m_vatlib->GetInputSquelch(); - emit squelchTestFinished(); - } - catch (...) - { - this->exceptionDispatcher(Q_FUNC_INFO); - } - } - - void CVoiceVatlib::onEndMicTest() - { - std::lock_guard locker(m_vatlib); - Q_ASSERT_X(m_vatlib->IsValid() && m_vatlib->IsSetup(), "CVoiceVatlib", "Cvatlib_Voice_Simple invalid or not setup!"); - - try - { - m_micTestResult = m_vatlib->EndMicTest(); - emit micTestFinished(); - } - catch (...) - { - this->exceptionDispatcher(Q_FUNC_INFO); - } - } - - /********************************** * * * * * * * * * * * * * * * * * * * ************************************/ - /********************************** shimlib callbacks ************************************/ - /********************************** * * * * * * * * * * * * * * * * * * * ************************************/ - - /*! - * \brief Cast from *void to *CVoiceVatlib - * \param cbvar - * \return - */ - CVoiceVatlib *cbvar_cast_voice(void *cbvar) - { - return static_cast(cbvar); } /* @@ -394,61 +137,6 @@ namespace BlackCore vatlibRoom->onRoomStatusUpdate(roomIndex, upd); } - /* - * Input hardware received - */ - void CVoiceVatlib::onInputHardwareDeviceReceived(Cvatlib_Voice_Simple *obj, const char *name, void *cbVar) - { - Q_UNUSED(obj) - BlackMisc::Audio::CAudioDeviceInfo inputDevice(BlackMisc::Audio::CAudioDeviceInfo::InputDevice, cbvar_cast_voice(cbVar)->m_devices.count(BlackMisc::Audio::CAudioDeviceInfo::InputDevice), QString(name)); - QMutexLocker lockForWriting(&(cbvar_cast_voice(cbVar)->m_lockDeviceList)); - cbvar_cast_voice(cbVar)->m_devices.push_back(inputDevice); - } - - /* - * Output hardware received - */ - void CVoiceVatlib::onOutputHardwareDeviceReceived(Cvatlib_Voice_Simple *obj, const char *name, void *cbVar) - { - Q_UNUSED(obj) - BlackMisc::Audio::CAudioDeviceInfo outputDevice(BlackMisc::Audio::CAudioDeviceInfo::OutputDevice, cbvar_cast_voice(cbVar)->m_devices.count(BlackMisc::Audio::CAudioDeviceInfo::OutputDevice), QString(name)); - QMutexLocker lockForWriting(&(cbvar_cast_voice(cbVar)->m_lockDeviceList)); - cbvar_cast_voice(cbVar)->m_devices.push_back(outputDevice); - } - - /* - * Forward exception as signal - */ - void CVoiceVatlib::exceptionDispatcher(const char *caller) - { - QString msg("Caller: "); - msg.append(caller).append(" ").append("Exception: "); - try - { - throw; - } - catch (const NetworkNotConnectedException &e) - { - // this could be caused by a race condition during normal operation, so not an error - CLogMessage(this).debug() << "NetworkNotConnectedException" << e.what() << "in" << caller; - } - catch (const VatlibException &e) - { - CLogMessage(this).error("VatlibException %1 in %2") << e.what() << caller; - Q_ASSERT(false); - } - catch (const std::exception &e) - { - CLogMessage(this).error("std::exception %1 in %2") << e.what() << caller; - Q_ASSERT(false); - } - catch (...) - { - CLogMessage(this).error("Unknown exception in %1") << caller; - Q_ASSERT(false); - } - } - void CVoiceVatlib::onRoomStatusUpdate(qint32 roomIndex, Cvatlib_Voice_Simple::roomStatusUpdate roomStatus) { QList voiceChannels = m_hashChannelIndex.values(); diff --git a/src/blackcore/voice_vatlib.h b/src/blackcore/voice_vatlib.h index d101a6314..cbc214e0b 100644 --- a/src/blackcore/voice_vatlib.h +++ b/src/blackcore/voice_vatlib.h @@ -7,18 +7,8 @@ #define BLACKCORE_VOICE_VATLIB_H #include "voice.h" -#include "../blacksound/soundgenerator.h" -#include "../blackmisc/nwuserlist.h" -#include "../blackmisc/avcallsignlist.h" -#include "../blackmisc/sharedlockablepointer.h" -#include -#include #include -#include -#include -#include -#include #ifdef Q_OS_WIN #ifndef NOMINMAX @@ -31,24 +21,6 @@ namespace BlackCore { - /*! - * \brief Deleter - */ - struct Cvatlib_Voice_Simple_Deleter - { - /*! - * \brief Cleanup - * \param pointer - */ - static inline void cleanup(Cvatlib_Voice_Simple *pointer) - { - if (pointer) pointer->Destroy(); - } - }; - - //! Shared lockable pointer to Cvatlib_Voice_Simple - typedef BlackMisc::SharedLockablePtr TVatlibPointer; - /*! * Vatlib implementation of the IVoice interface. */ @@ -81,25 +53,6 @@ namespace BlackCore //! \copydoc IVoice::defaultAudioOutputDevice() virtual const BlackMisc::Audio::CAudioDeviceInfo defaultAudioOutputDevice() const override; - /************************************************ - * SETUP TESTS - ***********************************************/ - - //! \copydoc IVoice::runSquelchTest - virtual void runSquelchTest() override; - - //! \copydoc IVoice::runMicTest - virtual void runMicrophoneTest() override; - - //! \copydoc IVoice::inputSquelch - virtual float inputSquelch() const override; - - //! \copydoc IVoice::micTestResult() - virtual qint32 micTestResult() const override; - - //! \copydoc IVoice::micTestResultAsString - virtual QString micTestResultAsString() const override; - //! \copydoc IVoice::getVoiceChannel virtual IVoiceChannel *getVoiceChannel(qint32 channelIndex) const override; @@ -131,34 +84,19 @@ namespace BlackCore */ virtual void timerEvent(QTimerEvent *); - private slots: - // slots for Mic tests - void onEndFindSquelch(); - void onEndMicTest(); - private: // shimlib callbacks static void onRoomStatusUpdate(Cvatlib_Voice_Simple *obj, Cvatlib_Voice_Simple::roomStatusUpdate upd, qint32 roomIndex, void *cbVar); - static void onInputHardwareDeviceReceived(Cvatlib_Voice_Simple *obj, const char *name, void *cbVar); - static void onOutputHardwareDeviceReceived(Cvatlib_Voice_Simple *obj, const char *name, void *cbVar); - void exceptionDispatcher(const char *caller); void onRoomStatusUpdate(qint32 roomIndex, Cvatlib_Voice_Simple::roomStatusUpdate roomStatus); - TVatlibPointer m_vatlib; BlackMisc::Audio::CAudioDeviceInfoList m_devices; /*!< in and output devices */ BlackMisc::Audio::CAudioDeviceInfo m_currentOutputDevice; BlackMisc::Audio::CAudioDeviceInfo m_currentInputDevice; - std::atomic m_inputSquelch; - std::atomic m_micTestResult; QHash m_hashChannelIndex; bool m_isAudioLoopbackEnabled; /*!< A flag whether audio loopback is enabled or not */ - // Thread serialization - mutable QMutex m_lockCurrentOutputDevice; - mutable QMutex m_lockCurrentInputDevice; - mutable QMutex m_lockDeviceList; }; } // namespace