From de75cdc214c64597f0985b1daad817a7143e9ee3 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 13 Oct 2019 23:52:49 +0200 Subject: [PATCH] [AFV] Ref T730 incorporated MS fixes see https://discordapp.com/channels/539048679160676382/623947987822837779/633025547999510530 --- src/blackcore/afv/clients/afvclient.cpp | 28 +++++++++++-------- src/blackcore/afv/clients/afvclient.h | 2 +- .../sampleprovider/volumesampleprovider.cpp | 2 +- .../context/testcontext/testcontext.cpp | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/blackcore/afv/clients/afvclient.cpp b/src/blackcore/afv/clients/afvclient.cpp index db8e1de25..678aaea03 100644 --- a/src/blackcore/afv/clients/afvclient.cpp +++ b/src/blackcore/afv/clients/afvclient.cpp @@ -13,7 +13,7 @@ #include "blackmisc/audio/audiodeviceinfolist.h" #include "blackmisc/threadutils.h" -#ifdef _WIN32 +#ifdef Q_OS_WIN #include "comdef.h" #endif @@ -493,10 +493,13 @@ namespace BlackCore QMutexLocker lock(&m_mutex); bool changed = !qFuzzyCompare(m_inputVolumeDb, valueDb); - m_inputVolumeDb = valueDb; - if (m_input) + if (changed) { - changed = m_input->setVolume(qPow(10, valueDb / 20.0)); + m_inputVolumeDb = valueDb; + if (m_input) + { + changed = m_input->setVolume(qPow(10, valueDb / 20.0)); + } } return changed; } @@ -690,7 +693,7 @@ namespace BlackCore void CAfvClient::initialize() { -#ifdef _WIN32 +#ifdef Q_OS_WIN if (!m_winCoInitialized) { HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); @@ -712,7 +715,7 @@ namespace BlackCore void CAfvClient::cleanup() { -#ifdef _WIN32 +#ifdef Q_OS_WIN if (m_winCoInitialized) { CoUninitialize(); @@ -882,12 +885,15 @@ namespace BlackCore QMutexLocker lock(&m_mutex); bool changed = !qFuzzyCompare(m_outputVolumeDb, valueDb); - m_outputVolumeDb = valueDb; - m_outputVolume = qPow(10, m_outputVolumeDb / 20.0); - - if (m_outputSampleProvider) + if (changed) { - changed = m_outputSampleProvider->setVolume(m_outputVolume); + m_outputVolumeDb = valueDb; + m_outputVolume = qPow(10, m_outputVolumeDb / 20.0); + + if (m_outputSampleProvider) + { + changed = m_outputSampleProvider->setVolume(m_outputVolume); + } } return changed; } diff --git a/src/blackcore/afv/clients/afvclient.h b/src/blackcore/afv/clients/afvclient.h index 3d89208be..a679495e6 100644 --- a/src/blackcore/afv/clients/afvclient.h +++ b/src/blackcore/afv/clients/afvclient.h @@ -272,7 +272,7 @@ namespace BlackCore static constexpr int PositionUpdatesMs = 5000; //!< position timer static constexpr int SampleRate = 48000; - static constexpr int FrameSize = 960; //!< 20ms + static constexpr int FrameSize = static_cast(SampleRate * 0.02); //!< 20ms static constexpr double MinDbIn = -18.0; static constexpr double MaxDbIn = 18.0; static constexpr double MinDbOut = -60.0; diff --git a/src/blacksound/sampleprovider/volumesampleprovider.cpp b/src/blacksound/sampleprovider/volumesampleprovider.cpp index 2eea9dc35..37047758f 100644 --- a/src/blacksound/sampleprovider/volumesampleprovider.cpp +++ b/src/blacksound/sampleprovider/volumesampleprovider.cpp @@ -37,7 +37,7 @@ namespace BlackSound bool CVolumeSampleProvider::setVolume(double volume) { const bool changed = !qFuzzyCompare(m_volume, volume); - m_volume = volume; + if (changed) { m_volume = volume; } return changed; } } // ns diff --git a/tests/blackcore/context/testcontext/testcontext.cpp b/tests/blackcore/context/testcontext/testcontext.cpp index e25807082..f75a6af3c 100644 --- a/tests/blackcore/context/testcontext/testcontext.cpp +++ b/tests/blackcore/context/testcontext/testcontext.cpp @@ -17,7 +17,7 @@ #include "test.h" #include -#ifdef _WIN32 +#ifdef Q_OS_WIN #include "comdef.h" #endif