From 2bd16542a5ac3d08ad318a124781bab1195a65b6 Mon Sep 17 00:00:00 2001 From: Martin Passing Date: Sun, 16 May 2021 21:10:19 +0200 Subject: [PATCH] apply clang-format style definition --- android/androiddebug.cpp | 84 +- android/ring_buffer.h | 114 ++- android/sound.cpp | 104 +-- android/sound.h | 26 +- ios/ios_app_delegate.h | 5 +- ios/sound.h | 27 +- linux/sound.cpp | 129 ++- linux/sound.h | 73 +- mac/activity.h | 8 +- mac/sound.cpp | 431 +++------ mac/sound.h | 48 +- src/analyzerconsole.cpp | 96 +-- src/analyzerconsole.h | 53 +- src/audiomixerboard.cpp | 585 ++++++------- src/audiomixerboard.h | 155 ++-- src/buffer.cpp | 96 +-- src/buffer.h | 169 ++-- src/channel.cpp | 180 ++-- src/channel.h | 190 ++-- src/chatdlg.cpp | 53 +- src/chatdlg.h | 9 +- src/client.cpp | 374 ++++---- src/client.h | 293 +++---- src/clientdlg.cpp | 600 ++++++------- src/clientdlg.h | 205 ++--- src/clientsettingsdlg.cpp | 812 ++++++++--------- src/clientsettingsdlg.h | 23 +- src/connectdlg.cpp | 194 ++--- src/connectdlg.h | 51 +- src/global.h | 239 +++-- src/levelmeter.cpp | 71 +- src/levelmeter.h | 27 +- src/main.cpp | 477 ++++------ src/multicolorled.cpp | 19 +- src/multicolorled.h | 21 +- src/protocol.cpp | 722 +++++----------- src/protocol.h | 318 +++---- src/recorder/creaperproject.cpp | 27 +- src/recorder/creaperproject.h | 17 +- src/recorder/cwavestream.cpp | 96 +-- src/recorder/cwavestream.h | 81 +- src/recorder/jamcontroller.cpp | 78 +- src/recorder/jamcontroller.h | 34 +- src/recorder/jamrecorder.cpp | 260 +++--- src/recorder/jamrecorder.h | 104 +-- src/server.cpp | 458 ++++------ src/server.h | 356 +++----- src/serverdlg.cpp | 339 ++++---- src/serverdlg.h | 63 +- src/serverlist.cpp | 113 +-- src/serverlist.h | 106 +-- src/serverlogging.cpp | 19 +- src/serverlogging.h | 18 +- src/settings.cpp | 402 +++------ src/settings.h | 137 ++- src/signalhandler.cpp | 37 +- src/signalhandler.h | 35 +- src/socket.cpp | 113 +-- src/socket.h | 120 ++- src/soundbase.cpp | 164 ++-- src/soundbase.h | 68 +- src/testbench.h | 81 +- src/threadpool.h | 71 +- src/util.cpp | 1438 ++++++++++++++++++++----------- src/util.h | 595 ++++++------- src/vstmain.cpp | 21 +- src/vstmain.h | 26 +- src/vstsound.h | 24 +- windows/nsProcess/ConvFunc.h | 855 +++++++++--------- windows/nsProcess/api.h | 67 +- windows/nsProcess/nsis_tchar.h | 270 +++--- windows/nsProcess/pluginapi.h | 152 ++-- windows/sound.cpp | 488 +++++------ windows/sound.h | 77 +- 74 files changed, 6508 insertions(+), 7983 deletions(-) mode change 100755 => 100644 linux/sound.cpp mode change 100755 => 100644 linux/sound.h mode change 100755 => 100644 mac/sound.cpp mode change 100755 => 100644 mac/sound.h mode change 100755 => 100644 src/audiomixerboard.cpp mode change 100755 => 100644 src/audiomixerboard.h mode change 100755 => 100644 src/buffer.cpp mode change 100755 => 100644 src/buffer.h mode change 100755 => 100644 src/channel.cpp mode change 100755 => 100644 src/channel.h mode change 100755 => 100644 src/chatdlg.cpp mode change 100755 => 100644 src/chatdlg.h mode change 100755 => 100644 src/client.cpp mode change 100755 => 100644 src/client.h mode change 100755 => 100644 src/clientdlg.cpp mode change 100755 => 100644 src/clientdlg.h mode change 100755 => 100644 src/clientsettingsdlg.cpp mode change 100755 => 100644 src/clientsettingsdlg.h mode change 100755 => 100644 src/connectdlg.cpp mode change 100755 => 100644 src/connectdlg.h mode change 100755 => 100644 src/global.h mode change 100755 => 100644 src/levelmeter.cpp mode change 100755 => 100644 src/levelmeter.h mode change 100755 => 100644 src/main.cpp mode change 100755 => 100644 src/multicolorled.cpp mode change 100755 => 100644 src/multicolorled.h mode change 100755 => 100644 src/protocol.cpp mode change 100755 => 100644 src/protocol.h mode change 100755 => 100644 src/recorder/jamcontroller.cpp mode change 100755 => 100644 src/recorder/jamcontroller.h mode change 100755 => 100644 src/recorder/jamrecorder.cpp mode change 100755 => 100644 src/recorder/jamrecorder.h mode change 100755 => 100644 src/serverdlg.h mode change 100755 => 100644 src/serverlist.cpp mode change 100755 => 100644 src/serverlist.h mode change 100755 => 100644 src/serverlogging.cpp mode change 100755 => 100644 src/serverlogging.h mode change 100755 => 100644 src/settings.cpp mode change 100755 => 100644 src/settings.h mode change 100755 => 100644 src/signalhandler.cpp mode change 100755 => 100644 src/signalhandler.h mode change 100755 => 100644 src/socket.cpp mode change 100755 => 100644 src/socket.h mode change 100755 => 100644 src/soundbase.cpp mode change 100755 => 100644 src/soundbase.h mode change 100755 => 100644 src/testbench.h mode change 100755 => 100644 src/util.cpp mode change 100755 => 100644 src/util.h mode change 100755 => 100644 src/vstmain.cpp mode change 100755 => 100644 src/vstmain.h mode change 100755 => 100644 src/vstsound.h mode change 100755 => 100644 windows/sound.cpp mode change 100755 => 100644 windows/sound.h diff --git a/android/androiddebug.cpp b/android/androiddebug.cpp index c2f08d09a5..c80ad7fc7f 100644 --- a/android/androiddebug.cpp +++ b/android/androiddebug.cpp @@ -22,60 +22,60 @@ * \******************************************************************************/ -const char*const applicationName = "Jamulus"; +const char* const applicationName = "Jamulus"; #ifdef ANDROIDDEBUG // Set in my myapp.pro file for android builds -#include -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include +# include void myMessageHandler ( QtMsgType type, const QMessageLogContext& context, const QString& msg ) { - QString report = msg; + QString report = msg; - if ( context.file && !QString ( context.file ).isEmpty() ) - { - report += " in file "; - report += QString ( context.file ); - report += " line "; - report += QString::number ( context.line ); - } + if ( context.file && !QString ( context.file ).isEmpty() ) + { + report += " in file "; + report += QString ( context.file ); + report += " line "; + report += QString::number ( context.line ); + } - if ( context.function && !QString ( context.function ).isEmpty() ) - { - report +=+" function "; - report += QString(context.function); - } + if ( context.function && !QString ( context.function ).isEmpty() ) + { + report += +" function "; + report += QString ( context.function ); + } - const char*const local = report.toLocal8Bit().constData(); + const char* const local = report.toLocal8Bit().constData(); - switch ( type ) - { - case QtDebugMsg: - __android_log_write ( ANDROID_LOG_DEBUG, applicationName, local) ; - break; + switch ( type ) + { + case QtDebugMsg: + __android_log_write ( ANDROID_LOG_DEBUG, applicationName, local ); + break; - case QtInfoMsg: - __android_log_write ( ANDROID_LOG_INFO, applicationName, local ); - break; + case QtInfoMsg: + __android_log_write ( ANDROID_LOG_INFO, applicationName, local ); + break; - case QtWarningMsg: - __android_log_write ( ANDROID_LOG_WARN, applicationName, local ); - break; + case QtWarningMsg: + __android_log_write ( ANDROID_LOG_WARN, applicationName, local ); + break; - case QtCriticalMsg: - __android_log_write ( ANDROID_LOG_ERROR, applicationName, local ); - break; + case QtCriticalMsg: + __android_log_write ( ANDROID_LOG_ERROR, applicationName, local ); + break; - case QtFatalMsg: - default: - __android_log_write ( ANDROID_LOG_FATAL, applicationName, local ); - abort(); - break; - } + case QtFatalMsg: + default: + __android_log_write ( ANDROID_LOG_FATAL, applicationName, local ); + abort(); + break; + } } #endif diff --git a/android/ring_buffer.h b/android/ring_buffer.h index 792e6812e3..cbdac0a328 100644 --- a/android/ring_buffer.h +++ b/android/ring_buffer.h @@ -30,35 +30,42 @@ * Data is contained in a vector dynamically allocated. */ template -class RingBuffer { +class RingBuffer +{ public: /** * @brief RingBuffer * @param max maximum number of elements that can be contained in the ring buffer */ - RingBuffer(std::size_t max = 0):mData(max),mRead(0),mWrite(0),mFull(false) { } + RingBuffer ( std::size_t max = 0 ) : mData ( max ), mRead ( 0 ), mWrite ( 0 ), mFull ( false ) {} /** * @brief Resets the ring_buffer * @param max maximum number of elements that can be contained in the ring buffer. */ - void reset(std::size_t max = 0) { - mData = std::vector(max); - mRead = 0; + void reset ( std::size_t max = 0 ) + { + mData = std::vector ( max ); + mRead = 0; mWrite = 0; - mFull = false; + mFull = false; } /** * @brief Current number of elements contained in the ring buffer * @return */ - std::size_t size() const { + std::size_t size() const + { std::size_t size = capacity(); - if(!mFull) { - if(mWrite >= mRead) { + if ( !mFull ) + { + if ( mWrite >= mRead ) + { size = mWrite - mRead; - } else { + } + else + { size = capacity() + mWrite - mRead; } } @@ -75,7 +82,7 @@ class RingBuffer { * @brief whether the ring buffer is empty. * @return */ - bool isEmpty() const { return !isFull() && (mRead == mWrite); } + bool isEmpty() const { return !isFull() && ( mRead == mWrite ); } /** * @brief Maximum number of elements in the ring buffer @@ -87,7 +94,8 @@ class RingBuffer { * @brief Adds a single value * @param v the value to add */ - void put(const T &v) { + void put ( const T& v ) + { mData[mWrite] = v; forward(); } @@ -97,12 +105,16 @@ class RingBuffer { * @param v the value read * @return true if the value was read */ - bool get(T&v) { - if(!isEmpty()) { + bool get ( T& v ) + { + if ( !isEmpty() ) + { v = mData[mRead]; backward(); return true; - } else { + } + else + { return false; } } @@ -112,13 +124,15 @@ class RingBuffer { * @param v pointer to the consecutive values * @param count number of consecutive values. */ - void put(const T *v, std::size_t count) { - std::size_t avail = mWrite - capacity(); - std::size_t to_copy = std::min(count,avail); - memcpy(mData.data() + mWrite,v, to_copy*sizeof(T)); - forward(to_copy); - if(to_copy < count) { - put(v+to_copy,count - to_copy); + void put ( const T* v, std::size_t count ) + { + std::size_t avail = mWrite - capacity(); + std::size_t to_copy = std::min ( count, avail ); + memcpy ( mData.data() + mWrite, v, to_copy * sizeof ( T ) ); + forward ( to_copy ); + if ( to_copy < count ) + { + put ( v + to_copy, count - to_copy ); } } @@ -128,45 +142,57 @@ class RingBuffer { * @param count Maximum available size in the memory area * @return actual number of elements read. */ - std::size_t get(T *v, std::size_t count) { + std::size_t get ( T* v, std::size_t count ) + { std::size_t avail = 0; - if(mRead < mWrite) { + if ( mRead < mWrite ) + { avail = mWrite - mRead; - } else { + } + else + { avail = mRead - capacity(); } - std::size_t to_copy = std::min(count, avail); - memcpy(v, mData.data() + mRead, to_copy * sizeof(T)); - backward(to_copy); - if((size()>0)&&(count > to_copy)) { - return to_copy + get(v + to_copy, count - to_copy); - } else { + std::size_t to_copy = std::min ( count, avail ); + memcpy ( v, mData.data() + mRead, to_copy * sizeof ( T ) ); + backward ( to_copy ); + if ( ( size() > 0 ) && ( count > to_copy ) ) + { + return to_copy + get ( v + to_copy, count - to_copy ); + } + else + { return to_copy; } } + private: - void forward() { - if(isFull()) { - mRead = (mRead + 1) % capacity(); + void forward() + { + if ( isFull() ) + { + mRead = ( mRead + 1 ) % capacity(); } - mWrite = (mWrite + 1) % capacity(); - mFull = (mRead == mWrite); + mWrite = ( mWrite + 1 ) % capacity(); + mFull = ( mRead == mWrite ); } - void forward(std::size_t count) { - for(std::size_t i=0; i mData; - std::size_t mRead; /** offset to reading point */ - std::size_t mWrite; /** offset to writing point */ - bool mFull; + std::size_t mRead; /** offset to reading point */ + std::size_t mWrite; /** offset to writing point */ + bool mFull; }; - diff --git a/android/sound.cpp b/android/sound.cpp index ffab760999..65e45b108c 100644 --- a/android/sound.cpp +++ b/android/sound.cpp @@ -29,15 +29,15 @@ const uint8_t CSound::RING_FACTOR = 20; -CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), +CSound::CSound ( void ( *fpNewProcessCallback ) ( CVector& psData, void* arg ), void* arg, const QString& strMIDISetup, - const bool , + const bool, const QString& ) : CSoundBase ( "Oboe", fpNewProcessCallback, arg, strMIDISetup ) { #ifdef ANDROIDDEBUG - qInstallMessageHandler(myMessageHandler); + qInstallMessageHandler ( myMessageHandler ); #endif } @@ -45,14 +45,13 @@ void CSound::setupCommonStreamParams ( oboe::AudioStreamBuilder* builder ) { // We request EXCLUSIVE mode since this will give us the lowest possible // latency. If EXCLUSIVE mode isn't available the builder will fall back to SHARED mode - builder - ->setFormat(oboe::AudioFormat::Float) - ->setSharingMode(oboe::SharingMode::Exclusive) - ->setChannelCount(oboe::ChannelCount::Stereo) - ->setSampleRate(SYSTEM_SAMPLE_RATE_HZ) - ->setFramesPerCallback(iOboeBufferSizeMono) - ->setSampleRateConversionQuality(oboe::SampleRateConversionQuality::Medium) - ->setPerformanceMode(oboe::PerformanceMode::LowLatency); + builder->setFormat ( oboe::AudioFormat::Float ) + ->setSharingMode ( oboe::SharingMode::Exclusive ) + ->setChannelCount ( oboe::ChannelCount::Stereo ) + ->setSampleRate ( SYSTEM_SAMPLE_RATE_HZ ) + ->setFramesPerCallback ( iOboeBufferSizeMono ) + ->setSampleRateConversionQuality ( oboe::SampleRateConversionQuality::Medium ) + ->setPerformanceMode ( oboe::PerformanceMode::LowLatency ); return; } @@ -66,22 +65,20 @@ void CSound::closeStream ( oboe::ManagedStream& stream ) if ( result != oboe::Result::OK ) { - throw CGenErr ( tr ( "Error closing stream: $s", - oboe::convertToText ( result ) ) ); + throw CGenErr ( tr ( "Error closing stream: $s", oboe::convertToText ( result ) ) ); } stream.reset(); } } - void CSound::openStreams() { // Setup output stream oboe::AudioStreamBuilder inBuilder, outBuilder; outBuilder.setDirection ( oboe::Direction::Output ); - outBuilder.setCallback(this); + outBuilder.setCallback ( this ); setupCommonStreamParams ( &outBuilder ); oboe::Result result = outBuilder.openManagedStream ( mPlayStream ); @@ -100,7 +97,7 @@ void CSound::openStreams() // Only set callback for the input direction // the output will be handled writing directly on the stream - inBuilder.setCallback(this); + inBuilder.setCallback ( this ); setupCommonStreamParams ( &inBuilder ); result = inBuilder.openManagedStream ( mRecordingStream ); @@ -120,7 +117,7 @@ void CSound::openStreams() void CSound::printStreamDetails ( oboe::ManagedStream& stream ) { - QString sDirection = ( stream->getDirection()==oboe::Direction::Input ? "Input" : "Output" ); + QString sDirection = ( stream->getDirection() == oboe::Direction::Input ? "Input" : "Output" ); QString sFramesPerBurst = QString::number ( stream->getFramesPerBurst() ); QString sBufferSizeInFrames = QString::number ( stream->getBufferSizeInFrames() ); QString sBytesPerFrame = QString::number ( stream->getBytesPerFrame() ); @@ -130,24 +127,16 @@ void CSound::printStreamDetails ( oboe::ManagedStream& stream ) QString sSharingMode = ( stream->getSharingMode() == oboe::SharingMode::Exclusive ? "Exclusive" : "Shared" ); QString sDeviceID = QString::number ( stream->getDeviceId() ); QString sSampleRate = QString::number ( stream->getSampleRate() ); - QString sAudioFormat = ( stream->getFormat()==oboe::AudioFormat::I16 ? "I16" : "Float" ); + QString sAudioFormat = ( stream->getFormat() == oboe::AudioFormat::I16 ? "I16" : "Float" ); QString sFramesPerCallback = QString::number ( stream->getFramesPerCallback() ); - qInfo() << "Stream details: [sDirection: " << sDirection << - ", FramesPerBurst: " << sFramesPerBurst << - ", BufferSizeInFrames: " << sBufferSizeInFrames << - ", BytesPerFrame: " << sBytesPerFrame << - ", BytesPerSample: " << sBytesPerSample << - ", BufferCapacityInFrames: " << sBufferCapacityInFrames << - ", PerformanceMode: " << sPerformanceMode << - ", SharingMode: " << sSharingMode << - ", DeviceID: " << sDeviceID << - ", SampleRate: " << sSampleRate << - ", AudioFormat: " << sAudioFormat << - ", FramesPerCallback: " << sFramesPerCallback << "]"; + qInfo() << "Stream details: [sDirection: " << sDirection << ", FramesPerBurst: " << sFramesPerBurst + << ", BufferSizeInFrames: " << sBufferSizeInFrames << ", BytesPerFrame: " << sBytesPerFrame << ", BytesPerSample: " << sBytesPerSample + << ", BufferCapacityInFrames: " << sBufferCapacityInFrames << ", PerformanceMode: " << sPerformanceMode + << ", SharingMode: " << sSharingMode << ", DeviceID: " << sDeviceID << ", SampleRate: " << sSampleRate + << ", AudioFormat: " << sAudioFormat << ", FramesPerCallback: " << sFramesPerCallback << "]"; } -void CSound::warnIfNotLowLatency ( oboe::ManagedStream& stream, - QString streamName ) +void CSound::warnIfNotLowLatency ( oboe::ManagedStream& stream, QString streamName ) { if ( stream->getPerformanceMode() != oboe::PerformanceMode::LowLatency ) { @@ -203,9 +192,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize ) // This is the main callback method for when an audio stream is ready to publish data to an output stream // or has received data on an input stream. As per manual much be very careful not to do anything in this back that // can cause delays such as sleeping, file processing, allocate memory, etc. -oboe::DataCallbackResult CSound::onAudioReady ( oboe::AudioStream* oboeStream, - void* audioData, - int32_t numFrames ) +oboe::DataCallbackResult CSound::onAudioReady ( oboe::AudioStream* oboeStream, void* audioData, int32_t numFrames ) { // only process if we are running if ( !bRun ) @@ -220,12 +207,12 @@ oboe::DataCallbackResult CSound::onAudioReady ( oboe::AudioStream* oboeStream, if ( oboeStream == mRecordingStream.get() && audioData ) { - return onAudioInput(oboeStream, audioData, numFrames); + return onAudioInput ( oboeStream, audioData, numFrames ); } - if ( oboeStream == mPlayStream.get() && audioData) + if ( oboeStream == mPlayStream.get() && audioData ) { - return onAudioOutput(oboeStream, audioData, numFrames); + return onAudioOutput ( oboeStream, audioData, numFrames ); } return oboe::DataCallbackResult::Continue; @@ -257,7 +244,7 @@ oboe::DataCallbackResult CSound::onAudioInput ( oboe::AudioStream* oboeStream, v for ( int channelNum = 0; channelNum < oboeStream->getChannelCount(); channelNum++ ) { vecsTmpInputAudioSndCrdStereo[frmNum * oboeStream->getChannelCount() + channelNum] = - static_cast(floatData[frmNum * oboeStream->getChannelCount() + channelNum] * _MAXSHORT); + static_cast ( floatData[frmNum * oboeStream->getChannelCount() + channelNum] * _MAXSHORT ); } } @@ -269,15 +256,15 @@ oboe::DataCallbackResult CSound::onAudioInput ( oboe::AudioStream* oboeStream, v mStats.frames_in += numFrames; // Tell parent class that we've put some data ready to send to the server - ProcessCallback ( vecsTmpInputAudioSndCrdStereo ); + ProcessCallback ( vecsTmpInputAudioSndCrdStereo ); // The callback has placed in the vector the samples to play - addOutputData(oboeStream->getChannelCount()); + addOutputData ( oboeStream->getChannelCount() ); return oboe::DataCallbackResult::Continue; } -void CSound::addOutputData(int channel_count) +void CSound::addOutputData ( int channel_count ) { QMutexLocker locker ( &MutexAudioProcessCallback ); @@ -291,8 +278,7 @@ void CSound::addOutputData(int channel_count) // copy sample received from server into output buffer // convert to 32 bit - const int32_t iCurSam = static_cast ( - vecsTmpInputAudioSndCrdStereo[frmNum * channel_count+ channelNum] ); + const int32_t iCurSam = static_cast ( vecsTmpInputAudioSndCrdStereo[frmNum * channel_count + channelNum] ); mOutBuffer.put ( ( static_cast ( iCurSam ) ) / _MAXSHORT ); } @@ -316,16 +302,14 @@ void CSound::addOutputData(int channel_count) } } -oboe::DataCallbackResult CSound::onAudioOutput ( oboe::AudioStream* oboeStream, - void* audioData, - int32_t numFrames ) +oboe::DataCallbackResult CSound::onAudioOutput ( oboe::AudioStream* oboeStream, void* audioData, int32_t numFrames ) { mStats.frames_out += numFrames; mStats.out_callback_calls++; QMutexLocker locker ( &MutexAudioProcessCallback ); - std::size_t to_write = numFrames*oboeStream->getChannelCount(); + std::size_t to_write = numFrames * oboeStream->getChannelCount(); std::size_t count = std::min ( mOutBuffer.size(), to_write ); mOutBuffer.get ( (float*) audioData, count ); @@ -340,20 +324,12 @@ oboe::DataCallbackResult CSound::onAudioOutput ( oboe::AudioStream* oboeStream, } // TODO better handling of stream closing errors -void CSound::onErrorAfterClose ( oboe::AudioStream* oboeStream, - oboe::Result result ) -{ - qDebug() << "CSound::onErrorAfterClose"; -} +void CSound::onErrorAfterClose ( oboe::AudioStream* oboeStream, oboe::Result result ) { qDebug() << "CSound::onErrorAfterClose"; } // TODO better handling of stream closing errors -void CSound::onErrorBeforeClose ( oboe::AudioStream* oboeStream, - oboe::Result result ) -{ - qDebug() << "CSound::onErrorBeforeClose"; -} +void CSound::onErrorBeforeClose ( oboe::AudioStream* oboeStream, oboe::Result result ) { qDebug() << "CSound::onErrorBeforeClose"; } -void CSound::Stats::reset() +void CSound::Stats::reset() { frames_in = 0; frames_out = 0; @@ -363,13 +339,9 @@ void CSound::Stats::reset() ring_overrun = 0; } -void CSound::Stats::log() const +void CSound::Stats::log() const { qDebug() << "Stats: " - << "frames_in: " << frames_in - << ",frames_out: " << frames_out - << ",frames_filled_out: " << frames_filled_out - << ",in_callback_calls: " << in_callback_calls - << ",out_callback_calls: " << out_callback_calls - << ",ring_overrun: " << ring_overrun; + << "frames_in: " << frames_in << ",frames_out: " << frames_out << ",frames_filled_out: " << frames_filled_out + << ",in_callback_calls: " << in_callback_calls << ",out_callback_calls: " << out_callback_calls << ",ring_overrun: " << ring_overrun; } diff --git a/android/sound.h b/android/sound.h index e16eceb0eb..f75c0ab881 100644 --- a/android/sound.h +++ b/android/sound.h @@ -39,10 +39,10 @@ class CSound : public CSoundBase, public oboe::AudioStreamCallback public: static const uint8_t RING_FACTOR; - CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), + CSound ( void ( *fpNewProcessCallback ) ( CVector& psData, void* arg ), void* arg, const QString& strMIDISetup, - const bool , + const bool, const QString& ); virtual ~CSound() {} @@ -52,14 +52,14 @@ class CSound : public CSoundBase, public oboe::AudioStreamCallback // Call backs for Oboe virtual oboe::DataCallbackResult onAudioReady ( oboe::AudioStream* oboeStream, void* audioData, int32_t numFrames ); - virtual void onErrorAfterClose ( oboe::AudioStream* oboeStream, oboe::Result result ); - virtual void onErrorBeforeClose ( oboe::AudioStream* oboeStream, oboe::Result result ); + virtual void onErrorAfterClose ( oboe::AudioStream* oboeStream, oboe::Result result ); + virtual void onErrorBeforeClose ( oboe::AudioStream* oboeStream, oboe::Result result ); - struct Stats + struct Stats { Stats() { reset(); } - void reset(); - void log() const; + void reset(); + void log() const; std::size_t frames_in; std::size_t frames_out; std::size_t frames_filled_out; @@ -85,14 +85,14 @@ class CSound : public CSoundBase, public oboe::AudioStreamCallback oboe::DataCallbackResult onAudioInput ( oboe::AudioStream* oboeStream, void* audioData, int32_t numFrames ); oboe::DataCallbackResult onAudioOutput ( oboe::AudioStream* oboeStream, void* audioData, int32_t numFrames ); - void addOutputData(int channel_count); + void addOutputData ( int channel_count ); - oboe::ManagedStream mRecordingStream; - oboe::ManagedStream mPlayStream; + oboe::ManagedStream mRecordingStream; + oboe::ManagedStream mPlayStream; // used to reach a state where the input buffer is // empty and the garbage in the first 500ms or so is discarded - static constexpr int32_t kNumCallbacksToDrain = 10; - int32_t mCountCallbacksToDrain = kNumCallbacksToDrain; - Stats mStats; + static constexpr int32_t kNumCallbacksToDrain = 10; + int32_t mCountCallbacksToDrain = kNumCallbacksToDrain; + Stats mStats; }; diff --git a/ios/ios_app_delegate.h b/ios/ios_app_delegate.h index efbee1bac7..55f973432b 100644 --- a/ios/ios_app_delegate.h +++ b/ios/ios_app_delegate.h @@ -1,8 +1,7 @@ #import #include -@interface QIOSApplicationDelegate : UIResponder -@property (strong, nonatomic) UIWindow *window; +@interface QIOSApplicationDelegate : UIResponder +@property ( strong, nonatomic ) UIWindow* window; @end - diff --git a/ios/sound.h b/ios/sound.h index a3182c5611..7f08179867 100644 --- a/ios/sound.h +++ b/ios/sound.h @@ -29,17 +29,16 @@ #include "soundbase.h" #include "global.h" - /* Classes ********************************************************************/ class CSound : public CSoundBase { Q_OBJECT public: - CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), + CSound ( void ( *fpNewProcessCallback ) ( CVector& psData, void* arg ), void* arg, const QString& strMIDISetup, - const bool , + const bool, const QString& ); virtual int Init ( const int iNewPrefMonoBufferSize ); @@ -49,16 +48,16 @@ class CSound : public CSoundBase // channel selection virtual int GetNumInputChannels() { return iNumInChanPlusAddChan; } virtual QString GetInputChannelName ( const int iDiD ) { return sChannelNamesInput[iDiD]; } - virtual void SetLeftInputChannel ( const int iNewChan ); + virtual void SetLeftInputChannel ( const int iNewChan ); virtual void SetRightInputChannel ( const int iNewChan ); - virtual int GetLeftInputChannel() { return iSelInputLeftChannel; } + virtual int GetLeftInputChannel() { return iSelInputLeftChannel; } virtual int GetRightInputChannel() { return iSelInputRightChannel; } virtual int GetNumOutputChannels() { return iNumOutChan; } virtual QString GetOutputChannelName ( const int iDiD ) { return sChannelNamesOutput[iDiD]; } - virtual void SetLeftOutputChannel ( const int iNewChan ); + virtual void SetLeftOutputChannel ( const int iNewChan ); virtual void SetRightOutputChannel ( const int iNewChan ); - virtual int GetLeftOutputChannel() { return iSelOutputLeftChannel; } + virtual int GetLeftOutputChannel() { return iSelOutputLeftChannel; } virtual int GetRightOutputChannel() { return iSelOutputRightChannel; } // these variables/functions should be protected but cannot since we want @@ -95,16 +94,14 @@ class CSound : public CSoundBase QString CheckDeviceCapabilities ( const int iDriverIdx ); void GetAvailableInOutDevices(); - static void callbackMIDI ( const MIDIPacketList* pktlist, - void* refCon, - void* ); + static void callbackMIDI ( const MIDIPacketList* pktlist, void* refCon, void* ); - //AVAudioSession audioSession; + // AVAudioSession audioSession; - MIDIPortRef midiInPortRef; + MIDIPortRef midiInPortRef; - QString sChannelNamesInput[MAX_NUM_IN_OUT_CHANNELS]; - QString sChannelNamesOutput[MAX_NUM_IN_OUT_CHANNELS]; + QString sChannelNamesInput[MAX_NUM_IN_OUT_CHANNELS]; + QString sChannelNamesOutput[MAX_NUM_IN_OUT_CHANNELS]; - QMutex Mutex; + QMutex Mutex; }; diff --git a/linux/sound.cpp b/linux/sound.cpp old mode 100755 new mode 100644 index 0134413b2a..692be8fa57 --- a/linux/sound.cpp +++ b/linux/sound.cpp @@ -27,17 +27,17 @@ #include "sound.h" #ifdef WITH_JACK -void CSound::OpenJack ( const bool bNoAutoJackConnect, - const char* jackClientName ) +void CSound::OpenJack ( const bool bNoAutoJackConnect, const char* jackClientName ) { jack_status_t JackStatus; - const char *serverName; + const char* serverName; - if ( ( serverName = getenv( "JACK_DEFAULT_SERVER" ) ) == NULL ) { + if ( ( serverName = getenv ( "JACK_DEFAULT_SERVER" ) ) == NULL ) + { serverName = "default"; } - qInfo() << qUtf8Printable( QString( "Connecting to jack \"%1\" instance (use the JACK_DEFAULT_SERVER environment variable to change this)." ) - .arg( serverName ) ); + qInfo() << qUtf8Printable ( + QString ( "Connecting to jack \"%1\" instance (use the JACK_DEFAULT_SERVER environment variable to change this)." ).arg ( serverName ) ); // try to become a client of the JACK server pJackClient = jack_client_open ( jackClientName, JackNullOption, &JackStatus ); @@ -45,10 +45,10 @@ void CSound::OpenJack ( const bool bNoAutoJackConnect, if ( pJackClient == nullptr ) { throw CGenErr ( tr ( "The Jack server is not running. This software " - "requires a Jack server to run. Normally if the Jack server is " - "not running this software will automatically start the Jack server. " - "It seems that this auto start has not worked. Try to start the Jack " - "server manually." ) ); + "requires a Jack server to run. Normally if the Jack server is " + "not running this software will automatically start the Jack server. " + "It seems that this auto start has not worked. Try to start the Jack " + "server manually." ) ); } // tell the JACK server to call "process()" whenever @@ -65,32 +65,27 @@ void CSound::OpenJack ( const bool bNoAutoJackConnect, if ( jack_get_sample_rate ( pJackClient ) != SYSTEM_SAMPLE_RATE_HZ ) { throw CGenErr ( tr ( "The Jack server sample rate is different from " - "the required one. The required sample rate is:" ) + " " + - QString().setNum ( SYSTEM_SAMPLE_RATE_HZ ) + " Hz. " + tr ( "You can " - "use a tool like QJackCtl " - "to adjust the Jack server sample rate." ) + "
" + tr ( "Make sure to set the " - "Frames/Period to a low value like " ) + - QString().setNum ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ) + - tr ( " to achieve a low delay." ) ); + "the required one. The required sample rate is:" ) + + " " + QString().setNum ( SYSTEM_SAMPLE_RATE_HZ ) + " Hz. " + + tr ( "You can " + "use a tool like QJackCtl " + "to adjust the Jack server sample rate." ) + + "
" + + tr ( "Make sure to set the " + "Frames/Period to a low value like " ) + + QString().setNum ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ) + tr ( " to achieve a low delay." ) ); } // create four ports (two for input, two for output -> stereo) - input_port_left = jack_port_register ( pJackClient, "input left", - JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0 ); + input_port_left = jack_port_register ( pJackClient, "input left", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0 ); - input_port_right = jack_port_register ( pJackClient, "input right", - JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0 ); + input_port_right = jack_port_register ( pJackClient, "input right", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0 ); - output_port_left = jack_port_register ( pJackClient, "output left", - JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 ); + output_port_left = jack_port_register ( pJackClient, "output left", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 ); - output_port_right = jack_port_register ( pJackClient, "output right", - JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 ); + output_port_right = jack_port_register ( pJackClient, "output right", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 ); - if ( ( input_port_left == nullptr ) || - ( input_port_right == nullptr ) || - ( output_port_left == nullptr ) || - ( output_port_right == nullptr ) ) + if ( ( input_port_left == nullptr ) || ( input_port_right == nullptr ) || ( output_port_left == nullptr ) || ( output_port_right == nullptr ) ) { throw CGenErr ( tr ( "The Jack port registering failed." ) ); } @@ -98,8 +93,7 @@ void CSound::OpenJack ( const bool bNoAutoJackConnect, // optional MIDI initialization if ( iCtrlMIDIChannel != INVALID_MIDI_CH ) { - input_port_midi = jack_port_register ( pJackClient, "input midi", - JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0 ); + input_port_midi = jack_port_register ( pJackClient, "input midi", JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0 ); if ( input_port_midi == nullptr ) { @@ -126,10 +120,7 @@ void CSound::OpenJack ( const bool bNoAutoJackConnect, const char** ports; // try to connect physical input ports - if ( ( ports = jack_get_ports ( pJackClient, - nullptr, - nullptr, - JackPortIsPhysical | JackPortIsOutput ) ) != nullptr ) + if ( ( ports = jack_get_ports ( pJackClient, nullptr, nullptr, JackPortIsPhysical | JackPortIsOutput ) ) != nullptr ) { jack_connect ( pJackClient, ports[0], jack_port_name ( input_port_left ) ); @@ -143,10 +134,7 @@ void CSound::OpenJack ( const bool bNoAutoJackConnect, } // try to connect physical output ports - if ( ( ports = jack_get_ports ( pJackClient, - nullptr, - nullptr, - JackPortIsPhysical | JackPortIsInput ) ) != nullptr ) + if ( ( ports = jack_get_ports ( pJackClient, nullptr, nullptr, JackPortIsPhysical | JackPortIsInput ) ) != nullptr ) { jack_connect ( pJackClient, jack_port_name ( output_port_left ), ports[0] ); @@ -162,14 +150,14 @@ void CSound::OpenJack ( const bool bNoAutoJackConnect, // input latency jack_latency_range_t latrange; latrange.min = 0; - latrange.max = 0 ; + latrange.max = 0; jack_port_get_latency_range ( input_port_left, JackCaptureLatency, &latrange ); int inLatency = latrange.min; // be optimistic - // output latency - latrange.min = 0; - latrange.max = 0 ; + // output latency + latrange.min = 0; + latrange.max = 0; jack_port_get_latency_range ( output_port_left, JackPlaybackLatency, &latrange ); int outLatency = latrange.min; // be optimistic @@ -210,25 +198,25 @@ void CSound::Stop() int CSound::Init ( const int /* iNewPrefMonoBufferSize */ ) { -// clang-format off + // clang-format off // try setting buffer size // TODO seems not to work! -> no audio after this operation! // Doesn't this give an infinite loop? The set buffer size function will call our // registered callback which calls "EmitReinitRequestSignal()". In that function // this CSound::Init() function is called... //jack_set_buffer_size ( pJackClient, iNewPrefMonoBufferSize ); -// clang-format on + // clang-format on // without a Jack server, Jamulus makes no sense to run, throw an error message if ( bJackWasShutDown ) { throw CGenErr ( tr ( "The Jack server was shut down. This software " - "requires a Jack server to run. Try to restart the software to " - "solve the issue." ) ); + "requires a Jack server to run. Try to restart the software to " + "solve the issue." ) ); } // get actual buffer size - iJACKBufferSizeMono = jack_get_buffer_size ( pJackClient ); + iJACKBufferSizeMono = jack_get_buffer_size ( pJackClient ); // init base class CSoundBase::Init ( iJACKBufferSizeMono ); @@ -242,7 +230,6 @@ int CSound::Init ( const int /* iNewPrefMonoBufferSize */ ) return iJACKBufferSizeMono; } - // JACK callbacks -------------------------------------------------------------- int CSound::process ( jack_nframes_t nframes, void* arg ) { @@ -255,13 +242,9 @@ int CSound::process ( jack_nframes_t nframes, void* arg ) if ( pSound->IsRunning() && ( nframes == static_cast ( pSound->iJACKBufferSizeMono ) ) ) { // get input data pointer - jack_default_audio_sample_t* in_left = - (jack_default_audio_sample_t*) jack_port_get_buffer ( - pSound->input_port_left, nframes ); + jack_default_audio_sample_t* in_left = (jack_default_audio_sample_t*) jack_port_get_buffer ( pSound->input_port_left, nframes ); - jack_default_audio_sample_t* in_right = - (jack_default_audio_sample_t*) jack_port_get_buffer ( - pSound->input_port_right, nframes ); + jack_default_audio_sample_t* in_right = (jack_default_audio_sample_t*) jack_port_get_buffer ( pSound->input_port_right, nframes ); // copy input audio data if ( ( in_left != nullptr ) && ( in_right != nullptr ) ) @@ -277,48 +260,34 @@ int CSound::process ( jack_nframes_t nframes, void* arg ) pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo ); // get output data pointer - jack_default_audio_sample_t* out_left = - (jack_default_audio_sample_t*) jack_port_get_buffer ( - pSound->output_port_left, nframes ); + jack_default_audio_sample_t* out_left = (jack_default_audio_sample_t*) jack_port_get_buffer ( pSound->output_port_left, nframes ); - jack_default_audio_sample_t* out_right = - (jack_default_audio_sample_t*) jack_port_get_buffer ( - pSound->output_port_right, nframes ); + jack_default_audio_sample_t* out_right = (jack_default_audio_sample_t*) jack_port_get_buffer ( pSound->output_port_right, nframes ); // copy output data if ( ( out_left != nullptr ) && ( out_right != nullptr ) ) { for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ ) { - out_left[i] = (jack_default_audio_sample_t) - pSound->vecsTmpAudioSndCrdStereo[2 * i] / _MAXSHORT; + out_left[i] = (jack_default_audio_sample_t) pSound->vecsTmpAudioSndCrdStereo[2 * i] / _MAXSHORT; - out_right[i] = (jack_default_audio_sample_t) - pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] / _MAXSHORT; + out_right[i] = (jack_default_audio_sample_t) pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] / _MAXSHORT; } } } else { // get output data pointer - jack_default_audio_sample_t* out_left = - (jack_default_audio_sample_t*) jack_port_get_buffer ( - pSound->output_port_left, nframes ); + jack_default_audio_sample_t* out_left = (jack_default_audio_sample_t*) jack_port_get_buffer ( pSound->output_port_left, nframes ); - jack_default_audio_sample_t* out_right = - (jack_default_audio_sample_t*) jack_port_get_buffer ( - pSound->output_port_right, nframes ); + jack_default_audio_sample_t* out_right = (jack_default_audio_sample_t*) jack_port_get_buffer ( pSound->output_port_right, nframes ); // clear output data if ( ( out_left != nullptr ) && ( out_right != nullptr ) ) { - memset ( out_left, - 0, - sizeof ( jack_default_audio_sample_t ) * nframes ); + memset ( out_left, 0, sizeof ( jack_default_audio_sample_t ) * nframes ); - memset ( out_right, - 0, - sizeof ( jack_default_audio_sample_t ) * nframes ); + memset ( out_right, 0, sizeof ( jack_default_audio_sample_t ) * nframes ); } } @@ -338,9 +307,9 @@ int CSound::process ( jack_nframes_t nframes, void* arg ) jack_midi_event_get ( &in_event, in_midi, j ); // copy packet and send it to the MIDI parser -// clang-format off + // clang-format off // TODO do not call malloc in real-time callback -// clang-format on + // clang-format on CVector vMIDIPaketBytes ( in_event.size ); for ( i = 0; i < static_cast ( in_event.size ); i++ ) @@ -352,7 +321,7 @@ int CSound::process ( jack_nframes_t nframes, void* arg ) } } - return 0; // zero on success, non-zero on error + return 0; // zero on success, non-zero on error } int CSound::bufferSizeCallback ( jack_nframes_t, void* arg ) diff --git a/linux/sound.h b/linux/sound.h old mode 100755 new mode 100644 index 6acdb9c016..659cf7b8b4 --- a/linux/sound.h +++ b/linux/sound.h @@ -25,8 +25,8 @@ #pragma once #ifndef JACK_REPLACES_ASIO // these headers are not available in Windows OS -# include -# include +# include +# include #endif #include #include @@ -39,21 +39,19 @@ #include "global.h" #if WITH_JACK -# include -# include +# include +# include #endif - /* Definitions ****************************************************************/ -#define NUM_IN_OUT_CHANNELS 2 // always stereo +#define NUM_IN_OUT_CHANNELS 2 // always stereo // the number of periods is critical for latency -#define NUM_PERIOD_BLOCKS_IN 2 -#define NUM_PERIOD_BLOCKS_OUT 1 - -#define MAX_SND_BUF_IN 200 -#define MAX_SND_BUF_OUT 200 +#define NUM_PERIOD_BLOCKS_IN 2 +#define NUM_PERIOD_BLOCKS_OUT 1 +#define MAX_SND_BUF_IN 200 +#define MAX_SND_BUF_OUT 200 /* Classes ********************************************************************/ #if WITH_JACK @@ -62,13 +60,15 @@ class CSound : public CSoundBase Q_OBJECT public: - CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), + CSound ( void ( *fpNewProcessCallback ) ( CVector& psData, void* arg ), void* arg, const QString& strMIDISetup, const bool bNoAutoJackConnect, const QString& strJackClientName ) : CSoundBase ( "Jack", fpNewProcessCallback, arg, strMIDISetup ), - iJACKBufferSizeMono ( 0 ), bJackWasShutDown ( false ), fInOutLatencyMs ( 0.0f ) + iJACKBufferSizeMono ( 0 ), + bJackWasShutDown ( false ), + fInOutLatencyMs ( 0.0f ) { QString strJackName = QString ( APP_NAME ); @@ -95,21 +95,20 @@ class CSound : public CSoundBase int iJACKBufferSizeStero; bool bJackWasShutDown; - jack_port_t* input_port_left; - jack_port_t* input_port_right; - jack_port_t* output_port_left; - jack_port_t* output_port_right; - jack_port_t* input_port_midi; + jack_port_t* input_port_left; + jack_port_t* input_port_right; + jack_port_t* output_port_left; + jack_port_t* output_port_right; + jack_port_t* input_port_midi; protected: - void OpenJack ( const bool bNoAutoJackConnect, - const char* jackClientName ); + void OpenJack ( const bool bNoAutoJackConnect, const char* jackClientName ); void CloseJack(); // callbacks static int process ( jack_nframes_t nframes, void* arg ); - static int bufferSizeCallback ( jack_nframes_t, void *arg ); + static int bufferSizeCallback ( jack_nframes_t, void* arg ); static void shutdownCallback ( void* ); jack_client_t* pJackClient; @@ -117,29 +116,41 @@ class CSound : public CSoundBase }; #else // no sound -> dummy class definition -#include "server.h" +# include "server.h" class CSound : public CSoundBase { Q_OBJECT public: - CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* pParg ), + CSound ( void ( *fpNewProcessCallback ) ( CVector& psData, void* pParg ), void* pParg, const QString& strMIDISetup, - const bool , + const bool, const QString& ) : CSoundBase ( "nosound", fpNewProcessCallback, pParg, strMIDISetup ), - HighPrecisionTimer ( true ) { HighPrecisionTimer.Start(); - QObject::connect ( &HighPrecisionTimer, &CHighPrecisionTimer::timeout, - this, &CSound::OnTimer ); } + HighPrecisionTimer ( true ) + { + HighPrecisionTimer.Start(); + QObject::connect ( &HighPrecisionTimer, &CHighPrecisionTimer::timeout, this, &CSound::OnTimer ); + } virtual ~CSound() {} - virtual int Init ( const int iNewPrefMonoBufferSize ) { CSoundBase::Init ( iNewPrefMonoBufferSize ); - vecsTemp.Init ( 2 * iNewPrefMonoBufferSize ); - return iNewPrefMonoBufferSize; } + virtual int Init ( const int iNewPrefMonoBufferSize ) + { + CSoundBase::Init ( iNewPrefMonoBufferSize ); + vecsTemp.Init ( 2 * iNewPrefMonoBufferSize ); + return iNewPrefMonoBufferSize; + } CHighPrecisionTimer HighPrecisionTimer; CVector vecsTemp; public slots: - void OnTimer() { vecsTemp.Reset ( 0 ); if ( IsRunning() ) { ProcessCallback ( vecsTemp ); } } + void OnTimer() + { + vecsTemp.Reset ( 0 ); + if ( IsRunning() ) + { + ProcessCallback ( vecsTemp ); + } + } }; #endif // WITH_JACK diff --git a/mac/activity.h b/mac/activity.h index f4c2f7dbc4..9e3ee084c2 100644 --- a/mac/activity.h +++ b/mac/activity.h @@ -33,13 +33,13 @@ class CActivityId; class CActivity { private: - CActivityId *pActivity; - + CActivityId* pActivity; + public: CActivity(); - + ~CActivity(); - + void BeginActivity(); void EndActivity(); diff --git a/mac/sound.cpp b/mac/sound.cpp old mode 100755 new mode 100644 index b758abd759..574a09929d --- a/mac/sound.cpp +++ b/mac/sound.cpp @@ -24,12 +24,11 @@ #include "sound.h" - /* Implementation *************************************************************/ -CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), +CSound::CSound ( void ( *fpNewProcessCallback ) ( CVector& psData, void* arg ), void* arg, const QString& strMIDISetup, - const bool , + const bool, const QString& ) : CSoundBase ( "CoreAudio", fpNewProcessCallback, arg, strMIDISetup ), midiInPortRef ( static_cast ( NULL ) ) @@ -43,16 +42,9 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData // following lines of code: // tell the HAL to use the current thread as it's run loop CFRunLoopRef theRunLoop = CFRunLoopGetCurrent(); - AudioObjectPropertyAddress property = { kAudioHardwarePropertyRunLoop, - kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster }; + AudioObjectPropertyAddress property = { kAudioHardwarePropertyRunLoop, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; - AudioObjectSetPropertyData ( kAudioObjectSystemObject, - &property, - 0, - NULL, - sizeof ( CFRunLoopRef ), - &theRunLoop ); + AudioObjectSetPropertyData ( kAudioObjectSystemObject, &property, 0, NULL, sizeof ( CFRunLoopRef ), &theRunLoop ); // initial query for available input/output sound devices in the system GetAvailableInOutDevices(); @@ -69,7 +61,6 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData iSelOutputLeftChannel = 0; iSelOutputRightChannel = 0; - // Optional MIDI initialization -------------------------------------------- if ( iCtrlMIDIChannel != INVALID_MIDI_CH ) { @@ -84,7 +75,7 @@ CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData for ( int i = 0; i < iNMIDISources; i++ ) { MIDIEndpointRef src = MIDIGetSource ( i ); - MIDIPortConnectSource ( midiInPortRef, src, NULL ) ; + MIDIPortConnectSource ( midiInPortRef, src, NULL ); } } } @@ -100,21 +91,12 @@ void CSound::GetAvailableInOutDevices() // first get property size of devices array and allocate memory stPropertyAddress.mSelector = kAudioHardwarePropertyDevices; - AudioObjectGetPropertyDataSize ( kAudioObjectSystemObject, - &stPropertyAddress, - 0, - NULL, - &iPropertySize ); + AudioObjectGetPropertyDataSize ( kAudioObjectSystemObject, &stPropertyAddress, 0, NULL, &iPropertySize ); CVector vAudioDevices ( iPropertySize ); // now actually query all devices present in the system - AudioObjectGetPropertyData ( kAudioObjectSystemObject, - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &vAudioDevices[0] ); + AudioObjectGetPropertyData ( kAudioObjectSystemObject, &stPropertyAddress, 0, NULL, &iPropertySize, &vAudioDevices[0] ); // calculate device count based on size of returned data array const UInt32 iDeviceCount = iPropertySize / sizeof ( AudioDeviceID ); @@ -126,12 +108,7 @@ void CSound::GetAvailableInOutDevices() iPropertySize = sizeof ( AudioDeviceID ); stPropertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice; - if ( AudioObjectGetPropertyData ( kAudioObjectSystemObject, - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &audioInputDevice[lNumDevs] ) ) + if ( AudioObjectGetPropertyData ( kAudioObjectSystemObject, &stPropertyAddress, 0, NULL, &iPropertySize, &audioInputDevice[lNumDevs] ) ) { throw CGenErr ( tr ( "CoreAudio input AudioHardwareGetProperty call failed. " "It seems that no sound card is available in the system." ) ); @@ -140,12 +117,7 @@ void CSound::GetAvailableInOutDevices() iPropertySize = sizeof ( AudioDeviceID ); stPropertyAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice; - if ( AudioObjectGetPropertyData ( kAudioObjectSystemObject, - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &audioOutputDevice[lNumDevs] ) ) + if ( AudioObjectGetPropertyData ( kAudioObjectSystemObject, &stPropertyAddress, 0, NULL, &iPropertySize, &audioOutputDevice[lNumDevs] ) ) { throw CGenErr ( tr ( "CoreAudio output AudioHardwareGetProperty call failed. " "It seems that no sound card is available in the system." ) ); @@ -170,23 +142,15 @@ void CSound::GetAvailableInOutDevices() bool bIsOutput_i; bool bIsOutput_j; - GetAudioDeviceInfos ( vAudioDevices[i], - strDeviceName_i, - bIsInput_i, - bIsOutput_i ); + GetAudioDeviceInfos ( vAudioDevices[i], strDeviceName_i, bIsInput_i, bIsOutput_i ); - GetAudioDeviceInfos ( vAudioDevices[j], - strDeviceName_j, - bIsInput_j, - bIsOutput_j ); + GetAudioDeviceInfos ( vAudioDevices[j], strDeviceName_j, bIsInput_j, bIsOutput_j ); // check if i device is input and j device is output and that we are // in range if ( bIsInput_i && bIsOutput_j && ( lNumDevs < MAX_NUMBER_SOUND_CARDS ) ) { - strDriverNames[lNumDevs] = "in: " + - strDeviceName_i + "/out: " + - strDeviceName_j; + strDriverNames[lNumDevs] = "in: " + strDeviceName_i + "/out: " + strDeviceName_j; // store audio device IDs audioInputDevice[lNumDevs] = vAudioDevices[i]; @@ -198,10 +162,7 @@ void CSound::GetAvailableInOutDevices() } } -void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID, - QString& strDeviceName, - bool& bIsInput, - bool& bIsOutput ) +void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID, QString& strDeviceName, bool& bIsInput, bool& bIsOutput ) { UInt32 iPropertySize; AudioObjectPropertyAddress stPropertyAddress; @@ -218,11 +179,7 @@ void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID, iPropertySize = 0; stPropertyAddress.mScope = kAudioDevicePropertyScopeInput; - AudioObjectGetPropertyDataSize ( DeviceID, - &stPropertyAddress, - 0, - NULL, - &iPropertySize ); + AudioObjectGetPropertyDataSize ( DeviceID, &stPropertyAddress, 0, NULL, &iPropertySize ); bIsInput = ( iPropertySize > 0 ); // check if any input streams are available @@ -230,11 +187,7 @@ void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID, iPropertySize = 0; stPropertyAddress.mScope = kAudioDevicePropertyScopeOutput; - AudioObjectGetPropertyDataSize ( DeviceID, - &stPropertyAddress, - 0, - NULL, - &iPropertySize ); + AudioObjectGetPropertyDataSize ( DeviceID, &stPropertyAddress, 0, NULL, &iPropertySize ); bIsOutput = ( iPropertySize > 0 ); // check if any output streams are available @@ -245,12 +198,7 @@ void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID, stPropertyAddress.mScope = kAudioObjectPropertyScopeGlobal; iPropertySize = sizeof ( CFStringRef ); - AudioObjectGetPropertyData ( DeviceID, - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &sPropertyStringValue ); + AudioObjectGetPropertyData ( DeviceID, &stPropertyAddress, 0, NULL, &iPropertySize, &sPropertyStringValue ); // convert string if ( !ConvertCFStringToQString ( sPropertyStringValue, strDeviceName ) ) @@ -260,8 +208,7 @@ void CSound::GetAudioDeviceInfos ( const AudioDeviceID DeviceID, } } -int CSound::CountChannels ( AudioDeviceID devID, - bool isInput ) +int CSound::CountChannels ( AudioDeviceID devID, bool isInput ) { OSStatus err; UInt32 propSize; @@ -280,13 +227,11 @@ int CSound::CountChannels ( AudioDeviceID devID, // in that case we assume that each input channel has its own buffer AudioObjectPropertyScope theScope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; - AudioObjectPropertyAddress theAddress = { kAudioDevicePropertyStreamConfiguration, - theScope, - 0 }; + AudioObjectPropertyAddress theAddress = { kAudioDevicePropertyStreamConfiguration, theScope, 0 }; AudioObjectGetPropertyDataSize ( devID, &theAddress, 0, NULL, &propSize ); - AudioBufferList *buflist = (AudioBufferList*) malloc ( propSize ); + AudioBufferList* buflist = (AudioBufferList*) malloc ( propSize ); err = AudioObjectGetPropertyData ( devID, &theAddress, 0, NULL, &propSize, buflist ); @@ -356,41 +301,23 @@ QString CSound::LoadAndInitializeDriver ( QString strDriverName, bool ) // unregister callback functions for device property changes stPropertyAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice; - AudioObjectRemovePropertyListener ( kAudioObjectSystemObject, - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectRemovePropertyListener ( kAudioObjectSystemObject, &stPropertyAddress, deviceNotification, this ); stPropertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice; - AudioObjectRemovePropertyListener ( kAudioObjectSystemObject, - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectRemovePropertyListener ( kAudioObjectSystemObject, &stPropertyAddress, deviceNotification, this ); stPropertyAddress.mSelector = kAudioDevicePropertyDeviceHasChanged; - AudioObjectRemovePropertyListener ( audioOutputDevice[lCurDev], - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectRemovePropertyListener ( audioOutputDevice[lCurDev], &stPropertyAddress, deviceNotification, this ); - AudioObjectRemovePropertyListener ( audioInputDevice[lCurDev], - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectRemovePropertyListener ( audioInputDevice[lCurDev], &stPropertyAddress, deviceNotification, this ); stPropertyAddress.mSelector = kAudioDevicePropertyDeviceIsAlive; - AudioObjectRemovePropertyListener ( audioOutputDevice[lCurDev], - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectRemovePropertyListener ( audioOutputDevice[lCurDev], &stPropertyAddress, deviceNotification, this ); - AudioObjectRemovePropertyListener ( audioInputDevice[lCurDev], - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectRemovePropertyListener ( audioInputDevice[lCurDev], &stPropertyAddress, deviceNotification, this ); } // store ID of selected driver if initialization was successful @@ -405,47 +332,29 @@ QString CSound::LoadAndInitializeDriver ( QString strDriverName, bool ) // setup callbacks for device property changes stPropertyAddress.mSelector = kAudioDevicePropertyDeviceHasChanged; - AudioObjectAddPropertyListener ( audioInputDevice[lCurDev], - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectAddPropertyListener ( audioInputDevice[lCurDev], &stPropertyAddress, deviceNotification, this ); - AudioObjectAddPropertyListener ( audioOutputDevice[lCurDev], - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectAddPropertyListener ( audioOutputDevice[lCurDev], &stPropertyAddress, deviceNotification, this ); stPropertyAddress.mSelector = kAudioDevicePropertyDeviceIsAlive; - AudioObjectAddPropertyListener ( audioInputDevice[lCurDev], - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectAddPropertyListener ( audioInputDevice[lCurDev], &stPropertyAddress, deviceNotification, this ); - AudioObjectAddPropertyListener ( audioOutputDevice[lCurDev], - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectAddPropertyListener ( audioOutputDevice[lCurDev], &stPropertyAddress, deviceNotification, this ); stPropertyAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice; - AudioObjectAddPropertyListener ( kAudioObjectSystemObject, - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectAddPropertyListener ( kAudioObjectSystemObject, &stPropertyAddress, deviceNotification, this ); stPropertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice; - AudioObjectAddPropertyListener ( kAudioObjectSystemObject, - &stPropertyAddress, - deviceNotification, - this ); + AudioObjectAddPropertyListener ( kAudioObjectSystemObject, &stPropertyAddress, deviceNotification, this ); // the device has changed, per definition we reset the channel // mapping to the defaults (first two available channels) - SetLeftInputChannel ( 0 ); - SetRightInputChannel ( 1 ); - SetLeftOutputChannel ( 0 ); + SetLeftInputChannel ( 0 ); + SetRightInputChannel ( 1 ); + SetLeftOutputChannel ( 0 ); SetRightOutputChannel ( 1 ); // store the current name of the driver @@ -458,25 +367,20 @@ QString CSound::LoadAndInitializeDriver ( QString strDriverName, bool ) QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) { UInt32 iPropertySize; - AudioStreamBasicDescription CurDevStreamFormat; + AudioStreamBasicDescription CurDevStreamFormat; Float64 inputSampleRate = 0; Float64 outputSampleRate = 0; const Float64 fSystemSampleRate = static_cast ( SYSTEM_SAMPLE_RATE_HZ ); AudioObjectPropertyAddress stPropertyAddress; - stPropertyAddress.mScope = kAudioObjectPropertyScopeGlobal; - stPropertyAddress.mElement = kAudioObjectPropertyElementMaster; + stPropertyAddress.mScope = kAudioObjectPropertyScopeGlobal; + stPropertyAddress.mElement = kAudioObjectPropertyElementMaster; // check input device sample rate stPropertyAddress.mSelector = kAudioDevicePropertyNominalSampleRate; iPropertySize = sizeof ( Float64 ); - if ( AudioObjectGetPropertyData ( audioInputDevice[iDriverIdx], - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &inputSampleRate ) ) + if ( AudioObjectGetPropertyData ( audioInputDevice[iDriverIdx], &stPropertyAddress, 0, NULL, &iPropertySize, &inputSampleRate ) ) { return QString ( tr ( "The audio input device is no longer available." ) ); } @@ -484,29 +388,21 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) if ( inputSampleRate != fSystemSampleRate ) { // try to change the sample rate - if ( AudioObjectSetPropertyData ( audioInputDevice[iDriverIdx], - &stPropertyAddress, - 0, - NULL, - sizeof ( Float64 ), - &fSystemSampleRate ) != noErr ) + if ( AudioObjectSetPropertyData ( audioInputDevice[iDriverIdx], &stPropertyAddress, 0, NULL, sizeof ( Float64 ), &fSystemSampleRate ) != + noErr ) { return QString ( tr ( "Current system audio input device sample " - "rate of %1 Hz is not supported. Please open the Audio-MIDI-Setup in " - "Applications->Utilities and try to set a sample rate of %2 Hz." ) ).arg ( - static_cast ( inputSampleRate ) ).arg ( SYSTEM_SAMPLE_RATE_HZ ); + "rate of %1 Hz is not supported. Please open the Audio-MIDI-Setup in " + "Applications->Utilities and try to set a sample rate of %2 Hz." ) ) + .arg ( static_cast ( inputSampleRate ) ) + .arg ( SYSTEM_SAMPLE_RATE_HZ ); } } // check output device sample rate iPropertySize = sizeof ( Float64 ); - if ( AudioObjectGetPropertyData ( audioOutputDevice[iDriverIdx], - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &outputSampleRate ) ) + if ( AudioObjectGetPropertyData ( audioOutputDevice[iDriverIdx], &stPropertyAddress, 0, NULL, &iPropertySize, &outputSampleRate ) ) { return QString ( tr ( "The audio output device is no longer available." ) ); } @@ -514,17 +410,14 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) if ( outputSampleRate != fSystemSampleRate ) { // try to change the sample rate - if ( AudioObjectSetPropertyData ( audioOutputDevice[iDriverIdx], - &stPropertyAddress, - 0, - NULL, - sizeof ( Float64 ), - &fSystemSampleRate ) != noErr ) + if ( AudioObjectSetPropertyData ( audioOutputDevice[iDriverIdx], &stPropertyAddress, 0, NULL, sizeof ( Float64 ), &fSystemSampleRate ) != + noErr ) { return QString ( tr ( "Current system audio output device sample " - "rate of %1 Hz is not supported. Please open the Audio-MIDI-Setup in " - "Applications->Utilities and try to set a sample rate of %2 Hz." ) ).arg ( - static_cast ( outputSampleRate ) ).arg ( SYSTEM_SAMPLE_RATE_HZ ); + "rate of %1 Hz is not supported. Please open the Audio-MIDI-Setup in " + "Applications->Utilities and try to set a sample rate of %2 Hz." ) ) + .arg ( static_cast ( outputSampleRate ) ) + .arg ( SYSTEM_SAMPLE_RATE_HZ ); } } @@ -533,20 +426,11 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) stPropertyAddress.mSelector = kAudioDevicePropertyStreams; stPropertyAddress.mScope = kAudioObjectPropertyScopeInput; - AudioObjectGetPropertyDataSize ( audioInputDevice[iDriverIdx], - &stPropertyAddress, - 0, - NULL, - &iPropertySize ); + AudioObjectGetPropertyDataSize ( audioInputDevice[iDriverIdx], &stPropertyAddress, 0, NULL, &iPropertySize ); CVector vInputStreamIDList ( iPropertySize ); - AudioObjectGetPropertyData ( audioInputDevice[iDriverIdx], - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &vInputStreamIDList[0] ); + AudioObjectGetPropertyData ( audioInputDevice[iDriverIdx], &stPropertyAddress, 0, NULL, &iPropertySize, &vInputStreamIDList[0] ); const AudioStreamID inputStreamID = vInputStreamIDList[0]; @@ -555,20 +439,11 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) stPropertyAddress.mSelector = kAudioDevicePropertyStreams; stPropertyAddress.mScope = kAudioObjectPropertyScopeOutput; - AudioObjectGetPropertyDataSize ( audioOutputDevice[iDriverIdx], - &stPropertyAddress, - 0, - NULL, - &iPropertySize ); + AudioObjectGetPropertyDataSize ( audioOutputDevice[iDriverIdx], &stPropertyAddress, 0, NULL, &iPropertySize ); CVector vOutputStreamIDList ( iPropertySize ); - AudioObjectGetPropertyData ( audioOutputDevice[iDriverIdx], - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &vOutputStreamIDList[0] ); + AudioObjectGetPropertyData ( audioOutputDevice[iDriverIdx], &stPropertyAddress, 0, NULL, &iPropertySize, &vOutputStreamIDList[0] ); const AudioStreamID outputStreamID = vOutputStreamIDList[0]; @@ -581,17 +456,10 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) stPropertyAddress.mSelector = kAudioStreamPropertyVirtualFormat; stPropertyAddress.mScope = kAudioObjectPropertyScopeGlobal; - AudioObjectGetPropertyData ( inputStreamID, - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &CurDevStreamFormat ); - - if ( ( CurDevStreamFormat.mFormatID != kAudioFormatLinearPCM ) || - ( CurDevStreamFormat.mFramesPerPacket != 1 ) || - ( CurDevStreamFormat.mBitsPerChannel != 32 ) || - ( !( CurDevStreamFormat.mFormatFlags & kAudioFormatFlagIsFloat ) ) || + AudioObjectGetPropertyData ( inputStreamID, &stPropertyAddress, 0, NULL, &iPropertySize, &CurDevStreamFormat ); + + if ( ( CurDevStreamFormat.mFormatID != kAudioFormatLinearPCM ) || ( CurDevStreamFormat.mFramesPerPacket != 1 ) || + ( CurDevStreamFormat.mBitsPerChannel != 32 ) || ( !( CurDevStreamFormat.mFormatFlags & kAudioFormatFlagIsFloat ) ) || ( !( CurDevStreamFormat.mFormatFlags & kAudioFormatFlagIsPacked ) ) ) { return tr ( "The audio input stream format for this audio device is " @@ -599,17 +467,10 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) } // check the output - AudioObjectGetPropertyData ( outputStreamID, - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &CurDevStreamFormat ); - - if ( ( CurDevStreamFormat.mFormatID != kAudioFormatLinearPCM ) || - ( CurDevStreamFormat.mFramesPerPacket != 1 ) || - ( CurDevStreamFormat.mBitsPerChannel != 32 ) || - ( !( CurDevStreamFormat.mFormatFlags & kAudioFormatFlagIsFloat ) ) || + AudioObjectGetPropertyData ( outputStreamID, &stPropertyAddress, 0, NULL, &iPropertySize, &CurDevStreamFormat ); + + if ( ( CurDevStreamFormat.mFormatID != kAudioFormatLinearPCM ) || ( CurDevStreamFormat.mFramesPerPacket != 1 ) || + ( CurDevStreamFormat.mBitsPerChannel != 32 ) || ( !( CurDevStreamFormat.mFormatFlags & kAudioFormatFlagIsFloat ) ) || ( !( CurDevStreamFormat.mFormatFlags & kAudioFormatFlagIsPacked ) ) ) { return tr ( "The audio output stream format for this audio device is " @@ -640,23 +501,16 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) stPropertyAddress.mScope = kAudioObjectPropertyScopeInput; iPropertySize = sizeof ( CFStringRef ); - AudioObjectGetPropertyData ( audioInputDevice[iDriverIdx], - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &sPropertyStringValue ); + AudioObjectGetPropertyData ( audioInputDevice[iDriverIdx], &stPropertyAddress, 0, NULL, &iPropertySize, &sPropertyStringValue ); // convert string - const bool bConvOK = ConvertCFStringToQString ( sPropertyStringValue, - sChannelNamesInput[iCurInCH] ); + const bool bConvOK = ConvertCFStringToQString ( sPropertyStringValue, sChannelNamesInput[iCurInCH] ); // add the "[n]:" at the beginning as is in the Audio-Midi-Setup if ( !bConvOK || ( iPropertySize == 0 ) ) { // use a default name in case there was an error or the name is empty - sChannelNamesInput[iCurInCH] = - QString ( "%1: Channel %1" ).arg ( iCurInCH + 1 ); + sChannelNamesInput[iCurInCH] = QString ( "%1: Channel %1" ).arg ( iCurInCH + 1 ); } else { @@ -674,23 +528,16 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) stPropertyAddress.mScope = kAudioObjectPropertyScopeOutput; iPropertySize = sizeof ( CFStringRef ); - AudioObjectGetPropertyData ( audioOutputDevice[iDriverIdx], - &stPropertyAddress, - 0, - NULL, - &iPropertySize, - &sPropertyStringValue ); + AudioObjectGetPropertyData ( audioOutputDevice[iDriverIdx], &stPropertyAddress, 0, NULL, &iPropertySize, &sPropertyStringValue ); // convert string - const bool bConvOK = ConvertCFStringToQString ( sPropertyStringValue, - sChannelNamesOutput[iCurOutCH] ); + const bool bConvOK = ConvertCFStringToQString ( sPropertyStringValue, sChannelNamesOutput[iCurOutCH] ); // add the "[n]:" at the beginning as is in the Audio-Midi-Setup if ( !bConvOK || ( iPropertySize == 0 ) ) { // use a default name in case there was an error or the name is empty - sChannelNamesOutput[iCurOutCH] = - QString ( "%1: Channel %1" ).arg ( iCurOutCH + 1 ); + sChannelNamesOutput[iCurOutCH] = QString ( "%1: Channel %1" ).arg ( iCurOutCH + 1 ); } else { @@ -713,8 +560,7 @@ QString CSound::CheckDeviceCapabilities ( const int iDriverIdx ) if ( iSelAddCH >= 0 ) { // for mixed channels, show both audio channel names to be mixed - sChannelNamesInput[iCh] = - sChannelNamesInput[iSelCH] + " + " + sChannelNamesInput[iSelAddCH]; + sChannelNamesInput[iCh] = sChannelNamesInput[iSelCH] + " + " + sChannelNamesInput[iSelAddCH]; } } } @@ -734,7 +580,7 @@ void CSound::UpdateChSelection() // channel index in the buffer, note that each buffer can have a different // number of interleaved channels int iChCnt; - int iSelCHLeft, iSelAddCHLeft; + int iSelCHLeft, iSelAddCHLeft; int iSelCHRight, iSelAddCHRight; // initialize all buffer indexes with an invalid value @@ -746,7 +592,7 @@ void CSound::UpdateChSelection() iSelOutBufferRight = INVALID_INDEX; // input - GetSelCHAndAddCH ( iSelInputLeftChannel, iNumInChan, iSelCHLeft, iSelAddCHLeft ); + GetSelCHAndAddCH ( iSelInputLeftChannel, iNumInChan, iSelCHLeft, iSelAddCHLeft ); GetSelCHAndAddCH ( iSelInputRightChannel, iNumInChan, iSelCHRight, iSelAddCHRight ); iChCnt = 0; @@ -781,7 +627,7 @@ void CSound::UpdateChSelection() } // output - GetSelCHAndAddCH ( iSelOutputLeftChannel, iNumOutChan, iSelCHLeft, iSelAddCHLeft ); + GetSelCHAndAddCH ( iSelOutputLeftChannel, iNumOutChan, iSelCHLeft, iSelAddCHLeft ); GetSelCHAndAddCH ( iSelOutputRightChannel, iNumOutChan, iSelCHRight, iSelAddCHRight ); iChCnt = 0; @@ -804,7 +650,7 @@ void CSound::UpdateChSelection() } } -void CSound::SetLeftInputChannel ( const int iNewChan ) +void CSound::SetLeftInputChannel ( const int iNewChan ) { // apply parameter after input parameter check if ( ( iNewChan >= 0 ) && ( iNewChan < iNumInChanPlusAddChan ) ) @@ -824,7 +670,7 @@ void CSound::SetRightInputChannel ( const int iNewChan ) } } -void CSound::SetLeftOutputChannel ( const int iNewChan ) +void CSound::SetLeftOutputChannel ( const int iNewChan ) { // apply parameter after input parameter check if ( ( iNewChan >= 0 ) && ( iNewChan < iNumOutChan ) ) @@ -847,15 +693,9 @@ void CSound::SetRightOutputChannel ( const int iNewChan ) void CSound::Start() { // register the callback function for input and output - AudioDeviceCreateIOProcID ( audioInputDevice[lCurDev], - callbackIO, - this, - &audioInputProcID ); + AudioDeviceCreateIOProcID ( audioInputDevice[lCurDev], callbackIO, this, &audioInputProcID ); - AudioDeviceCreateIOProcID ( audioOutputDevice[lCurDev], - callbackIO, - this, - &audioOutputProcID ); + AudioDeviceCreateIOProcID ( audioOutputDevice[lCurDev], callbackIO, this, &audioOutputProcID ); // start the audio stream AudioDeviceStart ( audioInputDevice[lCurDev], audioInputProcID ); @@ -886,19 +726,17 @@ int CSound::Init ( const int iNewPrefMonoBufferSize ) // Error message string: in case buffer sizes on input and output cannot be // set to the same value const QString strErrBufSize = tr ( "The buffer sizes of the current " - "input and output audio device cannot be set to a common value. Please " - "choose other input/output audio devices in your system settings." ); + "input and output audio device cannot be set to a common value. Please " + "choose other input/output audio devices in your system settings." ); // try to set input buffer size - iActualMonoBufferSize = - SetBufferSize ( audioInputDevice[lCurDev], true, iNewPrefMonoBufferSize ); + iActualMonoBufferSize = SetBufferSize ( audioInputDevice[lCurDev], true, iNewPrefMonoBufferSize ); if ( iActualMonoBufferSize != static_cast ( iNewPrefMonoBufferSize ) ) { // try to set the input buffer size to the output so that we // have a matching pair - if ( SetBufferSize ( audioOutputDevice[lCurDev], false, iActualMonoBufferSize ) != - iActualMonoBufferSize ) + if ( SetBufferSize ( audioOutputDevice[lCurDev], false, iActualMonoBufferSize ) != iActualMonoBufferSize ) { throw CGenErr ( strErrBufSize ); } @@ -906,8 +744,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize ) else { // try to set output buffer size - if ( SetBufferSize ( audioOutputDevice[lCurDev], false, iNewPrefMonoBufferSize ) != - static_cast ( iNewPrefMonoBufferSize ) ) + if ( SetBufferSize ( audioOutputDevice[lCurDev], false, iNewPrefMonoBufferSize ) != static_cast ( iNewPrefMonoBufferSize ) ) { throw CGenErr ( strErrBufSize ); } @@ -928,9 +765,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize ) return iCoreAudioBufferSizeMono; } -UInt32 CSound::SetBufferSize ( AudioDeviceID& audioDeviceID, - const bool bIsInput, - UInt32 iPrefBufferSize ) +UInt32 CSound::SetBufferSize ( AudioDeviceID& audioDeviceID, const bool bIsInput, UInt32 iPrefBufferSize ) { AudioObjectPropertyAddress stPropertyAddress; stPropertyAddress.mSelector = kAudioDevicePropertyBufferFrameSize; @@ -949,40 +784,25 @@ UInt32 CSound::SetBufferSize ( AudioDeviceID& audioDeviceID, // first set the value UInt32 iSizeBufValue = sizeof ( UInt32 ); - AudioObjectSetPropertyData ( audioDeviceID, - &stPropertyAddress, - 0, - NULL, - iSizeBufValue, - &iPrefBufferSize ); + AudioObjectSetPropertyData ( audioDeviceID, &stPropertyAddress, 0, NULL, iSizeBufValue, &iPrefBufferSize ); // read back which value is actually used UInt32 iActualMonoBufferSize = 0; - AudioObjectGetPropertyData ( audioDeviceID, - &stPropertyAddress, - 0, - NULL, - &iSizeBufValue, - &iActualMonoBufferSize ); + AudioObjectGetPropertyData ( audioDeviceID, &stPropertyAddress, 0, NULL, &iSizeBufValue, &iActualMonoBufferSize ); return iActualMonoBufferSize; } -OSStatus CSound::deviceNotification ( AudioDeviceID, - UInt32, - const AudioObjectPropertyAddress* inAddresses, - void* inRefCon ) +OSStatus CSound::deviceNotification ( AudioDeviceID, UInt32, const AudioObjectPropertyAddress* inAddresses, void* inRefCon ) { CSound* pSound = static_cast ( inRefCon ); - if ( ( inAddresses->mSelector == kAudioDevicePropertyDeviceHasChanged ) || - ( inAddresses->mSelector == kAudioDevicePropertyDeviceIsAlive ) || + if ( ( inAddresses->mSelector == kAudioDevicePropertyDeviceHasChanged ) || ( inAddresses->mSelector == kAudioDevicePropertyDeviceIsAlive ) || ( inAddresses->mSelector == kAudioHardwarePropertyDefaultOutputDevice ) || ( inAddresses->mSelector == kAudioHardwarePropertyDefaultInputDevice ) ) { - if ( ( inAddresses->mSelector == kAudioDevicePropertyDeviceHasChanged ) || - ( inAddresses->mSelector == kAudioDevicePropertyDeviceIsAlive ) ) + if ( ( inAddresses->mSelector == kAudioDevicePropertyDeviceHasChanged ) || ( inAddresses->mSelector == kAudioDevicePropertyDeviceIsAlive ) ) { // if any property of the device has changed, do a full reload pSound->EmitReinitRequestSignal ( RS_RELOAD_RESTART_AND_INIT ); @@ -998,13 +818,13 @@ OSStatus CSound::deviceNotification ( AudioDeviceID, return noErr; } -OSStatus CSound::callbackIO ( AudioDeviceID inDevice, +OSStatus CSound::callbackIO ( AudioDeviceID inDevice, const AudioTimeStamp*, const AudioBufferList* inInputData, const AudioTimeStamp*, - AudioBufferList* outOutputData, + AudioBufferList* outOutputData, const AudioTimeStamp*, - void* inRefCon ) + void* inRefCon ) { CSound* pSound = static_cast ( inRefCon ); @@ -1030,14 +850,14 @@ OSStatus CSound::callbackIO ( AudioDeviceID inDevice, if ( ( inDevice == pSound->CurrentAudioInputDeviceID ) && inInputData && pSound->bRun ) { // check sizes (note that float32 has four bytes) - if ( ( iSelInBufferLeft >= 0 ) && - ( iSelInBufferLeft < static_cast ( inInputData->mNumberBuffers ) ) && - ( iSelInBufferRight >= 0 ) && + if ( ( iSelInBufferLeft >= 0 ) && ( iSelInBufferLeft < static_cast ( inInputData->mNumberBuffers ) ) && ( iSelInBufferRight >= 0 ) && ( iSelInBufferRight < static_cast ( inInputData->mNumberBuffers ) ) && ( iSelAddInBufferLeft < static_cast ( inInputData->mNumberBuffers ) ) && ( iSelAddInBufferRight < static_cast ( inInputData->mNumberBuffers ) ) && - ( inInputData->mBuffers[iSelInBufferLeft].mDataByteSize == static_cast ( vecNumInBufChan[iSelInBufferLeft] * iCoreAudioBufferSizeMono * 4 ) ) && - ( inInputData->mBuffers[iSelInBufferRight].mDataByteSize == static_cast ( vecNumInBufChan[iSelInBufferRight] * iCoreAudioBufferSizeMono * 4 ) ) ) + ( inInputData->mBuffers[iSelInBufferLeft].mDataByteSize == + static_cast ( vecNumInBufChan[iSelInBufferLeft] * iCoreAudioBufferSizeMono * 4 ) ) && + ( inInputData->mBuffers[iSelInBufferRight].mDataByteSize == + static_cast ( vecNumInBufChan[iSelInBufferRight] * iCoreAudioBufferSizeMono * 4 ) ) ) { Float32* pLeftData = static_cast ( inInputData->mBuffers[iSelInBufferLeft].mData ); Float32* pRightData = static_cast ( inInputData->mBuffers[iSelInBufferRight].mData ); @@ -1060,8 +880,8 @@ OSStatus CSound::callbackIO ( AudioDeviceID inDevice, for ( int i = 0; i < iCoreAudioBufferSizeMono; i++ ) { - pSound->vecsTmpAudioSndCrdStereo[2 * i] = Float2Short ( - pSound->vecsTmpAudioSndCrdStereo[2 * i] + pLeftData[iNumChanPerFrameLeft * i + iSelAddInInterlChLeft] * _MAXSHORT ); + pSound->vecsTmpAudioSndCrdStereo[2 * i] = Float2Short ( pSound->vecsTmpAudioSndCrdStereo[2 * i] + + pLeftData[iNumChanPerFrameLeft * i + iSelAddInInterlChLeft] * _MAXSHORT ); } } @@ -1089,35 +909,33 @@ OSStatus CSound::callbackIO ( AudioDeviceID inDevice, if ( ( inDevice == pSound->CurrentAudioOutputDeviceID ) && outOutputData && pSound->bRun ) { - // check sizes (note that float32 has four bytes) - if ( ( iSelOutBufferLeft >= 0 ) && - ( iSelOutBufferLeft < static_cast ( outOutputData->mNumberBuffers ) ) && - ( iSelOutBufferRight >= 0 ) && - ( iSelOutBufferRight < static_cast ( outOutputData->mNumberBuffers ) ) && - ( outOutputData->mBuffers[iSelOutBufferLeft].mDataByteSize == static_cast ( vecNumOutBufChan[iSelOutBufferLeft] * iCoreAudioBufferSizeMono * 4 ) ) && - ( outOutputData->mBuffers[iSelOutBufferRight].mDataByteSize == static_cast ( vecNumOutBufChan[iSelOutBufferRight] * iCoreAudioBufferSizeMono * 4 ) ) ) - { - Float32* pLeftData = static_cast ( outOutputData->mBuffers[iSelOutBufferLeft].mData ); - Float32* pRightData = static_cast ( outOutputData->mBuffers[iSelOutBufferRight].mData ); - int iNumChanPerFrameLeft = vecNumOutBufChan[iSelOutBufferLeft]; - int iNumChanPerFrameRight = vecNumOutBufChan[iSelOutBufferRight]; - - // copy output data - for ( int i = 0; i < iCoreAudioBufferSizeMono; i++ ) - { - // copy left and right channels separately - pLeftData[iNumChanPerFrameLeft * i + iSelOutInterlChLeft] = (Float32) pSound->vecsTmpAudioSndCrdStereo[2 * i] / _MAXSHORT; - pRightData[iNumChanPerFrameRight * i + iSelOutInterlChRight] = (Float32) pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] / _MAXSHORT; - } + // check sizes (note that float32 has four bytes) + if ( ( iSelOutBufferLeft >= 0 ) && ( iSelOutBufferLeft < static_cast ( outOutputData->mNumberBuffers ) ) && + ( iSelOutBufferRight >= 0 ) && ( iSelOutBufferRight < static_cast ( outOutputData->mNumberBuffers ) ) && + ( outOutputData->mBuffers[iSelOutBufferLeft].mDataByteSize == + static_cast ( vecNumOutBufChan[iSelOutBufferLeft] * iCoreAudioBufferSizeMono * 4 ) ) && + ( outOutputData->mBuffers[iSelOutBufferRight].mDataByteSize == + static_cast ( vecNumOutBufChan[iSelOutBufferRight] * iCoreAudioBufferSizeMono * 4 ) ) ) + { + Float32* pLeftData = static_cast ( outOutputData->mBuffers[iSelOutBufferLeft].mData ); + Float32* pRightData = static_cast ( outOutputData->mBuffers[iSelOutBufferRight].mData ); + int iNumChanPerFrameLeft = vecNumOutBufChan[iSelOutBufferLeft]; + int iNumChanPerFrameRight = vecNumOutBufChan[iSelOutBufferRight]; + + // copy output data + for ( int i = 0; i < iCoreAudioBufferSizeMono; i++ ) + { + // copy left and right channels separately + pLeftData[iNumChanPerFrameLeft * i + iSelOutInterlChLeft] = (Float32) pSound->vecsTmpAudioSndCrdStereo[2 * i] / _MAXSHORT; + pRightData[iNumChanPerFrameRight * i + iSelOutInterlChRight] = (Float32) pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] / _MAXSHORT; + } } } return kAudioHardwareNoError; } -void CSound::callbackMIDI ( const MIDIPacketList* pktlist, - void* refCon, - void* ) +void CSound::callbackMIDI ( const MIDIPacketList* pktlist, void* refCon, void* ) { CSound* pSound = static_cast ( refCon ); @@ -1140,8 +958,7 @@ void CSound::callbackMIDI ( const MIDIPacketList* pktlist, } } -bool CSound::ConvertCFStringToQString ( const CFStringRef stringRef, - QString& sOut ) +bool CSound::ConvertCFStringToQString ( const CFStringRef stringRef, QString& sOut ) { // check if the string reference is a valid pointer if ( stringRef != NULL ) @@ -1150,13 +967,9 @@ bool CSound::ConvertCFStringToQString ( const CFStringRef stringRef, if ( CFStringGetLength ( stringRef ) > 0 ) { // convert CFString in c-string (quick hack!) and then in QString - char* sC_strPropValue = - (char*) malloc ( CFStringGetLength ( stringRef ) * 3 + 1 ); + char* sC_strPropValue = (char*) malloc ( CFStringGetLength ( stringRef ) * 3 + 1 ); - if ( CFStringGetCString ( stringRef, - sC_strPropValue, - CFStringGetLength ( stringRef ) * 3 + 1, - kCFStringEncodingUTF8 ) ) + if ( CFStringGetCString ( stringRef, sC_strPropValue, CFStringGetLength ( stringRef ) * 3 + 1, kCFStringEncodingUTF8 ) ) { sOut = sC_strPropValue; free ( sC_strPropValue ); diff --git a/mac/sound.h b/mac/sound.h old mode 100755 new mode 100644 index 42bd1c5e6f..78c8a276b5 --- a/mac/sound.h +++ b/mac/sound.h @@ -32,17 +32,16 @@ #include "soundbase.h" #include "global.h" - /* Classes ********************************************************************/ class CSound : public CSoundBase { Q_OBJECT public: - CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), + CSound ( void ( *fpNewProcessCallback ) ( CVector& psData, void* arg ), void* arg, const QString& strMIDISetup, - const bool , + const bool, const QString& ); virtual int Init ( const int iNewPrefMonoBufferSize ); @@ -52,16 +51,16 @@ class CSound : public CSoundBase // channel selection virtual int GetNumInputChannels() { return iNumInChanPlusAddChan; } virtual QString GetInputChannelName ( const int iDiD ) { return sChannelNamesInput[iDiD]; } - virtual void SetLeftInputChannel ( const int iNewChan ); + virtual void SetLeftInputChannel ( const int iNewChan ); virtual void SetRightInputChannel ( const int iNewChan ); - virtual int GetLeftInputChannel() { return iSelInputLeftChannel; } + virtual int GetLeftInputChannel() { return iSelInputLeftChannel; } virtual int GetRightInputChannel() { return iSelInputRightChannel; } virtual int GetNumOutputChannels() { return iNumOutChan; } virtual QString GetOutputChannelName ( const int iDiD ) { return sChannelNamesOutput[iDiD]; } - virtual void SetLeftOutputChannel ( const int iNewChan ); + virtual void SetLeftOutputChannel ( const int iNewChan ); virtual void SetRightOutputChannel ( const int iNewChan ); - virtual int GetLeftOutputChannel() { return iSelOutputLeftChannel; } + virtual int GetLeftOutputChannel() { return iSelOutputLeftChannel; } virtual int GetRightOutputChannel() { return iSelOutputRightChannel; } // these variables/functions should be protected but cannot since we want @@ -101,47 +100,36 @@ class CSound : public CSoundBase void UpdateChSelection(); void GetAvailableInOutDevices(); - int CountChannels ( AudioDeviceID devID, - bool isInput ); + int CountChannels ( AudioDeviceID devID, bool isInput ); - UInt32 SetBufferSize ( AudioDeviceID& audioDeviceID, - const bool bIsInput, - UInt32 iPrefBufferSize ); + UInt32 SetBufferSize ( AudioDeviceID& audioDeviceID, const bool bIsInput, UInt32 iPrefBufferSize ); - void GetAudioDeviceInfos ( const AudioDeviceID DeviceID, - QString& strDeviceName, - bool& bIsInput, - bool& bIsOutput ); + void GetAudioDeviceInfos ( const AudioDeviceID DeviceID, QString& strDeviceName, bool& bIsInput, bool& bIsOutput ); bool ConvertCFStringToQString ( const CFStringRef stringRef, QString& sOut ); // callbacks - static OSStatus deviceNotification ( AudioDeviceID, - UInt32, - const AudioObjectPropertyAddress* inAddresses, - void* inRefCon ); + static OSStatus deviceNotification ( AudioDeviceID, UInt32, const AudioObjectPropertyAddress* inAddresses, void* inRefCon ); - static OSStatus callbackIO ( AudioDeviceID inDevice, + static OSStatus callbackIO ( AudioDeviceID inDevice, const AudioTimeStamp*, const AudioBufferList* inInputData, const AudioTimeStamp*, - AudioBufferList* outOutputData, + AudioBufferList* outOutputData, const AudioTimeStamp*, - void* inRefCon ); + void* inRefCon ); - static void callbackMIDI ( const MIDIPacketList* pktlist, - void* refCon, - void* ); + static void callbackMIDI ( const MIDIPacketList* pktlist, void* refCon, void* ); AudioDeviceID audioInputDevice[MAX_NUMBER_SOUND_CARDS]; AudioDeviceID audioOutputDevice[MAX_NUMBER_SOUND_CARDS]; AudioDeviceIOProcID audioInputProcID; AudioDeviceIOProcID audioOutputProcID; - MIDIPortRef midiInPortRef; + MIDIPortRef midiInPortRef; - QString sChannelNamesInput[MAX_NUM_IN_OUT_CHANNELS]; - QString sChannelNamesOutput[MAX_NUM_IN_OUT_CHANNELS]; + QString sChannelNamesInput[MAX_NUM_IN_OUT_CHANNELS]; + QString sChannelNamesOutput[MAX_NUM_IN_OUT_CHANNELS]; - QMutex Mutex; + QMutex Mutex; }; diff --git a/src/analyzerconsole.cpp b/src/analyzerconsole.cpp index b0013a77b8..2f1b7b2210 100644 --- a/src/analyzerconsole.cpp +++ b/src/analyzerconsole.cpp @@ -2,46 +2,44 @@ * Copyright (c) 2004-2020 * * Author(s): - * Volker Fischer + * Volker Fischer * ****************************************************************************** * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ #include "analyzerconsole.h" - // Analyzer console implementation ********************************************* -CAnalyzerConsole::CAnalyzerConsole ( CClient* pNCliP, - QWidget* parent ) : - CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons - pClient ( pNCliP ), - GraphImage ( 1, 1, QImage::Format_RGB32 ), +CAnalyzerConsole::CAnalyzerConsole ( CClient* pNCliP, QWidget* parent ) : + CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons + pClient ( pNCliP ), + GraphImage ( 1, 1, QImage::Format_RGB32 ), GraphErrRateCanvasRect ( 0, 0, 600, 450 ), // defines total size of graph - iGridFrameOffset ( 10 ), - iLineWidth ( 2 ), - iMarkerSize ( 10 ), - iXAxisTextHeight ( 22 ), - GraphBackgroundColor ( Qt::white ), // background - GraphFrameColor ( Qt::black ), // frame - GraphGridColor ( Qt::gray ), // grid - LineColor ( Qt::blue ), - LineLimitColor ( Qt::green ), - LineMaxUpLimitColor ( Qt::red ) + iGridFrameOffset ( 10 ), + iLineWidth ( 2 ), + iMarkerSize ( 10 ), + iXAxisTextHeight ( 22 ), + GraphBackgroundColor ( Qt::white ), // background + GraphFrameColor ( Qt::black ), // frame + GraphGridColor ( Qt::gray ), // grid + LineColor ( Qt::blue ), + LineLimitColor ( Qt::green ), + LineMaxUpLimitColor ( Qt::red ) { // set the window icon and title text const QIcon icon = QIcon ( QString::fromUtf8 ( ":/png/main/res/fronticon.png" ) ); @@ -58,20 +56,17 @@ CAnalyzerConsole::CAnalyzerConsole ( CClient* pNCliP, setLayout ( pMainLayout ); // error rate gaph tab - pTabWidgetBufErrRate = new QWidget(); + pTabWidgetBufErrRate = new QWidget(); QVBoxLayout* pTabErrRateLayout = new QVBoxLayout ( pTabWidgetBufErrRate ); pGraphErrRate = new QLabel ( this ); pTabErrRateLayout->addWidget ( pGraphErrRate ); - pMainTabWidget->addTab ( pTabWidgetBufErrRate, - tr ( "Error Rate of Each Buffer Size" ) ); - + pMainTabWidget->addTab ( pTabWidgetBufErrRate, tr ( "Error Rate of Each Buffer Size" ) ); // Connections ------------------------------------------------------------- // timers - QObject::connect ( &TimerErrRateUpdate, &QTimer::timeout, - this, &CAnalyzerConsole::OnTimerErrRateUpdate ); + QObject::connect ( &TimerErrRateUpdate, &QTimer::timeout, this, &CAnalyzerConsole::OnTimerErrRateUpdate ); } void CAnalyzerConsole::showEvent ( QShowEvent* ) @@ -99,14 +94,13 @@ void CAnalyzerConsole::OnTimerErrRateUpdate() void CAnalyzerConsole::DrawFrame() { // scale image to correct size - GraphImage = GraphImage.scaled ( - GraphErrRateCanvasRect.width(), GraphErrRateCanvasRect.height() ); + GraphImage = GraphImage.scaled ( GraphErrRateCanvasRect.width(), GraphErrRateCanvasRect.height() ); // generate plot grid frame rectangle GraphGridFrame.setRect ( GraphErrRateCanvasRect.x() + iGridFrameOffset, - GraphErrRateCanvasRect.y() + iGridFrameOffset, - GraphErrRateCanvasRect.width() - 2 * iGridFrameOffset, - GraphErrRateCanvasRect.height() - 2 * iGridFrameOffset - iXAxisTextHeight ); + GraphErrRateCanvasRect.y() + iGridFrameOffset, + GraphErrRateCanvasRect.width() - 2 * iGridFrameOffset, + GraphErrRateCanvasRect.height() - 2 * iGridFrameOffset - iXAxisTextHeight ); GraphImage.fill ( GraphBackgroundColor.rgb() ); // fill background @@ -142,30 +136,23 @@ void CAnalyzerConsole::DrawErrorRateTrace() const double dMin = dLogLimit * 2; // calculate space between points on the x-axis - const double dXSpace = - static_cast ( GraphGridFrame.width() ) / ( iNumBuffers - 1 ); + const double dXSpace = static_cast ( GraphGridFrame.width() ) / ( iNumBuffers - 1 ); // plot the limit line as dashed line const double dYValLimitInGraph = CalcYPosInGraph ( dMin, dMax, dLogLimit ); - GraphPainter.setPen ( QPen ( QBrush ( LineLimitColor ), - iLineWidth, - Qt::DashLine ) ); + GraphPainter.setPen ( QPen ( QBrush ( LineLimitColor ), iLineWidth, Qt::DashLine ) ); GraphPainter.drawLine ( QPoint ( GraphGridFrame.x(), dYValLimitInGraph ), - QPoint ( GraphGridFrame.x() + - GraphGridFrame.width(), dYValLimitInGraph ) ); + QPoint ( GraphGridFrame.x() + GraphGridFrame.width(), dYValLimitInGraph ) ); // plot the maximum upper limit line as a dashed line const double dYValMaxUpLimitInGraph = CalcYPosInGraph ( dMin, dMax, dLogMaxUpLimit ); - GraphPainter.setPen ( QPen ( QBrush ( LineMaxUpLimitColor ), - iLineWidth, - Qt::DashLine ) ); + GraphPainter.setPen ( QPen ( QBrush ( LineMaxUpLimitColor ), iLineWidth, Qt::DashLine ) ); GraphPainter.drawLine ( QPoint ( GraphGridFrame.x(), dYValMaxUpLimitInGraph ), - QPoint ( GraphGridFrame.x() + - GraphGridFrame.width(), dYValMaxUpLimitInGraph ) ); + QPoint ( GraphGridFrame.x() + GraphGridFrame.width(), dYValMaxUpLimitInGraph ) ); // plot the data for ( int i = 0; i < iNumBuffers; i++ ) @@ -184,31 +171,21 @@ void CAnalyzerConsole::DrawErrorRateTrace() } // calculate the actual point in the graph (in pixels) - const QPoint curPoint ( - GraphGridFrame.x() + static_cast ( dXSpace * i ), - CalcYPosInGraph ( dMin, dMax, vecButErrorRates[i] ) ); + const QPoint curPoint ( GraphGridFrame.x() + static_cast ( dXSpace * i ), CalcYPosInGraph ( dMin, dMax, vecButErrorRates[i] ) ); // draw a marker and a solid line which goes from the bottom to the // marker (similar to Matlab stem() function) - GraphPainter.setPen ( QPen ( QBrush ( LineColor ), - iMarkerSize, - Qt::SolidLine, - Qt::RoundCap ) ); + GraphPainter.setPen ( QPen ( QBrush ( LineColor ), iMarkerSize, Qt::SolidLine, Qt::RoundCap ) ); GraphPainter.drawPoint ( curPoint ); GraphPainter.setPen ( QPen ( QBrush ( LineColor ), iLineWidth ) ); - GraphPainter.drawLine ( QPoint ( curPoint.x(), - GraphGridFrame.y() + - GraphGridFrame.height() ), - curPoint ); + GraphPainter.drawLine ( QPoint ( curPoint.x(), GraphGridFrame.y() + GraphGridFrame.height() ), curPoint ); } } -int CAnalyzerConsole::CalcYPosInGraph ( const double dAxisMin, - const double dAxisMax, - const double dValue ) const +int CAnalyzerConsole::CalcYPosInGraph ( const double dAxisMin, const double dAxisMax, const double dValue ) const { // calculate value range const double dValRange = dAxisMax - dAxisMin; @@ -217,6 +194,5 @@ int CAnalyzerConsole::CalcYPosInGraph ( const double dAxisMin, const double dYValNorm = ( dValue - dAxisMin ) / dValRange; // consider the graph grid size to calculate the final y-axis value - return GraphGridFrame.y() + static_cast ( - static_cast ( GraphGridFrame.height() ) * ( 1 - dYValNorm ) ); + return GraphGridFrame.y() + static_cast ( static_cast ( GraphGridFrame.height() ) * ( 1 - dYValNorm ) ); } diff --git a/src/analyzerconsole.h b/src/analyzerconsole.h index 2d8ce44e95..690c74c99e 100644 --- a/src/analyzerconsole.h +++ b/src/analyzerconsole.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -34,11 +34,9 @@ #include "client.h" #include "util.h" - /* Definitions ****************************************************************/ // defines the update time of the error rate graph -#define ERR_RATE_GRAPH_UPDATE_TIME_MS 200 // ms - +#define ERR_RATE_GRAPH_UPDATE_TIME_MS 200 // ms /* Classes ********************************************************************/ class CAnalyzerConsole : public CBaseDlg @@ -46,9 +44,7 @@ class CAnalyzerConsole : public CBaseDlg Q_OBJECT public: - CAnalyzerConsole ( CClient* pNCliP, - QWidget* parent = nullptr ); - + CAnalyzerConsole ( CClient* pNCliP, QWidget* parent = nullptr ); protected: virtual void showEvent ( QShowEvent* ); @@ -56,35 +52,32 @@ class CAnalyzerConsole : public CBaseDlg void DrawFrame(); void DrawErrorRateTrace(); - int CalcYPosInGraph ( const double dAxisMin, - const double dAxisMax, - const double dValue ) const; + int CalcYPosInGraph ( const double dAxisMin, const double dAxisMax, const double dValue ) const; - CClient* pClient; + CClient* pClient; QTabWidget* pMainTabWidget; QWidget* pTabWidgetBufErrRate; - QLabel* pGraphErrRate; - QImage GraphImage; - - QRect GraphErrRateCanvasRect; - QRect GraphGridFrame; + QLabel* pGraphErrRate; + QImage GraphImage; - int iGridFrameOffset; - int iLineWidth; - int iMarkerSize; - int iXAxisTextHeight; + QRect GraphErrRateCanvasRect; + QRect GraphGridFrame; - QColor GraphBackgroundColor; - QColor GraphFrameColor; - QColor GraphGridColor; - QColor LineColor; - QColor LineLimitColor; - QColor LineMaxUpLimitColor; + int iGridFrameOffset; + int iLineWidth; + int iMarkerSize; + int iXAxisTextHeight; - QTimer TimerErrRateUpdate; + QColor GraphBackgroundColor; + QColor GraphFrameColor; + QColor GraphGridColor; + QColor LineColor; + QColor LineLimitColor; + QColor LineMaxUpLimitColor; + QTimer TimerErrRateUpdate; public slots: void OnTimerErrRateUpdate(); diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp old mode 100755 new mode 100644 index 0b4cb108b7..9a2083efff --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -2,101 +2,98 @@ * Copyright (c) 2004-2020 * * Author(s): - * Volker Fischer + * Volker Fischer * ****************************************************************************** * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ #include "audiomixerboard.h" - /******************************************************************************\ * CChanneFader * \******************************************************************************/ CChannelFader::CChannelFader ( QWidget* pNW ) : eDesign ( GD_STANDARD ), - BitmapMutedIcon( QString::fromUtf8 ( ":/png/fader/res/mutediconorange.png" ) ) + BitmapMutedIcon ( QString::fromUtf8 ( ":/png/fader/res/mutediconorange.png" ) ) { // create new GUI control objects and store pointers to them (note that // QWidget takes the ownership of the pMainGrid so that this only has // to be created locally in this constructor) - pFrame = new QFrame ( pNW ); - - pLevelsBox = new QWidget ( pFrame ); - plbrChannelLevel = new CLevelMeter ( pLevelsBox ); - pFader = new QSlider ( Qt::Vertical, pLevelsBox ); - pPan = new QDial ( pLevelsBox ); - pPanLabel = new QLabel ( tr ( "Pan" ), pLevelsBox ); - pInfoLabel = new QLabel ( "", pLevelsBox ); - - pMuteSoloBox = new QWidget ( pFrame ); - pcbMute = new QCheckBox ( tr ( "Mute" ), pMuteSoloBox ); - pcbSolo = new QCheckBox ( tr ( "Solo" ), pMuteSoloBox ); - pcbGroup = new QCheckBox ( "", pMuteSoloBox ); - - pLabelInstBox = new QGroupBox ( pFrame ); - plblLabel = new QLabel ( "", pFrame ); - plblInstrument = new QLabel ( pFrame ); - plblCountryFlag = new QLabel ( pFrame ); - - QVBoxLayout* pMainGrid = new QVBoxLayout ( pFrame ); - QHBoxLayout* pLevelsGrid = new QHBoxLayout ( pLevelsBox ); - QVBoxLayout* pMuteSoloGrid = new QVBoxLayout ( pMuteSoloBox ); - pLabelGrid = new QHBoxLayout ( pLabelInstBox ); - pLabelPictGrid = new QVBoxLayout ( ); - QVBoxLayout* pPanGrid = new QVBoxLayout ( ); - QHBoxLayout* pPanInfoGrid = new QHBoxLayout ( ); + pFrame = new QFrame ( pNW ); + + pLevelsBox = new QWidget ( pFrame ); + plbrChannelLevel = new CLevelMeter ( pLevelsBox ); + pFader = new QSlider ( Qt::Vertical, pLevelsBox ); + pPan = new QDial ( pLevelsBox ); + pPanLabel = new QLabel ( tr ( "Pan" ), pLevelsBox ); + pInfoLabel = new QLabel ( "", pLevelsBox ); + + pMuteSoloBox = new QWidget ( pFrame ); + pcbMute = new QCheckBox ( tr ( "Mute" ), pMuteSoloBox ); + pcbSolo = new QCheckBox ( tr ( "Solo" ), pMuteSoloBox ); + pcbGroup = new QCheckBox ( "", pMuteSoloBox ); + + pLabelInstBox = new QGroupBox ( pFrame ); + plblLabel = new QLabel ( "", pFrame ); + plblInstrument = new QLabel ( pFrame ); + plblCountryFlag = new QLabel ( pFrame ); + + QVBoxLayout* pMainGrid = new QVBoxLayout ( pFrame ); + QHBoxLayout* pLevelsGrid = new QHBoxLayout ( pLevelsBox ); + QVBoxLayout* pMuteSoloGrid = new QVBoxLayout ( pMuteSoloBox ); + pLabelGrid = new QHBoxLayout ( pLabelInstBox ); + pLabelPictGrid = new QVBoxLayout(); + QVBoxLayout* pPanGrid = new QVBoxLayout(); + QHBoxLayout* pPanInfoGrid = new QHBoxLayout(); // define the popup menu for the group checkbox pGroupPopupMenu = new QMenu ( "", pcbGroup ); - pGroupPopupMenu->addAction ( tr ( "&No grouping" ), - this, [=] { OnGroupMenuGrp ( INVALID_INDEX ); } ); - for ( int iGrp = 0 ; iGrp < MAX_NUM_FADER_GROUPS ; iGrp++ ) + pGroupPopupMenu->addAction ( tr ( "&No grouping" ), this, [=] { OnGroupMenuGrp ( INVALID_INDEX ); } ); + for ( int iGrp = 0; iGrp < MAX_NUM_FADER_GROUPS; iGrp++ ) { - pGroupPopupMenu->addAction ( tr ( "Assign to group" ) + ( QString ( " &%1" ) .arg( iGrp + 1 ) ), - this, [=] { OnGroupMenuGrp ( iGrp ); } ); + pGroupPopupMenu->addAction ( tr ( "Assign to group" ) + ( QString ( " &%1" ).arg ( iGrp + 1 ) ), this, [=] { OnGroupMenuGrp ( iGrp ); } ); } #if ( MAX_NUM_FADER_GROUPS != 8 ) -# error "MAX_NUM_FADER_GROUPS must be set to 8, see implementation in CChannelFader()" +# error "MAX_NUM_FADER_GROUPS must be set to 8, see implementation in CChannelFader()" #endif // setup channel level plbrChannelLevel->setContentsMargins ( 0, 3, 2, 3 ); // setup slider - pFader->setPageStep ( 1 ); - pFader->setRange ( 0, AUD_MIX_FADER_MAX ); + pFader->setPageStep ( 1 ); + pFader->setRange ( 0, AUD_MIX_FADER_MAX ); pFader->setTickInterval ( AUD_MIX_FADER_MAX / 9 ); // setup panning control and info label - pPan->setRange ( 0, AUD_MIX_PAN_MAX ); - pPan->setValue ( AUD_MIX_PAN_MAX / 2 ); - pPan->setNotchesVisible ( true ); + pPan->setRange ( 0, AUD_MIX_PAN_MAX ); + pPan->setValue ( AUD_MIX_PAN_MAX / 2 ); + pPan->setNotchesVisible ( true ); pInfoLabel->setMinimumHeight ( 14 ); // prevents jitter when muting/unmuting (#811) - pInfoLabel->setAlignment ( Qt::AlignTop ); - pPanInfoGrid->addWidget ( pPanLabel, 0, Qt::AlignLeft | Qt::AlignTop ); - pPanInfoGrid->addWidget ( pInfoLabel, 0, Qt::AlignHCenter | Qt::AlignTop ); - pPanGrid->addLayout ( pPanInfoGrid ); - pPanGrid->addWidget ( pPan, 0, Qt::AlignHCenter ); + pInfoLabel->setAlignment ( Qt::AlignTop ); + pPanInfoGrid->addWidget ( pPanLabel, 0, Qt::AlignLeft | Qt::AlignTop ); + pPanInfoGrid->addWidget ( pInfoLabel, 0, Qt::AlignHCenter | Qt::AlignTop ); + pPanGrid->addLayout ( pPanInfoGrid ); + pPanGrid->addWidget ( pPan, 0, Qt::AlignHCenter ); // setup fader tag label (black bold text which is centered) plblLabel->setTextFormat ( Qt::PlainText ); - plblLabel->setAlignment ( Qt::AlignHCenter | Qt::AlignVCenter ); + plblLabel->setAlignment ( Qt::AlignHCenter | Qt::AlignVCenter ); // set margins of the layouts to zero to get maximum space for the controls pMainGrid->setContentsMargins ( 0, 0, 0, 0 ); @@ -115,20 +112,20 @@ CChannelFader::CChannelFader ( QWidget* pNW ) : // add user controls to the grids pLabelPictGrid->addWidget ( plblCountryFlag, 0, Qt::AlignHCenter ); - pLabelPictGrid->addWidget ( plblInstrument, 0, Qt::AlignHCenter ); + pLabelPictGrid->addWidget ( plblInstrument, 0, Qt::AlignHCenter ); pLabelGrid->addLayout ( pLabelPictGrid ); pLabelGrid->addWidget ( plblLabel, 0, Qt::AlignVCenter ); // note: just initial add, may be changed later pLevelsGrid->addWidget ( plbrChannelLevel, 0, Qt::AlignRight ); - pLevelsGrid->addWidget ( pFader, 0, Qt::AlignLeft ); + pLevelsGrid->addWidget ( pFader, 0, Qt::AlignLeft ); pMuteSoloGrid->addWidget ( pcbGroup, 0, Qt::AlignLeft ); - pMuteSoloGrid->addWidget ( pcbMute, 0, Qt::AlignLeft ); - pMuteSoloGrid->addWidget ( pcbSolo, 0, Qt::AlignLeft ); + pMuteSoloGrid->addWidget ( pcbMute, 0, Qt::AlignLeft ); + pMuteSoloGrid->addWidget ( pcbSolo, 0, Qt::AlignLeft ); pMainGrid->addLayout ( pPanGrid ); - pMainGrid->addWidget ( pLevelsBox, 0, Qt::AlignHCenter ); + pMainGrid->addWidget ( pLevelsBox, 0, Qt::AlignHCenter ); pMainGrid->addWidget ( pMuteSoloBox, 0, Qt::AlignHCenter ); pMainGrid->addWidget ( pLabelInstBox ); @@ -139,47 +136,48 @@ CChannelFader::CChannelFader ( QWidget* pNW ) : // add help text to controls plbrChannelLevel->setWhatsThis ( "" + tr ( "Channel Level" ) + ": " + - tr ( "Displays the pre-fader audio level of this channel. All clients connected to the " - "server will be assigned an audio level, the same value for every client." ) ); + tr ( "Displays the pre-fader audio level of this channel. All clients connected to the " + "server will be assigned an audio level, the same value for every client." ) ); plbrChannelLevel->setAccessibleName ( tr ( "Input level of the current audio " - "channel at the server" ) ); + "channel at the server" ) ); - pFader->setWhatsThis ( "" + tr ( "Mixer Fader" ) + ": " + tr ( - "Adjusts the audio level of this channel. All clients connected to the server " - "will be assigned an audio fader, displayed at each client, to adjust the local mix." ) ); + pFader->setWhatsThis ( "" + tr ( "Mixer Fader" ) + ": " + + tr ( "Adjusts the audio level of this channel. All clients connected to the server " + "will be assigned an audio fader, displayed at each client, to adjust the local mix." ) ); pFader->setAccessibleName ( tr ( "Local mix level setting of the current audio " - "channel at the server" ) ); + "channel at the server" ) ); - pInfoLabel->setWhatsThis ( "" + tr ( "Status Indicator" ) + ": " + tr ( - "Shows a status indication about the client which is assigned to this channel. " - "Supported indicators are:" ) + "
  • " + tr ( - "Speaker with cancellation stroke: Indicates that another client has muted you." ) + - "
" ); + pInfoLabel->setWhatsThis ( "" + tr ( "Status Indicator" ) + ": " + + tr ( "Shows a status indication about the client which is assigned to this channel. " + "Supported indicators are:" ) + + "
  • " + tr ( "Speaker with cancellation stroke: Indicates that another client has muted you." ) + "
" ); pInfoLabel->setAccessibleName ( tr ( "Status indicator label" ) ); - pPan->setWhatsThis ( "" + tr ( "Panning" ) + ": " + tr ( - "Sets the pan from Left to Right of the channel. " - "Works only in stereo or preferably mono in/stereo out mode." ) ); + pPan->setWhatsThis ( "" + tr ( "Panning" ) + ": " + + tr ( "Sets the pan from Left to Right of the channel. " + "Works only in stereo or preferably mono in/stereo out mode." ) ); pPan->setAccessibleName ( tr ( "Local panning position of the current audio channel at the server" ) ); - pcbMute->setWhatsThis ( "" + tr ( "Mute" ) + ": " + tr ( - "With the Mute checkbox, the audio channel can be muted." ) ); + pcbMute->setWhatsThis ( "" + tr ( "Mute" ) + ": " + tr ( "With the Mute checkbox, the audio channel can be muted." ) ); pcbMute->setAccessibleName ( tr ( "Mute button" ) ); - pcbSolo->setWhatsThis ( "" + tr ( "Solo" ) + ": " + tr ( "With the Solo checkbox, the " - "audio channel can be set to solo which means that all other channels " - "except the soloed channel are muted. It is possible to set more than " - "one channel to solo." ) ); + pcbSolo->setWhatsThis ( "" + tr ( "Solo" ) + ": " + + tr ( "With the Solo checkbox, the " + "audio channel can be set to solo which means that all other channels " + "except the soloed channel are muted. It is possible to set more than " + "one channel to solo." ) ); pcbSolo->setAccessibleName ( tr ( "Solo button" ) ); - pcbGroup->setWhatsThis ( "" + tr ( "Group" ) + ": " + tr ( "With the Grp checkbox, a " - "group of audio channels can be defined. All channel faders in a group are moved " - "in proportional synchronization if any one of the group faders are moved." ) ); + pcbGroup->setWhatsThis ( "" + tr ( "Group" ) + ": " + + tr ( "With the Grp checkbox, a " + "group of audio channels can be defined. All channel faders in a group are moved " + "in proportional synchronization if any one of the group faders are moved." ) ); pcbGroup->setAccessibleName ( tr ( "Group button" ) ); - QString strFaderText = "" + tr ( "Fader Tag" ) + ": " + tr ( "The fader tag " - "identifies the connected client. The tag name, a picture of your " - "instrument and the flag of your country can be set in the main window." ); + QString strFaderText = "" + tr ( "Fader Tag" ) + ": " + + tr ( "The fader tag " + "identifies the connected client. The tag name, a picture of your " + "instrument and the flag of your country can be set in the main window." ); plblInstrument->setWhatsThis ( strFaderText ); plblInstrument->setAccessibleName ( tr ( "Mixer channel instrument picture" ) ); @@ -188,22 +186,16 @@ CChannelFader::CChannelFader ( QWidget* pNW ) : plblCountryFlag->setWhatsThis ( strFaderText ); plblCountryFlag->setAccessibleName ( tr ( "Mixer channel country flag" ) ); - // Connections ------------------------------------------------------------- - QObject::connect ( pFader, &QSlider::valueChanged, - this, &CChannelFader::OnLevelValueChanged ); + QObject::connect ( pFader, &QSlider::valueChanged, this, &CChannelFader::OnLevelValueChanged ); - QObject::connect ( pPan, &QDial::valueChanged, - this, &CChannelFader::OnPanValueChanged ); + QObject::connect ( pPan, &QDial::valueChanged, this, &CChannelFader::OnPanValueChanged ); - QObject::connect ( pcbMute, &QCheckBox::stateChanged, - this, &CChannelFader::OnMuteStateChanged ); + QObject::connect ( pcbMute, &QCheckBox::stateChanged, this, &CChannelFader::OnMuteStateChanged ); - QObject::connect ( pcbSolo, &QCheckBox::stateChanged, - this, &CChannelFader::soloStateChanged ); + QObject::connect ( pcbSolo, &QCheckBox::stateChanged, this, &CChannelFader::soloStateChanged ); - QObject::connect ( pcbGroup, &QCheckBox::stateChanged, - this, &CChannelFader::OnGroupStateChanged ); + QObject::connect ( pcbGroup, &QCheckBox::stateChanged, this, &CChannelFader::OnGroupStateChanged ); } void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign ) @@ -213,58 +205,57 @@ void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign ) switch ( eNewDesign ) { case GD_ORIGINAL: - pFader->setStyleSheet ( - "QSlider { width: 45px;" - " border-image: url(:/png/fader/res/faderbackground.png) repeat;" - " border-top: 10px transparent;" - " border-bottom: 10px transparent;" - " border-left: 20px transparent;" - " border-right: -25px transparent; }" - "QSlider::groove { image: url(:/png/fader/res/transparent1x1.png);" - " padding-left: -34px;" - " padding-top: -10px;" - " padding-bottom: -15px; }" - "QSlider::handle { image: url(:/png/fader/res/faderhandle.png); }" ); - - pLabelGrid->addWidget ( plblLabel, 0, Qt::AlignVCenter ); // label next to icons - pLabelInstBox->setMinimumHeight ( 52 ); // maximum height of the instrument+flag pictures - pFader->setMinimumHeight ( 120 ); // if this value is too small, the fader might not be movable with the mouse for fancy skin (#292) - pPan->setFixedSize ( 50, 50 ); - pPanLabel->setText ( tr ( "PAN" ) ); - pcbMute->setText ( tr ( "MUTE" ) ); - pcbSolo->setText ( tr ( "SOLO" ) ); - strGroupBaseText = tr ( "GRP" ); + pFader->setStyleSheet ( "QSlider { width: 45px;" + " border-image: url(:/png/fader/res/faderbackground.png) repeat;" + " border-top: 10px transparent;" + " border-bottom: 10px transparent;" + " border-left: 20px transparent;" + " border-right: -25px transparent; }" + "QSlider::groove { image: url(:/png/fader/res/transparent1x1.png);" + " padding-left: -34px;" + " padding-top: -10px;" + " padding-bottom: -15px; }" + "QSlider::handle { image: url(:/png/fader/res/faderhandle.png); }" ); + + pLabelGrid->addWidget ( plblLabel, 0, Qt::AlignVCenter ); // label next to icons + pLabelInstBox->setMinimumHeight ( 52 ); // maximum height of the instrument+flag pictures + pFader->setMinimumHeight ( 120 ); // if this value is too small, the fader might not be movable with the mouse for fancy skin (#292) + pPan->setFixedSize ( 50, 50 ); + pPanLabel->setText ( tr ( "PAN" ) ); + pcbMute->setText ( tr ( "MUTE" ) ); + pcbSolo->setText ( tr ( "SOLO" ) ); + strGroupBaseText = tr ( "GRP" ); plbrChannelLevel->SetLevelMeterType ( CLevelMeter::MT_LED ); iInstrPicMaxWidth = INVALID_INDEX; // no instrument picture scaling break; case GD_SLIMFADER: - pLabelPictGrid->addWidget ( plblLabel, 0, Qt::AlignHCenter ); // label below icons - pLabelInstBox->setMinimumHeight ( 130 ); // maximum height of the instrument+flag+label - pFader->setMinimumHeight ( 85 ); - pPan->setFixedSize ( 28, 28 ); - pFader->setTickPosition ( QSlider::NoTicks ); - pFader->setStyleSheet ( "" ); - pPanLabel->setText ( tr ( "Pan" ) ); - pcbMute->setText ( tr ( "M" ) ); - pcbSolo->setText ( tr ( "S" ) ); - strGroupBaseText = tr ( "G" ); + pLabelPictGrid->addWidget ( plblLabel, 0, Qt::AlignHCenter ); // label below icons + pLabelInstBox->setMinimumHeight ( 130 ); // maximum height of the instrument+flag+label + pFader->setMinimumHeight ( 85 ); + pPan->setFixedSize ( 28, 28 ); + pFader->setTickPosition ( QSlider::NoTicks ); + pFader->setStyleSheet ( "" ); + pPanLabel->setText ( tr ( "Pan" ) ); + pcbMute->setText ( tr ( "M" ) ); + pcbSolo->setText ( tr ( "S" ) ); + strGroupBaseText = tr ( "G" ); plbrChannelLevel->SetLevelMeterType ( CLevelMeter::MT_SLIM_BAR ); iInstrPicMaxWidth = 18; // scale instrument picture to avoid enlarging the width by the picture break; default: // reset style sheet and set original parameters - pFader->setTickPosition ( QSlider::TicksBothSides ); - pFader->setStyleSheet ( "" ); - pLabelGrid->addWidget ( plblLabel, 0, Qt::AlignVCenter ); // label next to icons - pLabelInstBox->setMinimumHeight ( 52 ); // maximum height of the instrument+flag pictures - pFader->setMinimumHeight ( 85 ); - pPan->setFixedSize ( 50, 50 ); - pPanLabel->setText ( tr ( "Pan" ) ); - pcbMute->setText ( tr ( "Mute" ) ); - pcbSolo->setText ( tr ( "Solo" ) ); - strGroupBaseText = tr ( "Grp" ); + pFader->setTickPosition ( QSlider::TicksBothSides ); + pFader->setStyleSheet ( "" ); + pLabelGrid->addWidget ( plblLabel, 0, Qt::AlignVCenter ); // label next to icons + pLabelInstBox->setMinimumHeight ( 52 ); // maximum height of the instrument+flag pictures + pFader->setMinimumHeight ( 85 ); + pPan->setFixedSize ( 50, 50 ); + pPanLabel->setText ( tr ( "Pan" ) ); + pcbMute->setText ( tr ( "Mute" ) ); + pcbSolo->setText ( tr ( "Solo" ) ); + strGroupBaseText = tr ( "Grp" ); plbrChannelLevel->SetLevelMeterType ( CLevelMeter::MT_BAR ); iInstrPicMaxWidth = INVALID_INDEX; // no instrument picture scaling break; @@ -277,20 +268,14 @@ void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign ) SetChannelInfos ( cReceivedChanInfo ); } -void CChannelFader::SetDisplayChannelLevel ( const bool eNDCL ) -{ - plbrChannelLevel->setHidden ( !eNDCL ); -} +void CChannelFader::SetDisplayChannelLevel ( const bool eNDCL ) { plbrChannelLevel->setHidden ( !eNDCL ); } -bool CChannelFader::GetDisplayChannelLevel() -{ - return !plbrChannelLevel->isHidden(); -} +bool CChannelFader::GetDisplayChannelLevel() { return !plbrChannelLevel->isHidden(); } void CChannelFader::SetDisplayPans ( const bool eNDP ) { - pPanLabel->setHidden ( !eNDP ); - pPan->setHidden ( !eNDP ); + pPanLabel->setHidden ( !eNDP ); + pPan->setHidden ( !eNDP ); } void CChannelFader::SetupFaderTag ( const ESkillLevel eSkillLevel ) @@ -354,40 +339,36 @@ void CChannelFader::SetupFaderTag ( const ESkillLevel eSkillLevel ) // setup group box for label/instrument picture: set a thick black border // with nice round edges - QString strStile = - "QGroupBox { border: 2px " + strBorderStyle + " " + strBorderColor + ";" - " border-radius: 4px;" - " padding: 3px;"; + QString strStile = "QGroupBox { border: 2px " + strBorderStyle + " " + strBorderColor + + ";" + " border-radius: 4px;" + " padding: 3px;"; // the background color depends on the skill level switch ( eSkillLevel ) { case SL_BEGINNER: - strStile += QString ( "background-color: rgb(%1, %2, %3); }" ). - arg ( RGBCOL_R_SL_BEGINNER ). - arg ( RGBCOL_G_SL_BEGINNER ). - arg ( RGBCOL_B_SL_BEGINNER ); + strStile += + QString ( "background-color: rgb(%1, %2, %3); }" ).arg ( RGBCOL_R_SL_BEGINNER ).arg ( RGBCOL_G_SL_BEGINNER ).arg ( RGBCOL_B_SL_BEGINNER ); break; case SL_INTERMEDIATE: - strStile += QString ( "background-color: rgb(%1, %2, %3); }" ). - arg ( RGBCOL_R_SL_INTERMEDIATE ). - arg ( RGBCOL_G_SL_INTERMEDIATE ). - arg ( RGBCOL_B_SL_INTERMEDIATE ); + strStile += QString ( "background-color: rgb(%1, %2, %3); }" ) + .arg ( RGBCOL_R_SL_INTERMEDIATE ) + .arg ( RGBCOL_G_SL_INTERMEDIATE ) + .arg ( RGBCOL_B_SL_INTERMEDIATE ); break; case SL_PROFESSIONAL: - strStile += QString ( "background-color: rgb(%1, %2, %3); }" ). - arg ( RGBCOL_R_SL_SL_PROFESSIONAL ). - arg ( RGBCOL_G_SL_SL_PROFESSIONAL ). - arg ( RGBCOL_B_SL_SL_PROFESSIONAL ); + strStile += QString ( "background-color: rgb(%1, %2, %3); }" ) + .arg ( RGBCOL_R_SL_SL_PROFESSIONAL ) + .arg ( RGBCOL_G_SL_SL_PROFESSIONAL ) + .arg ( RGBCOL_B_SL_SL_PROFESSIONAL ); break; default: - strStile += QString ( "background-color: rgb(%1, %2, %3); }" ). - arg ( RGBCOL_R_SL_NOT_SET ). - arg ( RGBCOL_G_SL_NOT_SET ). - arg ( RGBCOL_B_SL_NOT_SET ); + strStile += + QString ( "background-color: rgb(%1, %2, %3); }" ).arg ( RGBCOL_R_SL_NOT_SET ).arg ( RGBCOL_G_SL_NOT_SET ).arg ( RGBCOL_B_SL_NOT_SET ); break; } @@ -414,10 +395,10 @@ void CChannelFader::Reset() plbrChannelLevel->ClipReset(); // clear instrument picture, country flag, tool tips and label text - plblLabel->setText ( "" ); - plblLabel->setToolTip ( "" ); - plblInstrument->setVisible ( false ); - plblInstrument->setToolTip ( "" ); + plblLabel->setText ( "" ); + plblLabel->setToolTip ( "" ); + plblInstrument->setVisible ( false ); + plblInstrument->setToolTip ( "" ); plblCountryFlag->setVisible ( false ); plblCountryFlag->setToolTip ( "" ); cReceivedChanInfo = CChannelInfo(); @@ -425,8 +406,8 @@ void CChannelFader::Reset() // set a defined tool tip time out const int iToolTipDurMs = 30000; - plblLabel->setToolTipDuration ( iToolTipDurMs ); - plblInstrument->setToolTipDuration ( iToolTipDurMs ); + plblLabel->setToolTipDuration ( iToolTipDurMs ); + plblInstrument->setToolTipDuration ( iToolTipDurMs ); plblCountryFlag->setToolTipDuration ( iToolTipDurMs ); bOtherChannelIsSolo = false; @@ -437,8 +418,7 @@ void CChannelFader::Reset() UpdateGroupIDDependencies(); } -void CChannelFader::SetFaderLevel ( const double dLevel, - const bool bIsGroupUpdate ) +void CChannelFader::SetFaderLevel ( const double dLevel, const bool bIsGroupUpdate ) { // first make a range check if ( dLevel >= 0 ) @@ -447,7 +427,7 @@ void CChannelFader::SetFaderLevel ( const double dLevel, // server about the change (block the signal of the fader since we want to // call SendFaderLevelToServer with a special additional parameter) pFader->blockSignals ( true ); - pFader->setValue ( std::min ( AUD_MIX_FADER_MAX, MathUtils::round ( dLevel ) ) ); + pFader->setValue ( std::min ( AUD_MIX_FADER_MAX, MathUtils::round ( dLevel ) ) ); pFader->blockSignals ( false ); SendFaderLevelToServer ( std::min ( static_cast ( AUD_MIX_FADER_MAX ), dLevel ), bIsGroupUpdate ); @@ -492,22 +472,20 @@ void CChannelFader::SetRemoteFaderIsMute ( const bool bIsMute ) if ( bIsMute ) { // show muted icon orange - pInfoLabel->setPixmap( BitmapMutedIcon ); + pInfoLabel->setPixmap ( BitmapMutedIcon ); } else { - pInfoLabel->setPixmap( QPixmap() ); + pInfoLabel->setPixmap ( QPixmap() ); } } -void CChannelFader::SendFaderLevelToServer ( const double dLevel, - const bool bIsGroupUpdate ) +void CChannelFader::SendFaderLevelToServer ( const double dLevel, const bool bIsGroupUpdate ) { // if mute flag is set or other channel is on solo, do not apply the new // fader value to the server (exception: we are on solo, in that case we // ignore the "other channel is on solo" flag) - const bool bSuppressServerUpdate = !( ( pcbMute->checkState() == Qt::Unchecked ) && - ( !bOtherChannelIsSolo || IsSolo() ) ); + const bool bSuppressServerUpdate = !( ( pcbMute->checkState() == Qt::Unchecked ) && ( !bOtherChannelIsSolo || IsSolo() ) ); // emit signal for new fader gain value emit gainValueChanged ( MathUtils::CalcFaderGain ( static_cast ( dLevel ) ), @@ -525,10 +503,7 @@ void CChannelFader::SendFaderLevelToServer ( const double dLevel, } } -void CChannelFader::SendPanValueToServer ( const int iPan ) -{ - emit panValueChanged ( static_cast ( iPan ) / AUD_MIX_PAN_MAX ); -} +void CChannelFader::SendPanValueToServer ( const int iPan ) { emit panValueChanged ( static_cast ( iPan ) / AUD_MIX_PAN_MAX ); } void CChannelFader::OnPanValueChanged ( int value ) { @@ -541,7 +516,7 @@ void CChannelFader::OnPanValueChanged ( int value ) // set the GUI control in the center position while deactivating // the signals to avoid an infinite loop pPan->blockSignals ( true ); - pPan->setValue ( value ); + pPan->setValue ( value ); pPan->blockSignals ( false ); } @@ -578,7 +553,7 @@ void CChannelFader::UpdateGroupIDDependencies() // update group checkbox text if ( iGroupID != INVALID_INDEX ) { - pcbGroup->setText ( strGroupBaseText + QString::number ( iGroupID + 1 ) ); + pcbGroup->setText ( strGroupBaseText + QString::number ( iGroupID + 1 ) ); } else { @@ -632,7 +607,11 @@ void CChannelFader::SetMute ( const bool bState ) if ( ( !bOtherChannelIsSolo || IsSolo() ) && bIsMutedAtServer ) { // mute was unchecked, get current fader value and apply - emit gainValueChanged ( MathUtils::CalcFaderGain ( GetFaderLevel() ), bIsMyOwnFader, false, false, -1 ); // set level ratio to in invalid value + emit gainValueChanged ( MathUtils::CalcFaderGain ( GetFaderLevel() ), + bIsMyOwnFader, + false, + false, + -1 ); // set level ratio to in invalid value bIsMutedAtServer = false; } } @@ -651,10 +630,7 @@ void CChannelFader::UpdateSoloState ( const bool bNewOtherSoloState ) } } -void CChannelFader::SetChannelLevel ( const uint16_t iLevel ) -{ - plbrChannelLevel->SetValue ( iLevel ); -} +void CChannelFader::SetChannelLevel ( const uint16_t iLevel ) { plbrChannelLevel->SetValue ( iLevel ); } void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo ) { @@ -665,7 +641,6 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo ) int iTTInstrument = CInstPictures::GetNotUsedInstrument(); QLocale::Country eTTCountry = QLocale::AnyCountry; - // Label text -------------------------------------------------------------- QString strModText = cChanInfo.strName; @@ -698,15 +673,12 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo ) plblLabel->setText ( strModText ); - // Instrument picture ------------------------------------------------------ // get the resource reference string for this instrument - const QString strCurResourceRef = - CInstPictures::GetResourceReference ( cChanInfo.iInstrument ); + const QString strCurResourceRef = CInstPictures::GetResourceReference ( cChanInfo.iInstrument ); // first check if instrument picture is used or not and if it is valid - if ( CInstPictures::IsNotUsedInstrument ( cChanInfo.iInstrument ) || - strCurResourceRef.isEmpty() ) + if ( CInstPictures::IsNotUsedInstrument ( cChanInfo.iInstrument ) || strCurResourceRef.isEmpty() ) { // disable instrument picture plblInstrument->setVisible ( false ); @@ -731,7 +703,6 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo ) plblInstrument->setVisible ( true ); } - // Country flag icon ------------------------------------------------------- if ( cChanInfo.eCountry != QLocale::AnyCountry ) { @@ -760,11 +731,9 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo ) plblCountryFlag->setVisible ( false ); } - // Skill level background color -------------------------------------------- SetupFaderTag ( cChanInfo.eSkillLevel ); - // Tool tip ---------------------------------------------------------------- // complete musician profile in the tool tip QString strToolTip = ""; @@ -775,40 +744,38 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo ) // alias/name if ( !cChanInfo.strName.isEmpty() ) { - strToolTip += "

" + tr ( "Alias/Name" ) + "

" + cChanInfo.strName; + strToolTip += "

" + tr ( "Alias/Name" ) + "

" + cChanInfo.strName; strAliasAccessible += cChanInfo.strName; } // instrument if ( !CInstPictures::IsNotUsedInstrument ( iTTInstrument ) ) { - strToolTip += "

" + tr ( "Instrument" ) + "

" + - CInstPictures::GetName ( iTTInstrument ); + strToolTip += "

" + tr ( "Instrument" ) + "

" + CInstPictures::GetName ( iTTInstrument ); strInstrumentAccessible += CInstPictures::GetName ( iTTInstrument ); } // location - if ( ( eTTCountry != QLocale::AnyCountry ) || - ( !cChanInfo.strCity.isEmpty() ) ) + if ( ( eTTCountry != QLocale::AnyCountry ) || ( !cChanInfo.strCity.isEmpty() ) ) { strToolTip += "

" + tr ( "Location" ) + "

"; if ( !cChanInfo.strCity.isEmpty() ) { - strToolTip += cChanInfo.strCity; + strToolTip += cChanInfo.strCity; strLocationAccessible += cChanInfo.strCity; if ( eTTCountry != QLocale::AnyCountry ) { - strToolTip += ", "; + strToolTip += ", "; strLocationAccessible += ", "; } } if ( eTTCountry != QLocale::AnyCountry ) { - strToolTip += QLocale::countryToString ( eTTCountry ); + strToolTip += QLocale::countryToString ( eTTCountry ); strLocationAccessible += QLocale::countryToString ( eTTCountry ); } } @@ -819,20 +786,20 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo ) switch ( cChanInfo.eSkillLevel ) { case SL_BEGINNER: - strSkillLevel = tr ( "Beginner" ); - strToolTip += "

" + tr ( "Skill Level" ) + "

" + strSkillLevel; + strSkillLevel = tr ( "Beginner" ); + strToolTip += "

" + tr ( "Skill Level" ) + "

" + strSkillLevel; strInstrumentAccessible += ", " + strSkillLevel; break; case SL_INTERMEDIATE: - strSkillLevel = tr ( "Intermediate" ); - strToolTip += "

" + tr ( "Skill Level" ) + "

" + strSkillLevel; + strSkillLevel = tr ( "Intermediate" ); + strToolTip += "

" + tr ( "Skill Level" ) + "

" + strSkillLevel; strInstrumentAccessible += ", " + strSkillLevel; break; case SL_PROFESSIONAL: - strSkillLevel = tr ( "Expert" ); - strToolTip += "

" + tr ( "Skill Level" ) + "

" + strSkillLevel; + strSkillLevel = tr ( "Expert" ); + strToolTip += "

" + tr ( "Skill Level" ) + "

" + strSkillLevel; strInstrumentAccessible += ", " + strSkillLevel; break; @@ -847,31 +814,30 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo ) strToolTip.prepend ( "

" + tr ( "Musician Profile" ) + "

" ); } - plblCountryFlag->setToolTip ( strToolTip ); + plblCountryFlag->setToolTip ( strToolTip ); plblCountryFlag->setAccessibleDescription ( strLocationAccessible ); - plblInstrument->setToolTip ( strToolTip ); - plblInstrument->setAccessibleDescription ( strInstrumentAccessible ); - plblLabel->setToolTip ( strToolTip ); - plblLabel->setAccessibleName ( strAliasAccessible ); - plblLabel->setAccessibleDescription ( tr ( "Alias" ) ); + plblInstrument->setToolTip ( strToolTip ); + plblInstrument->setAccessibleDescription ( strInstrumentAccessible ); + plblLabel->setToolTip ( strToolTip ); + plblLabel->setAccessibleName ( strAliasAccessible ); + plblLabel->setAccessibleDescription ( tr ( "Alias" ) ); } - /******************************************************************************\ * CAudioMixerBoard * \******************************************************************************/ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent ) : - QGroupBox ( parent ), - pSettings ( nullptr ), - bDisplayPans ( false ), - bIsPanSupported ( false ), - bNoFaderVisible ( true ), - iMyChannelID ( INVALID_INDEX ), + QGroupBox ( parent ), + pSettings ( nullptr ), + bDisplayPans ( false ), + bIsPanSupported ( false ), + bNoFaderVisible ( true ), + iMyChannelID ( INVALID_INDEX ), iRunningNewClientCnt ( 0 ), - iNumMixerPanelRows ( 1 ), // pSettings->iNumMixerPanelRows is not yet available - strServerName ( "" ), - eRecorderState ( RS_UNDEFINED ), - eChSortType ( ST_NO_SORT ) + iNumMixerPanelRows ( 1 ), // pSettings->iNumMixerPanelRows is not yet available + strServerName ( "" ), + eRecorderState ( RS_UNDEFINED ), + eChSortType ( ST_NO_SORT ) { // add group box and hboxlayout QHBoxLayout* pGroupBoxLayout = new QHBoxLayout ( this ); @@ -880,10 +846,10 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent ) : pMainLayout = new QGridLayout ( pMixerWidget ); setAccessibleName ( "Personal Mix at the Server groupbox" ); - setWhatsThis ( "" + tr ( "Personal Mix at the Server" ) + ": " + tr ( - "When connected to a server, the controls here allow you to set your " - "local mix without affecting what others hear from you. The title shows " - "the server name and, when known, whether it is actively recording." ) ); + setWhatsThis ( "" + tr ( "Personal Mix at the Server" ) + ": " + + tr ( "When connected to a server, the controls here allow you to set your " + "local mix without affecting what others hear from you. The title shows " + "the server name and, when known, whether it is actively recording." ) ); // set title text (default: no server given) SetServerName ( "" ); @@ -906,12 +872,11 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent ) : pGroupBoxLayout->setContentsMargins ( 0, 0, 0, 1 ); // note: to avoid problems at the bottom, use a small margin for that // add the group box to the scroll area - pScrollArea->setMinimumWidth ( 200 ); // at least two faders shall be visible - pScrollArea->setWidget ( pMixerWidget ); + pScrollArea->setMinimumWidth ( 200 ); // at least two faders shall be visible + pScrollArea->setWidget ( pMixerWidget ); pScrollArea->setWidgetResizable ( true ); // make sure it fills the entire scroll area - pScrollArea->setFrameShape ( QFrame::NoFrame ); - pGroupBoxLayout->addWidget ( pScrollArea ); - + pScrollArea->setFrameShape ( QFrame::NoFrame ); + pGroupBoxLayout->addWidget ( pScrollArea ); // Connections ------------------------------------------------------------- connectFaderSignalsToMixerBoardSlots(); @@ -930,26 +895,22 @@ inline void CAudioMixerBoard::connectFaderSignalsToMixerBoardSlots() { int iCurChanID = slotId - 1; - void ( CAudioMixerBoard::* pGainValueChanged )( float, bool, bool, bool, double ) = - &CAudioMixerBoardSlots::OnChGainValueChanged; + void ( CAudioMixerBoard::*pGainValueChanged ) ( float, bool, bool, bool, double ) = &CAudioMixerBoardSlots::OnChGainValueChanged; - void ( CAudioMixerBoard::* pPanValueChanged )( float ) = - &CAudioMixerBoardSlots::OnChPanValueChanged; + void ( CAudioMixerBoard::*pPanValueChanged ) ( float ) = &CAudioMixerBoardSlots::OnChPanValueChanged; - QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::soloStateChanged, - this, &CAudioMixerBoard::UpdateSoloStates ); + QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::soloStateChanged, this, &CAudioMixerBoard::UpdateSoloStates ); - QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::gainValueChanged, - this, pGainValueChanged ); + QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::gainValueChanged, this, pGainValueChanged ); - QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::panValueChanged, - this, pPanValueChanged ); + QObject::connect ( vecpChanFader[iCurChanID], &CChannelFader::panValueChanged, this, pPanValueChanged ); connectFaderSignalsToMixerBoardSlots(); } template<> -inline void CAudioMixerBoard::connectFaderSignalsToMixerBoardSlots<0>() {} +inline void CAudioMixerBoard::connectFaderSignalsToMixerBoardSlots<0>() +{} void CAudioMixerBoard::SetServerName ( const QString& strNewServerName ) { @@ -1032,7 +993,7 @@ void CAudioMixerBoard::HideAll() ChangeFaderOrder ( ST_NO_SORT ); // Reset recording indication styleSheet - setStyleSheet( "" ); + setStyleSheet ( "" ); // emit status of connected clients emit NumClientsChanged ( 0 ); // -> no clients connected @@ -1057,8 +1018,8 @@ void CAudioMixerBoard::ChangeFaderOrder ( const EChSortType eChSortType ) QMutexLocker locker ( &Mutex ); // create a pair list of lower strings and fader ID for each channel - QList > PairList; - int iNumVisibleFaders = 0; + QList> PairList; + int iNumVisibleFaders = 0; for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { @@ -1074,7 +1035,8 @@ void CAudioMixerBoard::ChangeFaderOrder ( const EChSortType eChSortType ) { // sort first "by instrument" and second "by name" by adding the name after the instrument PairList << QPair ( CInstPictures::GetName ( vecpChanFader[i]->GetReceivedInstrument() ) + - vecpChanFader[i]->GetReceivedName().toLower(), i ); + vecpChanFader[i]->GetReceivedName().toLower(), + i ); } else if ( eChSortType == ST_BY_GROUPID ) { @@ -1092,8 +1054,7 @@ void CAudioMixerBoard::ChangeFaderOrder ( const EChSortType eChSortType ) { // per definition for no sort: faders are sorted in the order they appeared (note that we // pad to a total of 11 characters with zeros to make sure the sorting is done correctly) - PairList << QPair ( QString ( "%1" ).arg ( - vecpChanFader[i]->GetRunningNewClientCnt(), 11, 10, QLatin1Char ( '0' ) ), i ); + PairList << QPair ( QString ( "%1" ).arg ( vecpChanFader[i]->GetRunningNewClientCnt(), 11, 10, QLatin1Char ( '0' ) ), i ); } // count the number of visible faders @@ -1124,8 +1085,8 @@ void CAudioMixerBoard::ChangeFaderOrder ( const EChSortType eChSortType ) // channels are added row-first, up to iNumFadersFirstRow, then onto // the next row. pMainLayout->addWidget ( vecpChanFader[iCurFaderID]->GetMainWidget(), - iVisibleFaderCnt / iNumFadersFirstRow, - iVisibleFaderCnt % iNumFadersFirstRow ); + iVisibleFaderCnt / iNumFadersFirstRow, + iVisibleFaderCnt % iNumFadersFirstRow ); iVisibleFaderCnt++; } @@ -1205,13 +1166,11 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector& vecChanInf // we can adjust the level even if no fader was visible. // The fader level of 100 % is the default in the // server, in that case we do not have to do anything here. - if ( ( !bNoFaderVisible || - ( ( iMyChannelID != INVALID_INDEX ) && ( iMyChannelID != i ) ) ) && + if ( ( !bNoFaderVisible || ( ( iMyChannelID != INVALID_INDEX ) && ( iMyChannelID != i ) ) ) && ( pSettings->iNewClientFaderLevel != 100 ) ) { // the value is in percent -> convert range - vecpChanFader[i]->SetFaderLevel ( - pSettings->iNewClientFaderLevel / 100.0 * AUD_MIX_FADER_MAX ); + vecpChanFader[i]->SetFaderLevel ( pSettings->iNewClientFaderLevel / 100.0 * AUD_MIX_FADER_MAX ); } } @@ -1233,11 +1192,11 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector& vecChanInf bStoredFaderIsMute, iGroupID ) ) { - vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel, true ); // suppress group update - vecpChanFader[i]->SetPanValue ( iStoredPanValue ); + vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel, true ); // suppress group update + vecpChanFader[i]->SetPanValue ( iStoredPanValue ); vecpChanFader[i]->SetFaderIsSolo ( bStoredFaderIsSolo ); vecpChanFader[i]->SetFaderIsMute ( bStoredFaderIsMute ); - vecpChanFader[i]->SetGroupID ( iGroupID ); // Must be the last to be set in the fader! + vecpChanFader[i]->SetGroupID ( iGroupID ); // Must be the last to be set in the fader! } } @@ -1274,8 +1233,7 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector& vecChanInf emit NumClientsChanged ( iNumConnectedClients ); } -void CAudioMixerBoard::SetFaderLevel ( const int iChannelIdx, - const int iValue ) +void CAudioMixerBoard::SetFaderLevel ( const int iChannelIdx, const int iValue ) { // only apply new fader level if channel index is valid and the fader is visible if ( ( iChannelIdx >= 0 ) && ( iChannelIdx < MAX_NUM_CHANNELS ) ) @@ -1287,12 +1245,10 @@ void CAudioMixerBoard::SetFaderLevel ( const int iChannelIdx, } } -void CAudioMixerBoard::SetPanValue ( const int iChannelIdx, - const int iValue ) +void CAudioMixerBoard::SetPanValue ( const int iChannelIdx, const int iValue ) { // only apply new pan value if channel index is valid and the panner is visible - if ( ( iChannelIdx >= 0 ) && ( iChannelIdx < MAX_NUM_CHANNELS ) - && bDisplayPans ) + if ( ( iChannelIdx >= 0 ) && ( iChannelIdx < MAX_NUM_CHANNELS ) && bDisplayPans ) { if ( vecpChanFader[iChannelIdx]->IsVisible() ) { @@ -1301,8 +1257,7 @@ void CAudioMixerBoard::SetPanValue ( const int iChannelIdx, } } -void CAudioMixerBoard::SetFaderIsSolo ( const int iChannelIdx, - const bool bIsSolo ) +void CAudioMixerBoard::SetFaderIsSolo ( const int iChannelIdx, const bool bIsSolo ) { // only apply solo if channel index is valid and the fader is visible if ( ( iChannelIdx >= 0 ) && ( iChannelIdx < MAX_NUM_CHANNELS ) ) @@ -1315,8 +1270,7 @@ void CAudioMixerBoard::SetFaderIsSolo ( const int iChannelIdx, } } -void CAudioMixerBoard::SetFaderIsMute ( const int iChannelIdx, - const bool bIsMute ) +void CAudioMixerBoard::SetFaderIsMute ( const int iChannelIdx, const bool bIsMute ) { // only apply mute if channel index is valid and the fader is visible if ( ( iChannelIdx >= 0 ) && ( iChannelIdx < MAX_NUM_CHANNELS ) ) @@ -1340,8 +1294,7 @@ void CAudioMixerBoard::SetAllFaderLevelsToNewClientLevel() // the value is in percent -> convert range, also use the group // update flag to make sure the group values are all set to the // same fader level now - vecpChanFader[i]->SetFaderLevel ( - pSettings->iNewClientFaderLevel / 100.0 * AUD_MIX_FADER_MAX, true ); + vecpChanFader[i]->SetFaderLevel ( pSettings->iNewClientFaderLevel / 100.0 * AUD_MIX_FADER_MAX, true ); } } } @@ -1355,7 +1308,7 @@ void CAudioMixerBoard::AutoAdjustAllFaderLevels() int vecChannelsPerGroup[MAX_NUM_FADER_GROUPS + 1]; for ( int i = 0; i < MAX_NUM_FADER_GROUPS + 1; ++i ) { - vecMaxLevel[i] = LOW_BOUND_SIG_METER; + vecMaxLevel[i] = LOW_BOUND_SIG_METER; vecChannelsPerGroup[i] = 0; } CVector> levels; @@ -1369,9 +1322,7 @@ void CAudioMixerBoard::AutoAdjustAllFaderLevels() { // map averaged meter output level to decibels // (invert CStereoSignalLevelMeter::CalcLogResultForMeter) - float leveldB = vecAvgLevels[i] * - ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ) / - NUM_STEPS_LED_BAR + LOW_BOUND_SIG_METER; + float leveldB = vecAvgLevels[i] * ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ) / NUM_STEPS_LED_BAR + LOW_BOUND_SIG_METER; int group = vecpChanFader[i]->GetGroupID(); if ( group == INVALID_INDEX ) @@ -1402,29 +1353,25 @@ void CAudioMixerBoard::AutoAdjustAllFaderLevels() } // only my channel is active, nothing to do - if ( cntActiveGroups == 0 && - vecChannelsPerGroup[MAX_NUM_FADER_GROUPS] == 0 ) + if ( cntActiveGroups == 0 && vecChannelsPerGroup[MAX_NUM_FADER_GROUPS] == 0 ) { return; } // compute target level for each group // (prevent clipping when each group contributes at maximum level) - float targetLevelPerGroup = -20.0f * log10 ( - std::max ( cntActiveGroups, 1 ) ); + float targetLevelPerGroup = -20.0f * log10 ( std::max ( cntActiveGroups, 1 ) ); // compute target levels for the channels of each group individually float vecTargetChannelLevel[MAX_NUM_FADER_GROUPS + 1]; float levelOffset = 0.0f; - float minFader = 0.0f; + float minFader = 0.0f; for ( int i = 0; i < MAX_NUM_FADER_GROUPS + 1; ++i ) { // compute the target level for each channel in the current group // (prevent clipping when each channel in this group contributes at // the maximum level) - vecTargetChannelLevel[i] = vecChannelsPerGroup[i] > 0 ? - targetLevelPerGroup - 20.0f * log10 ( vecChannelsPerGroup[i] ) : - 0.0f; + vecTargetChannelLevel[i] = vecChannelsPerGroup[i] > 0 ? targetLevelPerGroup - 20.0f * log10 ( vecChannelsPerGroup[i] ) : 0.0f; // get median level int cntChannels = levels[i].Size(); @@ -1441,12 +1388,10 @@ void CAudioMixerBoard::AutoAdjustAllFaderLevels() { // otherwise, we adjust the level offset in such a way that // the level can be reached - levelOffset = fmin ( levelOffset, - refLevel - vecTargetChannelLevel[i] ); + levelOffset = fmin ( levelOffset, refLevel - vecTargetChannelLevel[i] ); // compute the minimum necessary fader setting - minFader = fmin ( minFader, -vecMaxLevel[i] + - vecTargetChannelLevel[i] + levelOffset ); + minFader = fmin ( minFader, -vecMaxLevel[i] + vecTargetChannelLevel[i] + levelOffset ); } } @@ -1467,9 +1412,7 @@ void CAudioMixerBoard::AutoAdjustAllFaderLevels() { // map averaged meter output level to decibels // (invert CStereoSignalLevelMeter::CalcLogResultForMeter) - float leveldB = vecAvgLevels[i] * - ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ) / - NUM_STEPS_LED_BAR + LOW_BOUND_SIG_METER; + float leveldB = vecAvgLevels[i] * ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ) / NUM_STEPS_LED_BAR + LOW_BOUND_SIG_METER; int group = vecpChanFader[i]->GetGroupID(); if ( group == INVALID_INDEX ) @@ -1490,17 +1433,14 @@ void CAudioMixerBoard::AutoAdjustAllFaderLevels() if ( leveldB >= AUTO_FADER_NOISE_THRESHOLD_DB ) { // compute new level - float newdBLevel = -leveldB + vecTargetChannelLevel[group] + - levelOffset; + float newdBLevel = -leveldB + vecTargetChannelLevel[group] + levelOffset; // map range from decibels to fader level // (this inverts MathUtils::CalcFaderGain) - float newFaderLevel = ( newdBLevel / AUD_MIX_FADER_RANGE_DB + - 1.0f ) * AUD_MIX_FADER_MAX; + float newFaderLevel = ( newdBLevel / AUD_MIX_FADER_RANGE_DB + 1.0f ) * AUD_MIX_FADER_MAX; // limit fader - newFaderLevel = fmin ( fmax ( newFaderLevel, 0.0f), - float ( AUD_MIX_FADER_MAX ) ); + newFaderLevel = fmin ( fmax ( newFaderLevel, 0.0f ), float ( AUD_MIX_FADER_MAX ) ); // set fader level vecpChanFader[i]->SetFaderLevel ( newFaderLevel, true ); @@ -1538,17 +1478,16 @@ void CAudioMixerBoard::LoadAllFaderSettings() bStoredFaderIsMute, iGroupID ) ) { - vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel, true ); // suppress group update - vecpChanFader[i]->SetPanValue ( iStoredPanValue ); + vecpChanFader[i]->SetFaderLevel ( iStoredFaderLevel, true ); // suppress group update + vecpChanFader[i]->SetPanValue ( iStoredPanValue ); vecpChanFader[i]->SetFaderIsSolo ( bStoredFaderIsSolo ); vecpChanFader[i]->SetFaderIsMute ( bStoredFaderIsMute ); - vecpChanFader[i]->SetGroupID ( iGroupID ); // Must be the last to be set in the fader! + vecpChanFader[i]->SetGroupID ( iGroupID ); // Must be the last to be set in the fader! } } } -void CAudioMixerBoard::SetRemoteFaderIsMute ( const int iChannelIdx, - const bool bIsMute ) +void CAudioMixerBoard::SetRemoteFaderIsMute ( const int iChannelIdx, const bool bIsMute ) { // only apply remote mute state if channel index is valid and the fader is visible if ( ( iChannelIdx >= 0 ) && ( iChannelIdx < MAX_NUM_CHANNELS ) ) @@ -1606,10 +1545,8 @@ void CAudioMixerBoard::UpdateGainValue ( const int iChannelIdx, for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { // update rest of faders selected - if ( vecpChanFader[i]->IsVisible() && - ( vecpChanFader[i]->GetGroupID() == vecpChanFader[iChannelIdx]->GetGroupID() ) && - ( i != iChannelIdx ) && - ( dLevelRatio >= 0 ) ) + if ( vecpChanFader[i]->IsVisible() && ( vecpChanFader[i]->GetGroupID() == vecpChanFader[iChannelIdx]->GetGroupID() ) && + ( i != iChannelIdx ) && ( dLevelRatio >= 0 ) ) { // synchronize faders with moving fader level (it is important // to set the group flag to avoid infinite looping) @@ -1619,22 +1556,17 @@ void CAudioMixerBoard::UpdateGainValue ( const int iChannelIdx, } } -void CAudioMixerBoard::UpdatePanValue ( const int iChannelIdx, - const float fValue ) -{ - emit ChangeChanPan ( iChannelIdx, fValue ); -} +void CAudioMixerBoard::UpdatePanValue ( const int iChannelIdx, const float fValue ) { emit ChangeChanPan ( iChannelIdx, fValue ); } void CAudioMixerBoard::StoreFaderSettings ( CChannelFader* pChanFader ) { // if the fader was visible and the name is not empty, we store the old gain - if ( pChanFader->IsVisible() && - !pChanFader->GetReceivedName().isEmpty() ) + if ( pChanFader->IsVisible() && !pChanFader->GetReceivedName().isEmpty() ) { - CVector viOldStoredFaderLevels ( pSettings->vecStoredFaderLevels ); - CVector viOldStoredPanValues ( pSettings->vecStoredPanValues ); - CVector vbOldStoredFaderIsSolo ( pSettings->vecStoredFaderIsSolo ); - CVector vbOldStoredFaderIsMute ( pSettings->vecStoredFaderIsMute ); + CVector viOldStoredFaderLevels ( pSettings->vecStoredFaderLevels ); + CVector viOldStoredPanValues ( pSettings->vecStoredPanValues ); + CVector vbOldStoredFaderIsSolo ( pSettings->vecStoredFaderIsSolo ); + CVector vbOldStoredFaderIsMute ( pSettings->vecStoredFaderIsMute ); CVector vbOldStoredFaderGroupID ( pSettings->vecStoredFaderGroupID ); // put new value on the top of the list @@ -1713,9 +1645,7 @@ void CAudioMixerBoard::SetChannelLevels ( const CVector& vecChannelLev if ( vecpChanFader[iChId]->IsVisible() && ( i < iNumChannelLevels ) ) { // compute exponential moving average - vecAvgLevels[iChId] = - (1.0f - AUTO_FADER_ADJUST_ALPHA) * vecAvgLevels[iChId] + - AUTO_FADER_ADJUST_ALPHA * vecChannelLevel[i]; + vecAvgLevels[iChId] = ( 1.0f - AUTO_FADER_ADJUST_ALPHA ) * vecAvgLevels[iChId] + AUTO_FADER_ADJUST_ALPHA * vecChannelLevel[i]; vecpChanFader[iChId]->SetChannelLevel ( vecChannelLevel[i++] ); @@ -1729,7 +1659,4 @@ void CAudioMixerBoard::SetChannelLevels ( const CVector& vecChannelLev } } -void CAudioMixerBoard::MuteMyChannel() -{ - SetFaderIsMute ( iMyChannelID, true ); -} +void CAudioMixerBoard::MuteMyChannel() { SetFaderIsMute ( iMyChannelID, true ); } diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h old mode 100755 new mode 100644 index 7e8573635d..ddeeefac45 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -43,7 +43,6 @@ #include "levelmeter.h" #include "settings.h" - /* Classes ********************************************************************/ class CChannelFader : public QObject { @@ -73,8 +72,7 @@ class CChannelFader : public QObject void SetFaderIsMute ( const bool bIsMute ); void SetGroupID ( const int iNGroupID ); void SetRemoteFaderIsMute ( const bool bIsMute ); - void SetFaderLevel ( const double dLevel, - const bool bIsGroupUpdate = false ); + void SetFaderLevel ( const double dLevel, const bool bIsGroupUpdate = false ); int GetFaderLevel() { return pFader->value(); } double GetPreviousFaderLevel() { return dPreviousFaderLevel; } @@ -87,14 +85,13 @@ class CChannelFader : public QObject void UpdateSoloState ( const bool bNewOtherSoloState ); protected: - void UpdateGroupIDDependencies(); - void SetMute ( const bool bState ); - void SetupFaderTag ( const ESkillLevel eSkillLevel ); - void SendPanValueToServer ( const int iPan ); - void SendFaderLevelToServer ( const double dLevel, - const bool bIsGroupUpdate ); + void UpdateGroupIDDependencies(); + void SetMute ( const bool bState ); + void SetupFaderTag ( const ESkillLevel eSkillLevel ); + void SendPanValueToServer ( const int iPan ); + void SendFaderLevelToServer ( const double dLevel, const bool bIsGroupUpdate ); - QFrame* pFrame; + QFrame* pFrame; QWidget* pLevelsBox; QWidget* pMuteSoloBox; @@ -106,31 +103,36 @@ class CChannelFader : public QObject QHBoxLayout* pLabelGrid; QVBoxLayout* pLabelPictGrid; - QCheckBox* pcbMute; - QCheckBox* pcbSolo; - QCheckBox* pcbGroup; - QMenu* pGroupPopupMenu; + QCheckBox* pcbMute; + QCheckBox* pcbSolo; + QCheckBox* pcbGroup; + QMenu* pGroupPopupMenu; - QGroupBox* pLabelInstBox; - QLabel* plblLabel; - QLabel* plblInstrument; - QLabel* plblCountryFlag; + QGroupBox* pLabelInstBox; + QLabel* plblLabel; + QLabel* plblInstrument; + QLabel* plblCountryFlag; CChannelInfo cReceivedChanInfo; - bool bOtherChannelIsSolo; - bool bIsMyOwnFader; - bool bIsMutedAtServer; - double dPreviousFaderLevel; - int iGroupID; - QString strGroupBaseText; - int iRunningNewClientCnt; - int iInstrPicMaxWidth; - EGUIDesign eDesign; - QPixmap BitmapMutedIcon; + bool bOtherChannelIsSolo; + bool bIsMyOwnFader; + bool bIsMutedAtServer; + double dPreviousFaderLevel; + int iGroupID; + QString strGroupBaseText; + int iRunningNewClientCnt; + int iInstrPicMaxWidth; + EGUIDesign eDesign; + QPixmap BitmapMutedIcon; public slots: - void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value, QGuiApplication::keyboardModifiers() == Qt::ShiftModifier ); /* isolate a channel from the group temporarily with shift-click-drag (#695) */ } + void OnLevelValueChanged ( int value ) + { + SendFaderLevelToServer ( value, + QGuiApplication::keyboardModifiers() == + Qt::ShiftModifier ); /* isolate a channel from the group temporarily with shift-click-drag (#695) */ + } void OnPanValueChanged ( int value ); void OnMuteStateChanged ( int value ); @@ -139,13 +141,9 @@ public slots: void OnGroupMenuGrp ( int iGrp ) { SetGroupID ( iGrp ); } signals: - void gainValueChanged ( float value, - bool bIsMyOwnFader, - bool bIsGroupUpdate, - bool bSuppressServerUpdate, - double dLevelRatio ); + void gainValueChanged ( float value, bool bIsMyOwnFader, bool bIsGroupUpdate, bool bSuppressServerUpdate, double dLevelRatio ); - void panValueChanged ( float value ); + void panValueChanged ( float value ); void soloStateChanged ( int value ); }; @@ -153,16 +151,10 @@ template class CAudioMixerBoardSlots : public CAudioMixerBoardSlots { public: - void OnChGainValueChanged ( float fValue, - bool bIsMyOwnFader, - bool bIsGroupUpdate, - bool bSuppressServerUpdate, - double dLevelRatio ) { UpdateGainValue ( slotId - 1, - fValue, - bIsMyOwnFader, - bIsGroupUpdate, - bSuppressServerUpdate, - dLevelRatio ); } + void OnChGainValueChanged ( float fValue, bool bIsMyOwnFader, bool bIsGroupUpdate, bool bSuppressServerUpdate, double dLevelRatio ) + { + UpdateGainValue ( slotId - 1, fValue, bIsMyOwnFader, bIsGroupUpdate, bSuppressServerUpdate, dLevelRatio ); + } void OnChPanValueChanged ( float fValue ) { UpdatePanValue ( slotId - 1, fValue ); } @@ -174,16 +166,14 @@ class CAudioMixerBoardSlots : public CAudioMixerBoardSlots const bool bSuppressServerUpdate, const double dLevelRatio ) = 0; - virtual void UpdatePanValue ( const int iChannelIdx, - const float fValue ) = 0; + virtual void UpdatePanValue ( const int iChannelIdx, const float fValue ) = 0; }; template<> -class CAudioMixerBoardSlots<0> {}; +class CAudioMixerBoardSlots<0> +{}; -class CAudioMixerBoard : - public QGroupBox, - public CAudioMixerBoardSlots +class CAudioMixerBoard : public QGroupBox, public CAudioMixerBoardSlots { Q_OBJECT @@ -192,47 +182,43 @@ class CAudioMixerBoard : virtual ~CAudioMixerBoard(); - void SetSettingsPointer ( CClientSettings* pNSet ) { pSettings = pNSet; } - void HideAll(); - void ApplyNewConClientList ( CVector& vecChanInfo ); - void SetServerName ( const QString& strNewServerName ); - QString GetServerName() { return strServerName; } - void SetGUIDesign ( const EGUIDesign eNewDesign ); - void SetDisplayPans ( const bool eNDP ); - void SetPanIsSupported(); - void SetRemoteFaderIsMute ( const int iChannelIdx, const bool bIsMute ); - void SetMyChannelID ( const int iChannelIdx ) { iMyChannelID = iChannelIdx; } - int GetMyChannelID() const { return iMyChannelID; } + void SetSettingsPointer ( CClientSettings* pNSet ) { pSettings = pNSet; } + void HideAll(); + void ApplyNewConClientList ( CVector& vecChanInfo ); + void SetServerName ( const QString& strNewServerName ); + QString GetServerName() { return strServerName; } + void SetGUIDesign ( const EGUIDesign eNewDesign ); + void SetDisplayPans ( const bool eNDP ); + void SetPanIsSupported(); + void SetRemoteFaderIsMute ( const int iChannelIdx, const bool bIsMute ); + void SetMyChannelID ( const int iChannelIdx ) { iMyChannelID = iChannelIdx; } + int GetMyChannelID() const { return iMyChannelID; } - void SetFaderLevel ( const int iChannelIdx, - const int iValue ); + void SetFaderLevel ( const int iChannelIdx, const int iValue ); - void SetPanValue ( const int iChannelIdx, - const int iValue ); + void SetPanValue ( const int iChannelIdx, const int iValue ); - void SetFaderIsSolo ( const int iChannelIdx, - const bool bIsSolo ); + void SetFaderIsSolo ( const int iChannelIdx, const bool bIsSolo ); - void SetFaderIsMute ( const int iChannelIdx, - const bool bIsMute ); + void SetFaderIsMute ( const int iChannelIdx, const bool bIsMute ); - void SetNumMixerPanelRows ( const int iNNumMixerPanelRows ); - int GetNumMixerPanelRows() { return iNumMixerPanelRows; } + void SetNumMixerPanelRows ( const int iNNumMixerPanelRows ); + int GetNumMixerPanelRows() { return iNumMixerPanelRows; } - void SetFaderSorting ( const EChSortType eNChSortType ); - EChSortType GetFaderSorting() { return eChSortType; } + void SetFaderSorting ( const EChSortType eNChSortType ); + EChSortType GetFaderSorting() { return eChSortType; } - void SetChannelLevels ( const CVector& vecChannelLevel ); + void SetChannelLevels ( const CVector& vecChannelLevel ); - void SetRecorderState ( const ERecorderState newRecorderState ); - ERecorderState GetRecorderState() { return eRecorderState; }; + void SetRecorderState ( const ERecorderState newRecorderState ); + ERecorderState GetRecorderState() { return eRecorderState; }; - void SetAllFaderLevelsToNewClientLevel(); - void StoreAllFaderSettings(); - void LoadAllFaderSettings(); - void AutoAdjustAllFaderLevels(); + void SetAllFaderLevelsToNewClientLevel(); + void StoreAllFaderSettings(); + void LoadAllFaderSettings(); + void AutoAdjustAllFaderLevels(); - void MuteMyChannel(); + void MuteMyChannel(); protected: class CMixerBoardScrollArea : public QScrollArea @@ -266,7 +252,7 @@ class CAudioMixerBoard : CClientSettings* pSettings; CVector vecpChanFader; CMixerBoardScrollArea* pScrollArea; - QGridLayout * pMainLayout; + QGridLayout* pMainLayout; bool bDisplayPans; bool bIsPanSupported; bool bNoFaderVisible; @@ -286,8 +272,7 @@ class CAudioMixerBoard : const bool bSuppressServerUpdate, const double dLevelRatio ); - virtual void UpdatePanValue ( const int iChannelIdx, - const float fValue ); + virtual void UpdatePanValue ( const int iChannelIdx, const float fValue ); template inline void connectFaderSignalsToMixerBoardSlots(); diff --git a/src/buffer.cpp b/src/buffer.cpp old mode 100755 new mode 100644 index 53307433fc..c937aa1000 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -27,12 +27,8 @@ #include "buffer.h" - /* Network buffer implementation **********************************************/ -void CNetBuf::Init ( const int iNewBlockSize, - const int iNewNumBlocks, - const bool bNUseSequenceNumber, - const bool bPreserve ) +void CNetBuf::Init ( const int iNewBlockSize, const int iNewNumBlocks, const bool bNUseSequenceNumber, const bool bPreserve ) { // store the sequence number activation flag bUseSequenceNumber = bNUseSequenceNumber; @@ -44,7 +40,7 @@ void CNetBuf::Init ( const int iNewBlockSize, if ( bPreserve && ( !bIsSimulation ) && bIsInitialized && ( iBlockSize == iNewBlockSize ) ) { // extract all data from buffer in temporary storage - CVector > vecvecTempMemory = vecvecMemory; // allocate worst case memory by copying + CVector> vecvecTempMemory = vecvecMemory; // allocate worst case memory by copying if ( !bNUseSequenceNumber ) { @@ -62,8 +58,7 @@ void CNetBuf::Init ( const int iNewBlockSize, // data back as the new buffer size can hold) int iDataCnt = 0; - while ( ( iDataCnt < iPreviousDataCnt ) && - Put ( vecvecTempMemory[iDataCnt], iBlockSize ) ) + while ( ( iDataCnt < iPreviousDataCnt ) && Put ( vecvecTempMemory[iDataCnt], iBlockSize ) ) { iDataCnt++; } @@ -112,11 +107,10 @@ void CNetBuf::Init ( const int iNewBlockSize, bIsInitialized = true; } -void CNetBuf::Resize ( const int iNewNumBlocks, - const int iNewBlockSize ) +void CNetBuf::Resize ( const int iNewNumBlocks, const int iNewBlockSize ) { // allocate memory for actual data buffer - vecvecMemory.Init ( iNewNumBlocks ); + vecvecMemory.Init ( iNewNumBlocks ); veciBlockValid.Init ( iNewNumBlocks, 0 ); // initialize with zeros = invalid if ( !bIsSimulation ) @@ -135,8 +129,7 @@ void CNetBuf::Resize ( const int iNewNumBlocks, iNumBlocksMemory = iNewNumBlocks; } -bool CNetBuf::Put ( const CVector& vecbyData, - int iInSize ) +bool CNetBuf::Put ( const CVector& vecbyData, int iInSize ) { // if the sequence number is used, we need a complete different way of applying // the new network packet @@ -262,8 +255,7 @@ bool CNetBuf::Put ( const CVector& vecbyData, { // check if there is not enough space available and that the input size is a // multiple of the block size - if ( ( GetAvailSpace() < iInSize ) || - ( ( iInSize % iBlockSize ) != 0 ) ) + if ( ( GetAvailSpace() < iInSize ) || ( ( iInSize % iBlockSize ) != 0 ) ) { return false; } @@ -306,15 +298,12 @@ bool CNetBuf::Put ( const CVector& vecbyData, return true; } -bool CNetBuf::Get ( CVector& vecbyData, - const int iOutSize ) +bool CNetBuf::Get ( CVector& vecbyData, const int iOutSize ) { bool bReturn = true; // check requested output size and available buffer data - if ( ( iOutSize == 0 ) || - ( iOutSize != iBlockSize ) || - ( GetAvailData() < iOutSize ) ) + if ( ( iOutSize == 0 ) || ( iOutSize != iBlockSize ) || ( GetAvailData() < iOutSize ) ) { return false; } @@ -333,9 +322,7 @@ bool CNetBuf::Get ( CVector& vecbyData, if ( !bIsSimulation && bReturn ) { // copy data from internal buffer in output buffer - std::copy ( vecvecMemory[iBlockGetPos].begin(), - vecvecMemory[iBlockGetPos].begin() + iBlockSize, - vecbyData.begin() ); + std::copy ( vecvecMemory[iBlockGetPos].begin(), vecvecMemory[iBlockGetPos].begin() + iBlockSize, vecbyData.begin() ); } // set the get position and sequence number one block further @@ -410,18 +397,17 @@ int CNetBuf::GetAvailData() const return iAvBlocks * iBlockSize; } - /* Network buffer with statistic calculations implementation ******************/ CNetBufWithStats::CNetBufWithStats() : - CNetBuf ( false ), // base class init: no simulation mode - iMaxStatisticCount ( MAX_STATISTIC_COUNT ), + CNetBuf ( false ), // base class init: no simulation mode + iMaxStatisticCount ( MAX_STATISTIC_COUNT ), bUseDoubleSystemFrameSize ( false ), - dAutoFilt_WightUpNormal ( IIR_WEIGTH_UP_NORMAL ), + dAutoFilt_WightUpNormal ( IIR_WEIGTH_UP_NORMAL ), dAutoFilt_WightDownNormal ( IIR_WEIGTH_DOWN_NORMAL ), - dAutoFilt_WightUpFast ( IIR_WEIGTH_UP_FAST ), - dAutoFilt_WightDownFast ( IIR_WEIGTH_DOWN_FAST ), - dErrorRateBound ( ERROR_RATE_BOUND ), - dUpMaxErrorBound ( UP_MAX_ERROR_BOUND ) + dAutoFilt_WightUpFast ( IIR_WEIGTH_UP_FAST ), + dAutoFilt_WightDownFast ( IIR_WEIGTH_DOWN_FAST ), + dErrorRateBound ( ERROR_RATE_BOUND ), + dUpMaxErrorBound ( UP_MAX_ERROR_BOUND ) { // Define the sizes of the simulation buffers, // must be NUM_STAT_SIMULATION_BUFFERS elements! @@ -446,9 +432,7 @@ CNetBufWithStats::CNetBufWithStats() : } } -void CNetBufWithStats::GetErrorRates ( CVector& vecErrRates, - double& dLimit, - double& dMaxUpLimit ) +void CNetBufWithStats::GetErrorRates ( CVector& vecErrRates, double& dLimit, double& dMaxUpLimit ) { // get all the averages of the error statistic vecErrRates.Init ( NUM_STAT_SIMULATION_BUFFERS ); @@ -463,10 +447,7 @@ void CNetBufWithStats::GetErrorRates ( CVector& vecErrRates, dMaxUpLimit = dUpMaxErrorBound; } -void CNetBufWithStats::Init ( const int iNewBlockSize, - const int iNewNumBlocks, - const bool bNUseSequenceNumber, - const bool bPreserve ) +void CNetBufWithStats::Init ( const int iNewBlockSize, const int iNewNumBlocks, const bool bNUseSequenceNumber, const bool bPreserve ) { // call base class Init CNetBuf::Init ( iNewBlockSize, iNewNumBlocks, bNUseSequenceNumber, bPreserve ); @@ -526,8 +507,7 @@ void CNetBufWithStats::ResetInitCounter() iInitCounter = iMaxStatisticCount / 4; } -bool CNetBufWithStats::Put ( const CVector& vecbyData, - const int iInSize ) +bool CNetBufWithStats::Put ( const CVector& vecbyData, const int iInSize ) { // call base class Put const bool bPutOK = CNetBuf::Put ( vecbyData, iInSize ); @@ -535,15 +515,13 @@ bool CNetBufWithStats::Put ( const CVector& vecbyData, // update statistics calculations for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ ) { - ErrorRateStatistic[i].Update ( - !SimulationBuffer[i].Put ( vecbyData, iInSize ) ); + ErrorRateStatistic[i].Update ( !SimulationBuffer[i].Put ( vecbyData, iInSize ) ); } return bPutOK; } -bool CNetBufWithStats::Get ( CVector& vecbyData, - const int iOutSize ) +bool CNetBufWithStats::Get ( CVector& vecbyData, const int iOutSize ) { // call base class Get const bool bGetOK = CNetBuf::Get ( vecbyData, iOutSize ); @@ -551,8 +529,7 @@ bool CNetBufWithStats::Get ( CVector& vecbyData, // update statistics calculations for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ ) { - ErrorRateStatistic[i].Update ( - !SimulationBuffer[i].Get ( vecbyData, iOutSize ) ); + ErrorRateStatistic[i].Update ( !SimulationBuffer[i].Get ( vecbyData, iOutSize ) ); } // update auto setting @@ -567,7 +544,6 @@ void CNetBufWithStats::UpdateAutoSetting() int iCurMaxUpDecision = 0; // dummy initialization bool bDecisionFound; - // Get regular error rate decision ----------------------------------------- // Use a specified error bound to identify the best buffer size for the // current network situation. Start with the smallest buffer and @@ -576,8 +552,7 @@ void CNetBufWithStats::UpdateAutoSetting() for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS - 1; i++ ) { - if ( ( !bDecisionFound ) && - ( ErrorRateStatistic[i].GetAverage() <= dErrorRateBound ) ) + if ( ( !bDecisionFound ) && ( ErrorRateStatistic[i].GetAverage() <= dErrorRateBound ) ) { iCurDecision = viBufSizesForSim[i]; bDecisionFound = true; @@ -590,7 +565,6 @@ void CNetBufWithStats::UpdateAutoSetting() iCurDecision = viBufSizesForSim[NUM_STAT_SIMULATION_BUFFERS - 1]; } - // Get maximum upper error rate decision ----------------------------------- // Use a specified error bound to identify the maximum upper error rate // to identify if we have a too low buffer setting which gives a very @@ -600,8 +574,7 @@ void CNetBufWithStats::UpdateAutoSetting() for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS - 1; i++ ) { - if ( ( !bDecisionFound ) && - ( ErrorRateStatistic[i].GetAverage() <= dUpMaxErrorBound ) ) + if ( ( !bDecisionFound ) && ( ErrorRateStatistic[i].GetAverage() <= dUpMaxErrorBound ) ) { iCurMaxUpDecision = viBufSizesForSim[i]; bDecisionFound = true; @@ -619,7 +592,6 @@ void CNetBufWithStats::UpdateAutoSetting() ResetInitCounter(); } - // Post calculation (filtering) -------------------------------------------- // Define different weights for up and down direction. Up direction // filtering shall be slower than for down direction since we assume @@ -663,12 +635,9 @@ void CNetBufWithStats::UpdateAutoSetting() } // apply non-linear IIR filter - MathUtils().UpDownIIR1 ( dCurIIRFilterResult, - static_cast ( iCurDecision ), - dWeightUp, - dWeightDown ); + MathUtils().UpDownIIR1 ( dCurIIRFilterResult, static_cast ( iCurDecision ), dWeightUp, dWeightDown ); -// clang-format off + // clang-format off /* // TEST store important detection parameters in file for debugging static FILE* pFile = fopen ( "test.dat", "w" ); @@ -684,14 +653,10 @@ else icnt++; } */ -// clang-format on + // clang-format on // apply a hysteresis - iCurAutoBufferSizeSetting = - MathUtils().DecideWithHysteresis ( dCurIIRFilterResult, - iCurDecidedResult, - dHysteresisValue ); - + iCurAutoBufferSizeSetting = MathUtils().DecideWithHysteresis ( dCurIIRFilterResult, iCurDecidedResult, dHysteresisValue ); // Initialization phase check and correction ------------------------------- // sometimes in the very first period after a connection we get a bad error @@ -699,8 +664,7 @@ else if ( iInitCounter == iMaxStatisticCount / 8 ) { // check error rate of the largest buffer as the indicator - if ( ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1]. - GetAverage() > dErrorRateBound ) + if ( ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].GetAverage() > dErrorRateBound ) { for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ ) { diff --git a/src/buffer.h b/src/buffer.h old mode 100755 new mode 100644 index a54d4365a7..910f0dfca5 --- a/src/buffer.h +++ b/src/buffer.h @@ -27,57 +27,56 @@ #include "util.h" #include "global.h" - /* Definitions ****************************************************************/ // number of simulation network jitter buffers for evaluating the statistic // NOTE If you want to change this number, the code has to modified, too! -#define NUM_STAT_SIMULATION_BUFFERS 10 +#define NUM_STAT_SIMULATION_BUFFERS 10 // hysteresis for buffer size decision to avoid fast changes if close to the bound -#define FILTER_DECISION_HYSTERESIS 0.1 +#define FILTER_DECISION_HYSTERESIS 0.1 // definition of the upper error bound of the jitter buffers -#define ERROR_RATE_BOUND_DOUBLE_FRAME_SIZE 0.0005 -#define ERROR_RATE_BOUND ( ERROR_RATE_BOUND_DOUBLE_FRAME_SIZE / 2 ) +#define ERROR_RATE_BOUND_DOUBLE_FRAME_SIZE 0.0005 +#define ERROR_RATE_BOUND ( ERROR_RATE_BOUND_DOUBLE_FRAME_SIZE / 2 ) // definition of the upper jitter buffer error bound, if that one is reached we // have to speed up the filtering to quickly get out of a incorrect buffer // size state -#define UP_MAX_ERROR_BOUND_DOUBLE_FRAME_SIZE 0.01 -#define UP_MAX_ERROR_BOUND ( UP_MAX_ERROR_BOUND_DOUBLE_FRAME_SIZE / 2 ) +#define UP_MAX_ERROR_BOUND_DOUBLE_FRAME_SIZE 0.01 +#define UP_MAX_ERROR_BOUND ( UP_MAX_ERROR_BOUND_DOUBLE_FRAME_SIZE / 2 ) // each regular buffer access lead to a count for put and get, assuming 2.66 ms // blocks we have 15 s / 2.66 ms * 2 = approx. 11000 -#define MAX_STATISTIC_COUNT_DOUBLE_FRAME_SIZE 11000 +#define MAX_STATISTIC_COUNT_DOUBLE_FRAME_SIZE 11000 // each regular buffer access lead to a count for put and get, assuming 1.33 ms // blocks we have 15 s / 1.33 ms * 2 = approx. 22500 -#define MAX_STATISTIC_COUNT 22500 +#define MAX_STATISTIC_COUNT 22500 // Note that the following definitions of the weigh constants assume a block // size of 128 samples at a sampling rate of 48 kHz. -#define IIR_WEIGTH_UP_NORMAL_DOUBLE_FRAME_SIZE 0.999995 -#define IIR_WEIGTH_DOWN_NORMAL_DOUBLE_FRAME_SIZE 0.9999 -#define IIR_WEIGTH_UP_FAST_DOUBLE_FRAME_SIZE 0.9995 -#define IIR_WEIGTH_DOWN_FAST_DOUBLE_FRAME_SIZE 0.999 +#define IIR_WEIGTH_UP_NORMAL_DOUBLE_FRAME_SIZE 0.999995 +#define IIR_WEIGTH_DOWN_NORMAL_DOUBLE_FRAME_SIZE 0.9999 +#define IIR_WEIGTH_UP_FAST_DOUBLE_FRAME_SIZE 0.9995 +#define IIR_WEIGTH_DOWN_FAST_DOUBLE_FRAME_SIZE 0.999 // convert numbers from 128 samples case using http://www.tsdconseil.fr/tutos/tuto-iir1-en.pdf // and https://octave-online.net: // gamma = exp(-Ts/tau), after some calculations we get: x=0.999995;exp(64/128*log(x)) -#define IIR_WEIGTH_UP_NORMAL 0.9999975 -#define IIR_WEIGTH_DOWN_NORMAL 0.99994999875 -#define IIR_WEIGTH_UP_FAST 0.9997499687422 -#define IIR_WEIGTH_DOWN_FAST 0.999499875 - +#define IIR_WEIGTH_UP_NORMAL 0.9999975 +#define IIR_WEIGTH_DOWN_NORMAL 0.99994999875 +#define IIR_WEIGTH_UP_FAST 0.9997499687422 +#define IIR_WEIGTH_DOWN_FAST 0.999499875 /* Classes ********************************************************************/ // Buffer base class ----------------------------------------------------------- -template class CBuffer +template +class CBuffer { public: CBuffer() {} - void Init ( const int iNewMemSize ) + void Init ( const int iNewMemSize ) { // allocate memory for actual data buffer vecMemory.Init ( iNewMemSize ); @@ -91,8 +90,7 @@ template class CBuffer iMemSize = iNewMemSize; } - virtual bool Put ( const CVector& vecData, - const int iInSize ) + virtual bool Put ( const CVector& vecData, const int iInSize ) { // copy new data in internal buffer int iCurPos = 0; @@ -116,9 +114,7 @@ template class CBuffer else { // data can be written in one step - std::copy ( vecData.begin(), - vecData.begin() + iInSize, - vecMemory.begin() + iPutPos ); + std::copy ( vecData.begin(), vecData.begin() + iInSize, vecMemory.begin() + iPutPos ); // set the put position one block further (no wrap around needs // to be considered here) @@ -144,8 +140,7 @@ template class CBuffer return true; // no error check in base class, always return ok } - virtual bool Get ( CVector& vecData, - const int iOutSize ) + virtual bool Get ( CVector& vecData, const int iOutSize ) { // copy data from internal buffer in output buffer int iCurPos = 0; @@ -169,9 +164,7 @@ template class CBuffer else { // data can be read in one step - std::copy ( vecMemory.begin() + iGetPos, - vecMemory.begin() + iGetPos + iOutSize, - vecData.begin() ); + std::copy ( vecMemory.begin() + iGetPos, vecMemory.begin() + iGetPos + iOutSize, vecData.begin() ); // set the get position one block further (no wrap around needs // to be considered here) @@ -219,7 +212,12 @@ template class CBuffer } protected: - enum EBufState { BS_OK, BS_FULL, BS_EMPTY }; + enum EBufState + { + BS_OK, + BS_FULL, + BS_EMPTY + }; CVector vecMemory; int iMemSize; @@ -228,18 +226,13 @@ template class CBuffer EBufState eBufState; }; - // Network buffer (jitter buffer) ---------------------------------------------- class CNetBuf { public: - CNetBuf ( const bool bNIsSim = false ) : - iSequenceNumberAtGetPos ( 0 ), bIsSimulation ( bNIsSim ), bIsInitialized ( false ) {} + CNetBuf ( const bool bNIsSim = false ) : iSequenceNumberAtGetPos ( 0 ), bIsSimulation ( bNIsSim ), bIsInitialized ( false ) {} - void Init ( const int iNewBlockSize, - const int iNewNumBlocks, - const bool bNUseSequenceNumber, - const bool bPreserve = false ); + void Init ( const int iNewBlockSize, const int iNewNumBlocks, const bool bNUseSequenceNumber, const bool bPreserve = false ); void SetIsSimulation ( const bool bNIsSim ) { bIsSimulation = bNIsSim; } @@ -247,48 +240,47 @@ class CNetBuf virtual bool Get ( CVector& vecbyData, const int iOutSize ); protected: - enum EBufState { BS_OK, BS_FULL, BS_EMPTY }; + enum EBufState + { + BS_OK, + BS_FULL, + BS_EMPTY + }; - int GetAvailSpace() const; - int GetAvailData() const; + int GetAvailSpace() const; + int GetAvailData() const; void Resize ( const int iNewNumBlocks, const int iNewBlockSize ); - CVector > vecvecMemory; - CVector veciBlockValid; - int iNumBlocksMemory; - int iBlockGetPos; - int iBlockPutPos; - int iBlockSize; - uint8_t iSequenceNumberAtGetPos; // uint8_t so that it wraps automatically - EBufState eBufState; - bool bUseSequenceNumber; - bool bIsSimulation; - bool bIsInitialized; + CVector> vecvecMemory; + CVector veciBlockValid; + int iNumBlocksMemory; + int iBlockGetPos; + int iBlockPutPos; + int iBlockSize; + uint8_t iSequenceNumberAtGetPos; // uint8_t so that it wraps automatically + EBufState eBufState; + bool bUseSequenceNumber; + bool bIsSimulation; + bool bIsInitialized; static constexpr int iNumBytesSeqNum = 1; // per definition 1 byte sequence counter }; - // Network buffer (jitter buffer) with statistic calculations ------------------ class CNetBufWithStats : public CNetBuf { public: CNetBufWithStats(); - void Init ( const int iNewBlockSize, - const int iNewNumBlocks, - const bool bNUseSequenceNumber, - const bool bPreserve = false ); + void Init ( const int iNewBlockSize, const int iNewNumBlocks, const bool bNUseSequenceNumber, const bool bPreserve = false ); void SetUseDoubleSystemFrameSize ( const bool bNDSFSize ) { bUseDoubleSystemFrameSize = bNDSFSize; } virtual bool Put ( const CVector& vecbyData, const int iInSize ); virtual bool Get ( CVector& vecbyData, const int iOutSize ); - int GetAutoSetting() { return iCurAutoBufferSizeSetting; } - void GetErrorRates ( CVector& vecErrRates, - double& dLimit, - double& dMaxUpLimit ); + int GetAutoSetting() { return iCurAutoBufferSizeSetting; } + void GetErrorRates ( CVector& vecErrRates, double& dLimit, double& dMaxUpLimit ); protected: void UpdateAutoSetting(); @@ -300,33 +292,32 @@ class CNetBufWithStats : public CNetBuf CNetBuf SimulationBuffer[NUM_STAT_SIMULATION_BUFFERS]; int viBufSizesForSim[NUM_STAT_SIMULATION_BUFFERS]; - double dCurIIRFilterResult; - int iCurDecidedResult; - int iInitCounter; - int iCurAutoBufferSizeSetting; - int iMaxStatisticCount; - - bool bUseDoubleSystemFrameSize; - double dAutoFilt_WightUpNormal; - double dAutoFilt_WightDownNormal; - double dAutoFilt_WightUpFast; - double dAutoFilt_WightDownFast; - double dErrorRateBound; - double dUpMaxErrorBound; + double dCurIIRFilterResult; + int iCurDecidedResult; + int iInitCounter; + int iCurAutoBufferSizeSetting; + int iMaxStatisticCount; + + bool bUseDoubleSystemFrameSize; + double dAutoFilt_WightUpNormal; + double dAutoFilt_WightDownNormal; + double dAutoFilt_WightUpFast; + double dAutoFilt_WightDownFast; + double dErrorRateBound; + double dUpMaxErrorBound; }; - // Conversion buffer (very simple buffer) -------------------------------------- // For this very simple buffer no wrap around mechanism is implemented. We // assume here, that the applied buffers are an integer fraction of the total // buffer size. -template class CConvBuf +template +class CConvBuf { public: CConvBuf() { Init ( 0 ); } - void Init ( const int iNewMemSize, - const bool bNUseSequenceNumber = false ) + void Init ( const int iNewMemSize, const bool bNUseSequenceNumber = false ) { // allocate internal memory and reset read/write positions vecMemory.Init ( iNewMemSize ); @@ -361,9 +352,7 @@ template class CConvBuf vecMemory.begin() ); } - bool Put ( const CVector& vecData, - const int iVecSize, - const TData SequenceNumber = 0 ) + bool Put ( const CVector& vecData, const int iVecSize, const TData SequenceNumber = 0 ) { // calculate the end position after copying int iEnd = iPutPos + iVecSize; @@ -378,9 +367,7 @@ template class CConvBuf if ( iEnd <= iBufferSize ) { // copy new data in internal buffer - std::copy ( vecData.begin(), - vecData.begin() + iVecSize, - vecMemory.begin() + iPutPos ); + std::copy ( vecData.begin(), vecData.begin() + iVecSize, vecMemory.begin() + iPutPos ); // add optional sequence number (NOTE that we currently // only support a single sequence number per packet) @@ -407,19 +394,15 @@ template class CConvBuf return vecMemory; } - void GetAll ( CVector& vecsData, - const int iVecSize ) + void GetAll ( CVector& vecsData, const int iVecSize ) { iPutPos = 0; // copy data from internal buffer in given buffer - std::copy ( vecMemory.begin(), - vecMemory.begin() + iVecSize, - vecsData.begin() ); + std::copy ( vecMemory.begin(), vecMemory.begin() + iVecSize, vecsData.begin() ); } - bool Get ( CVector& vecsData, - const int iVecSize ) + bool Get ( CVector& vecsData, const int iVecSize ) { // calculate the input size and the end position after copying const int iEnd = iGetPos + iVecSize; @@ -428,9 +411,7 @@ template class CConvBuf if ( iEnd <= iBufferSize ) { // copy new data from internal buffer - std::copy ( vecMemory.begin() + iGetPos, - vecMemory.begin() + iGetPos + iVecSize, - vecsData.begin() ); + std::copy ( vecMemory.begin() + iGetPos, vecMemory.begin() + iGetPos + iVecSize, vecsData.begin() ); // set buffer pointer one block further iGetPos = iEnd; diff --git a/src/channel.cpp b/src/channel.cpp old mode 100755 new mode 100644 index 67073f5de4..cb0afb0041 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -8,38 +8,37 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ #include "channel.h" - // CChannel implementation ***************************************************** CChannel::CChannel ( const bool bNIsServer ) : - vecfGains ( MAX_NUM_CHANNELS, 1.0f ), - vecfPannings ( MAX_NUM_CHANNELS, 0.5f ), - iCurSockBufNumFrames ( INVALID_INDEX ), - bDoAutoSockBufSize ( true ), - bUseSequenceNumber ( false ), // this is important since in the client we reset on Channel.SetEnable ( false ) - iSendSequenceNumber ( 0 ), - iFadeInCnt ( 0 ), - iFadeInCntMax ( FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE ), - bIsEnabled ( false ), - bIsServer ( bNIsServer ), - bIsIdentified ( false ), + vecfGains ( MAX_NUM_CHANNELS, 1.0f ), + vecfPannings ( MAX_NUM_CHANNELS, 0.5f ), + iCurSockBufNumFrames ( INVALID_INDEX ), + bDoAutoSockBufSize ( true ), + bUseSequenceNumber ( false ), // this is important since in the client we reset on Channel.SetEnable ( false ) + iSendSequenceNumber ( 0 ), + iFadeInCnt ( 0 ), + iFadeInCntMax ( FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE ), + bIsEnabled ( false ), + bIsServer ( bNIsServer ), + bIsIdentified ( false ), iAudioFrameSizeSamples ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ), - SignalLevelMeter ( false, 0.5 ) // server mode with mono out and faster smoothing + SignalLevelMeter ( false, 0.5 ) // server mode with mono out and faster smoothing { // reset network transport properties ResetNetworkTransportProperties(); @@ -58,71 +57,51 @@ CChannel::CChannel ( const bool bNIsServer ) : // initialize channel info ResetInfo(); - // Connections ------------------------------------------------------------- -// clang-format off + // clang-format off // TODO if we later do not fire vectors in the emits, we can remove this again qRegisterMetaType > ( "CVector" ); qRegisterMetaType ( "CHostAddress" ); -// clang-format on + // clang-format on - QObject::connect ( &Protocol, &CProtocol::MessReadyForSending, - this, &CChannel::OnSendProtMessage ); + QObject::connect ( &Protocol, &CProtocol::MessReadyForSending, this, &CChannel::OnSendProtMessage ); - QObject::connect ( &Protocol, &CProtocol::ChangeJittBufSize, - this, &CChannel::OnJittBufSizeChange ); + QObject::connect ( &Protocol, &CProtocol::ChangeJittBufSize, this, &CChannel::OnJittBufSizeChange ); - QObject::connect ( &Protocol, &CProtocol::ReqJittBufSize, - this, &CChannel::ReqJittBufSize ); + QObject::connect ( &Protocol, &CProtocol::ReqJittBufSize, this, &CChannel::ReqJittBufSize ); - QObject::connect ( &Protocol, &CProtocol::ReqChanInfo, - this, &CChannel::ReqChanInfo ); + QObject::connect ( &Protocol, &CProtocol::ReqChanInfo, this, &CChannel::ReqChanInfo ); - QObject::connect ( &Protocol, &CProtocol::ReqConnClientsList, - this, &CChannel::ReqConnClientsList ); + QObject::connect ( &Protocol, &CProtocol::ReqConnClientsList, this, &CChannel::ReqConnClientsList ); - QObject::connect ( &Protocol, &CProtocol::ConClientListMesReceived, - this, &CChannel::ConClientListMesReceived ); + QObject::connect ( &Protocol, &CProtocol::ConClientListMesReceived, this, &CChannel::ConClientListMesReceived ); - QObject::connect ( &Protocol, &CProtocol::ChangeChanGain, - this, &CChannel::OnChangeChanGain ); + QObject::connect ( &Protocol, &CProtocol::ChangeChanGain, this, &CChannel::OnChangeChanGain ); - QObject::connect ( &Protocol, &CProtocol::ChangeChanPan, - this, &CChannel::OnChangeChanPan ); + QObject::connect ( &Protocol, &CProtocol::ChangeChanPan, this, &CChannel::OnChangeChanPan ); - QObject::connect ( &Protocol, &CProtocol::ClientIDReceived, - this, &CChannel::ClientIDReceived ); + QObject::connect ( &Protocol, &CProtocol::ClientIDReceived, this, &CChannel::ClientIDReceived ); - QObject::connect ( &Protocol, &CProtocol::MuteStateHasChangedReceived, - this, &CChannel::MuteStateHasChangedReceived ); + QObject::connect ( &Protocol, &CProtocol::MuteStateHasChangedReceived, this, &CChannel::MuteStateHasChangedReceived ); - QObject::connect ( &Protocol, &CProtocol::ChangeChanInfo, - this, &CChannel::OnChangeChanInfo ); + QObject::connect ( &Protocol, &CProtocol::ChangeChanInfo, this, &CChannel::OnChangeChanInfo ); - QObject::connect ( &Protocol, &CProtocol::ChatTextReceived, - this, &CChannel::ChatTextReceived ); + QObject::connect ( &Protocol, &CProtocol::ChatTextReceived, this, &CChannel::ChatTextReceived ); - QObject::connect ( &Protocol, &CProtocol::NetTranspPropsReceived, - this, &CChannel::OnNetTranspPropsReceived ); + QObject::connect ( &Protocol, &CProtocol::NetTranspPropsReceived, this, &CChannel::OnNetTranspPropsReceived ); - QObject::connect ( &Protocol, &CProtocol::ReqNetTranspProps, - this, &CChannel::OnReqNetTranspProps ); + QObject::connect ( &Protocol, &CProtocol::ReqNetTranspProps, this, &CChannel::OnReqNetTranspProps ); - QObject::connect ( &Protocol, &CProtocol::ReqSplitMessSupport, - this, &CChannel::OnReqSplitMessSupport ); + QObject::connect ( &Protocol, &CProtocol::ReqSplitMessSupport, this, &CChannel::OnReqSplitMessSupport ); - QObject::connect ( &Protocol, &CProtocol::SplitMessSupported, - this, &CChannel::OnSplitMessSupported ); + QObject::connect ( &Protocol, &CProtocol::SplitMessSupported, this, &CChannel::OnSplitMessSupported ); - QObject::connect ( &Protocol, &CProtocol::LicenceRequired, - this, &CChannel::LicenceRequired ); + QObject::connect ( &Protocol, &CProtocol::LicenceRequired, this, &CChannel::LicenceRequired ); - QObject::connect ( &Protocol, &CProtocol::VersionAndOSReceived, - this, &CChannel::OnVersionAndOSReceived ); + QObject::connect ( &Protocol, &CProtocol::VersionAndOSReceived, this, &CChannel::OnVersionAndOSReceived ); - QObject::connect ( &Protocol, &CProtocol::RecorderStateReceived, - this, &CChannel::RecorderStateReceived ); + QObject::connect ( &Protocol, &CProtocol::RecorderStateReceived, this, &CChannel::RecorderStateReceived ); } bool CChannel::ProtocolIsEnabled() @@ -165,21 +144,17 @@ void CChannel::SetEnable ( const bool bNEnStat ) } } -void CChannel::OnVersionAndOSReceived ( COSUtil::EOpSystemType eOSType, - QString strVersion ) +void CChannel::OnVersionAndOSReceived ( COSUtil::EOpSystemType eOSType, QString strVersion ) { // check if audio packet counter is supported by the server (minimum version is 3.6.0) -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) if ( QVersionNumber::compare ( QVersionNumber::fromString ( strVersion ), QVersionNumber ( 3, 6, 0 ) ) >= 0 ) { // activate sequence counter and update the audio stream properties (which // does all the initialization and tells the server about the change) bUseSequenceNumber = true; - SetAudioStreamProperties ( eAudioCompressionType, - iCeltNumCodedBytes, - iNetwFrameSizeFact, - iNumAudioChannels ); + SetAudioStreamProperties ( eAudioCompressionType, iCeltNumCodedBytes, iNetwFrameSizeFact, iNumAudioChannels ); } #endif @@ -191,9 +166,9 @@ void CChannel::SetAudioStreamProperties ( const EAudComprType eNewAudComprType, const int iNewNetwFrameSizeFact, const int iNewNumAudioChannels ) { -/* - this function is intended for the client (not the server) -*/ + /* + this function is intended for the client (not the server) + */ CNetworkTransportProps NetworkTransportProps; Mutex.lock(); @@ -248,15 +223,13 @@ void CChannel::SetAudioStreamProperties ( const EAudComprType eNewAudComprType, Protocol.CreateNetwTranspPropsMes ( NetworkTransportProps ); } -bool CChannel::SetSockBufNumFrames ( const int iNewNumFrames, - const bool bPreserve ) +bool CChannel::SetSockBufNumFrames ( const int iNewNumFrames, const bool bPreserve ) { bool ReturnValue = true; // init with error bool bCurDoAutoSockBufSize = false; // we have to init but init values does not matter // first check for valid input parameter range - if ( ( iNewNumFrames >= MIN_NET_BUF_SIZE_NUM_BL ) && - ( iNewNumFrames <= MAX_NET_BUF_SIZE_NUM_BL ) ) + if ( ( iNewNumFrames >= MIN_NET_BUF_SIZE_NUM_BL ) && ( iNewNumFrames <= MAX_NET_BUF_SIZE_NUM_BL ) ) { // only apply parameter if new parameter is different from current one if ( iCurSockBufNumFrames != iNewNumFrames ) @@ -297,8 +270,7 @@ bool CChannel::SetSockBufNumFrames ( const int iNewNumFrames, return ReturnValue; // set error flag } -void CChannel::SetGain ( const int iChanID, - const float fNewGain ) +void CChannel::SetGain ( const int iChanID, const float fNewGain ) { QMutexLocker locker ( &Mutex ); @@ -334,8 +306,7 @@ float CChannel::GetGain ( const int iChanID ) } } -void CChannel::SetPan ( const int iChanID, - const float fNewPan ) +void CChannel::SetPan ( const int iChanID, const float fNewPan ) { QMutexLocker locker ( &Mutex ); @@ -363,7 +334,7 @@ float CChannel::GetPan ( const int iChanID ) void CChannel::SetChanInfo ( const CChannelCoreInfo& NChanInf ) { - bIsIdentified = true; // Indicate we have received channel info + bIsIdentified = true; // Indicate we have received channel info // apply value (if different from previous one) if ( ChannelInfo != NChanInf ) @@ -423,22 +394,11 @@ void CChannel::OnJittBufSizeChange ( int iNewJitBufSize ) } } -void CChannel::OnChangeChanGain ( int iChanID, - float fNewGain ) -{ - SetGain ( iChanID, fNewGain ); -} +void CChannel::OnChangeChanGain ( int iChanID, float fNewGain ) { SetGain ( iChanID, fNewGain ); } -void CChannel::OnChangeChanPan ( int iChanID, - float fNewPan ) -{ - SetPan ( iChanID, fNewPan ); -} +void CChannel::OnChangeChanPan ( int iChanID, float fNewPan ) { SetPan ( iChanID, fNewPan ); } -void CChannel::OnChangeChanInfo ( CChannelCoreInfo ChanInfo ) -{ - SetChanInfo ( ChanInfo ); -} +void CChannel::OnChangeChanInfo ( CChannelCoreInfo ChanInfo ) { SetChanInfo ( ChanInfo ); } bool CChannel::GetAddress ( CHostAddress& RetAddr ) { @@ -462,8 +422,7 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor if ( bIsServer ) { // OPUS and OPUS64 codecs are the only supported codecs right now - if ( ( NetworkTransportProps.eAudioCodingType != CT_OPUS ) && - ( NetworkTransportProps.eAudioCodingType != CT_OPUS64 ) ) + if ( ( NetworkTransportProps.eAudioCodingType != CT_OPUS ) && ( NetworkTransportProps.eAudioCodingType != CT_OPUS64 ) ) { Protocol.CreateOpusSupportedMes(); return; @@ -570,27 +529,20 @@ void CChannel::Disconnect() } } -void CChannel::PutProtcolData ( const int iRecCounter, - const int iRecID, - const CVector& vecbyMesBodyData, - const CHostAddress& RecHostAddr ) +void CChannel::PutProtcolData ( const int iRecCounter, const int iRecID, const CVector& vecbyMesBodyData, const CHostAddress& RecHostAddr ) { // Only process protocol message if: // - for client only: the packet comes from the server we want to talk to // - the channel is enabled // - the protocol mechanism is enabled - if ( ( bIsServer || ( GetAddress() == RecHostAddr ) ) && - IsEnabled() && - ProtocolIsEnabled() ) + if ( ( bIsServer || ( GetAddress() == RecHostAddr ) ) && IsEnabled() && ProtocolIsEnabled() ) { // parse the message assuming this is a regular protocol message Protocol.ParseMessageBody ( vecbyMesBodyData, iRecCounter, iRecID ); } } -EPutDataStat CChannel::PutAudioData ( const CVector& vecbyData, - const int iNumBytes, - CHostAddress RecHostAddr ) +EPutDataStat CChannel::PutAudioData ( const CVector& vecbyData, const int iNumBytes, CHostAddress RecHostAddr ) { // init return state EPutDataStat eRet = PS_GEN_ERROR; @@ -598,8 +550,7 @@ EPutDataStat CChannel::PutAudioData ( const CVector& vecbyData, // Only process audio data if: // - for client only: the packet comes from the server we want to talk to // - the channel is enabled - if ( ( bIsServer || ( GetAddress() == RecHostAddr ) ) && - IsEnabled() ) + if ( ( bIsServer || ( GetAddress() == RecHostAddr ) ) && IsEnabled() ) { MutexSocketBuf.lock(); { @@ -663,8 +614,7 @@ EPutDataStat CChannel::PutAudioData ( const CVector& vecbyData, return eRet; } -EGetDataStat CChannel::GetData ( CVector& vecbyData, - const int iNumBytes ) +EGetDataStat CChannel::GetData ( CVector& vecbyData, const int iNumBytes ) { EGetDataStat eGetStatus; @@ -726,9 +676,7 @@ EGetDataStat CChannel::GetData ( CVector& vecbyData, return eGetStatus; } -void CChannel::PrepAndSendPacket ( CHighPrioSocket* pSocket, - const CVector& vecbyNPacket, - const int iNPacketLen ) +void CChannel::PrepAndSendPacket ( CHighPrioSocket* pSocket, const CVector& vecbyNPacket, const int iNPacketLen ) { // From v3.8.0 onwards, a server will not send audio to a client until that client has sent channel info. // This addresses #1243 but means that clients earlier than v3.3.0 (24 Feb 2013) will no longer be compatible. @@ -748,14 +696,10 @@ void CChannel::PrepAndSendPacket ( CHighPrioSocket* pSocket, } } -double CChannel::UpdateAndGetLevelForMeterdB ( const CVector& vecsAudio, - const int iInSize, - const bool bIsStereoIn ) +double CChannel::UpdateAndGetLevelForMeterdB ( const CVector& vecsAudio, const int iInSize, const bool bIsStereoIn ) { // update the signal level meter and immediately return the current value - SignalLevelMeter.Update ( vecsAudio, - iInSize, - bIsStereoIn ); + SignalLevelMeter.Update ( vecsAudio, iInSize, bIsStereoIn ); return SignalLevelMeter.GetLevelForMeterdBLeftOrMono(); } @@ -770,9 +714,7 @@ int CChannel::GetUploadRateKbps() // 8 (UDP) + 20 (IP without optional fields) = 28 bytes // 2 (PPP) + 6 (PPPoE) + 18 (MAC) = 26 bytes // 5 (RFC1483B) + 8 (AAL) + 10 (ATM) = 23 bytes - return ( iNetwFrameSize * iNetwFrameSizeFact + 28 + 26 + 23 /* header */ ) * - 8 /* bits per byte */ * - SYSTEM_SAMPLE_RATE_HZ / iAudioSizeOut / 1000; + return ( iNetwFrameSize * iNetwFrameSizeFact + 28 + 26 + 23 /* header */ ) * 8 /* bits per byte */ * SYSTEM_SAMPLE_RATE_HZ / iAudioSizeOut / 1000; } void CChannel::UpdateSocketBufferSize() diff --git a/src/channel.h b/src/channel.h old mode 100755 new mode 100644 index f83a106f17..5d36a4d4bc --- a/src/channel.h +++ b/src/channel.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -27,8 +27,8 @@ #include #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) -# include +#if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) +# include #endif #include "global.h" #include "buffer.h" @@ -36,17 +36,15 @@ #include "protocol.h" #include "socket.h" - /* Definitions ****************************************************************/ // set the time-out for the input buffer until the state changes from // connected to not connected (the actual time depends on the way the error // correction is implemented) -#define CON_TIME_OUT_SEC_MAX 30 // seconds +#define CON_TIME_OUT_SEC_MAX 30 // seconds // number of frames for audio fade-in, 48 kHz, x samples: 3 sec / (x samples / 48 kHz) -#define FADE_IN_NUM_FRAMES 2250 -#define FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE 1125 - +#define FADE_IN_NUM_FRAMES 2250 +#define FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE 1125 enum EPutDataStat { @@ -60,7 +58,6 @@ enum EPutDataStat PS_NEW_CONNECTION }; - /* Classes ********************************************************************/ class CChannel : public QObject { @@ -71,21 +68,13 @@ class CChannel : public QObject // use constructor initialization in the server for a vector of channels CChannel ( const bool bNIsServer = true ); - void PutProtcolData ( const int iRecCounter, - const int iRecID, - const CVector& vecbyMesBodyData, - const CHostAddress& RecHostAddr ); + void PutProtcolData ( const int iRecCounter, const int iRecID, const CVector& vecbyMesBodyData, const CHostAddress& RecHostAddr ); - EPutDataStat PutAudioData ( const CVector& vecbyData, - const int iNumBytes, - CHostAddress RecHostAddr ); + EPutDataStat PutAudioData ( const CVector& vecbyData, const int iNumBytes, CHostAddress RecHostAddr ); - EGetDataStat GetData ( CVector& vecbyData, - const int iNumBytes ); + EGetDataStat GetData ( CVector& vecbyData, const int iNumBytes ); - void PrepAndSendPacket ( CHighPrioSocket* pSocket, - const CVector& vecbyNPacket, - const int iNPacketLen ); + void PrepAndSendPacket ( CHighPrioSocket* pSocket, const CVector& vecbyNPacket, const int iNPacketLen ); void ResetTimeOutCounter() { iConTimeOut = iConTimeOutStartVal; } bool IsConnected() const { return iConTimeOut > 0; } @@ -94,38 +83,38 @@ class CChannel : public QObject void SetEnable ( const bool bNEnStat ); bool IsEnabled() { return bIsEnabled; } - void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; } - bool GetAddress ( CHostAddress& RetAddr ); + void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; } + bool GetAddress ( CHostAddress& RetAddr ); const CHostAddress& GetAddress() const { return InetAddr; } - void ResetInfo() { bIsIdentified = false; ChannelInfo = CChannelCoreInfo(); } // reset does not emit a message - QString GetName(); - void SetChanInfo ( const CChannelCoreInfo& NChanInf ); + void ResetInfo() + { + bIsIdentified = false; + ChannelInfo = CChannelCoreInfo(); + } // reset does not emit a message + QString GetName(); + void SetChanInfo ( const CChannelCoreInfo& NChanInf ); CChannelCoreInfo& GetChanInfo() { return ChannelInfo; } - void SetRemoteInfo ( const CChannelCoreInfo ChInfo ) - { Protocol.CreateChanInfoMes ( ChInfo ); } + void SetRemoteInfo ( const CChannelCoreInfo ChInfo ) { Protocol.CreateChanInfoMes ( ChInfo ); } void CreateReqChanInfoMes() { Protocol.CreateReqChanInfoMes(); } void CreateVersionAndOSMes() { Protocol.CreateVersionAndOSMes(); } void CreateMuteStateHasChangedMes ( const int iChanID, const bool bIsMuted ) { Protocol.CreateMuteStateHasChangedMes ( iChanID, bIsMuted ); } - void SetGain ( const int iChanID, const float fNewGain ); + void SetGain ( const int iChanID, const float fNewGain ); float GetGain ( const int iChanID ); float GetFadeInGain() { return static_cast ( iFadeInCnt ) / iFadeInCntMax; } - void SetPan ( const int iChanID, const float fNewPan ); + void SetPan ( const int iChanID, const float fNewPan ); float GetPan ( const int iChanID ); - void SetRemoteChanGain ( const int iId, const float fGain ) - { Protocol.CreateChanGainMes ( iId, fGain ); } + void SetRemoteChanGain ( const int iId, const float fGain ) { Protocol.CreateChanGainMes ( iId, fGain ); } - void SetRemoteChanPan ( const int iId, const float fPan ) - { Protocol.CreateChanPanMes ( iId, fPan ); } + void SetRemoteChanPan ( const int iId, const float fPan ) { Protocol.CreateChanPanMes ( iId, fPan ); } - bool SetSockBufNumFrames ( const int iNewNumFrames, - const bool bPreserve = false ); - int GetSockBufNumFrames() const { return iCurSockBufNumFrames; } + bool SetSockBufNumFrames ( const int iNewNumFrames, const bool bPreserve = false ); + int GetSockBufNumFrames() const { return iCurSockBufNumFrames; } void UpdateSocketBufferSize(); @@ -133,12 +122,11 @@ class CChannel : public QObject // set/get network out buffer size and size factor void SetAudioStreamProperties ( const EAudComprType eNewAudComprType, - const int iNewNetwFrameSize, - const int iNewNetwFrameSizeFact, - const int iNewNumAudioChannels ); + const int iNewNetwFrameSize, + const int iNewNetwFrameSizeFact, + const int iNewNumAudioChannels ); - void SetDoAutoSockBufSize ( const bool bValue ) - { bDoAutoSockBufSize = bValue; } + void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; } bool GetDoAutoSockBufSize() const { return bDoAutoSockBufSize; } @@ -146,43 +134,41 @@ class CChannel : public QObject int GetCeltNumCodedBytes() const { return iCeltNumCodedBytes; } void GetBufErrorRates ( CVector& vecErrRates, double& dLimit, double& dMaxUpLimit ) - { SockBuf.GetErrorRates ( vecErrRates, dLimit, dMaxUpLimit ); } + { + SockBuf.GetErrorRates ( vecErrRates, dLimit, dMaxUpLimit ); + } EAudComprType GetAudioCompressionType() { return eAudioCompressionType; } - int GetNumAudioChannels() const { return iNumAudioChannels; } + int GetNumAudioChannels() const { return iNumAudioChannels; } // network protocol interface void CreateJitBufMes ( const int iJitBufSize ) - { + { if ( ProtocolIsEnabled() ) { Protocol.CreateJitBufMes ( iJitBufSize ); } } - void CreateClientIDMes ( const int iChanID ) { Protocol.CreateClientIDMes ( iChanID ); } - void CreateReqNetwTranspPropsMes() { Protocol.CreateReqNetwTranspPropsMes(); } - void CreateReqSplitMessSupportMes() { Protocol.CreateReqSplitMessSupportMes(); } - void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); } - void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); } - void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); } + void CreateClientIDMes ( const int iChanID ) { Protocol.CreateClientIDMes ( iChanID ); } + void CreateReqNetwTranspPropsMes() { Protocol.CreateReqNetwTranspPropsMes(); } + void CreateReqSplitMessSupportMes() { Protocol.CreateReqSplitMessSupportMes(); } + void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); } + void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); } + void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); } void CreateLicReqMes ( const ELicenceType eLicenceType ) { Protocol.CreateLicenceRequiredMes ( eLicenceType ); } -// clang-format off + // clang-format off // TODO needed for compatibility to old servers >= 3.4.6 and <= 3.5.12 void CreateReqChannelLevelListMes() { Protocol.CreateReqChannelLevelListMes(); } -// clang-format on + // clang-format on - void CreateConClientListMes ( const CVector& vecChanInfo ) - { Protocol.CreateConClientListMes ( vecChanInfo ); } + void CreateConClientListMes ( const CVector& vecChanInfo ) { Protocol.CreateConClientListMes ( vecChanInfo ); } - void CreateRecorderStateMes ( const ERecorderState eRecorderState ) - { Protocol.CreateRecorderStateMes ( eRecorderState ); } + void CreateRecorderStateMes ( const ERecorderState eRecorderState ) { Protocol.CreateRecorderStateMes ( eRecorderState ); } CNetworkTransportProps GetNetworkTransportPropsFromCurrentSettings(); - double UpdateAndGetLevelForMeterdB ( const CVector& vecsAudio, - const int iInSize, - const bool bIsStereoIn ); + double UpdateAndGetLevelForMeterdB ( const CVector& vecsAudio, const int iInSize, const bool bIsStereoIn ); protected: bool ProtocolIsEnabled(); @@ -201,48 +187,48 @@ void CreateReqChannelLevelListMes() { Protocol.CreateReqChannelLevelListMes(); } } // connection parameters - CHostAddress InetAddr; + CHostAddress InetAddr; // channel info - CChannelCoreInfo ChannelInfo; + CChannelCoreInfo ChannelInfo; // mixer and effect settings - CVector vecfGains; - CVector vecfPannings; + CVector vecfGains; + CVector vecfPannings; // network jitter-buffer - CNetBufWithStats SockBuf; - int iCurSockBufNumFrames; - bool bDoAutoSockBufSize; - bool bUseSequenceNumber; - uint8_t iSendSequenceNumber; + CNetBufWithStats SockBuf; + int iCurSockBufNumFrames; + bool bDoAutoSockBufSize; + bool bUseSequenceNumber; + uint8_t iSendSequenceNumber; // network output conversion buffer - CConvBuf ConvBuf; + CConvBuf ConvBuf; // network protocol - CProtocol Protocol; + CProtocol Protocol; - int iConTimeOut; - int iConTimeOutStartVal; - int iFadeInCnt; - int iFadeInCntMax; + int iConTimeOut; + int iConTimeOutStartVal; + int iFadeInCnt; + int iFadeInCntMax; - bool bIsEnabled; - bool bIsServer; - bool bIsIdentified; + bool bIsEnabled; + bool bIsServer; + bool bIsIdentified; - int iNetwFrameSizeFact; - int iNetwFrameSize; - int iCeltNumCodedBytes; - int iAudioFrameSizeSamples; + int iNetwFrameSizeFact; + int iNetwFrameSize; + int iCeltNumCodedBytes; + int iAudioFrameSizeSamples; - EAudComprType eAudioCompressionType; - int iNumAudioChannels; + EAudComprType eAudioCompressionType; + int iNumAudioChannels; - QMutex Mutex; - QMutex MutexSocketBuf; - QMutex MutexConvBuf; + QMutex Mutex; + QMutex MutexSocketBuf; + QMutex MutexConvBuf; CStereoSignalLevelMeter SignalLevelMeter; @@ -257,28 +243,20 @@ public slots: void OnReqSplitMessSupport(); void OnSplitMessSupported() { Protocol.SetSplitMessageSupported ( true ); } - void OnVersionAndOSReceived ( COSUtil::EOpSystemType eOSType, - QString strVersion ); + void OnVersionAndOSReceived ( COSUtil::EOpSystemType eOSType, QString strVersion ); - void OnParseMessageBody ( CVector vecbyMesBodyData, - int iRecCounter, - int iRecID ) + void OnParseMessageBody ( CVector vecbyMesBodyData, int iRecCounter, int iRecID ) { // note that the return value is ignored here Protocol.ParseMessageBody ( vecbyMesBodyData, iRecCounter, iRecID ); } - void OnProtcolMessageReceived ( int iRecCounter, - int iRecID, - CVector vecbyMesBodyData, - CHostAddress RecHostAddr ) + void OnProtcolMessageReceived ( int iRecCounter, int iRecID, CVector vecbyMesBodyData, CHostAddress RecHostAddr ) { PutProtcolData ( iRecCounter, iRecID, vecbyMesBodyData, RecHostAddr ); } - void OnProtcolCLMessageReceived ( int iRecID, - CVector vecbyMesBodyData, - CHostAddress RecHostAddr ) + void OnProtcolCLMessageReceived ( int iRecID, CVector vecbyMesBodyData, CHostAddress RecHostAddr ) { emit DetectedCLMessage ( vecbyMesBodyData, iRecID, RecHostAddr ); } @@ -305,11 +283,7 @@ public slots: void RecorderStateReceived ( ERecorderState eRecorderState ); void Disconnected(); - void DetectedCLMessage ( CVector vecbyMesBodyData, - int iRecID, - CHostAddress RecHostAddr ); + void DetectedCLMessage ( CVector vecbyMesBodyData, int iRecID, CHostAddress RecHostAddr ); - void ParseMessageBody ( CVector vecbyMesBodyData, - int iRecCounter, - int iRecID ); + void ParseMessageBody ( CVector vecbyMesBodyData, int iRecCounter, int iRecID ); }; diff --git a/src/chatdlg.cpp b/src/chatdlg.cpp old mode 100755 new mode 100644 index 62dcfa74f2..e248c5c8e5 --- a/src/chatdlg.cpp +++ b/src/chatdlg.cpp @@ -8,46 +8,41 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ #include "chatdlg.h" - /* Implementation *************************************************************/ -CChatDlg::CChatDlg ( QWidget* parent ) : - CBaseDlg ( parent, Qt::Window ) // use Qt::Window to get min/max window buttons +CChatDlg::CChatDlg ( QWidget* parent ) : CBaseDlg ( parent, Qt::Window ) // use Qt::Window to get min/max window buttons { setupUi ( this ); - // Add help text to controls ----------------------------------------------- // chat window - txvChatWindow->setWhatsThis ( "" + tr ( "Chat Window" ) + ": " + tr ( - "The chat window shows a history of all chat messages." ) ); + txvChatWindow->setWhatsThis ( "" + tr ( "Chat Window" ) + ": " + tr ( "The chat window shows a history of all chat messages." ) ); txvChatWindow->setAccessibleName ( tr ( "Chat history" ) ); // input message text - edtLocalInputText->setWhatsThis ( "" + tr ( "Input Message Text" ) + ": " + tr ( - "Enter the chat message text in the edit box and press enter to send the " - "message to the server which distributes the message to all connected " - "clients. Your message will then show up in the chat window." ) ); + edtLocalInputText->setWhatsThis ( "" + tr ( "Input Message Text" ) + ": " + + tr ( "Enter the chat message text in the edit box and press enter to send the " + "message to the server which distributes the message to all connected " + "clients. Your message will then show up in the chat window." ) ); edtLocalInputText->setAccessibleName ( tr ( "New chat text edit box" ) ); - // clear chat window and edit line txvChatWindow->clear(); edtLocalInputText->clear(); @@ -58,33 +53,27 @@ CChatDlg::CChatDlg ( QWidget* parent ) : // set a placeholder text to make sure where to type the message in (#384) edtLocalInputText->setPlaceholderText ( tr ( "Type a message here" ) ); - // Menu ------------------------------------------------------------------- QMenuBar* pMenu = new QMenuBar ( this ); QMenu* pEditMenu = new QMenu ( tr ( "&Edit" ), this ); - pEditMenu->addAction ( tr ( "Cl&ear Chat History" ), this, - SLOT ( OnClearChatHistory() ), QKeySequence ( Qt::CTRL + Qt::Key_E ) ); + pEditMenu->addAction ( tr ( "Cl&ear Chat History" ), this, SLOT ( OnClearChatHistory() ), QKeySequence ( Qt::CTRL + Qt::Key_E ) ); pMenu->addMenu ( pEditMenu ); -#if defined ( Q_OS_IOS ) - QAction *action = pMenu->addAction ( tr ( "&Close" ) ); - connect ( action, SIGNAL( triggered() ), this, SLOT ( close() ) ); +#if defined( Q_OS_IOS ) + QAction* action = pMenu->addAction ( tr ( "&Close" ) ); + connect ( action, SIGNAL ( triggered() ), this, SLOT ( close() ) ); #endif // Now tell the layout about the menu layout()->setMenuBar ( pMenu ); - // Connections ------------------------------------------------------------- - QObject::connect ( edtLocalInputText, &QLineEdit::textChanged, - this, &CChatDlg::OnLocalInputTextTextChanged ); + QObject::connect ( edtLocalInputText, &QLineEdit::textChanged, this, &CChatDlg::OnLocalInputTextTextChanged ); - QObject::connect ( butSend, &QPushButton::clicked, - this, &CChatDlg::OnSendText ); + QObject::connect ( butSend, &QPushButton::clicked, this, &CChatDlg::OnSendText ); - QObject::connect ( txvChatWindow, &QTextBrowser::anchorClicked, - this, &CChatDlg::OnAnchorClicked ); + QObject::connect ( txvChatWindow, &QTextBrowser::anchorClicked, this, &CChatDlg::OnAnchorClicked ); } void CChatDlg::OnLocalInputTextTextChanged ( const QString& strNewText ) @@ -103,7 +92,7 @@ void CChatDlg::OnSendText() if ( !edtLocalInputText->text().isEmpty() ) { emit NewLocalInputText ( edtLocalInputText->text() ); - edtLocalInputText->clear(); + edtLocalInputText->clear(); } } @@ -137,8 +126,10 @@ void CChatDlg::OnAnchorClicked ( const QUrl& Url ) // only allow http(s) URLs to be opened in an external browser if ( Url.scheme() == QLatin1String ( "https" ) || Url.scheme() == QLatin1String ( "http" ) ) { - if ( QMessageBox::question ( this, APP_NAME, tr ( "Do you want to open the link" ) + " " + Url.toString() + - " " + tr ( "in an external browser?" ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) + if ( QMessageBox::question ( this, + APP_NAME, + tr ( "Do you want to open the link" ) + " " + Url.toString() + " " + tr ( "in an external browser?" ), + QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes ) { QDesktopServices::openUrl ( Url ); } diff --git a/src/chatdlg.h b/src/chatdlg.h old mode 100755 new mode 100644 index a5e99b8655..19c170640a --- a/src/chatdlg.h +++ b/src/chatdlg.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -38,7 +38,6 @@ #include "util.h" #include "ui_chatdlgbase.h" - /* Classes ********************************************************************/ class CChatDlg : public CBaseDlg, private Ui_CChatDlgBase { diff --git a/src/client.cpp b/src/client.cpp old mode 100755 new mode 100644 index 8cd4f919f7..783f8bb955 --- a/src/client.cpp +++ b/src/client.cpp @@ -24,7 +24,6 @@ #include "client.h" - /* Implementation *************************************************************/ CClient::CClient ( const quint16 iPortNumber, const quint16 iQosNumber, @@ -33,173 +32,138 @@ CClient::CClient ( const quint16 iPortNumber, const bool bNoAutoJackConnect, const QString& strNClientName, const bool bNMuteMeInPersonalMix ) : - ChannelInfo ( ), - strClientName ( strNClientName ), - Channel ( false ), /* we need a client channel -> "false" */ - CurOpusEncoder ( nullptr ), - CurOpusDecoder ( nullptr ), - eAudioCompressionType ( CT_OPUS ), - iCeltNumCodedBytes ( OPUS_NUM_BYTES_MONO_LOW_QUALITY ), - iOPUSFrameSizeSamples ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ), - eAudioQuality ( AQ_NORMAL ), - eAudioChannelConf ( CC_MONO ), - iNumAudioChannels ( 1 ), - bIsInitializationPhase ( true ), - bMuteOutStream ( false ), - fMuteOutStreamGain ( 1.0f ), - Socket ( &Channel, iPortNumber, iQosNumber ), - Sound ( AudioCallback, this, strMIDISetup, bNoAutoJackConnect, strNClientName ), - iAudioInFader ( AUD_FADER_IN_MIDDLE ), - bReverbOnLeftChan ( false ), - iReverbLevel ( 0 ), - iInputBoost ( 1 ), - iSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ), - iSndCrdFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ), - bSndCrdConversionBufferRequired ( false ), + ChannelInfo(), + strClientName ( strNClientName ), + Channel ( false ), /* we need a client channel -> "false" */ + CurOpusEncoder ( nullptr ), + CurOpusDecoder ( nullptr ), + eAudioCompressionType ( CT_OPUS ), + iCeltNumCodedBytes ( OPUS_NUM_BYTES_MONO_LOW_QUALITY ), + iOPUSFrameSizeSamples ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ), + eAudioQuality ( AQ_NORMAL ), + eAudioChannelConf ( CC_MONO ), + iNumAudioChannels ( 1 ), + bIsInitializationPhase ( true ), + bMuteOutStream ( false ), + fMuteOutStreamGain ( 1.0f ), + Socket ( &Channel, iPortNumber, iQosNumber ), + Sound ( AudioCallback, this, strMIDISetup, bNoAutoJackConnect, strNClientName ), + iAudioInFader ( AUD_FADER_IN_MIDDLE ), + bReverbOnLeftChan ( false ), + iReverbLevel ( 0 ), + iInputBoost ( 1 ), + iSndCrdPrefFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ), + iSndCrdFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT ), + bSndCrdConversionBufferRequired ( false ), iSndCardMonoBlockSizeSamConvBuff ( 0 ), - bFraSiFactPrefSupported ( false ), - bFraSiFactDefSupported ( false ), - bFraSiFactSafeSupported ( false ), - eGUIDesign ( GD_ORIGINAL ), - bEnableOPUS64 ( false ), - bJitterBufferOK ( true ), - bNuteMeInPersonalMix ( bNMuteMeInPersonalMix ), - iServerSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL ), - pSignalHandler ( CSignalHandler::getSingletonP() ) + bFraSiFactPrefSupported ( false ), + bFraSiFactDefSupported ( false ), + bFraSiFactSafeSupported ( false ), + eGUIDesign ( GD_ORIGINAL ), + bEnableOPUS64 ( false ), + bJitterBufferOK ( true ), + bNuteMeInPersonalMix ( bNMuteMeInPersonalMix ), + iServerSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL ), + pSignalHandler ( CSignalHandler::getSingletonP() ) { int iOpusError; - OpusMode = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ, - DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES, - &iOpusError ); + OpusMode = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ, DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES, &iOpusError ); - Opus64Mode = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ, - SYSTEM_FRAME_SIZE_SAMPLES, - &iOpusError ); + Opus64Mode = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ, SYSTEM_FRAME_SIZE_SAMPLES, &iOpusError ); // init audio encoders and decoders - OpusEncoderMono = opus_custom_encoder_create ( OpusMode, 1, &iOpusError ); // mono encoder legacy - OpusDecoderMono = opus_custom_decoder_create ( OpusMode, 1, &iOpusError ); // mono decoder legacy - OpusEncoderStereo = opus_custom_encoder_create ( OpusMode, 2, &iOpusError ); // stereo encoder legacy - OpusDecoderStereo = opus_custom_decoder_create ( OpusMode, 2, &iOpusError ); // stereo decoder legacy + OpusEncoderMono = opus_custom_encoder_create ( OpusMode, 1, &iOpusError ); // mono encoder legacy + OpusDecoderMono = opus_custom_decoder_create ( OpusMode, 1, &iOpusError ); // mono decoder legacy + OpusEncoderStereo = opus_custom_encoder_create ( OpusMode, 2, &iOpusError ); // stereo encoder legacy + OpusDecoderStereo = opus_custom_decoder_create ( OpusMode, 2, &iOpusError ); // stereo decoder legacy Opus64EncoderMono = opus_custom_encoder_create ( Opus64Mode, 1, &iOpusError ); // mono encoder OPUS64 Opus64DecoderMono = opus_custom_decoder_create ( Opus64Mode, 1, &iOpusError ); // mono decoder OPUS64 Opus64EncoderStereo = opus_custom_encoder_create ( Opus64Mode, 2, &iOpusError ); // stereo encoder OPUS64 Opus64DecoderStereo = opus_custom_decoder_create ( Opus64Mode, 2, &iOpusError ); // stereo decoder OPUS64 // we require a constant bit rate - opus_custom_encoder_ctl ( OpusEncoderMono, OPUS_SET_VBR ( 0 ) ); - opus_custom_encoder_ctl ( OpusEncoderStereo, OPUS_SET_VBR ( 0 ) ); - opus_custom_encoder_ctl ( Opus64EncoderMono, OPUS_SET_VBR ( 0 ) ); + opus_custom_encoder_ctl ( OpusEncoderMono, OPUS_SET_VBR ( 0 ) ); + opus_custom_encoder_ctl ( OpusEncoderStereo, OPUS_SET_VBR ( 0 ) ); + opus_custom_encoder_ctl ( Opus64EncoderMono, OPUS_SET_VBR ( 0 ) ); opus_custom_encoder_ctl ( Opus64EncoderStereo, OPUS_SET_VBR ( 0 ) ); // for 64 samples frame size we have to adjust the PLC behavior to avoid loud artifacts - opus_custom_encoder_ctl ( Opus64EncoderMono, OPUS_SET_PACKET_LOSS_PERC ( 35 ) ); + opus_custom_encoder_ctl ( Opus64EncoderMono, OPUS_SET_PACKET_LOSS_PERC ( 35 ) ); opus_custom_encoder_ctl ( Opus64EncoderStereo, OPUS_SET_PACKET_LOSS_PERC ( 35 ) ); // we want as low delay as possible - opus_custom_encoder_ctl ( OpusEncoderMono, OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); - opus_custom_encoder_ctl ( OpusEncoderStereo, OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); - opus_custom_encoder_ctl ( Opus64EncoderMono, OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); + opus_custom_encoder_ctl ( OpusEncoderMono, OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); + opus_custom_encoder_ctl ( OpusEncoderStereo, OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); + opus_custom_encoder_ctl ( Opus64EncoderMono, OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); opus_custom_encoder_ctl ( Opus64EncoderStereo, OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); // set encoder low complexity for legacy 128 samples frame size - opus_custom_encoder_ctl ( OpusEncoderMono, OPUS_SET_COMPLEXITY ( 1 ) ); + opus_custom_encoder_ctl ( OpusEncoderMono, OPUS_SET_COMPLEXITY ( 1 ) ); opus_custom_encoder_ctl ( OpusEncoderStereo, OPUS_SET_COMPLEXITY ( 1 ) ); - // Connections ------------------------------------------------------------- // connections for the protocol mechanism - QObject::connect ( &Channel, &CChannel::MessReadyForSending, - this, &CClient::OnSendProtMessage ); + QObject::connect ( &Channel, &CChannel::MessReadyForSending, this, &CClient::OnSendProtMessage ); - QObject::connect ( &Channel, &CChannel::DetectedCLMessage, - this, &CClient::OnDetectedCLMessage ); + QObject::connect ( &Channel, &CChannel::DetectedCLMessage, this, &CClient::OnDetectedCLMessage ); - QObject::connect ( &Channel, &CChannel::ReqJittBufSize, - this, &CClient::OnReqJittBufSize ); + QObject::connect ( &Channel, &CChannel::ReqJittBufSize, this, &CClient::OnReqJittBufSize ); - QObject::connect ( &Channel, &CChannel::JittBufSizeChanged, - this, &CClient::OnJittBufSizeChanged ); + QObject::connect ( &Channel, &CChannel::JittBufSizeChanged, this, &CClient::OnJittBufSizeChanged ); - QObject::connect ( &Channel, &CChannel::ReqChanInfo, - this, &CClient::OnReqChanInfo ); + QObject::connect ( &Channel, &CChannel::ReqChanInfo, this, &CClient::OnReqChanInfo ); - QObject::connect ( &Channel, &CChannel::ConClientListMesReceived, - this, &CClient::ConClientListMesReceived ); + QObject::connect ( &Channel, &CChannel::ConClientListMesReceived, this, &CClient::ConClientListMesReceived ); - QObject::connect ( &Channel, &CChannel::Disconnected, - this, &CClient::Disconnected ); + QObject::connect ( &Channel, &CChannel::Disconnected, this, &CClient::Disconnected ); - QObject::connect ( &Channel, &CChannel::NewConnection, - this, &CClient::OnNewConnection ); + QObject::connect ( &Channel, &CChannel::NewConnection, this, &CClient::OnNewConnection ); - QObject::connect ( &Channel, &CChannel::ChatTextReceived, - this, &CClient::ChatTextReceived ); + QObject::connect ( &Channel, &CChannel::ChatTextReceived, this, &CClient::ChatTextReceived ); - QObject::connect ( &Channel, &CChannel::ClientIDReceived, - this, &CClient::OnClientIDReceived ); + QObject::connect ( &Channel, &CChannel::ClientIDReceived, this, &CClient::OnClientIDReceived ); - QObject::connect ( &Channel, &CChannel::MuteStateHasChangedReceived, - this, &CClient::MuteStateHasChangedReceived ); + QObject::connect ( &Channel, &CChannel::MuteStateHasChangedReceived, this, &CClient::MuteStateHasChangedReceived ); - QObject::connect ( &Channel, &CChannel::LicenceRequired, - this, &CClient::LicenceRequired ); + QObject::connect ( &Channel, &CChannel::LicenceRequired, this, &CClient::LicenceRequired ); - QObject::connect ( &Channel, &CChannel::VersionAndOSReceived, - this, &CClient::VersionAndOSReceived ); + QObject::connect ( &Channel, &CChannel::VersionAndOSReceived, this, &CClient::VersionAndOSReceived ); - QObject::connect ( &Channel, &CChannel::RecorderStateReceived, - this, &CClient::RecorderStateReceived ); + QObject::connect ( &Channel, &CChannel::RecorderStateReceived, this, &CClient::RecorderStateReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLMessReadyForSending, - this, &CClient::OnSendCLProtMessage ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLMessReadyForSending, this, &CClient::OnSendCLProtMessage ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLServerListReceived, - this, &CClient::CLServerListReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLServerListReceived, this, &CClient::CLServerListReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLRedServerListReceived, - this, &CClient::CLRedServerListReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLRedServerListReceived, this, &CClient::CLRedServerListReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLConnClientsListMesReceived, - this, &CClient::CLConnClientsListMesReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLConnClientsListMesReceived, this, &CClient::CLConnClientsListMesReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLPingReceived, - this, &CClient::OnCLPingReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLPingReceived, this, &CClient::OnCLPingReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLPingWithNumClientsReceived, - this, &CClient::OnCLPingWithNumClientsReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLPingWithNumClientsReceived, this, &CClient::OnCLPingWithNumClientsReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLDisconnection , - this, &CClient::OnCLDisconnection ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLDisconnection, this, &CClient::OnCLDisconnection ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLVersionAndOSReceived, - this, &CClient::CLVersionAndOSReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLVersionAndOSReceived, this, &CClient::CLVersionAndOSReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLChannelLevelListReceived, - this, &CClient::CLChannelLevelListReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLChannelLevelListReceived, this, &CClient::CLChannelLevelListReceived ); // other - QObject::connect ( &Sound, &CSound::ReinitRequest, - this, &CClient::OnSndCrdReinitRequest ); + QObject::connect ( &Sound, &CSound::ReinitRequest, this, &CClient::OnSndCrdReinitRequest ); - QObject::connect ( &Sound, &CSound::ControllerInFaderLevel, - this, &CClient::OnControllerInFaderLevel ); + QObject::connect ( &Sound, &CSound::ControllerInFaderLevel, this, &CClient::OnControllerInFaderLevel ); - QObject::connect ( &Sound, &CSound::ControllerInPanValue, - this, &CClient::OnControllerInPanValue ); + QObject::connect ( &Sound, &CSound::ControllerInPanValue, this, &CClient::OnControllerInPanValue ); - QObject::connect ( &Sound, &CSound::ControllerInFaderIsSolo, - this, &CClient::OnControllerInFaderIsSolo ); + QObject::connect ( &Sound, &CSound::ControllerInFaderIsSolo, this, &CClient::OnControllerInFaderIsSolo ); - QObject::connect ( &Sound, &CSound::ControllerInFaderIsMute, - this, &CClient::OnControllerInFaderIsMute ); + QObject::connect ( &Sound, &CSound::ControllerInFaderIsMute, this, &CClient::OnControllerInFaderIsMute ); - QObject::connect ( &Socket, &CHighPrioSocket::InvalidPacketReceived, - this, &CClient::OnInvalidPacketReceived ); + QObject::connect ( &Socket, &CHighPrioSocket::InvalidPacketReceived, this, &CClient::OnInvalidPacketReceived ); - QObject::connect ( pSignalHandler, &CSignalHandler::HandledSignal, - this, &CClient::OnHandledSignal ); + QObject::connect ( pSignalHandler, &CSignalHandler::HandledSignal, this, &CClient::OnHandledSignal ); // start timer so that elapsed time works PreciseTime.start(); @@ -246,8 +210,7 @@ void CClient::OnSendProtMessage ( CVector vecMessage ) Socket.SendPacket ( vecMessage, Channel.GetAddress() ); } -void CClient::OnSendCLProtMessage ( CHostAddress InetAddr, - CVector vecMessage ) +void CClient::OnSendCLProtMessage ( CHostAddress InetAddr, CVector vecMessage ) { // the protocol queries me to call the function to send the message // send it through the network @@ -266,14 +229,10 @@ void CClient::OnInvalidPacketReceived ( CHostAddress RecHostAddr ) } } -void CClient::OnDetectedCLMessage ( CVector vecbyMesBodyData, - int iRecID, - CHostAddress RecHostAddr ) +void CClient::OnDetectedCLMessage ( CVector vecbyMesBodyData, int iRecID, CHostAddress RecHostAddr ) { // connection less messages are always processed - ConnLessProtocol.ParseConnectionLessMessageBody ( vecbyMesBodyData, - iRecID, - RecHostAddr ); + ConnLessProtocol.ParseConnectionLessMessageBody ( vecbyMesBodyData, iRecID, RecHostAddr ); } void CClient::OnJittBufSizeChanged ( int iNewJitBufSize ) @@ -304,10 +263,10 @@ void CClient::OnNewConnection() Channel.CreateReqConnClientsList(); CreateServerJitterBufferMessage(); -// clang-format off + // clang-format off // TODO needed for compatibility to old servers >= 3.4.6 and <= 3.5.12 Channel.CreateReqChannelLevelListMes(); -// clang-format on + // clang-format on } void CClient::CreateServerJitterBufferMessage() @@ -326,8 +285,7 @@ void CClient::CreateServerJitterBufferMessage() } } -void CClient::OnCLPingReceived ( CHostAddress InetAddr, - int iMs ) +void CClient::OnCLPingReceived ( CHostAddress InetAddr, int iMs ) { // make sure we are running and the server address is correct if ( IsRunning() && ( InetAddr == Channel.GetAddress() ) ) @@ -341,17 +299,13 @@ void CClient::OnCLPingReceived ( CHostAddress InetAddr, } } -void CClient::OnCLPingWithNumClientsReceived ( CHostAddress InetAddr, - int iMs, - int iNumClients ) +void CClient::OnCLPingWithNumClientsReceived ( CHostAddress InetAddr, int iMs, int iNumClients ) { // take care of wrap arounds (if wrapping, do not use result) const int iCurDiff = EvaluatePingMessage ( iMs ); if ( iCurDiff >= 0 ) { - emit CLPingTimeWithNumClientsReceived ( InetAddr, - iCurDiff, - iNumClients ); + emit CLPingTimeWithNumClientsReceived ( InetAddr, iCurDiff, iNumClients ); } } @@ -376,9 +330,7 @@ void CClient::SetDoAutoSockBufSize ( const bool bValue ) CreateServerJitterBufferMessage(); } -void CClient::SetRemoteChanGain ( const int iId, - const float fGain, - const bool bIsMyOwnFader ) +void CClient::SetRemoteChanGain ( const int iId, const float fGain, const bool bIsMyOwnFader ) { // if this gain is for my own channel, apply the value for the Mute Myself function if ( bIsMyOwnFader ) @@ -392,8 +344,7 @@ void CClient::SetRemoteChanGain ( const int iId, bool CClient::SetServerAddr ( QString strNAddr ) { CHostAddress HostAddress; - if ( NetworkUtil().ParseNetworkAddress ( strNAddr, - HostAddress ) ) + if ( NetworkUtil().ParseNetworkAddress ( strNAddr, HostAddress ) ) { // apply address to the channel Channel.SetAddress ( HostAddress ); @@ -432,9 +383,7 @@ bool CClient::GetAndResetbJitterBufferOKFlag() void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor ) { // first check new input parameter - if ( ( iNewFactor == FRAME_SIZE_FACTOR_PREFERRED ) || - ( iNewFactor == FRAME_SIZE_FACTOR_DEFAULT ) || - ( iNewFactor == FRAME_SIZE_FACTOR_SAFE ) ) + if ( ( iNewFactor == FRAME_SIZE_FACTOR_PREFERRED ) || ( iNewFactor == FRAME_SIZE_FACTOR_DEFAULT ) || ( iNewFactor == FRAME_SIZE_FACTOR_SAFE ) ) { // init with new parameter, if client was running then first // stop it and restart again after new initialization @@ -639,8 +588,7 @@ void CClient::OnSndCrdReinitRequest ( int iSndCrdResetType ) { // in older QT versions, enums cannot easily be used in signals without // registering them -> workaroud: we use the int type and cast to the enum - const ESndCrdResetType eSndCrdResetType = - static_cast ( iSndCrdResetType ); + const ESndCrdResetType eSndCrdResetType = static_cast ( iSndCrdResetType ); // if client was running then first // stop it and restart again after new initialization @@ -704,8 +652,7 @@ void CClient::OnHandledSignal ( int sigNum ) #endif } -void CClient::OnControllerInFaderLevel ( int iChannelIdx, - int iValue ) +void CClient::OnControllerInFaderLevel ( int iChannelIdx, int iValue ) { // in case of a headless client the faders cannot be moved so we need // to send the controller information directly to the server @@ -720,21 +667,19 @@ void CClient::OnControllerInFaderLevel ( int iChannelIdx, emit ControllerInFaderLevel ( iChannelIdx, iValue ); } -void CClient::OnControllerInPanValue ( int iChannelIdx, - int iValue ) +void CClient::OnControllerInPanValue ( int iChannelIdx, int iValue ) { // in case of a headless client the panners cannot be moved so we need // to send the controller information directly to the server #ifdef HEADLESS // channel index is valid - SetRemoteChanPan ( iChannelIdx, static_cast( iValue ) / AUD_MIX_PAN_MAX); + SetRemoteChanPan ( iChannelIdx, static_cast ( iValue ) / AUD_MIX_PAN_MAX ); #endif emit ControllerInPanValue ( iChannelIdx, iValue ); } -void CClient::OnControllerInFaderIsSolo ( int iChannelIdx, - bool bIsSolo ) +void CClient::OnControllerInFaderIsSolo ( int iChannelIdx, bool bIsSolo ) { // in case of a headless client the buttons are not displayed so we need // to send the controller information directly to the server @@ -745,8 +690,7 @@ void CClient::OnControllerInFaderIsSolo ( int iChannelIdx, emit ControllerInFaderIsSolo ( iChannelIdx, bIsSolo ); } -void CClient::OnControllerInFaderIsMute ( int iChannelIdx, - bool bIsMute ) +void CClient::OnControllerInFaderIsMute ( int iChannelIdx, bool bIsMute ) { // in case of a headless client the buttons are not displayed so we need // to send the controller information directly to the server @@ -801,8 +745,7 @@ void CClient::Stop() // that if the user initiates a connection and disconnection quickly // (e.g. quickly pressing enter five times), the software can get into // an unknown state - QCoreApplication::processEvents ( - QEventLoop::ExcludeUserInputEvents, 100 ); + QCoreApplication::processEvents ( QEventLoop::ExcludeUserInputEvents, 100 ); } // Send disconnect message to server (Since we disable our protocol @@ -825,8 +768,8 @@ void CClient::Init() const int iFraSizeSafe = SYSTEM_FRAME_SIZE_SAMPLES * FRAME_SIZE_FACTOR_SAFE; bFraSiFactPrefSupported = ( Sound.Init ( iFraSizePreffered ) == iFraSizePreffered ); - bFraSiFactDefSupported = ( Sound.Init ( iFraSizeDefault ) == iFraSizeDefault ); - bFraSiFactSafeSupported = ( Sound.Init ( iFraSizeSafe ) == iFraSizeSafe ); + bFraSiFactDefSupported = ( Sound.Init ( iFraSizeDefault ) == iFraSizeDefault ); + bFraSiFactSafeSupported = ( Sound.Init ( iFraSizeSafe ) == iFraSizeSafe ); // translate block size index in actual block size const int iPrefMonoFrameSize = iSndCrdPrefFrameSizeFactor * SYSTEM_FRAME_SIZE_SAMPLES; @@ -877,7 +820,7 @@ void CClient::Init() } else { - if ( iMonoBlockSizeSam < DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ) + if ( iMonoBlockSizeSam < DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ) { eAudioCompressionType = CT_OPUS64; } @@ -885,8 +828,7 @@ void CClient::Init() { // since we use double size frame size for OPUS, we have to adjust the frame size factor iSndCrdFrameSizeFactor /= 2; - eAudioCompressionType = CT_OPUS; - + eAudioCompressionType = CT_OPUS; } } @@ -903,9 +845,15 @@ void CClient::Init() switch ( eAudioQuality ) { - case AQ_LOW: iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_LOW_QUALITY_DBLE_FRAMESIZE; break; - case AQ_NORMAL: iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_NORMAL_QUALITY_DBLE_FRAMESIZE; break; - case AQ_HIGH: iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_HIGH_QUALITY_DBLE_FRAMESIZE; break; + case AQ_LOW: + iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_LOW_QUALITY_DBLE_FRAMESIZE; + break; + case AQ_NORMAL: + iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_NORMAL_QUALITY_DBLE_FRAMESIZE; + break; + case AQ_HIGH: + iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_HIGH_QUALITY_DBLE_FRAMESIZE; + break; } } else @@ -916,9 +864,15 @@ void CClient::Init() switch ( eAudioQuality ) { - case AQ_LOW: iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_LOW_QUALITY_DBLE_FRAMESIZE; break; - case AQ_NORMAL: iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_NORMAL_QUALITY_DBLE_FRAMESIZE; break; - case AQ_HIGH: iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_HIGH_QUALITY_DBLE_FRAMESIZE; break; + case AQ_LOW: + iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_LOW_QUALITY_DBLE_FRAMESIZE; + break; + case AQ_NORMAL: + iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_NORMAL_QUALITY_DBLE_FRAMESIZE; + break; + case AQ_HIGH: + iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_HIGH_QUALITY_DBLE_FRAMESIZE; + break; } } } @@ -934,9 +888,15 @@ void CClient::Init() switch ( eAudioQuality ) { - case AQ_LOW: iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_LOW_QUALITY; break; - case AQ_NORMAL: iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_NORMAL_QUALITY; break; - case AQ_HIGH: iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_HIGH_QUALITY; break; + case AQ_LOW: + iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_LOW_QUALITY; + break; + case AQ_NORMAL: + iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_NORMAL_QUALITY; + break; + case AQ_HIGH: + iCeltNumCodedBytes = OPUS_NUM_BYTES_MONO_HIGH_QUALITY; + break; } } else @@ -947,9 +907,15 @@ void CClient::Init() switch ( eAudioQuality ) { - case AQ_LOW: iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_LOW_QUALITY; break; - case AQ_NORMAL: iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_NORMAL_QUALITY; break; - case AQ_HIGH: iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_HIGH_QUALITY; break; + case AQ_LOW: + iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_LOW_QUALITY; + break; + case AQ_NORMAL: + iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_NORMAL_QUALITY; + break; + case AQ_HIGH: + iCeltNumCodedBytes = OPUS_NUM_BYTES_STEREO_HIGH_QUALITY; + break; } } } @@ -964,23 +930,16 @@ void CClient::Init() fMuteOutStreamGain = 1.0f; opus_custom_encoder_ctl ( CurOpusEncoder, - OPUS_SET_BITRATE ( - CalcBitRateBitsPerSecFromCodedBytes ( - iCeltNumCodedBytes, iOPUSFrameSizeSamples ) ) ); + OPUS_SET_BITRATE ( CalcBitRateBitsPerSecFromCodedBytes ( iCeltNumCodedBytes, iOPUSFrameSizeSamples ) ) ); // inits for network and channel vecbyNetwData.Init ( iCeltNumCodedBytes ); // set the channel network properties - Channel.SetAudioStreamProperties ( eAudioCompressionType, - iCeltNumCodedBytes, - iSndCrdFrameSizeFactor, - iNumAudioChannels ); + Channel.SetAudioStreamProperties ( eAudioCompressionType, iCeltNumCodedBytes, iSndCrdFrameSizeFactor, iNumAudioChannels ); // init reverberation - AudioReverb.Init ( eAudioChannelConf, - iStereoBlockSizeSam, - SYSTEM_SAMPLE_RATE_HZ ); + AudioReverb.Init ( eAudioChannelConf, iStereoBlockSizeSam, SYSTEM_SAMPLE_RATE_HZ ); // init the sound card conversion buffers if ( bSndCrdConversionBufferRequired ) @@ -990,9 +949,9 @@ void CClient::Init() const int iSndCardStereoBlockSizeSamConvBuff = 2 * iSndCardMonoBlockSizeSamConvBuff; const int iConBufSize = iStereoBlockSizeSam + iSndCardStereoBlockSizeSamConvBuff; - SndCrdConversionBufferIn.Init ( iConBufSize ); + SndCrdConversionBufferIn.Init ( iConBufSize ); SndCrdConversionBufferOut.Init ( iConBufSize ); - vecDataConvBuf.Init ( iStereoBlockSizeSam ); + vecDataConvBuf.Init ( iStereoBlockSizeSam ); // the output conversion buffer must be filled with the inner // block size for initialization (this is the latency which is @@ -1012,13 +971,13 @@ void CClient::AudioCallback ( CVector& psData, void* arg ) // process audio data pMyClientObj->ProcessSndCrdAudioData ( psData ); -// clang-format off + // clang-format off /* // TEST do a soundcard jitter measurement static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); */ -// clang-format on + // clang-format on } void CClient::ProcessSndCrdAudioData ( CVector& vecsStereoSndCrd ) @@ -1057,10 +1016,10 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) int i, j, iUnused; unsigned char* pCurCodedData; - // Transmit signal --------------------------------------------------------- - if ( iInputBoost != 1 ) { + if ( iInputBoost != 1 ) + { // apply a general gain boost to all audio input: for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 ) { @@ -1071,17 +1030,13 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) // update stereo signal level meter (not needed in headless mode) #ifndef HEADLESS - SignalLevelMeter.Update ( vecsStereoSndCrd, - iMonoBlockSizeSam, - true ); + SignalLevelMeter.Update ( vecsStereoSndCrd, iMonoBlockSizeSam, true ); #endif // add reverberation effect if activated if ( iReverbLevel != 0 ) { - AudioReverb.Process ( vecsStereoSndCrd, - bReverbOnLeftChan, - static_cast ( iReverbLevel ) / AUD_REVERB_MAX / 4 ); + AudioReverb.Process ( vecsStereoSndCrd, bReverbOnLeftChan, static_cast ( iReverbLevel ) / AUD_REVERB_MAX / 4 ); } // apply pan (audio fader) and mix mono signals @@ -1093,7 +1048,7 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) if ( eAudioChannelConf == CC_STEREO ) { // for stereo only apply pan attenuation on one channel (same as pan in the server) - const float fGainL = MathUtils::GetLeftPan ( fPan, false ); + const float fGainL = MathUtils::GetLeftPan ( fPan, false ); const float fGainR = MathUtils::GetRightPan ( fPan, false ); for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 ) @@ -1108,14 +1063,13 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) { // for mono implement a cross-fade between channels and mix them, for // mono-in/stereo-out use no attenuation in pan center - const float fGainL = MathUtils::GetLeftPan ( fPan, eAudioChannelConf != CC_MONO_IN_STEREO_OUT ); + const float fGainL = MathUtils::GetLeftPan ( fPan, eAudioChannelConf != CC_MONO_IN_STEREO_OUT ); const float fGainR = MathUtils::GetRightPan ( fPan, eAudioChannelConf != CC_MONO_IN_STEREO_OUT ); for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 ) { // note that we need the Float2Short for stereo pan mode - vecsStereoSndCrd[i] = Float2Short ( - fGainL * vecsStereoSndCrd[j] + fGainR * vecsStereoSndCrd[j + 1] ); + vecsStereoSndCrd[i] = Float2Short ( fGainL * vecsStereoSndCrd[j] + fGainR * vecsStereoSndCrd[j + 1] ); } } } @@ -1159,12 +1113,9 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) } // send coded audio through the network - Channel.PrepAndSendPacket ( &Socket, - vecCeltData, - iCeltNumCodedBytes ); + Channel.PrepAndSendPacket ( &Socket, vecCeltData, iCeltNumCodedBytes ); } - // Receive signal ---------------------------------------------------------- // in case of mute stream, store local data if ( bMuteOutStream ) @@ -1175,8 +1126,7 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) for ( i = 0; i < iSndCrdFrameSizeFactor; i++ ) { // receive a new block - const bool bReceiveDataOk = - ( Channel.GetData ( vecbyNetwData, iCeltNumCodedBytes ) == GS_BUFFER_OK ); + const bool bReceiveDataOk = ( Channel.GetData ( vecbyNetwData, iCeltNumCodedBytes ) == GS_BUFFER_OK ); // get pointer to coded data and manage the flags if ( bReceiveDataOk ) @@ -1211,8 +1161,7 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) { for ( i = 0; i < iStereoBlockSizeSam; i++ ) { - vecsStereoSndCrd[i] = Float2Short ( - vecsStereoSndCrd[i] + vecsStereoSndCrdMuteStream[i] * fMuteOutStreamGain ); + vecsStereoSndCrd[i] = Float2Short ( vecsStereoSndCrd[i] + vecsStereoSndCrdMuteStream[i] * fMuteOutStreamGain ); } } @@ -1244,21 +1193,18 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) int CClient::EstimatedOverallDelay ( const int iPingTimeMs ) { - const float fSystemBlockDurationMs = static_cast ( iOPUSFrameSizeSamples ) / - SYSTEM_SAMPLE_RATE_HZ * 1000; + const float fSystemBlockDurationMs = static_cast ( iOPUSFrameSizeSamples ) / SYSTEM_SAMPLE_RATE_HZ * 1000; // If the jitter buffers are set effectively, i.e. they are exactly the // size of the network jitter, then the delay of the buffer is the buffer // length. Since that is usually not the case but the buffers are usually // a bit larger than necessary, we introduce some factor for compensation. // Consider the jitter buffer on the client and on the server side, too. - const float fTotalJitterBufferDelayMs = fSystemBlockDurationMs * - ( GetSockBufNumFrames() + GetServerSockBufNumFrames() ) * 0.7f; + const float fTotalJitterBufferDelayMs = fSystemBlockDurationMs * ( GetSockBufNumFrames() + GetServerSockBufNumFrames() ) * 0.7f; // consider delay introduced by the sound card conversion buffer by using // "GetSndCrdConvBufAdditionalDelayMonoBlSize()" - float fTotalSoundCardDelayMs = GetSndCrdConvBufAdditionalDelayMonoBlSize() * - 1000.0f / SYSTEM_SAMPLE_RATE_HZ; + float fTotalSoundCardDelayMs = GetSndCrdConvBufAdditionalDelayMonoBlSize() * 1000.0f / SYSTEM_SAMPLE_RATE_HZ; // try to get the actual input/output sound card delay from the audio // interface, per definition it is not available if a 0 is returned @@ -1272,9 +1218,7 @@ int CClient::EstimatedOverallDelay ( const int iPingTimeMs ) // output, therefore we have "3 *" instead of "2 *" (for input and output) // the actual sound card buffer size // "GetSndCrdConvBufAdditionalDelayMonoBlSize" - fTotalSoundCardDelayMs += - ( 3 * GetSndCrdActualMonoBlSize() ) * - 1000.0f / SYSTEM_SAMPLE_RATE_HZ; + fTotalSoundCardDelayMs += ( 3 * GetSndCrdActualMonoBlSize() ) * 1000.0f / SYSTEM_SAMPLE_RATE_HZ; } else { @@ -1284,17 +1228,13 @@ int CClient::EstimatedOverallDelay ( const int iPingTimeMs ) // network packets are of the same size as the audio packets per definition // if no sound card conversion buffer is used - const float fDelayToFillNetworkPacketsMs = - GetSystemMonoBlSize() * 1000.0f / SYSTEM_SAMPLE_RATE_HZ; + const float fDelayToFillNetworkPacketsMs = GetSystemMonoBlSize() * 1000.0f / SYSTEM_SAMPLE_RATE_HZ; // OPUS additional delay at small frame sizes is half a frame size const float fAdditionalAudioCodecDelayMs = fSystemBlockDurationMs / 2; const float fTotalBufferDelayMs = - fDelayToFillNetworkPacketsMs + - fTotalJitterBufferDelayMs + - fTotalSoundCardDelayMs + - fAdditionalAudioCodecDelayMs; + fDelayToFillNetworkPacketsMs + fTotalJitterBufferDelayMs + fTotalSoundCardDelayMs + fAdditionalAudioCodecDelayMs; return MathUtils::round ( fTotalBufferDelayMs + iPingTimeMs ); } diff --git a/src/client.h b/src/client.h old mode 100755 new mode 100644 index 29d2020b3c..929da28853 --- a/src/client.h +++ b/src/client.h @@ -30,9 +30,9 @@ #include #include #ifdef USE_OPUS_SHARED_LIB -# include "opus/opus_custom.h" +# include "opus/opus_custom.h" #else -# include "opus_custom.h" +# include "opus_custom.h" #endif #include "global.h" #include "socket.h" @@ -41,40 +41,40 @@ #include "buffer.h" #include "signalhandler.h" #ifdef LLCON_VST_PLUGIN -# include "vstsound.h" +# include "vstsound.h" #else -# if defined ( _WIN32 ) && !defined ( JACK_REPLACES_ASIO ) -# include "../windows/sound.h" -# else -# if ( defined ( Q_OS_MACX ) ) && !defined ( JACK_REPLACES_COREAUDIO ) -# include "../mac/sound.h" -# else -# if defined ( Q_OS_IOS ) -# include "../ios/sound.h" +# if defined( _WIN32 ) && !defined( JACK_REPLACES_ASIO ) +# include "../windows/sound.h" # else -# ifdef ANDROID -# include "../android/sound.h" -# else -# include "../linux/sound.h" -# ifndef JACK_REPLACES_ASIO // these headers are not available in Windows OS -# include -# include -# endif -# include +# if ( defined( Q_OS_MACX ) ) && !defined( JACK_REPLACES_COREAUDIO ) +# include "../mac/sound.h" +# else +# if defined( Q_OS_IOS ) +# include "../ios/sound.h" +# else +# ifdef ANDROID +# include "../android/sound.h" +# else +# include "../linux/sound.h" +# ifndef JACK_REPLACES_ASIO // these headers are not available in Windows OS +# include +# include +# endif +# include +# endif +# endif +# endif # endif -# endif -# endif -# endif #endif /* Definitions ****************************************************************/ // audio in fader range -#define AUD_FADER_IN_MIN 0 -#define AUD_FADER_IN_MAX 100 -#define AUD_FADER_IN_MIDDLE ( AUD_FADER_IN_MAX / 2 ) +#define AUD_FADER_IN_MIN 0 +#define AUD_FADER_IN_MAX 100 +#define AUD_FADER_IN_MIDDLE ( AUD_FADER_IN_MAX / 2 ) // audio reverberation range -#define AUD_REVERB_MAX 100 +#define AUD_REVERB_MAX 100 // OPUS number of coded bytes per audio packet // TODO we have to use new numbers for OPUS to avoid that old CELT packets @@ -87,12 +87,12 @@ // Fs: sampling rate (SYSTEM_SAMPLE_RATE_HZ) // L: number of samples per packet (SYSTEM_FRAME_SIZE_SAMPLES) // N: number of bytes per packet (values below) -#define OPUS_NUM_BYTES_MONO_LOW_QUALITY 12 -#define OPUS_NUM_BYTES_MONO_NORMAL_QUALITY 22 -#define OPUS_NUM_BYTES_MONO_HIGH_QUALITY 36 -#define OPUS_NUM_BYTES_MONO_LOW_QUALITY_DBLE_FRAMESIZE 25 -#define OPUS_NUM_BYTES_MONO_NORMAL_QUALITY_DBLE_FRAMESIZE 45 -#define OPUS_NUM_BYTES_MONO_HIGH_QUALITY_DBLE_FRAMESIZE 82 +#define OPUS_NUM_BYTES_MONO_LOW_QUALITY 12 +#define OPUS_NUM_BYTES_MONO_NORMAL_QUALITY 22 +#define OPUS_NUM_BYTES_MONO_HIGH_QUALITY 36 +#define OPUS_NUM_BYTES_MONO_LOW_QUALITY_DBLE_FRAMESIZE 25 +#define OPUS_NUM_BYTES_MONO_NORMAL_QUALITY_DBLE_FRAMESIZE 45 +#define OPUS_NUM_BYTES_MONO_HIGH_QUALITY_DBLE_FRAMESIZE 82 #define OPUS_NUM_BYTES_STEREO_LOW_QUALITY 24 #define OPUS_NUM_BYTES_STEREO_NORMAL_QUALITY 35 @@ -101,7 +101,6 @@ #define OPUS_NUM_BYTES_STEREO_NORMAL_QUALITY_DBLE_FRAMESIZE 71 #define OPUS_NUM_BYTES_STEREO_HIGH_QUALITY_DBLE_FRAMESIZE 165 - /* Classes ********************************************************************/ class CClient : public QObject { @@ -118,27 +117,27 @@ class CClient : public QObject virtual ~CClient(); - void Start(); - void Stop(); - bool IsRunning() { return Sound.IsRunning(); } - bool IsCallbackEntered() const { return Sound.IsCallbackEntered(); } - bool SetServerAddr ( QString strNAddr ); + void Start(); + void Stop(); + bool IsRunning() { return Sound.IsRunning(); } + bool IsCallbackEntered() const { return Sound.IsCallbackEntered(); } + bool SetServerAddr ( QString strNAddr ); - double GetLevelForMeterdBLeft() { return SignalLevelMeter.GetLevelForMeterdBLeftOrMono(); } + double GetLevelForMeterdBLeft() { return SignalLevelMeter.GetLevelForMeterdBLeftOrMono(); } double GetLevelForMeterdBRight() { return SignalLevelMeter.GetLevelForMeterdBRight(); } - bool GetAndResetbJitterBufferOKFlag(); + bool GetAndResetbJitterBufferOKFlag(); - bool IsConnected() { return Channel.IsConnected(); } + bool IsConnected() { return Channel.IsConnected(); } EGUIDesign GetGUIDesign() const { return eGUIDesign; } void SetGUIDesign ( const EGUIDesign eNGD ) { eGUIDesign = eNGD; } EAudioQuality GetAudioQuality() const { return eAudioQuality; } - void SetAudioQuality ( const EAudioQuality eNAudioQuality ); + void SetAudioQuality ( const EAudioQuality eNAudioQuality ); EAudChanConf GetAudioChannels() const { return eAudioChannelConf; } - void SetAudioChannels ( const EAudChanConf eNAudChanConf ); + void SetAudioChannels ( const EAudChanConf eNAudChanConf ); int GetAudioInFader() const { return iAudioInFader; } void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; } @@ -156,14 +155,10 @@ class CClient : public QObject void SetDoAutoSockBufSize ( const bool bValue ); bool GetDoAutoSockBufSize() const { return Channel.GetDoAutoSockBufSize(); } - void SetSockBufNumFrames ( const int iNumBlocks, - const bool bPreserve = false ) - { - Channel.SetSockBufNumFrames ( iNumBlocks, bPreserve ); - } - int GetSockBufNumFrames() { return Channel.GetSockBufNumFrames(); } + void SetSockBufNumFrames ( const int iNumBlocks, const bool bPreserve = false ) { Channel.SetSockBufNumFrames ( iNumBlocks, bPreserve ); } + int GetSockBufNumFrames() { return Channel.GetSockBufNumFrames(); } - void SetServerSockBufNumFrames ( const int iNumBlocks ) + void SetServerSockBufNumFrames ( const int iNumBlocks ) { iServerSockBufNumFrames = iNumBlocks; @@ -178,7 +173,7 @@ class CClient : public QObject int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); } // sound card device selection - QStringList GetSndCrdDevNames() { return Sound.GetDevNames(); } + QStringList GetSndCrdDevNames() { return Sound.GetDevNames(); } QString SetSndCrdDev ( const QString strNewDev ); QString GetSndCrdDev() { return Sound.GetDev(); } @@ -187,16 +182,16 @@ class CClient : public QObject // sound card channel selection int GetSndCrdNumInputChannels() { return Sound.GetNumInputChannels(); } QString GetSndCrdInputChannelName ( const int iDiD ) { return Sound.GetInputChannelName ( iDiD ); } - void SetSndCrdLeftInputChannel ( const int iNewChan ); + void SetSndCrdLeftInputChannel ( const int iNewChan ); void SetSndCrdRightInputChannel ( const int iNewChan ); - int GetSndCrdLeftInputChannel() { return Sound.GetLeftInputChannel(); } + int GetSndCrdLeftInputChannel() { return Sound.GetLeftInputChannel(); } int GetSndCrdRightInputChannel() { return Sound.GetRightInputChannel(); } int GetSndCrdNumOutputChannels() { return Sound.GetNumOutputChannels(); } QString GetSndCrdOutputChannelName ( const int iDiD ) { return Sound.GetOutputChannelName ( iDiD ); } - void SetSndCrdLeftOutputChannel ( const int iNewChan ); + void SetSndCrdLeftOutputChannel ( const int iNewChan ); void SetSndCrdRightOutputChannel ( const int iNewChan ); - int GetSndCrdLeftOutputChannel() { return Sound.GetLeftOutputChannel(); } + int GetSndCrdLeftOutputChannel() { return Sound.GetLeftOutputChannel(); } int GetSndCrdRightOutputChannel() { return Sound.GetRightOutputChannel(); } void SetSndCrdPrefFrameSizeFactor ( const int iNewFactor ); @@ -234,46 +229,40 @@ class CClient : public QObject } bool GetFraSiFactPrefSupported() { return bFraSiFactPrefSupported; } - bool GetFraSiFactDefSupported() { return bFraSiFactDefSupported; } + bool GetFraSiFactDefSupported() { return bFraSiFactDefSupported; } bool GetFraSiFactSafeSupported() { return bFraSiFactSafeSupported; } void SetMuteOutStream ( const bool bDoMute ) { bMuteOutStream = bDoMute; } void SetRemoteChanGain ( const int iId, const float fGain, const bool bIsMyOwnFader ); - void SetRemoteChanPan ( const int iId, const float fPan ) - { Channel.SetRemoteChanPan ( iId, fPan ); } + void SetRemoteChanPan ( const int iId, const float fPan ) { Channel.SetRemoteChanPan ( iId, fPan ); } void SetInputBoost ( const int iNewBoost ) { iInputBoost = iNewBoost; } void SetRemoteInfo() { Channel.SetRemoteInfo ( ChannelInfo ); } - void CreateChatTextMes ( const QString& strChatText ) - { Channel.CreateChatTextMes ( strChatText ); } + void CreateChatTextMes ( const QString& strChatText ) { Channel.CreateChatTextMes ( strChatText ); } - void CreateCLPingMes() - { ConnLessProtocol.CreateCLPingMes ( Channel.GetAddress(), PreparePingMessage() ); } + void CreateCLPingMes() { ConnLessProtocol.CreateCLPingMes ( Channel.GetAddress(), PreparePingMessage() ); } void CreateCLServerListPingMes ( const CHostAddress& InetAddr ) { - ConnLessProtocol.CreateCLPingWithNumClientsMes ( InetAddr, - PreparePingMessage(), - 0 /* dummy */ ); + ConnLessProtocol.CreateCLPingWithNumClientsMes ( InetAddr, PreparePingMessage(), 0 /* dummy */ ); } - void CreateCLServerListReqVerAndOSMes ( const CHostAddress& InetAddr ) - { ConnLessProtocol.CreateCLReqVersionAndOSMes ( InetAddr ); } + void CreateCLServerListReqVerAndOSMes ( const CHostAddress& InetAddr ) { ConnLessProtocol.CreateCLReqVersionAndOSMes ( InetAddr ); } - void CreateCLServerListReqConnClientsListMes ( const CHostAddress& InetAddr ) - { ConnLessProtocol.CreateCLReqConnClientsListMes ( InetAddr ); } + void CreateCLServerListReqConnClientsListMes ( const CHostAddress& InetAddr ) { ConnLessProtocol.CreateCLReqConnClientsListMes ( InetAddr ); } - void CreateCLReqServerListMes ( const CHostAddress& InetAddr ) - { ConnLessProtocol.CreateCLReqServerListMes ( InetAddr ); } + void CreateCLReqServerListMes ( const CHostAddress& InetAddr ) { ConnLessProtocol.CreateCLReqServerListMes ( InetAddr ); } int EstimatedOverallDelay ( const int iPingTimeMs ); void GetBufErrorRates ( CVector& vecErrRates, double& dLimit, double& dMaxUpLimit ) - { Channel.GetBufErrorRates ( vecErrRates, dLimit, dMaxUpLimit ); } + { + Channel.GetBufErrorRates ( vecErrRates, dLimit, dMaxUpLimit ); + } // settings CChannelCoreInfo ChannelInfo; @@ -288,110 +277,110 @@ class CClient : public QObject // callback function must be static, otherwise it does not work static void AudioCallback ( CVector& psData, void* arg ); - void Init(); - void ProcessSndCrdAudioData ( CVector& vecsStereoSndCrd ); - void ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ); + void Init(); + void ProcessSndCrdAudioData ( CVector& vecsStereoSndCrd ); + void ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ); - int PreparePingMessage(); - int EvaluatePingMessage ( const int iMs ); - void CreateServerJitterBufferMessage(); + int PreparePingMessage(); + int EvaluatePingMessage ( const int iMs ); + void CreateServerJitterBufferMessage(); // only one channel is needed for client application - CChannel Channel; - CProtocol ConnLessProtocol; + CChannel Channel; + CProtocol ConnLessProtocol; // audio encoder/decoder - OpusCustomMode* Opus64Mode; - OpusCustomEncoder* Opus64EncoderMono; - OpusCustomDecoder* Opus64DecoderMono; - OpusCustomEncoder* Opus64EncoderStereo; - OpusCustomDecoder* Opus64DecoderStereo; - OpusCustomMode* OpusMode; - OpusCustomEncoder* OpusEncoderMono; - OpusCustomDecoder* OpusDecoderMono; - OpusCustomEncoder* OpusEncoderStereo; - OpusCustomDecoder* OpusDecoderStereo; - OpusCustomEncoder* CurOpusEncoder; - OpusCustomDecoder* CurOpusDecoder; - EAudComprType eAudioCompressionType; - int iCeltNumCodedBytes; - int iOPUSFrameSizeSamples; - EAudioQuality eAudioQuality; - EAudChanConf eAudioChannelConf; - int iNumAudioChannels; - bool bIsInitializationPhase; - bool bMuteOutStream; - float fMuteOutStreamGain; - CVector vecCeltData; + OpusCustomMode* Opus64Mode; + OpusCustomEncoder* Opus64EncoderMono; + OpusCustomDecoder* Opus64DecoderMono; + OpusCustomEncoder* Opus64EncoderStereo; + OpusCustomDecoder* Opus64DecoderStereo; + OpusCustomMode* OpusMode; + OpusCustomEncoder* OpusEncoderMono; + OpusCustomDecoder* OpusDecoderMono; + OpusCustomEncoder* OpusEncoderStereo; + OpusCustomDecoder* OpusDecoderStereo; + OpusCustomEncoder* CurOpusEncoder; + OpusCustomDecoder* CurOpusDecoder; + EAudComprType eAudioCompressionType; + int iCeltNumCodedBytes; + int iOPUSFrameSizeSamples; + EAudioQuality eAudioQuality; + EAudChanConf eAudioChannelConf; + int iNumAudioChannels; + bool bIsInitializationPhase; + bool bMuteOutStream; + float fMuteOutStreamGain; + CVector vecCeltData; CHighPrioSocket Socket; CSound Sound; CStereoSignalLevelMeter SignalLevelMeter; - CVector vecbyNetwData; + CVector vecbyNetwData; - int iAudioInFader; - bool bReverbOnLeftChan; - int iReverbLevel; - CAudioReverb AudioReverb; - int iInputBoost; + int iAudioInFader; + bool bReverbOnLeftChan; + int iReverbLevel; + CAudioReverb AudioReverb; + int iInputBoost; - int iSndCrdPrefFrameSizeFactor; - int iSndCrdFrameSizeFactor; + int iSndCrdPrefFrameSizeFactor; + int iSndCrdFrameSizeFactor; - bool bSndCrdConversionBufferRequired; - int iSndCardMonoBlockSizeSamConvBuff; - CBuffer SndCrdConversionBufferIn; - CBuffer SndCrdConversionBufferOut; - CVector vecDataConvBuf; - CVector vecsStereoSndCrdMuteStream; - CVector vecZeros; + bool bSndCrdConversionBufferRequired; + int iSndCardMonoBlockSizeSamConvBuff; + CBuffer SndCrdConversionBufferIn; + CBuffer SndCrdConversionBufferOut; + CVector vecDataConvBuf; + CVector vecsStereoSndCrdMuteStream; + CVector vecZeros; - bool bFraSiFactPrefSupported; - bool bFraSiFactDefSupported; - bool bFraSiFactSafeSupported; + bool bFraSiFactPrefSupported; + bool bFraSiFactDefSupported; + bool bFraSiFactSafeSupported; - int iMonoBlockSizeSam; - int iStereoBlockSizeSam; + int iMonoBlockSizeSam; + int iStereoBlockSizeSam; - EGUIDesign eGUIDesign; - bool bEnableOPUS64; + EGUIDesign eGUIDesign; + bool bEnableOPUS64; - bool bJitterBufferOK; - bool bNuteMeInPersonalMix; - QMutex MutexDriverReinit; + bool bJitterBufferOK; + bool bNuteMeInPersonalMix; + QMutex MutexDriverReinit; // server settings - int iServerSockBufNumFrames; + int iServerSockBufNumFrames; // for ping measurement - QElapsedTimer PreciseTime; + QElapsedTimer PreciseTime; - CSignalHandler* pSignalHandler; + CSignalHandler* pSignalHandler; protected slots: void OnHandledSignal ( int sigNum ); void OnSendProtMessage ( CVector vecMessage ); void OnInvalidPacketReceived ( CHostAddress RecHostAddr ); - void OnDetectedCLMessage ( CVector vecbyMesBodyData, - int iRecID, - CHostAddress RecHostAddr ); + void OnDetectedCLMessage ( CVector vecbyMesBodyData, int iRecID, CHostAddress RecHostAddr ); void OnReqJittBufSize() { CreateServerJitterBufferMessage(); } void OnJittBufSizeChanged ( int iNewJitBufSize ); void OnReqChanInfo() { Channel.SetRemoteInfo ( ChannelInfo ); } void OnNewConnection(); - void OnCLDisconnection ( CHostAddress InetAddr ) { if ( InetAddr == Channel.GetAddress() ) { emit Disconnected(); } } - void OnCLPingReceived ( CHostAddress InetAddr, - int iMs ); + void OnCLDisconnection ( CHostAddress InetAddr ) + { + if ( InetAddr == Channel.GetAddress() ) + { + emit Disconnected(); + } + } + void OnCLPingReceived ( CHostAddress InetAddr, int iMs ); - void OnSendCLProtMessage ( CHostAddress InetAddr, - CVector vecMessage ); + void OnSendCLProtMessage ( CHostAddress InetAddr, CVector vecMessage ); - void OnCLPingWithNumClientsReceived ( CHostAddress InetAddr, - int iMs, - int iNumClients ); + void OnCLPingWithNumClientsReceived ( CHostAddress InetAddr, int iMs, int iNumClients ); void OnSndCrdReinitRequest ( int iSndCrdResetType ); void OnControllerInFaderLevel ( int iChannelIdx, int iValue ); @@ -410,25 +399,17 @@ protected slots: void PingTimeReceived ( int iPingTime ); void RecorderStateReceived ( ERecorderState eRecorderState ); - void CLServerListReceived ( CHostAddress InetAddr, - CVector vecServerInfo ); + void CLServerListReceived ( CHostAddress InetAddr, CVector vecServerInfo ); - void CLRedServerListReceived ( CHostAddress InetAddr, - CVector vecServerInfo ); + void CLRedServerListReceived ( CHostAddress InetAddr, CVector vecServerInfo ); - void CLConnClientsListMesReceived ( CHostAddress InetAddr, - CVector vecChanInfo ); + void CLConnClientsListMesReceived ( CHostAddress InetAddr, CVector vecChanInfo ); - void CLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, - int iPingTime, - int iNumClients ); + void CLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, int iPingTime, int iNumClients ); - void CLVersionAndOSReceived ( CHostAddress InetAddr, - COSUtil::EOpSystemType eOSType, - QString strVersion ); + void CLVersionAndOSReceived ( CHostAddress InetAddr, COSUtil::EOpSystemType eOSType, QString strVersion ); - void CLChannelLevelListReceived ( CHostAddress InetAddr, - CVector vecLevelList ); + void CLChannelLevelListReceived ( CHostAddress InetAddr, CVector vecLevelList ); void Disconnected(); void SoundDeviceChanged ( QString strError ); diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp old mode 100755 new mode 100644 index bae820fdd4..25eb8b09f5 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -24,7 +24,6 @@ #include "clientdlg.h" - /* Implementation *************************************************************/ CClientDlg::CClientDlg ( CClient* pNCliP, CClientSettings* pNSetP, @@ -34,74 +33,78 @@ CClientDlg::CClientDlg ( CClient* pNCliP, const bool bShowAnalyzerConsole, const bool bMuteStream, QWidget* parent ) : - CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons - pClient ( pNCliP ), - pSettings ( pNSetP ), + CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons + pClient ( pNCliP ), + pSettings ( pNSetP ), bConnectDlgWasShown ( false ), - bMIDICtrlUsed ( !strMIDISetup.isEmpty() ), - eLastRecorderState ( RS_UNDEFINED ), // for SetMixerBoardDeco - eLastDesign ( GD_ORIGINAL ), // " - ClientSettingsDlg ( pNCliP, pNSetP, parent ), - ChatDlg ( parent ), - ConnectDlg ( pNSetP, bNewShowComplRegConnList, parent ), - AnalyzerConsole ( pNCliP, parent ) + bMIDICtrlUsed ( !strMIDISetup.isEmpty() ), + eLastRecorderState ( RS_UNDEFINED ), // for SetMixerBoardDeco + eLastDesign ( GD_ORIGINAL ), // " + ClientSettingsDlg ( pNCliP, pNSetP, parent ), + ChatDlg ( parent ), + ConnectDlg ( pNSetP, bNewShowComplRegConnList, parent ), + AnalyzerConsole ( pNCliP, parent ) { setupUi ( this ); // Add help text to controls ----------------------------------------------- // input level meter - QString strInpLevH = "" + tr ( "Input Level Meter" ) + ": " + tr ( "This shows " - "the level of the two stereo channels " - "for your audio input." ) + "
" + - tr ( "Make sure not to clip the input signal to avoid distortions of the " - "audio signal." ); + QString strInpLevH = "" + tr ( "Input Level Meter" ) + ": " + + tr ( "This shows " + "the level of the two stereo channels " + "for your audio input." ) + + "
" + + tr ( "Make sure not to clip the input signal to avoid distortions of the " + "audio signal." ); QString strInpLevHTT = tr ( "If the application " - "is connected to a server and " - "you play your instrument/sing into the microphone, the VU " - "meter should flicker. If this is not the case, you have " - "probably selected the wrong input channel (e.g. 'line in' instead " - "of the microphone input) or set the input gain too low in the " - "(Windows) audio mixer." ) + "
" + tr ( "For proper usage of the " - "application, you should not hear your singing/instrument through " - "the loudspeaker or your headphone when the software is not connected." - "This can be achieved by muting your input audio channel in the " - "Playback mixer (not the Recording mixer!)." ) + TOOLTIP_COM_END_TEXT; + "is connected to a server and " + "you play your instrument/sing into the microphone, the VU " + "meter should flicker. If this is not the case, you have " + "probably selected the wrong input channel (e.g. 'line in' instead " + "of the microphone input) or set the input gain too low in the " + "(Windows) audio mixer." ) + + "
" + + tr ( "For proper usage of the " + "application, you should not hear your singing/instrument through " + "the loudspeaker or your headphone when the software is not connected." + "This can be achieved by muting your input audio channel in the " + "Playback mixer (not the Recording mixer!)." ) + + TOOLTIP_COM_END_TEXT; QString strInpLevHAccText = tr ( "Input level meter" ); QString strInpLevHAccDescr = tr ( "Simulates an analog LED level meter." ); - lblInputLEDMeter->setWhatsThis ( strInpLevH ); - lblLevelMeterLeft->setWhatsThis ( strInpLevH ); - lblLevelMeterRight->setWhatsThis ( strInpLevH ); - lbrInputLevelL->setWhatsThis ( strInpLevH ); - lbrInputLevelL->setAccessibleName ( strInpLevHAccText ); + lblInputLEDMeter->setWhatsThis ( strInpLevH ); + lblLevelMeterLeft->setWhatsThis ( strInpLevH ); + lblLevelMeterRight->setWhatsThis ( strInpLevH ); + lbrInputLevelL->setWhatsThis ( strInpLevH ); + lbrInputLevelL->setAccessibleName ( strInpLevHAccText ); lbrInputLevelL->setAccessibleDescription ( strInpLevHAccDescr ); - lbrInputLevelL->setToolTip ( strInpLevHTT ); - lbrInputLevelL->setEnabled ( false ); - lbrInputLevelR->setWhatsThis ( strInpLevH ); - lbrInputLevelR->setAccessibleName ( strInpLevHAccText ); + lbrInputLevelL->setToolTip ( strInpLevHTT ); + lbrInputLevelL->setEnabled ( false ); + lbrInputLevelR->setWhatsThis ( strInpLevH ); + lbrInputLevelR->setAccessibleName ( strInpLevHAccText ); lbrInputLevelR->setAccessibleDescription ( strInpLevHAccDescr ); - lbrInputLevelR->setToolTip ( strInpLevHTT ); - lbrInputLevelR->setEnabled ( false ); + lbrInputLevelR->setToolTip ( strInpLevHTT ); + lbrInputLevelR->setEnabled ( false ); // connect/disconnect button butConnect->setWhatsThis ( "" + tr ( "Connect/Disconnect Button" ) + ": " + - tr ( "Opens a dialog where you can select a server to connect to. " - "If you are connected, pressing this button will end the session." ) ); + tr ( "Opens a dialog where you can select a server to connect to. " + "If you are connected, pressing this button will end the session." ) ); - butConnect->setAccessibleName ( - tr ( "Connect and disconnect toggle button" ) ); + butConnect->setAccessibleName ( tr ( "Connect and disconnect toggle button" ) ); // reverberation level QString strAudReverb = "" + tr ( "Reverb effect" ) + ": " + - tr ( "Reverb can be applied to one local mono audio channel or to both " - "channels in stereo mode. The mono channel selection and the " - "reverb level can be modified. For example, if " - "a microphone signal is fed in to the right audio channel of the " - "sound card and a reverb effect needs to be applied, set the " - "channel selector to right and move the fader upwards until the " - "desired reverb level is reached." ); + tr ( "Reverb can be applied to one local mono audio channel or to both " + "channels in stereo mode. The mono channel selection and the " + "reverb level can be modified. For example, if " + "a microphone signal is fed in to the right audio channel of the " + "sound card and a reverb effect needs to be applied, set the " + "channel selector to right and move the fader upwards until the " + "desired reverb level is reached." ); lblAudioReverb->setWhatsThis ( strAudReverb ); sldAudioReverb->setWhatsThis ( strAudReverb ); @@ -110,9 +113,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP, // reverberation channel selection QString strRevChanSel = "" + tr ( "Reverb Channel Selection" ) + ": " + - tr ( "With these radio buttons the audio input channel on which the " - "reverb effect is applied can be chosen. Either the left " - "or right input channel can be selected." ); + tr ( "With these radio buttons the audio input channel on which the " + "reverb effect is applied can be chosen. Either the left " + "or right input channel can be selected." ); rbtReverbSelL->setWhatsThis ( strRevChanSel ); rbtReverbSelL->setAccessibleName ( tr ( "Left channel selection for reverb" ) ); @@ -120,39 +123,58 @@ CClientDlg::CClientDlg ( CClient* pNCliP, rbtReverbSelR->setAccessibleName ( tr ( "Right channel selection for reverb" ) ); // delay LED - QString strLEDDelay = "" + tr ( "Delay Status LED" ) + ": " + - tr ( "Shows the current audio delay status:" ) + - "
    " - "
  • " "" + tr ( "Green" ) + ": " + tr ( "The delay is perfect for a jam " - "session." ) + "
  • " - "
  • " "" + tr ( "Yellow" ) + ": " + tr ( "A session is still possible " - "but it may be harder to play." ) + "
  • " - "
  • " "" + tr ( "Red" ) + ": " + tr ( "The delay is too large for " - "jamming." ) + "
  • " - "
"; + QString strLEDDelay = "" + tr ( "Delay Status LED" ) + ": " + tr ( "Shows the current audio delay status:" ) + + "
    " + "
  • " + "" + + tr ( "Green" ) + ": " + + tr ( "The delay is perfect for a jam " + "session." ) + + "
  • " + "
  • " + "" + + tr ( "Yellow" ) + ": " + + tr ( "A session is still possible " + "but it may be harder to play." ) + + "
  • " + "
  • " + "" + + tr ( "Red" ) + ": " + + tr ( "The delay is too large for " + "jamming." ) + + "
  • " + "
"; lblDelay->setWhatsThis ( strLEDDelay ); ledDelay->setWhatsThis ( strLEDDelay ); ledDelay->setToolTip ( tr ( "If this LED indicator turns red, " - "you will not have much fun using the application." ) + - TOOLTIP_COM_END_TEXT ); + "you will not have much fun using the application." ) + + TOOLTIP_COM_END_TEXT ); ledDelay->setAccessibleName ( tr ( "Delay status LED indicator" ) ); // buffers LED QString strLEDBuffers = "" + tr ( "Buffers Status LED" ) + ": " + - tr ( "The buffers status LED shows the current audio/streaming " - "status. If the light is red, the audio stream is interrupted. " - "This is caused by one of the following problems:" ) + - "
    " - "
  • " + tr ( "The network jitter buffer is not large enough for the current " - "network/audio interface jitter." ) + "
  • " - "
  • " + tr ( "The sound card's buffer delay (buffer size) is too small " - "(see Settings window)." ) + "
  • " - "
  • " + tr ( "The upload or download stream rate is too high for your " - "internet bandwidth." ) + "
  • " - "
  • " + tr ( "The CPU of the client or server is at 100%." ) + "
  • " - "
"; + tr ( "The buffers status LED shows the current audio/streaming " + "status. If the light is red, the audio stream is interrupted. " + "This is caused by one of the following problems:" ) + + "
    " + "
  • " + + tr ( "The network jitter buffer is not large enough for the current " + "network/audio interface jitter." ) + + "
  • " + "
  • " + + tr ( "The sound card's buffer delay (buffer size) is too small " + "(see Settings window)." ) + + "
  • " + "
  • " + + tr ( "The upload or download stream rate is too high for your " + "internet bandwidth." ) + + "
  • " + "
  • " + + tr ( "The CPU of the client or server is at 100%." ) + + "
  • " + "
"; lblBuffers->setWhatsThis ( strLEDBuffers ); ledBuffers->setWhatsThis ( strLEDBuffers ); @@ -206,15 +228,13 @@ CClientDlg::CClientDlg ( CClient* pNCliP, lblGlobalInfoLabel->hide(); // prepare update check info label (invisible by default) - lblUpdateCheck->setText ( "" + QString ( APP_NAME ) + " " + - tr ( "software upgrade available" ) + "" ); + lblUpdateCheck->setText ( "" + QString ( APP_NAME ) + " " + tr ( "software upgrade available" ) + "" ); lblUpdateCheck->hide(); // setup timers TimerCheckAudioDeviceOk.setSingleShot ( true ); // only check once after connection TimerDetectFeedback.setSingleShot ( true ); - // Connect on startup ------------------------------------------------------ if ( !strConnOnStartupAddress.isEmpty() ) { @@ -223,65 +243,55 @@ CClientDlg::CClientDlg ( CClient* pNCliP, Connect ( strConnOnStartupAddress, strConnOnStartupAddress ); } - // File menu -------------------------------------------------------------- QMenu* pFileMenu = new QMenu ( tr ( "&File" ), this ); - pFileMenu->addAction ( tr ( "&Load Mixer Channels Setup..." ), this, - SLOT ( OnLoadChannelSetup() ) ); + pFileMenu->addAction ( tr ( "&Load Mixer Channels Setup..." ), this, SLOT ( OnLoadChannelSetup() ) ); - pFileMenu->addAction ( tr ( "&Save Mixer Channels Setup..." ), this, - SLOT ( OnSaveChannelSetup() ) ); + pFileMenu->addAction ( tr ( "&Save Mixer Channels Setup..." ), this, SLOT ( OnSaveChannelSetup() ) ); pFileMenu->addSeparator(); - pFileMenu->addAction ( tr ( "E&xit" ), this, - SLOT ( close() ), QKeySequence ( Qt::CTRL + Qt::Key_Q ) ); - + pFileMenu->addAction ( tr ( "E&xit" ), this, SLOT ( close() ), QKeySequence ( Qt::CTRL + Qt::Key_Q ) ); // View menu -------------------------------------------------------------- QMenu* pViewMenu = new QMenu ( tr ( "&View" ), this ); - pViewMenu->addAction ( tr ( "&Connection Setup..." ), this, - SLOT ( OnOpenConnectionSetupDialog() ), QKeySequence ( Qt::CTRL + Qt::Key_C ) ); + pViewMenu->addAction ( tr ( "&Connection Setup..." ), this, SLOT ( OnOpenConnectionSetupDialog() ), QKeySequence ( Qt::CTRL + Qt::Key_C ) ); - pViewMenu->addAction ( tr ( "C&hat..." ), this, - SLOT ( OnOpenChatDialog() ), QKeySequence ( Qt::CTRL + Qt::Key_H ) ); + pViewMenu->addAction ( tr ( "C&hat..." ), this, SLOT ( OnOpenChatDialog() ), QKeySequence ( Qt::CTRL + Qt::Key_H ) ); - pViewMenu->addAction ( tr ( "My &Profile..." ), this, - SLOT ( OnOpenUserProfileSettings() ), QKeySequence ( Qt::CTRL + Qt::Key_P ) ); + pViewMenu->addAction ( tr ( "My &Profile..." ), this, SLOT ( OnOpenUserProfileSettings() ), QKeySequence ( Qt::CTRL + Qt::Key_P ) ); - pViewMenu->addAction ( tr ( "Audio/Network &Settings..." ), this, - SLOT ( OnOpenAudioNetSettings() ), QKeySequence ( Qt::CTRL + Qt::Key_S ) ); + pViewMenu->addAction ( tr ( "Audio/Network &Settings..." ), this, SLOT ( OnOpenAudioNetSettings() ), QKeySequence ( Qt::CTRL + Qt::Key_S ) ); - pViewMenu->addAction ( tr ( "A&dvanced Settings..." ), this, - SLOT ( OnOpenAdvancedSettings() ), QKeySequence ( Qt::CTRL + Qt::Key_D ) ); + pViewMenu->addAction ( tr ( "A&dvanced Settings..." ), this, SLOT ( OnOpenAdvancedSettings() ), QKeySequence ( Qt::CTRL + Qt::Key_D ) ); // optionally show analyzer console entry if ( bShowAnalyzerConsole ) { - pViewMenu->addAction ( tr ( "&Analyzer Console..." ), this, - SLOT ( OnOpenAnalyzerConsole() ) ); + pViewMenu->addAction ( tr ( "&Analyzer Console..." ), this, SLOT ( OnOpenAnalyzerConsole() ) ); } - // Edit menu -------------------------------------------------------------- QMenu* pEditMenu = new QMenu ( tr ( "&Edit" ), this ); - QAction* NoSortAction = pEditMenu->addAction ( tr ( "N&o User Sorting" ), this, - SLOT ( OnNoSortChannels() ), QKeySequence ( Qt::CTRL + Qt::Key_O ) ); + QAction* NoSortAction = + pEditMenu->addAction ( tr ( "N&o User Sorting" ), this, SLOT ( OnNoSortChannels() ), QKeySequence ( Qt::CTRL + Qt::Key_O ) ); - QAction* ByNameAction = pEditMenu->addAction ( tr ( "Sort Users by &Name" ), this, - SLOT ( OnSortChannelsByName() ), QKeySequence ( Qt::CTRL + Qt::Key_N ) ); + QAction* ByNameAction = + pEditMenu->addAction ( tr ( "Sort Users by &Name" ), this, SLOT ( OnSortChannelsByName() ), QKeySequence ( Qt::CTRL + Qt::Key_N ) ); - QAction* ByInstrAction = pEditMenu->addAction ( tr ( "Sort Users by &Instrument" ), this, - SLOT ( OnSortChannelsByInstrument() ), QKeySequence ( Qt::CTRL + Qt::Key_I ) ); + QAction* ByInstrAction = pEditMenu->addAction ( tr ( "Sort Users by &Instrument" ), + this, + SLOT ( OnSortChannelsByInstrument() ), + QKeySequence ( Qt::CTRL + Qt::Key_I ) ); - QAction* ByGroupAction = pEditMenu->addAction ( tr ( "Sort Users by &Group" ), this, - SLOT ( OnSortChannelsByGroupID() ), QKeySequence ( Qt::CTRL + Qt::Key_G ) ); + QAction* ByGroupAction = + pEditMenu->addAction ( tr ( "Sort Users by &Group" ), this, SLOT ( OnSortChannelsByGroupID() ), QKeySequence ( Qt::CTRL + Qt::Key_G ) ); - QAction* ByCityAction = pEditMenu->addAction ( tr ( "Sort Users by &City" ), this, - SLOT ( OnSortChannelsByCity() ), QKeySequence ( Qt::CTRL + Qt::Key_T ) ); + QAction* ByCityAction = + pEditMenu->addAction ( tr ( "Sort Users by &City" ), this, SLOT ( OnSortChannelsByCity() ), QKeySequence ( Qt::CTRL + Qt::Key_T ) ); // the sorting menu entries shall be checkable and exclusive QActionGroup* SortActionGroup = new QActionGroup ( this ); @@ -300,24 +310,34 @@ CClientDlg::CClientDlg ( CClient* pNCliP, // initialize sort type setting (i.e., recover stored setting) switch ( pSettings->eChannelSortType ) { - case ST_NO_SORT: NoSortAction->setChecked ( true ); break; - case ST_BY_NAME: ByNameAction->setChecked ( true ); break; - case ST_BY_INSTRUMENT: ByInstrAction->setChecked ( true ); break; - case ST_BY_GROUPID: ByGroupAction->setChecked ( true ); break; - case ST_BY_CITY: ByCityAction->setChecked ( true ); break; + case ST_NO_SORT: + NoSortAction->setChecked ( true ); + break; + case ST_BY_NAME: + ByNameAction->setChecked ( true ); + break; + case ST_BY_INSTRUMENT: + ByInstrAction->setChecked ( true ); + break; + case ST_BY_GROUPID: + ByGroupAction->setChecked ( true ); + break; + case ST_BY_CITY: + ByCityAction->setChecked ( true ); + break; } MainMixerBoard->SetFaderSorting ( pSettings->eChannelSortType ); pEditMenu->addSeparator(); - pEditMenu->addAction ( tr ( "Clear &All Stored Solo and Mute Settings" ), this, - SLOT ( OnClearAllStoredSoloMuteSettings() ) ); + pEditMenu->addAction ( tr ( "Clear &All Stored Solo and Mute Settings" ), this, SLOT ( OnClearAllStoredSoloMuteSettings() ) ); - pEditMenu->addAction ( tr ( "Set All Faders to New Client &Level" ), this, - SLOT ( OnSetAllFadersToNewClientLevel() ), QKeySequence ( Qt::CTRL + Qt::Key_L ) ); + pEditMenu->addAction ( tr ( "Set All Faders to New Client &Level" ), + this, + SLOT ( OnSetAllFadersToNewClientLevel() ), + QKeySequence ( Qt::CTRL + Qt::Key_L ) ); - pEditMenu->addAction ( tr ( "Auto-Adjust all &Faders" ), this, - SLOT ( OnAutoAdjustAllFaderLevels() ), QKeySequence ( Qt::CTRL + Qt::Key_F ) ); + pEditMenu->addAction ( tr ( "Auto-Adjust all &Faders" ), this, SLOT ( OnAutoAdjustAllFaderLevels() ), QKeySequence ( Qt::CTRL + Qt::Key_F ) ); // Main menu bar ----------------------------------------------------------- QMenuBar* pMenu = new QMenuBar ( this ); @@ -330,7 +350,6 @@ CClientDlg::CClientDlg ( CClient* pNCliP, // Now tell the layout about the menu layout()->setMenuBar ( pMenu ); - // Window positions -------------------------------------------------------- // main window if ( !pSettings->vecWindowPosMain.isEmpty() && !pSettings->vecWindowPosMain.isNull() ) @@ -346,7 +365,7 @@ CClientDlg::CClientDlg ( CClient* pNCliP, if ( pSettings->bWindowWasShownSettings ) { - ShowGeneralSettings( pSettings->iSettingsTab ); + ShowGeneralSettings ( pSettings->iSettingsTab ); } // chat window @@ -366,162 +385,119 @@ CClientDlg::CClientDlg ( CClient* pNCliP, ConnectDlg.restoreGeometry ( pSettings->vecWindowPosConnect ); } - // Connections ------------------------------------------------------------- // push buttons - QObject::connect ( butConnect, &QPushButton::clicked, - this, &CClientDlg::OnConnectDisconBut ); + QObject::connect ( butConnect, &QPushButton::clicked, this, &CClientDlg::OnConnectDisconBut ); // check boxes - QObject::connect ( chbSettings, &QCheckBox::stateChanged, - this, &CClientDlg::OnSettingsStateChanged ); + QObject::connect ( chbSettings, &QCheckBox::stateChanged, this, &CClientDlg::OnSettingsStateChanged ); - QObject::connect ( chbChat, &QCheckBox::stateChanged, - this, &CClientDlg::OnChatStateChanged ); + QObject::connect ( chbChat, &QCheckBox::stateChanged, this, &CClientDlg::OnChatStateChanged ); - QObject::connect ( chbLocalMute, &QCheckBox::stateChanged, - this, &CClientDlg::OnLocalMuteStateChanged ); + QObject::connect ( chbLocalMute, &QCheckBox::stateChanged, this, &CClientDlg::OnLocalMuteStateChanged ); // timers - QObject::connect ( &TimerSigMet, &QTimer::timeout, - this, &CClientDlg::OnTimerSigMet ); + QObject::connect ( &TimerSigMet, &QTimer::timeout, this, &CClientDlg::OnTimerSigMet ); - QObject::connect ( &TimerBuffersLED, &QTimer::timeout, - this, &CClientDlg::OnTimerBuffersLED ); + QObject::connect ( &TimerBuffersLED, &QTimer::timeout, this, &CClientDlg::OnTimerBuffersLED ); - QObject::connect ( &TimerStatus, &QTimer::timeout, - this, &CClientDlg::OnTimerStatus ); + QObject::connect ( &TimerStatus, &QTimer::timeout, this, &CClientDlg::OnTimerStatus ); - QObject::connect ( &TimerPing, &QTimer::timeout, - this, &CClientDlg::OnTimerPing ); + QObject::connect ( &TimerPing, &QTimer::timeout, this, &CClientDlg::OnTimerPing ); - QObject::connect ( &TimerCheckAudioDeviceOk, &QTimer::timeout, - this, &CClientDlg::OnTimerCheckAudioDeviceOk ); + QObject::connect ( &TimerCheckAudioDeviceOk, &QTimer::timeout, this, &CClientDlg::OnTimerCheckAudioDeviceOk ); - QObject::connect ( &TimerDetectFeedback, &QTimer::timeout, - this, &CClientDlg::OnTimerDetectFeedback ); + QObject::connect ( &TimerDetectFeedback, &QTimer::timeout, this, &CClientDlg::OnTimerDetectFeedback ); - QObject::connect ( sldAudioReverb, &QSlider::valueChanged, - this, &CClientDlg::OnAudioReverbValueChanged ); + QObject::connect ( sldAudioReverb, &QSlider::valueChanged, this, &CClientDlg::OnAudioReverbValueChanged ); // radio buttons - QObject::connect ( rbtReverbSelL, &QRadioButton::clicked, - this, &CClientDlg::OnReverbSelLClicked ); + QObject::connect ( rbtReverbSelL, &QRadioButton::clicked, this, &CClientDlg::OnReverbSelLClicked ); - QObject::connect ( rbtReverbSelR, &QRadioButton::clicked, - this, &CClientDlg::OnReverbSelRClicked ); + QObject::connect ( rbtReverbSelR, &QRadioButton::clicked, this, &CClientDlg::OnReverbSelRClicked ); // other - QObject::connect ( pClient, &CClient::ConClientListMesReceived, - this, &CClientDlg::OnConClientListMesReceived ); + QObject::connect ( pClient, &CClient::ConClientListMesReceived, this, &CClientDlg::OnConClientListMesReceived ); - QObject::connect ( pClient, &CClient::Disconnected, - this, &CClientDlg::OnDisconnected ); + QObject::connect ( pClient, &CClient::Disconnected, this, &CClientDlg::OnDisconnected ); - QObject::connect ( pClient, &CClient::ChatTextReceived, - this, &CClientDlg::OnChatTextReceived ); + QObject::connect ( pClient, &CClient::ChatTextReceived, this, &CClientDlg::OnChatTextReceived ); - QObject::connect ( pClient, &CClient::ClientIDReceived, - this, &CClientDlg::OnClientIDReceived ); + QObject::connect ( pClient, &CClient::ClientIDReceived, this, &CClientDlg::OnClientIDReceived ); - QObject::connect ( pClient, &CClient::MuteStateHasChangedReceived, - this, &CClientDlg::OnMuteStateHasChangedReceived ); + QObject::connect ( pClient, &CClient::MuteStateHasChangedReceived, this, &CClientDlg::OnMuteStateHasChangedReceived ); - QObject::connect ( pClient, &CClient::RecorderStateReceived, - this, &CClientDlg::OnRecorderStateReceived ); + QObject::connect ( pClient, &CClient::RecorderStateReceived, this, &CClientDlg::OnRecorderStateReceived ); // This connection is a special case. On receiving a licence required message via the // protocol, a modal licence dialog is opened. Since this blocks the thread, we need // a queued connection to make sure the core protocol mechanism is not blocked, too. qRegisterMetaType ( "ELicenceType" ); - QObject::connect ( pClient, &CClient::LicenceRequired, - this, &CClientDlg::OnLicenceRequired, Qt::QueuedConnection ); + QObject::connect ( pClient, &CClient::LicenceRequired, this, &CClientDlg::OnLicenceRequired, Qt::QueuedConnection ); - QObject::connect ( pClient, &CClient::PingTimeReceived, - this, &CClientDlg::OnPingTimeResult ); + QObject::connect ( pClient, &CClient::PingTimeReceived, this, &CClientDlg::OnPingTimeResult ); - QObject::connect ( pClient, &CClient::CLServerListReceived, - this, &CClientDlg::OnCLServerListReceived ); + QObject::connect ( pClient, &CClient::CLServerListReceived, this, &CClientDlg::OnCLServerListReceived ); - QObject::connect ( pClient, &CClient::CLRedServerListReceived, - this, &CClientDlg::OnCLRedServerListReceived ); + QObject::connect ( pClient, &CClient::CLRedServerListReceived, this, &CClientDlg::OnCLRedServerListReceived ); - QObject::connect ( pClient, &CClient::CLConnClientsListMesReceived, - this, &CClientDlg::OnCLConnClientsListMesReceived ); + QObject::connect ( pClient, &CClient::CLConnClientsListMesReceived, this, &CClientDlg::OnCLConnClientsListMesReceived ); - QObject::connect ( pClient, &CClient::CLPingTimeWithNumClientsReceived, - this, &CClientDlg::OnCLPingTimeWithNumClientsReceived ); + QObject::connect ( pClient, &CClient::CLPingTimeWithNumClientsReceived, this, &CClientDlg::OnCLPingTimeWithNumClientsReceived ); - QObject::connect ( pClient, &CClient::ControllerInFaderLevel, - this, &CClientDlg::OnControllerInFaderLevel ); + QObject::connect ( pClient, &CClient::ControllerInFaderLevel, this, &CClientDlg::OnControllerInFaderLevel ); - QObject::connect ( pClient, &CClient::ControllerInPanValue, - this, &CClientDlg::OnControllerInPanValue ); + QObject::connect ( pClient, &CClient::ControllerInPanValue, this, &CClientDlg::OnControllerInPanValue ); - QObject::connect ( pClient, &CClient::ControllerInFaderIsSolo, - this, &CClientDlg::OnControllerInFaderIsSolo ); + QObject::connect ( pClient, &CClient::ControllerInFaderIsSolo, this, &CClientDlg::OnControllerInFaderIsSolo ); - QObject::connect ( pClient, &CClient::ControllerInFaderIsMute, - this, &CClientDlg::OnControllerInFaderIsMute ); + QObject::connect ( pClient, &CClient::ControllerInFaderIsMute, this, &CClientDlg::OnControllerInFaderIsMute ); - QObject::connect ( pClient, &CClient::CLChannelLevelListReceived, - this, &CClientDlg::OnCLChannelLevelListReceived ); + QObject::connect ( pClient, &CClient::CLChannelLevelListReceived, this, &CClientDlg::OnCLChannelLevelListReceived ); - QObject::connect ( pClient, &CClient::VersionAndOSReceived, - this, &CClientDlg::OnVersionAndOSReceived ); + QObject::connect ( pClient, &CClient::VersionAndOSReceived, this, &CClientDlg::OnVersionAndOSReceived ); - QObject::connect ( pClient, &CClient::CLVersionAndOSReceived, - this, &CClientDlg::OnCLVersionAndOSReceived ); + QObject::connect ( pClient, &CClient::CLVersionAndOSReceived, this, &CClientDlg::OnCLVersionAndOSReceived ); - QObject::connect ( pClient, &CClient::SoundDeviceChanged, - this, &CClientDlg::OnSoundDeviceChanged ); + QObject::connect ( pClient, &CClient::SoundDeviceChanged, this, &CClientDlg::OnSoundDeviceChanged ); - QObject::connect ( &ClientSettingsDlg, &CClientSettingsDlg::GUIDesignChanged, - this, &CClientDlg::OnGUIDesignChanged ); + QObject::connect ( &ClientSettingsDlg, &CClientSettingsDlg::GUIDesignChanged, this, &CClientDlg::OnGUIDesignChanged ); - QObject::connect ( &ClientSettingsDlg, &CClientSettingsDlg::AudioChannelsChanged, - this, &CClientDlg::OnAudioChannelsChanged ); + QObject::connect ( &ClientSettingsDlg, &CClientSettingsDlg::AudioChannelsChanged, this, &CClientDlg::OnAudioChannelsChanged ); - QObject::connect ( &ClientSettingsDlg, &CClientSettingsDlg::CustomCentralServerAddrChanged, - &ConnectDlg, &CConnectDlg::OnCustomCentralServerAddrChanged ); + QObject::connect ( &ClientSettingsDlg, + &CClientSettingsDlg::CustomCentralServerAddrChanged, + &ConnectDlg, + &CConnectDlg::OnCustomCentralServerAddrChanged ); - QObject::connect ( &ClientSettingsDlg, &CClientSettingsDlg::NumMixerPanelRowsChanged, - this, &CClientDlg::OnNumMixerPanelRowsChanged ); + QObject::connect ( &ClientSettingsDlg, &CClientSettingsDlg::NumMixerPanelRowsChanged, this, &CClientDlg::OnNumMixerPanelRowsChanged ); - QObject::connect ( this, &CClientDlg::SendTabChange, - &ClientSettingsDlg, &CClientSettingsDlg::OnMakeTabChange ); + QObject::connect ( this, &CClientDlg::SendTabChange, &ClientSettingsDlg, &CClientSettingsDlg::OnMakeTabChange ); - QObject::connect ( MainMixerBoard, &CAudioMixerBoard::ChangeChanGain, - this, &CClientDlg::OnChangeChanGain ); + QObject::connect ( MainMixerBoard, &CAudioMixerBoard::ChangeChanGain, this, &CClientDlg::OnChangeChanGain ); - QObject::connect ( MainMixerBoard, &CAudioMixerBoard::ChangeChanPan, - this, &CClientDlg::OnChangeChanPan ); + QObject::connect ( MainMixerBoard, &CAudioMixerBoard::ChangeChanPan, this, &CClientDlg::OnChangeChanPan ); - QObject::connect ( MainMixerBoard, &CAudioMixerBoard::NumClientsChanged, - this, &CClientDlg::OnNumClientsChanged ); + QObject::connect ( MainMixerBoard, &CAudioMixerBoard::NumClientsChanged, this, &CClientDlg::OnNumClientsChanged ); - QObject::connect ( &ChatDlg, &CChatDlg::NewLocalInputText, - this, &CClientDlg::OnNewLocalInputText ); + QObject::connect ( &ChatDlg, &CChatDlg::NewLocalInputText, this, &CClientDlg::OnNewLocalInputText ); - QObject::connect ( &ConnectDlg, &CConnectDlg::ReqServerListQuery, - this, &CClientDlg::OnReqServerListQuery ); + QObject::connect ( &ConnectDlg, &CConnectDlg::ReqServerListQuery, this, &CClientDlg::OnReqServerListQuery ); // note that this connection must be a queued connection, otherwise the server list ping // times are not accurate and the client list may not be retrieved for all servers listed // (it seems the sendto() function needs to be called from different threads to fire the // packet immediately and do not collect packets before transmitting) - QObject::connect ( &ConnectDlg, &CConnectDlg::CreateCLServerListPingMes, - this, &CClientDlg::OnCreateCLServerListPingMes, Qt::QueuedConnection ); - - QObject::connect ( &ConnectDlg, &CConnectDlg::CreateCLServerListReqVerAndOSMes, - this, &CClientDlg::OnCreateCLServerListReqVerAndOSMes ); + QObject::connect ( &ConnectDlg, &CConnectDlg::CreateCLServerListPingMes, this, &CClientDlg::OnCreateCLServerListPingMes, Qt::QueuedConnection ); - QObject::connect ( &ConnectDlg, &CConnectDlg::CreateCLServerListReqConnClientsListMes, - this, &CClientDlg::OnCreateCLServerListReqConnClientsListMes ); + QObject::connect ( &ConnectDlg, &CConnectDlg::CreateCLServerListReqVerAndOSMes, this, &CClientDlg::OnCreateCLServerListReqVerAndOSMes ); - QObject::connect ( &ConnectDlg, &CConnectDlg::accepted, - this, &CClientDlg::OnConnectDlgAccepted ); + QObject::connect ( &ConnectDlg, + &CConnectDlg::CreateCLServerListReqConnClientsListMes, + this, + &CClientDlg::OnCreateCLServerListReqConnClientsListMes ); + QObject::connect ( &ConnectDlg, &CConnectDlg::accepted, this, &CClientDlg::OnConnectDlgAccepted ); // Initializations which have to be done after the signals are connected --- // start timer for status bar @@ -594,8 +570,7 @@ void CClientDlg::closeEvent ( QCloseEvent* Event ) Event->accept(); } -void CClientDlg::ManageDragNDrop ( QDropEvent* Event, - const bool bCheckAccept ) +void CClientDlg::ManageDragNDrop ( QDropEvent* Event, const bool bCheckAccept ) { // we only want to use drag'n'drop with file URLs QListIterator UrlIterator ( Event->mimeData()->urls() ); @@ -666,8 +641,7 @@ void CClientDlg::OnConnectDlgAccepted() // only store new host address in our data base if the address is // not empty and it was not a server list item (only the addresses // typed in manually are stored by definition) - if ( !strSelectedAddress.isEmpty() && - !ConnectDlg.GetServerListItemWasChosen() ) + if ( !strSelectedAddress.isEmpty() && !ConnectDlg.GetServerListItemWasChosen() ) { // store new address at the top of the list, if the list was already // full, the last element is thrown out @@ -722,7 +696,7 @@ void CClientDlg::OnConnectDisconBut() if ( pClient->IsRunning() ) { Disconnect(); - SetMixerBoardDeco( RS_UNDEFINED, pClient->GetGUIDesign() ); + SetMixerBoardDeco ( RS_UNDEFINED, pClient->GetGUIDesign() ); } else { @@ -742,10 +716,7 @@ void CClientDlg::OnClearAllStoredSoloMuteSettings() void CClientDlg::OnLoadChannelSetup() { - QString strFileName = QFileDialog::getOpenFileName ( this, - tr ( "Select Channel Setup File" ), - "", - QString ( "*." ) + MIX_SETTINGS_FILE_SUFFIX ); + QString strFileName = QFileDialog::getOpenFileName ( this, tr ( "Select Channel Setup File" ), "", QString ( "*." ) + MIX_SETTINGS_FILE_SUFFIX ); if ( !strFileName.isEmpty() ) { @@ -757,10 +728,7 @@ void CClientDlg::OnLoadChannelSetup() void CClientDlg::OnSaveChannelSetup() { - QString strFileName = QFileDialog::getSaveFileName ( this, - tr ( "Select Channel Setup File" ), - "", - QString ( "*." ) + MIX_SETTINGS_FILE_SUFFIX ); + QString strFileName = QFileDialog::getSaveFileName ( this, tr ( "Select Channel Setup File" ), "", QString ( "*." ) + MIX_SETTINGS_FILE_SUFFIX ); if ( !strFileName.isEmpty() ) { @@ -771,11 +739,10 @@ void CClientDlg::OnSaveChannelSetup() } } -void CClientDlg::OnVersionAndOSReceived ( COSUtil::EOpSystemType , - QString strVersion ) +void CClientDlg::OnVersionAndOSReceived ( COSUtil::EOpSystemType, QString strVersion ) { // check if Pan is supported by the server (minimum version is 3.5.4) -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) if ( QVersionNumber::compare ( QVersionNumber::fromString ( strVersion ), QVersionNumber ( 3, 5, 4 ) ) >= 0 ) { MainMixerBoard->SetPanIsSupported(); @@ -783,16 +750,14 @@ void CClientDlg::OnVersionAndOSReceived ( COSUtil::EOpSystemType , #endif } -void CClientDlg::OnCLVersionAndOSReceived ( CHostAddress , - COSUtil::EOpSystemType , - QString strVersion ) +void CClientDlg::OnCLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString strVersion ) { // update check -#if ( QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) ) && !defined ( DISABLE_VERSION_CHECK ) - int mySuffixIndex; +#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) ) && !defined( DISABLE_VERSION_CHECK ) + int mySuffixIndex; QVersionNumber myVersion = QVersionNumber::fromString ( VERSION, &mySuffixIndex ); - int serverSuffixIndex; + int serverSuffixIndex; QVersionNumber serverVersion = QVersionNumber::fromString ( strVersion, &serverSuffixIndex ); // only compare if the server version has no suffix (such as dev or beta) @@ -865,20 +830,11 @@ void CClientDlg::OnNumClientsChanged ( int iNewNumClients ) SetMyWindowTitle ( iNewNumClients ); } -void CClientDlg::OnOpenAudioNetSettings() -{ - ShowGeneralSettings ( SETTING_TAB_AUDIONET ); -} +void CClientDlg::OnOpenAudioNetSettings() { ShowGeneralSettings ( SETTING_TAB_AUDIONET ); } -void CClientDlg::OnOpenAdvancedSettings() -{ - ShowGeneralSettings ( SETTING_TAB_ADVANCED ); -} +void CClientDlg::OnOpenAdvancedSettings() { ShowGeneralSettings ( SETTING_TAB_ADVANCED ); } -void CClientDlg::OnOpenUserProfileSettings() -{ - ShowGeneralSettings ( SETTING_TAB_USER ); -} +void CClientDlg::OnOpenUserProfileSettings() { ShowGeneralSettings ( SETTING_TAB_USER ); } void CClientDlg::SetMyWindowTitle ( const int iNumClients ) { @@ -924,11 +880,11 @@ void CClientDlg::SetMyWindowTitle ( const int iNumClients ) setWindowTitle ( strWinTitle ); -#if defined ( Q_OS_MACX ) +#if defined( Q_OS_MACX ) // for MacOS only we show the number of connected clients as a // badge label text if more than one user is connected // (only available in Qt5.2) -# if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) +# if QT_VERSION >= QT_VERSION_CHECK( 5, 2, 0 ) if ( iNumClients > 1 ) { // show the number of connected clients @@ -939,7 +895,7 @@ void CClientDlg::SetMyWindowTitle ( const int iNumClients ) // clear the text (apply an empty string) QtMac::setBadgeLabelText ( "" ); } -# endif +# endif #endif } @@ -948,19 +904,19 @@ void CClientDlg::ShowConnectionSetupDialog() // show connect dialog bConnectDlgWasShown = true; ConnectDlg.show(); - ConnectDlg.setWindowTitle ( MakeClientNameTitle ( tr ( "Connect" ) , pClient->strClientName ) ); + ConnectDlg.setWindowTitle ( MakeClientNameTitle ( tr ( "Connect" ), pClient->strClientName ) ); // make sure dialog is upfront and has focus ConnectDlg.raise(); ConnectDlg.activateWindow(); } -void CClientDlg::ShowGeneralSettings( int iTab ) +void CClientDlg::ShowGeneralSettings ( int iTab ) { // open general settings dialog emit SendTabChange ( iTab ); ClientSettingsDlg.show(); - ClientSettingsDlg.setWindowTitle ( MakeClientNameTitle ( tr ( "Settings" ) , pClient->strClientName ) ); + ClientSettingsDlg.setWindowTitle ( MakeClientNameTitle ( tr ( "Settings" ), pClient->strClientName ) ); // make sure dialog is upfront and has focus ClientSettingsDlg.raise(); @@ -970,7 +926,7 @@ void CClientDlg::ShowGeneralSettings( int iTab ) void CClientDlg::ShowChatWindow ( const bool bForceRaise ) { ChatDlg.show(); - ChatDlg.setWindowTitle ( MakeClientNameTitle ( tr ( "Chat" ) , pClient->strClientName ) ); + ChatDlg.setWindowTitle ( MakeClientNameTitle ( tr ( "Chat" ), pClient->strClientName ) ); if ( bForceRaise ) { @@ -997,7 +953,7 @@ void CClientDlg::OnSettingsStateChanged ( int value ) { if ( value == Qt::Checked ) { - ShowGeneralSettings( SETTING_TAB_AUDIONET ); + ShowGeneralSettings ( SETTING_TAB_AUDIONET ); } else { @@ -1039,8 +995,7 @@ void CClientDlg::OnTimerSigMet() lbrInputLevelR->SetValue ( pClient->GetLevelForMeterdBRight() ); if ( bDetectFeedback && - ( pClient->GetLevelForMeterdBLeft() > NUM_STEPS_LED_BAR - 0.5 || - pClient->GetLevelForMeterdBRight() > NUM_STEPS_LED_BAR - 0.5 ) ) + ( pClient->GetLevelForMeterdBLeft() > NUM_STEPS_LED_BAR - 0.5 || pClient->GetLevelForMeterdBRight() > NUM_STEPS_LED_BAR - 0.5 ) ) { // mute locally and mute channel chbLocalMute->setCheckState ( Qt::Checked ); @@ -1048,19 +1003,17 @@ void CClientDlg::OnTimerSigMet() // show message box about feedback issue QCheckBox* chb = new QCheckBox ( tr ( "Enable feedback detection" ) ); - chb->setCheckState ( pSettings->bEnableFeedbackDetection ? - Qt::Checked : Qt::Unchecked ); + chb->setCheckState ( pSettings->bEnableFeedbackDetection ? Qt::Checked : Qt::Unchecked ); QMessageBox msgbox; msgbox.setText ( tr ( "Audio feedback or loud signal detected.\n\n" - "We muted your channel and activated 'Mute Myself'. Please solve " - "the feedback issue first and unmute yourself afterwards." ) ); + "We muted your channel and activated 'Mute Myself'. Please solve " + "the feedback issue first and unmute yourself afterwards." ) ); msgbox.setIcon ( QMessageBox::Icon::Warning ); msgbox.addButton ( QMessageBox::Ok ); msgbox.setDefaultButton ( QMessageBox::Ok ); msgbox.setCheckBox ( chb ); - QObject::connect ( chb, &QCheckBox::stateChanged, - this, &CClientDlg::OnFeedbackDetectionChanged ); + QObject::connect ( chb, &QCheckBox::stateChanged, this, &CClientDlg::OnFeedbackDetectionChanged ); msgbox.exec(); } @@ -1120,9 +1073,7 @@ void CClientDlg::OnPingTimeResult ( int iPingTime ) if ( ClientSettingsDlg.isVisible() ) { // set ping time result to general settings dialog - ClientSettingsDlg.SetPingTimeResult ( iPingTime, - iOverallDelayMs, - eOverallDelayLEDColor ); + ClientSettingsDlg.SetPingTimeResult ( iPingTime, iOverallDelayMs, eOverallDelayLEDColor ); } // update delay LED on the main window @@ -1137,15 +1088,14 @@ void CClientDlg::OnTimerCheckAudioDeviceOk() // it is trying to connect the server which does not help to solve the problem (#129)) if ( !pClient->IsCallbackEntered() ) { - QMessageBox::warning ( this, APP_NAME, tr ( "Your sound card is not working correctly. " - "Please open the settings dialog and check the device selection and the driver settings." ) ); + QMessageBox::warning ( this, + APP_NAME, + tr ( "Your sound card is not working correctly. " + "Please open the settings dialog and check the device selection and the driver settings." ) ); } } -void CClientDlg::OnTimerDetectFeedback() -{ - bDetectFeedback = false; -} +void CClientDlg::OnTimerDetectFeedback() { bDetectFeedback = false; } void CClientDlg::OnSoundDeviceChanged ( QString strError ) { @@ -1177,18 +1127,13 @@ void CClientDlg::OnSoundDeviceChanged ( QString strError ) ClientSettingsDlg.UpdateSoundDeviceChannelSelectionFrame(); } -void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, - int iPingTime, - int iNumClients ) +void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, int iPingTime, int iNumClients ) { // update connection dialog server list - ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr, - iPingTime, - iNumClients ); + ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr, iPingTime, iNumClients ); } -void CClientDlg::Connect ( const QString& strSelectedAddress, - const QString& strMixerBoardLabel ) +void CClientDlg::Connect ( const QString& strSelectedAddress, const QString& strMixerBoardLabel ) { // set address and check if address is valid if ( pClient->SetServerAddr ( strSelectedAddress ) ) @@ -1222,9 +1167,9 @@ void CClientDlg::Connect ( const QString& strSelectedAddress, MainMixerBoard->SetServerName ( strMixerBoardLabel ); // start timer for level meter bar and ping time measurement - TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS ); - TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS ); - TimerPing.start ( PING_UPDATE_TIME_MS ); + TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS ); + TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS ); + TimerPing.start ( PING_UPDATE_TIME_MS ); TimerCheckAudioDeviceOk.start ( CHECK_AUDIO_DEV_OK_TIME_MS ); // is single shot timer // audio feedback detection @@ -1270,13 +1215,11 @@ void CClientDlg::Disconnect() TimerDetectFeedback.stop(); bDetectFeedback = false; - -// clang-format off + // clang-format off // TODO is this still required??? // immediately update status bar OnTimerStatus(); -// clang-format on - + // clang-format on // reset LEDs ledBuffers->Reset(); @@ -1293,26 +1236,26 @@ void CClientDlg::UpdateDisplay() if ( chbSettings->isChecked() && !ClientSettingsDlg.isVisible() ) { chbSettings->blockSignals ( true ); - chbSettings->setChecked ( false ); + chbSettings->setChecked ( false ); chbSettings->blockSignals ( false ); } if ( !chbSettings->isChecked() && ClientSettingsDlg.isVisible() ) { chbSettings->blockSignals ( true ); - chbSettings->setChecked ( true ); + chbSettings->setChecked ( true ); chbSettings->blockSignals ( false ); } if ( chbChat->isChecked() && !ChatDlg.isVisible() ) { chbChat->blockSignals ( true ); - chbChat->setChecked ( false ); + chbChat->setChecked ( false ); chbChat->blockSignals ( false ); } if ( !chbChat->isChecked() && ChatDlg.isVisible() ) { chbChat->blockSignals ( true ); - chbChat->setChecked ( true ); + chbChat->setChecked ( true ); chbChat->blockSignals ( false ); } } @@ -1352,20 +1295,20 @@ void CClientDlg::SetGUIDesign ( const EGUIDesign eNewDesign ) " font: bold; }" ); #ifdef _WIN32 -// Workaround QT-Windows problem: This should not be necessary since in the -// background frame the style sheet for QRadioButton was already set. But it -// seems that it is only applied if the style was set to default and then back -// to GD_ORIGINAL. This seems to be a QT related issue... -rbtReverbSelL->setStyleSheet ( "color: rgb(220, 220, 220);" - "font: bold;" ); -rbtReverbSelR->setStyleSheet ( "color: rgb(220, 220, 220);" - "font: bold;" ); + // Workaround QT-Windows problem: This should not be necessary since in the + // background frame the style sheet for QRadioButton was already set. But it + // seems that it is only applied if the style was set to default and then back + // to GD_ORIGINAL. This seems to be a QT related issue... + rbtReverbSelL->setStyleSheet ( "color: rgb(220, 220, 220);" + "font: bold;" ); + rbtReverbSelR->setStyleSheet ( "color: rgb(220, 220, 220);" + "font: bold;" ); #endif lbrInputLevelL->SetLevelMeterType ( CLevelMeter::MT_LED ); lbrInputLevelR->SetLevelMeterType ( CLevelMeter::MT_LED ); - ledBuffers->SetType ( CMultiColorLED::MT_LED ); - ledDelay->SetType ( CMultiColorLED::MT_LED ); + ledBuffers->SetType ( CMultiColorLED::MT_LED ); + ledDelay->SetType ( CMultiColorLED::MT_LED ); break; default: @@ -1373,15 +1316,15 @@ rbtReverbSelR->setStyleSheet ( "color: rgb(220, 220, 220);" backgroundFrame->setStyleSheet ( "" ); #ifdef _WIN32 -// Workaround QT-Windows problem: See above description -rbtReverbSelL->setStyleSheet ( "" ); -rbtReverbSelR->setStyleSheet ( "" ); + // Workaround QT-Windows problem: See above description + rbtReverbSelL->setStyleSheet ( "" ); + rbtReverbSelR->setStyleSheet ( "" ); #endif lbrInputLevelL->SetLevelMeterType ( CLevelMeter::MT_BAR ); lbrInputLevelR->SetLevelMeterType ( CLevelMeter::MT_BAR ); - ledBuffers->SetType ( CMultiColorLED::MT_INDICATOR ); - ledDelay->SetType ( CMultiColorLED::MT_INDICATOR ); + ledBuffers->SetType ( CMultiColorLED::MT_INDICATOR ); + ledDelay->SetType ( CMultiColorLED::MT_INDICATOR ); break; } @@ -1389,7 +1332,7 @@ rbtReverbSelR->setStyleSheet ( "" ); MainMixerBoard->SetGUIDesign ( eNewDesign ); } -void CClientDlg::OnRecorderStateReceived ( const ERecorderState newRecorderState ) +void CClientDlg::OnRecorderStateReceived ( const ERecorderState newRecorderState ) { MainMixerBoard->SetRecorderState ( newRecorderState ); SetMixerBoardDeco ( newRecorderState, pClient->GetGUIDesign() ); @@ -1401,40 +1344,37 @@ void CClientDlg::OnGUIDesignChanged() SetMixerBoardDeco ( MainMixerBoard->GetRecorderState(), pClient->GetGUIDesign() ); } -void CClientDlg::SetMixerBoardDeco( const ERecorderState newRecorderState, const EGUIDesign eNewDesign ) +void CClientDlg::SetMixerBoardDeco ( const ERecorderState newRecorderState, const EGUIDesign eNewDesign ) { // return if no change if ( ( newRecorderState == eLastRecorderState ) && ( eNewDesign == eLastDesign ) ) return; eLastRecorderState = newRecorderState; - eLastDesign = eNewDesign; + eLastDesign = eNewDesign; if ( newRecorderState == RS_RECORDING ) { - MainMixerBoard->setStyleSheet ( - "QGroupBox::title { subcontrol-origin: margin; " - " subcontrol-position: left top;" - " left: 7px;" - " color: rgb(255,255,255);" - " background-color: rgb(255,0,0); }" ); + MainMixerBoard->setStyleSheet ( "QGroupBox::title { subcontrol-origin: margin; " + " subcontrol-position: left top;" + " left: 7px;" + " color: rgb(255,255,255);" + " background-color: rgb(255,0,0); }" ); } else { if ( eNewDesign == GD_ORIGINAL ) { - MainMixerBoard->setStyleSheet ( - "QGroupBox::title { subcontrol-origin: margin;" - " subcontrol-position: left top;" - " left: 7px;" - " color: rgb(220,220,220); }" ); + MainMixerBoard->setStyleSheet ( "QGroupBox::title { subcontrol-origin: margin;" + " subcontrol-position: left top;" + " left: 7px;" + " color: rgb(220,220,220); }" ); } else { - MainMixerBoard->setStyleSheet ( - "QGroupBox::title { subcontrol-origin: margin;" - " subcontrol-position: left top;" - " left: 7px;" - " color: rgb(0,0,0); }" ); + MainMixerBoard->setStyleSheet ( "QGroupBox::title { subcontrol-origin: margin;" + " subcontrol-position: left top;" + " left: 7px;" + " color: rgb(0,0,0); }" ); } } } diff --git a/src/clientdlg.h b/src/clientdlg.h old mode 100755 new mode 100644 index 3d534392f0..479f07c072 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -37,8 +37,8 @@ #include #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) -# include +#if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) +# include #endif #include "global.h" #include "util.h" @@ -51,24 +51,22 @@ #include "connectdlg.h" #include "analyzerconsole.h" #include "ui_clientdlgbase.h" -#if defined ( __APPLE__ ) || defined ( __MACOSX ) -# if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) -# include -# endif +#if defined( __APPLE__ ) || defined( __MACOSX ) +# if QT_VERSION >= QT_VERSION_CHECK( 5, 2, 0 ) +# include +# endif #endif - /* Definitions ****************************************************************/ // update time for GUI controls -#define LEVELMETER_UPDATE_TIME_MS 100 // ms -#define BUFFER_LED_UPDATE_TIME_MS 300 // ms -#define LED_BAR_UPDATE_TIME_MS 1000 // ms -#define CHECK_AUDIO_DEV_OK_TIME_MS 5000 // ms -#define DETECT_FEEDBACK_TIME_MS 3000 // ms +#define LEVELMETER_UPDATE_TIME_MS 100 // ms +#define BUFFER_LED_UPDATE_TIME_MS 300 // ms +#define LED_BAR_UPDATE_TIME_MS 1000 // ms +#define CHECK_AUDIO_DEV_OK_TIME_MS 5000 // ms +#define DETECT_FEEDBACK_TIME_MS 3000 // ms // number of ping times > upper bound until error message is shown -#define NUM_HIGH_PINGS_UNTIL_ERROR 5 - +#define NUM_HIGH_PINGS_UNTIL_ERROR 5 /* Classes ********************************************************************/ class CClientDlg : public CBaseDlg, private Ui_CClientDlgBase @@ -86,40 +84,38 @@ class CClientDlg : public CBaseDlg, private Ui_CClientDlgBase QWidget* parent = nullptr ); protected: - void SetGUIDesign ( const EGUIDesign eNewDesign ); - void SetMyWindowTitle ( const int iNumClients ); - void ShowConnectionSetupDialog(); - void ShowGeneralSettings( int iTab ); - void ShowChatWindow ( const bool bForceRaise = true ); - void ShowAnalyzerConsole(); - void UpdateAudioFaderSlider(); - void UpdateRevSelection(); - void Connect ( const QString& strSelectedAddress, - const QString& strMixerBoardLabel ); - void Disconnect(); - void ManageDragNDrop ( QDropEvent* Event, - const bool bCheckAccept ); - - CClient* pClient; - CClientSettings* pSettings; - - bool bConnected; - bool bConnectDlgWasShown; - bool bMIDICtrlUsed; - bool bDetectFeedback; - ERecorderState eLastRecorderState; - EGUIDesign eLastDesign; - QTimer TimerSigMet; - QTimer TimerBuffersLED; - QTimer TimerStatus; - QTimer TimerPing; - QTimer TimerCheckAudioDeviceOk; - QTimer TimerDetectFeedback; - - virtual void closeEvent ( QCloseEvent* Event ); - virtual void dragEnterEvent ( QDragEnterEvent* Event ) { ManageDragNDrop ( Event, true ); } - virtual void dropEvent ( QDropEvent* Event ) { ManageDragNDrop ( Event, false ); } - void UpdateDisplay(); + void SetGUIDesign ( const EGUIDesign eNewDesign ); + void SetMyWindowTitle ( const int iNumClients ); + void ShowConnectionSetupDialog(); + void ShowGeneralSettings ( int iTab ); + void ShowChatWindow ( const bool bForceRaise = true ); + void ShowAnalyzerConsole(); + void UpdateAudioFaderSlider(); + void UpdateRevSelection(); + void Connect ( const QString& strSelectedAddress, const QString& strMixerBoardLabel ); + void Disconnect(); + void ManageDragNDrop ( QDropEvent* Event, const bool bCheckAccept ); + + CClient* pClient; + CClientSettings* pSettings; + + bool bConnected; + bool bConnectDlgWasShown; + bool bMIDICtrlUsed; + bool bDetectFeedback; + ERecorderState eLastRecorderState; + EGUIDesign eLastDesign; + QTimer TimerSigMet; + QTimer TimerBuffersLED; + QTimer TimerStatus; + QTimer TimerPing; + QTimer TimerCheckAudioDeviceOk; + QTimer TimerDetectFeedback; + + virtual void closeEvent ( QCloseEvent* Event ); + virtual void dragEnterEvent ( QDragEnterEvent* Event ) { ManageDragNDrop ( Event, true ); } + virtual void dropEvent ( QDropEvent* Event ) { ManageDragNDrop ( Event, false ); } + void UpdateDisplay(); CClientSettingsDlg ClientSettingsDlg; CChatDlg ChatDlg; @@ -137,32 +133,19 @@ public slots: void OnTimerPing(); void OnPingTimeResult ( int iPingTime ); - void OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, - int iPingTime, - int iNumClients ); + void OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, int iPingTime, int iNumClients ); - void OnControllerInFaderLevel ( const int iChannelIdx, - const int iValue ) { MainMixerBoard->SetFaderLevel ( iChannelIdx, - iValue ); } + void OnControllerInFaderLevel ( const int iChannelIdx, const int iValue ) { MainMixerBoard->SetFaderLevel ( iChannelIdx, iValue ); } - void OnControllerInPanValue ( const int iChannelIdx, - const int iValue ) { MainMixerBoard->SetPanValue ( iChannelIdx, - iValue ); } + void OnControllerInPanValue ( const int iChannelIdx, const int iValue ) { MainMixerBoard->SetPanValue ( iChannelIdx, iValue ); } - void OnControllerInFaderIsSolo ( const int iChannelIdx, - const bool bIsSolo ) { MainMixerBoard->SetFaderIsSolo ( iChannelIdx, - bIsSolo ); } + void OnControllerInFaderIsSolo ( const int iChannelIdx, const bool bIsSolo ) { MainMixerBoard->SetFaderIsSolo ( iChannelIdx, bIsSolo ); } - void OnControllerInFaderIsMute ( const int iChannelIdx, - const bool bIsMute ) { MainMixerBoard->SetFaderIsMute ( iChannelIdx, - bIsMute ); } + void OnControllerInFaderIsMute ( const int iChannelIdx, const bool bIsMute ) { MainMixerBoard->SetFaderIsMute ( iChannelIdx, bIsMute ); } - void OnVersionAndOSReceived ( COSUtil::EOpSystemType , - QString strVersion ); + void OnVersionAndOSReceived ( COSUtil::EOpSystemType, QString strVersion ); - void OnCLVersionAndOSReceived ( CHostAddress , - COSUtil::EOpSystemType , - QString strVersion ); + void OnCLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString strVersion ); void OnLoadChannelSetup(); void OnSaveChannelSetup(); @@ -172,11 +155,11 @@ public slots: void OnOpenAdvancedSettings(); void OnOpenChatDialog() { ShowChatWindow(); } void OnOpenAnalyzerConsole() { ShowAnalyzerConsole(); } - void OnNoSortChannels() { MainMixerBoard->SetFaderSorting ( ST_NO_SORT ); } - void OnSortChannelsByName() { MainMixerBoard->SetFaderSorting ( ST_BY_NAME ); } + void OnNoSortChannels() { MainMixerBoard->SetFaderSorting ( ST_NO_SORT ); } + void OnSortChannelsByName() { MainMixerBoard->SetFaderSorting ( ST_BY_NAME ); } void OnSortChannelsByInstrument() { MainMixerBoard->SetFaderSorting ( ST_BY_INSTRUMENT ); } - void OnSortChannelsByGroupID() { MainMixerBoard->SetFaderSorting ( ST_BY_GROUPID ); } - void OnSortChannelsByCity() { MainMixerBoard->SetFaderSorting ( ST_BY_CITY ); } + void OnSortChannelsByGroupID() { MainMixerBoard->SetFaderSorting ( ST_BY_GROUPID ); } + void OnSortChannelsByCity() { MainMixerBoard->SetFaderSorting ( ST_BY_CITY ); } void OnClearAllStoredSoloMuteSettings(); void OnSetAllFadersToNewClientLevel() { MainMixerBoard->SetAllFaderLevelsToNewClientLevel(); } void OnAutoAdjustAllFaderLevels() { MainMixerBoard->AutoAdjustAllFaderLevels(); } @@ -186,71 +169,62 @@ public slots: void OnChatStateChanged ( int value ); void OnLocalMuteStateChanged ( int value ); - void OnAudioReverbValueChanged ( int value ) - { pClient->SetReverbLevel ( value ); } + void OnAudioReverbValueChanged ( int value ) { pClient->SetReverbLevel ( value ); } - void OnReverbSelLClicked() - { pClient->SetReverbOnLeftChan ( true ); } + void OnReverbSelLClicked() { pClient->SetReverbOnLeftChan ( true ); } - void OnReverbSelRClicked() - { pClient->SetReverbOnLeftChan ( false ); } + void OnReverbSelRClicked() { pClient->SetReverbOnLeftChan ( false ); } - void OnFeedbackDetectionChanged ( int state ) - { ClientSettingsDlg.SetEnableFeedbackDetection ( state == Qt::Checked ); } + void OnFeedbackDetectionChanged ( int state ) { ClientSettingsDlg.SetEnableFeedbackDetection ( state == Qt::Checked ); } void OnConClientListMesReceived ( CVector vecChanInfo ); void OnChatTextReceived ( QString strChatText ); void OnLicenceRequired ( ELicenceType eLicenceType ); void OnSoundDeviceChanged ( QString strError ); - void OnChangeChanGain ( int iId, float fGain, bool bIsMyOwnFader ) - { pClient->SetRemoteChanGain ( iId, fGain, bIsMyOwnFader ); } + void OnChangeChanGain ( int iId, float fGain, bool bIsMyOwnFader ) { pClient->SetRemoteChanGain ( iId, fGain, bIsMyOwnFader ); } - void OnChangeChanPan ( int iId, float fPan ) - { pClient->SetRemoteChanPan ( iId, fPan ); } + void OnChangeChanPan ( int iId, float fPan ) { pClient->SetRemoteChanPan ( iId, fPan ); } - void OnNewLocalInputText ( QString strChatText ) - { pClient->CreateChatTextMes ( strChatText ); } + void OnNewLocalInputText ( QString strChatText ) { pClient->CreateChatTextMes ( strChatText ); } - void OnReqServerListQuery ( CHostAddress InetAddr ) - { pClient->CreateCLReqServerListMes ( InetAddr ); } + void OnReqServerListQuery ( CHostAddress InetAddr ) { pClient->CreateCLReqServerListMes ( InetAddr ); } - void OnCreateCLServerListPingMes ( CHostAddress InetAddr ) - { pClient->CreateCLServerListPingMes ( InetAddr ); } + void OnCreateCLServerListPingMes ( CHostAddress InetAddr ) { pClient->CreateCLServerListPingMes ( InetAddr ); } - void OnCreateCLServerListReqVerAndOSMes ( CHostAddress InetAddr ) - { pClient->CreateCLServerListReqVerAndOSMes ( InetAddr ); } + void OnCreateCLServerListReqVerAndOSMes ( CHostAddress InetAddr ) { pClient->CreateCLServerListReqVerAndOSMes ( InetAddr ); } - void OnCreateCLServerListReqConnClientsListMes ( CHostAddress InetAddr ) - { pClient->CreateCLServerListReqConnClientsListMes ( InetAddr ); } + void OnCreateCLServerListReqConnClientsListMes ( CHostAddress InetAddr ) { pClient->CreateCLServerListReqConnClientsListMes ( InetAddr ); } - void OnCLServerListReceived ( CHostAddress InetAddr, - CVector vecServerInfo ) - { ConnectDlg.SetServerList ( InetAddr, vecServerInfo ); } + void OnCLServerListReceived ( CHostAddress InetAddr, CVector vecServerInfo ) + { + ConnectDlg.SetServerList ( InetAddr, vecServerInfo ); + } - void OnCLRedServerListReceived ( CHostAddress InetAddr, - CVector vecServerInfo ) - { ConnectDlg.SetServerList ( InetAddr, vecServerInfo, true ); } + void OnCLRedServerListReceived ( CHostAddress InetAddr, CVector vecServerInfo ) + { + ConnectDlg.SetServerList ( InetAddr, vecServerInfo, true ); + } - void OnCLConnClientsListMesReceived ( CHostAddress InetAddr, - CVector vecChanInfo ) - { ConnectDlg.SetConnClientsList ( InetAddr, vecChanInfo ); } + void OnCLConnClientsListMesReceived ( CHostAddress InetAddr, CVector vecChanInfo ) + { + ConnectDlg.SetConnClientsList ( InetAddr, vecChanInfo ); + } - void OnClientIDReceived ( int iChanID ) - { MainMixerBoard->SetMyChannelID ( iChanID ); } + void OnClientIDReceived ( int iChanID ) { MainMixerBoard->SetMyChannelID ( iChanID ); } - void OnMuteStateHasChangedReceived ( int iChanID, bool bIsMuted ) - { MainMixerBoard->SetRemoteFaderIsMute ( iChanID, bIsMuted ); } + void OnMuteStateHasChangedReceived ( int iChanID, bool bIsMuted ) { MainMixerBoard->SetRemoteFaderIsMute ( iChanID, bIsMuted ); } - void OnCLChannelLevelListReceived ( CHostAddress /* unused */, - CVector vecLevelList ) - { MainMixerBoard->SetChannelLevels ( vecLevelList ); } + void OnCLChannelLevelListReceived ( CHostAddress /* unused */, CVector vecLevelList ) + { + MainMixerBoard->SetChannelLevels ( vecLevelList ); + } void OnConnectDlgAccepted(); void OnDisconnected() { Disconnect(); } void OnGUIDesignChanged(); void OnRecorderStateReceived ( ERecorderState eRecorderState ); - void SetMixerBoardDeco( const ERecorderState newRecorderState, const EGUIDesign eNewDesign ); + void SetMixerBoardDeco ( const ERecorderState newRecorderState, const EGUIDesign eNewDesign ); void OnAudioChannelsChanged() { UpdateRevSelection(); } void OnNumClientsChanged ( int iNewNumClients ); @@ -258,5 +232,4 @@ public slots: signals: void SendTabChange ( int iTabIdx ); - }; diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp old mode 100755 new mode 100644 index 4981c7b722..21cb0f8d28 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -24,122 +24,124 @@ #include "clientsettingsdlg.h" - /* Implementation *************************************************************/ -CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, - CClientSettings* pNSetP, - QWidget* parent ) : - CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons - pClient ( pNCliP ), +CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSetP, QWidget* parent ) : + CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons + pClient ( pNCliP ), pSettings ( pNSetP ) { setupUi ( this ); -#if defined ( Q_OS_IOS ) +#if defined( Q_OS_IOS ) // IOS needs menu to close - QMenuBar* pMenu = new QMenuBar ( this ); - QAction *action = pMenu->addAction ( tr ( "&Close" ) ); + QMenuBar* pMenu = new QMenuBar ( this ); + QAction* action = pMenu->addAction ( tr ( "&Close" ) ); connect ( action, SIGNAL ( triggered() ), this, SLOT ( close() ) ); // Now tell the layout about the menu layout()->setMenuBar ( pMenu ); #endif - // Add help text to controls ----------------------------------------------- // local audio input fader QString strAudFader = "" + tr ( "Local Audio Input Fader" ) + ": " + - tr ( "Controls the relative levels of the left and right local audio " - "channels. For a mono signal it acts as a pan between the two channels." - "For example, if a microphone is connected to " - "the right input channel and an instrument is connected to the left " - "input channel which is much louder than the microphone, move the " - "audio fader in a direction where the label above the fader shows " ) + - "" + tr ( "L" ) + " -x" + tr ( ", where" ) + " x " + - tr ( "is the current attenuation indicator." ); - - lblAudioPan->setWhatsThis ( strAudFader ); + tr ( "Controls the relative levels of the left and right local audio " + "channels. For a mono signal it acts as a pan between the two channels." + "For example, if a microphone is connected to " + "the right input channel and an instrument is connected to the left " + "input channel which is much louder than the microphone, move the " + "audio fader in a direction where the label above the fader shows " ) + + "" + tr ( "L" ) + " -x" + tr ( ", where" ) + " x " + tr ( "is the current attenuation indicator." ); + + lblAudioPan->setWhatsThis ( strAudFader ); lblAudioPanValue->setWhatsThis ( strAudFader ); - sldAudioPan->setWhatsThis ( strAudFader ); + sldAudioPan->setWhatsThis ( strAudFader ); sldAudioPan->setAccessibleName ( tr ( "Local audio input fader (left/right)" ) ); - // jitter buffer - QString strJitterBufferSize = "" + tr ( "Jitter Buffer Size" ) + ": " + tr ( - "The jitter buffer compensates for network and sound card timing jitters. The " - "size of the buffer therefore influences the quality of " - "the audio stream (how many dropouts occur) and the overall delay " - "(the longer the buffer, the higher the delay)." ) + "
" + tr ( - "You can set the jitter buffer size manually for the local client " - "and the remote server. For the local jitter buffer, dropouts in the " - "audio stream are indicated by the light below the " - "jitter buffer size faders. If the light turns to red, a buffer " - "overrun/underrun has taken place and the audio stream is interrupted." ) + "
" + tr ( - "The jitter buffer setting is therefore a trade-off between audio " - "quality and overall delay." ) + "
" + tr ( - "If the Auto setting is enabled, the jitter buffers of the local client and " - "the remote server are set automatically " - "based on measurements of the network and sound card timing jitter. If " - "Auto is enabled, the jitter buffer size faders are " - "disabled (they cannot be moved with the mouse)." ); + QString strJitterBufferSize = "" + tr ( "Jitter Buffer Size" ) + ": " + + tr ( "The jitter buffer compensates for network and sound card timing jitters. The " + "size of the buffer therefore influences the quality of " + "the audio stream (how many dropouts occur) and the overall delay " + "(the longer the buffer, the higher the delay)." ) + + "
" + + tr ( "You can set the jitter buffer size manually for the local client " + "and the remote server. For the local jitter buffer, dropouts in the " + "audio stream are indicated by the light below the " + "jitter buffer size faders. If the light turns to red, a buffer " + "overrun/underrun has taken place and the audio stream is interrupted." ) + + "
" + + tr ( "The jitter buffer setting is therefore a trade-off between audio " + "quality and overall delay." ) + + "
" + + tr ( "If the Auto setting is enabled, the jitter buffers of the local client and " + "the remote server are set automatically " + "based on measurements of the network and sound card timing jitter. If " + "Auto is enabled, the jitter buffer size faders are " + "disabled (they cannot be moved with the mouse)." ); QString strJitterBufferSizeTT = tr ( "If the Auto setting " - "is enabled, the network buffers of the local client and " - "the remote server are set to a conservative " - "value to minimize the audio dropout probability. To tweak the " - "audio delay/latency it is recommended to disable the Auto setting " - "and to lower the jitter buffer size manually by " - "using the sliders until your personal acceptable amount " - "of dropouts is reached. The LED indicator will display the audio " - "dropouts of the local jitter buffer with a red light." ) + - TOOLTIP_COM_END_TEXT; - - lblNetBuf->setWhatsThis ( strJitterBufferSize ); - lblNetBuf->setToolTip ( strJitterBufferSizeTT ); - grbJitterBuffer->setWhatsThis ( strJitterBufferSize ); - grbJitterBuffer->setToolTip ( strJitterBufferSizeTT ); - sldNetBuf->setWhatsThis ( strJitterBufferSize ); - sldNetBuf->setAccessibleName ( tr ( "Local jitter buffer slider control" ) ); - sldNetBuf->setToolTip ( strJitterBufferSizeTT ); - sldNetBufServer->setWhatsThis ( strJitterBufferSize ); + "is enabled, the network buffers of the local client and " + "the remote server are set to a conservative " + "value to minimize the audio dropout probability. To tweak the " + "audio delay/latency it is recommended to disable the Auto setting " + "and to lower the jitter buffer size manually by " + "using the sliders until your personal acceptable amount " + "of dropouts is reached. The LED indicator will display the audio " + "dropouts of the local jitter buffer with a red light." ) + + TOOLTIP_COM_END_TEXT; + + lblNetBuf->setWhatsThis ( strJitterBufferSize ); + lblNetBuf->setToolTip ( strJitterBufferSizeTT ); + grbJitterBuffer->setWhatsThis ( strJitterBufferSize ); + grbJitterBuffer->setToolTip ( strJitterBufferSizeTT ); + sldNetBuf->setWhatsThis ( strJitterBufferSize ); + sldNetBuf->setAccessibleName ( tr ( "Local jitter buffer slider control" ) ); + sldNetBuf->setToolTip ( strJitterBufferSizeTT ); + sldNetBufServer->setWhatsThis ( strJitterBufferSize ); sldNetBufServer->setAccessibleName ( tr ( "Server jitter buffer slider control" ) ); - sldNetBufServer->setToolTip ( strJitterBufferSizeTT ); - chbAutoJitBuf->setAccessibleName ( tr ( "Auto jitter buffer switch" ) ); - chbAutoJitBuf->setToolTip ( strJitterBufferSizeTT ); - ledNetw->setAccessibleName ( tr ( "Jitter buffer status LED indicator" ) ); - ledNetw->setToolTip ( strJitterBufferSizeTT ); + sldNetBufServer->setToolTip ( strJitterBufferSizeTT ); + chbAutoJitBuf->setAccessibleName ( tr ( "Auto jitter buffer switch" ) ); + chbAutoJitBuf->setToolTip ( strJitterBufferSizeTT ); + ledNetw->setAccessibleName ( tr ( "Jitter buffer status LED indicator" ) ); + ledNetw->setToolTip ( strJitterBufferSizeTT ); // sound card device - lblSoundcardDevice->setWhatsThis ( "" + tr ( "Sound Card Device" ) + ": " + - tr ( "The ASIO driver (sound card) can be selected using " ) + APP_NAME + - tr ( " under the Windows operating system. Under MacOS/Linux, no sound " - "card selection is possible. If the selected ASIO driver is not valid " - "an error message is shown and the previous valid driver is selected." ) + "
" + tr ( - "If the driver is selected during an active connection, the connection " - "is stopped, the driver is changed and the connection is started again " - "automatically." ) ); + lblSoundcardDevice->setWhatsThis ( "" + tr ( "Sound Card Device" ) + ": " + tr ( "The ASIO driver (sound card) can be selected using " ) + + APP_NAME + + tr ( " under the Windows operating system. Under MacOS/Linux, no sound " + "card selection is possible. If the selected ASIO driver is not valid " + "an error message is shown and the previous valid driver is selected." ) + + "
" + + tr ( "If the driver is selected during an active connection, the connection " + "is stopped, the driver is changed and the connection is started again " + "automatically." ) ); cbxSoundcard->setAccessibleName ( tr ( "Sound card device selector combo box" ) ); #ifdef _WIN32 // set Windows specific tool tip cbxSoundcard->setToolTip ( tr ( "If the ASIO4ALL driver is used, " - "please note that this driver usually introduces approx. 10-30 ms of " - "additional audio delay. Using a sound card with a native ASIO driver " - "is therefore recommended." ) + "
" + tr ( "If you are using the kX ASIO " - "driver, make sure to connect the ASIO inputs in the kX DSP settings " - "panel." ) + TOOLTIP_COM_END_TEXT ); + "please note that this driver usually introduces approx. 10-30 ms of " + "additional audio delay. Using a sound card with a native ASIO driver " + "is therefore recommended." ) + + "
" + + tr ( "If you are using the kX ASIO " + "driver, make sure to connect the ASIO inputs in the kX DSP settings " + "panel." ) + + TOOLTIP_COM_END_TEXT ); #endif // sound card input/output channel mapping QString strSndCrdChanMapp = "" + tr ( "Sound Card Channel Mapping" ) + ": " + - tr ( "If the selected sound card device offers more than one " - "input or output channel, the Input Channel Mapping and Output " - "Channel Mapping settings are visible." ) + "
" + tr ( - "For each " ) + APP_NAME + tr ( " input/output channel (Left and " - "Right channel) a different actual sound card channel can be " - "selected." ); + tr ( "If the selected sound card device offers more than one " + "input or output channel, the Input Channel Mapping and Output " + "Channel Mapping settings are visible." ) + + "
" + tr ( "For each " ) + APP_NAME + + tr ( " input/output channel (Left and " + "Right channel) a different actual sound card channel can be " + "selected." ); lblInChannelMapping->setWhatsThis ( strSndCrdChanMapp ); lblOutChannelMapping->setWhatsThis ( strSndCrdChanMapp ); @@ -153,66 +155,78 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, cbxROutChan->setAccessibleName ( tr ( "Right output channel selection combo box" ) ); // enable OPUS64 - chbEnableOPUS64->setWhatsThis ( "" + tr ( "Enable Small Network Buffers" ) + ": " + tr ( - "If enabled, the support for very small network audio packets is activated. Very small " - "network packets are only actually used if the sound card buffer delay is smaller than " ) + - QString().setNum ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ) + tr ( " samples. The " - "smaller the network buffers, the lower the audio latency. But at the same time " - "the network load increases and the probability of audio dropouts also increases." ) ); + chbEnableOPUS64->setWhatsThis ( "" + tr ( "Enable Small Network Buffers" ) + ": " + + tr ( "If enabled, the support for very small network audio packets is activated. Very small " + "network packets are only actually used if the sound card buffer delay is smaller than " ) + + QString().setNum ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ) + + tr ( " samples. The " + "smaller the network buffers, the lower the audio latency. But at the same time " + "the network load increases and the probability of audio dropouts also increases." ) ); chbEnableOPUS64->setAccessibleName ( tr ( "Enable small network buffers check box" ) ); // sound card buffer delay QString strSndCrdBufDelay = "" + tr ( "Sound Card Buffer Delay" ) + ": " + - tr ( "The buffer delay setting is a fundamental setting of this " - "software. This setting has an influence on many " - "connection properties." ) + "
" + tr ( - "Three buffer sizes are supported" ) + - ":
    " - "
  • " + tr ( "64 samples: The preferred setting. Provides the lowest latency " - "but does not work with all sound cards." ) + "
  • " - "
  • " + tr ( "128 samples: Should work for most available sound cards." ) + - "
  • " - "
  • " + tr ( "256 samples: Should only be used on very slow " - "computers or with a slow internet connection." ) + "
  • " - "
" + tr ( - "Some sound card drivers do not allow the buffer delay to be changed " - "from within the application. " - "In this case the buffer delay setting is disabled and has to be " - "changed using the sound card driver. On Windows, press the " - "ASIO Device Settings button to open the driver settings panel. On Linux, " - "use the Jack configuration tool to change the buffer size." ) + "
" + tr ( - "If no buffer size is selected and all settings are disabled, an " - "unsupported buffer size is used by the driver. The application " - "will still work with this setting but with restricted " - "performance." ) + "
" + tr ( - "The actual buffer delay has influence on the connection status, the " - "current upload rate and the overall delay. The lower the buffer size, " - "the higher the probability of a red light in the status indicator (drop " - "outs) and the higher the upload rate and the lower the overall " - "delay." ) + "
" + tr ( - "The buffer setting is therefore a trade-off between audio " - "quality and overall delay." ); + tr ( "The buffer delay setting is a fundamental setting of this " + "software. This setting has an influence on many " + "connection properties." ) + + "
" + tr ( "Three buffer sizes are supported" ) + + ":
    " + "
  • " + + tr ( "64 samples: The preferred setting. Provides the lowest latency " + "but does not work with all sound cards." ) + + "
  • " + "
  • " + + tr ( "128 samples: Should work for most available sound cards." ) + + "
  • " + "
  • " + + tr ( "256 samples: Should only be used on very slow " + "computers or with a slow internet connection." ) + + "
  • " + "
" + + tr ( "Some sound card drivers do not allow the buffer delay to be changed " + "from within the application. " + "In this case the buffer delay setting is disabled and has to be " + "changed using the sound card driver. On Windows, press the " + "ASIO Device Settings button to open the driver settings panel. On Linux, " + "use the Jack configuration tool to change the buffer size." ) + + "
" + + tr ( "If no buffer size is selected and all settings are disabled, an " + "unsupported buffer size is used by the driver. The application " + "will still work with this setting but with restricted " + "performance." ) + + "
" + + tr ( "The actual buffer delay has influence on the connection status, the " + "current upload rate and the overall delay. The lower the buffer size, " + "the higher the probability of a red light in the status indicator (drop " + "outs) and the higher the upload rate and the lower the overall " + "delay." ) + + "
" + + tr ( "The buffer setting is therefore a trade-off between audio " + "quality and overall delay." ); QString strSndCrdBufDelayTT = tr ( "If the buffer delay settings are " - "disabled, it is prohibited by the audio driver to modify this " - "setting from within the software. " - "On Windows, press the ASIO Device Settings button to open the " - "driver settings panel. On Linux, use the Jack configuration tool to " - "change the buffer size." ) + TOOLTIP_COM_END_TEXT; - - // Driver setup button - QString strSndCardDriverSetup = "" + tr ( "Sound card driver settings" ) + ": " + - tr ( "This opens the driver settings of your sound card. Some drivers " - "allow you to change buffer settings, others like ASIO4ALL " - "let you choose input or outputs of your device(s). " - "More information can be found on jamulus.io." ); - - QString strSndCardDriverSetupTT = tr ( "Opens the driver settings. Note: " ) + APP_NAME + - tr ( " currently only supports devices supporting a sample rate of " ) - + QString().setNum ( SYSTEM_SAMPLE_RATE_HZ ) + tr ( "Hz. " - "You will not be able to select a driver/device which doesn't. " - "For more help see jamulus.io." ) + TOOLTIP_COM_END_TEXT; + "disabled, it is prohibited by the audio driver to modify this " + "setting from within the software. " + "On Windows, press the ASIO Device Settings button to open the " + "driver settings panel. On Linux, use the Jack configuration tool to " + "change the buffer size." ) + + TOOLTIP_COM_END_TEXT; + + // Driver setup button + QString strSndCardDriverSetup = "" + tr ( "Sound card driver settings" ) + ": " + + tr ( "This opens the driver settings of your sound card. Some drivers " + "allow you to change buffer settings, others like ASIO4ALL " + "let you choose input or outputs of your device(s). " + "More information can be found on jamulus.io." ); + + QString strSndCardDriverSetupTT = tr ( "Opens the driver settings. Note: " ) + APP_NAME + + tr ( " currently only supports devices supporting a sample rate of " ) + + QString().setNum ( SYSTEM_SAMPLE_RATE_HZ ) + + tr ( "Hz. " + "You will not be able to select a driver/device which doesn't. " + "For more help see jamulus.io." ) + + TOOLTIP_COM_END_TEXT; rbtBufferDelayPreferred->setWhatsThis ( strSndCrdBufDelay ); rbtBufferDelayPreferred->setAccessibleName ( tr ( "64 samples setting radio button" ) ); @@ -228,48 +242,57 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, butDriverSetup->setToolTip ( strSndCardDriverSetupTT ); // fancy skin - lblSkin->setWhatsThis ( "" + tr ( "Skin" ) + ": " + tr ( - "Select the skin to be used for the main window." ) ); + lblSkin->setWhatsThis ( "" + tr ( "Skin" ) + ": " + tr ( "Select the skin to be used for the main window." ) ); cbxSkin->setAccessibleName ( tr ( "Skin combo box" ) ); // Interface Language - lblLanguage->setWhatsThis ( "" + tr ( "Language" ) + ": " + tr ( - "Select the language to be used for the user interface." ) ); + lblLanguage->setWhatsThis ( "" + tr ( "Language" ) + ": " + tr ( "Select the language to be used for the user interface." ) ); cbxLanguage->setAccessibleName ( tr ( "Language combo box" ) ); // audio channels - QString strAudioChannels = "" + tr ( "Audio Channels" ) + ": " + tr ( - "Selects the number of audio channels to be used for communication between " - "client and server. There are three modes available:" ) + - "
    " - "
  • " "" + tr ( "Mono" ) + " " + tr ( "and " ) + - "" + tr ( "Stereo" ) + ": " + tr ( "These modes use " - "one and two audio channels respectively." ) + "
  • " - "
  • " "" + tr ( "Mono in/Stereo-out" ) + ": " + tr ( - "The audio signal sent to the server is mono but the " - "return signal is stereo. This is useful if the " - "sound card has the instrument on one input channel and the " - "microphone on the other. In that case the two input signals " - "can be mixed to one mono channel but the server mix is heard in " - "stereo." ) + "
  • " - "
  • " + tr ( "Enabling " ) + "" + tr ( "Stereo" ) + " " + tr ( " mode " - "will increase your stream's data rate. Make sure your upload rate does not " - "exceed the available upload speed of your internet connection." ) + "
  • " - "
" + "
" + tr ( "In stereo streaming mode, no audio channel selection " - "for the reverb effect will be available on the main window " - "since the effect is applied to both channels in this case." ); + QString strAudioChannels = "" + tr ( "Audio Channels" ) + ": " + + tr ( "Selects the number of audio channels to be used for communication between " + "client and server. There are three modes available:" ) + + "
    " + "
  • " + "" + + tr ( "Mono" ) + " " + tr ( "and " ) + "" + tr ( "Stereo" ) + ": " + + tr ( "These modes use " + "one and two audio channels respectively." ) + + "
  • " + "
  • " + "" + + tr ( "Mono in/Stereo-out" ) + ": " + + tr ( "The audio signal sent to the server is mono but the " + "return signal is stereo. This is useful if the " + "sound card has the instrument on one input channel and the " + "microphone on the other. In that case the two input signals " + "can be mixed to one mono channel but the server mix is heard in " + "stereo." ) + + "
  • " + "
  • " + + tr ( "Enabling " ) + "" + tr ( "Stereo" ) + " " + + tr ( " mode " + "will increase your stream's data rate. Make sure your upload rate does not " + "exceed the available upload speed of your internet connection." ) + + "
  • " + "
" + + "
" + + tr ( "In stereo streaming mode, no audio channel selection " + "for the reverb effect will be available on the main window " + "since the effect is applied to both channels in this case." ); lblAudioChannels->setWhatsThis ( strAudioChannels ); cbxAudioChannels->setWhatsThis ( strAudioChannels ); cbxAudioChannels->setAccessibleName ( tr ( "Audio channels combo box" ) ); // audio quality - QString strAudioQuality = "" + tr ( "Audio Quality" ) + ": " + tr ( - "The higher the audio quality, the higher your audio stream's " - "data rate. Make sure your upload rate does not exceed the " - "available bandwidth of your internet connection."); + QString strAudioQuality = "" + tr ( "Audio Quality" ) + ": " + + tr ( "The higher the audio quality, the higher your audio stream's " + "data rate. Make sure your upload rate does not exceed the " + "available bandwidth of your internet connection." ); lblAudioQuality->setWhatsThis ( strAudioQuality ); cbxAudioQuality->setWhatsThis ( strAudioQuality ); @@ -277,11 +300,11 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, // new client fader level QString strNewClientLevel = "" + tr ( "New Client Level" ) + ": " + - tr ( "This setting defines the fader level of a newly " - "connected client in percent. If a new client connects " - "to the current server, they will get the specified initial " - "fader level if no other fader level from a previous connection " - "of that client was already stored." ); + tr ( "This setting defines the fader level of a newly " + "connected client in percent. If a new client connects " + "to the current server, they will get the specified initial " + "fader level if no other fader level from a previous connection " + "of that client was already stored." ); lblNewClientLevel->setWhatsThis ( strNewClientLevel ); edtNewClientLevel->setWhatsThis ( strNewClientLevel ); @@ -289,66 +312,70 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, // input boost QString strInputBoost = "" + tr ( "Input Boost" ) + ": " + - tr ( "This setting allows you to increase your input signal level " - "by factors up to 10 (+20dB)." - "If your sound is too quiet, first try to increase the level by " - "getting closer to the microphone, adjusting your sound equipment " - "or increasing levels in your operating system's input settings. " - "Only if this fails, set a factor here. " - "If your sound is too loud, sounds distorted and is clipping, this " - "option will not help. Do not use it. The distortion will still be " - "there. Instead, decrease your input level by getting farther away " - "from your microphone, adjusting your sound equipment " - "or by decreasing your operating system's input settings." - ); + tr ( "This setting allows you to increase your input signal level " + "by factors up to 10 (+20dB)." + "If your sound is too quiet, first try to increase the level by " + "getting closer to the microphone, adjusting your sound equipment " + "or increasing levels in your operating system's input settings. " + "Only if this fails, set a factor here. " + "If your sound is too loud, sounds distorted and is clipping, this " + "option will not help. Do not use it. The distortion will still be " + "there. Instead, decrease your input level by getting farther away " + "from your microphone, adjusting your sound equipment " + "or by decreasing your operating system's input settings." ); lblInputBoost->setWhatsThis ( strInputBoost ); cbxInputBoost->setWhatsThis ( strInputBoost ); cbxInputBoost->setAccessibleName ( tr ( "Input Boost combo box" ) ); // custom directory server address QString strCentrServAddr = "" + tr ( "Custom Directory Server Address" ) + ": " + - tr ( "Leave this blank unless you need to enter the address of a directory " - "server other than the default." ); + tr ( "Leave this blank unless you need to enter the address of a directory " + "server other than the default." ); lblCentralServerAddress->setWhatsThis ( strCentrServAddr ); cbxCentralServerAddress->setWhatsThis ( strCentrServAddr ); cbxCentralServerAddress->setAccessibleName ( tr ( "Directory server address combo box" ) ); // current connection status parameter - QString strConnStats = "" + tr ( "Current Connection Status " - "Parameter" ) + ": " + tr ( "The Ping Time is the time required for the audio " - "stream to travel from the client to the server and back again. This " - "delay is introduced by the network and should be about " - "20-30 ms. If this delay is higher than about 50 ms, your distance to " - "the server is too large or your internet connection is not " - "sufficient." ) + "
" + tr ( - "Overall Delay is calculated from the current Ping Time and the " - "delay introduced by the current buffer settings." ) + "
" + tr ( - "Audio Upstream Rate depends on the current audio packet size and " - "compression setting. Make sure that the upstream rate is not " - "higher than your available internet upload speed (check this with a " - "service such as speedtest.net)." ); - - lblPingTime->setWhatsThis ( strConnStats ); - lblPingTimeValue->setWhatsThis ( strConnStats ); - lblOverallDelay->setWhatsThis ( strConnStats ); + QString strConnStats = "" + + tr ( "Current Connection Status " + "Parameter" ) + + ": " + + tr ( "The Ping Time is the time required for the audio " + "stream to travel from the client to the server and back again. This " + "delay is introduced by the network and should be about " + "20-30 ms. If this delay is higher than about 50 ms, your distance to " + "the server is too large or your internet connection is not " + "sufficient." ) + + "
" + + tr ( "Overall Delay is calculated from the current Ping Time and the " + "delay introduced by the current buffer settings." ) + + "
" + + tr ( "Audio Upstream Rate depends on the current audio packet size and " + "compression setting. Make sure that the upstream rate is not " + "higher than your available internet upload speed (check this with a " + "service such as speedtest.net)." ); + + lblPingTime->setWhatsThis ( strConnStats ); + lblPingTimeValue->setWhatsThis ( strConnStats ); + lblOverallDelay->setWhatsThis ( strConnStats ); lblOverallDelayValue->setWhatsThis ( strConnStats ); - lblUpstream->setWhatsThis ( strConnStats ); - lblUpstreamValue->setWhatsThis ( strConnStats ); - ledOverallDelay->setWhatsThis ( strConnStats ); + lblUpstream->setWhatsThis ( strConnStats ); + lblUpstreamValue->setWhatsThis ( strConnStats ); + ledOverallDelay->setWhatsThis ( strConnStats ); ledOverallDelay->setToolTip ( tr ( "If this LED indicator turns red, " - "you will not have much fun using the " ) + APP_NAME + - tr ( " software." ) + TOOLTIP_COM_END_TEXT ); + "you will not have much fun using the " ) + + APP_NAME + tr ( " software." ) + TOOLTIP_COM_END_TEXT ); - QString strNumMixerPanelRows = "" + tr ( "Number of Mixer Panel Rows" ) + ": " + - tr ( "Adjust the number of rows used to arrange the mixer panel." ); + QString strNumMixerPanelRows = + "" + tr ( "Number of Mixer Panel Rows" ) + ": " + tr ( "Adjust the number of rows used to arrange the mixer panel." ); lblMixerRows->setWhatsThis ( strNumMixerPanelRows ); spnMixerRows->setWhatsThis ( strNumMixerPanelRows ); spnMixerRows->setAccessibleName ( tr ( "Number of Mixer Panel Rows spin box" ) ); QString strDetectFeedback = "" + tr ( "Feedback Protection" ) + ": " + - tr ( "Enable feedback protection to detect acoustic feedback between " - "microphone and speakers." ); + tr ( "Enable feedback protection to detect acoustic feedback between " + "microphone and speakers." ); lblDetectFeedback->setWhatsThis ( strDetectFeedback ); chbDetectFeedback->setWhatsThis ( strDetectFeedback ); chbDetectFeedback->setAccessibleName ( tr ( "Feedback Protection check box" ) ); @@ -369,20 +396,19 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, // init delay and other information controls ledNetw->Reset(); ledOverallDelay->Reset(); - ledNetw->SetType ( CMultiColorLED::MT_INDICATOR ); - ledOverallDelay->SetType ( CMultiColorLED::MT_INDICATOR ); - lblUpstreamValue->setText ( "---" ); - lblUpstreamUnit->setText ( "" ); - lblPingTimeValue->setText ( "---" ); - lblPingTimeUnit->setText ( "" ); + ledNetw->SetType ( CMultiColorLED::MT_INDICATOR ); + ledOverallDelay->SetType ( CMultiColorLED::MT_INDICATOR ); + lblUpstreamValue->setText ( "---" ); + lblUpstreamUnit->setText ( "" ); + lblPingTimeValue->setText ( "---" ); + lblPingTimeUnit->setText ( "" ); lblOverallDelayValue->setText ( "---" ); - lblOverallDelayUnit->setText ( "" ); + lblOverallDelayUnit->setText ( "" ); edtNewClientLevel->setValidator ( new QIntValidator ( 0, 100, this ) ); // % range from 0-100 - // init slider controls --- // network buffer sliders - sldNetBuf->setRange ( MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL ); + sldNetBuf->setRange ( MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL ); sldNetBufServer->setRange ( MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL ); UpdateJitterBufferFrame(); @@ -414,7 +440,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, cbxLanguage->Init ( pSettings->strLanguage ); // init custom directory server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries) - cbxCentralServerAddress->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS ); + cbxCentralServerAddress->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS ); cbxCentralServerAddress->setInsertPolicy ( QComboBox::NoInsert ); // update new client fader level edit box @@ -423,8 +449,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, // Input Boost combo box cbxInputBoost->clear(); cbxInputBoost->addItem ( tr ( "None" ) ); - for ( int i = 2; i <= 10; i++ ) { - cbxInputBoost->addItem ( QString( "%1x" ).arg( i ) ); + for ( int i = 2; i <= 10; i++ ) + { + cbxInputBoost->addItem ( QString ( "%1x" ).arg ( i ) ); } // factor is 1-based while index is 0-based: cbxInputBoost->setCurrentIndex ( pSettings->iInputBoost - 1 ); @@ -433,22 +460,18 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, spnMixerRows->setValue ( pSettings->iNumMixerPanelRows ); // update feedback detection - chbDetectFeedback->setCheckState ( pSettings->bEnableFeedbackDetection ? - Qt::Checked : Qt::Unchecked ); + chbDetectFeedback->setCheckState ( pSettings->bEnableFeedbackDetection ? Qt::Checked : Qt::Unchecked ); // update enable small network buffers check box chbEnableOPUS64->setCheckState ( pClient->GetEnableOPUS64() ? Qt::Checked : Qt::Unchecked ); // set text for sound card buffer delay radio buttons - rbtBufferDelayPreferred->setText ( GenSndCrdBufferDelayString ( - FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES ) ); + rbtBufferDelayPreferred->setText ( GenSndCrdBufferDelayString ( FRAME_SIZE_FACTOR_PREFERRED * SYSTEM_FRAME_SIZE_SAMPLES ) ); - rbtBufferDelayDefault->setText ( GenSndCrdBufferDelayString ( - FRAME_SIZE_FACTOR_DEFAULT * SYSTEM_FRAME_SIZE_SAMPLES, - ", " + tr ( "preferred" ) ) ); + rbtBufferDelayDefault->setText ( + GenSndCrdBufferDelayString ( FRAME_SIZE_FACTOR_DEFAULT * SYSTEM_FRAME_SIZE_SAMPLES, ", " + tr ( "preferred" ) ) ); - rbtBufferDelaySafe->setText ( GenSndCrdBufferDelayString ( - FRAME_SIZE_FACTOR_SAFE * SYSTEM_FRAME_SIZE_SAMPLES ) ); + rbtBufferDelaySafe->setText ( GenSndCrdBufferDelayString ( FRAME_SIZE_FACTOR_SAFE * SYSTEM_FRAME_SIZE_SAMPLES ) ); // sound card buffer delay inits SndCrdBufferDelayButtonGroup.addButton ( rbtBufferDelayPreferred ); @@ -460,14 +483,15 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, // Add help text to controls ----------------------------------------------- // Musician Profile QString strFaderTag = "" + tr ( "Musician Profile" ) + ": " + - tr ( "Write your name or an alias here so the other musicians you want to " - "play with know who you are. You may also add a picture of the instrument " - "you play and a flag of the country you are located in. " - "Your city and skill level playing your instrument may also be added." ) + - "
" + tr ( "What you set here will appear at your fader on the mixer " - "board when you are connected to a Jamulus server. This tag will " - "also be shown at each client which is connected to the same server as " - "you." ); + tr ( "Write your name or an alias here so the other musicians you want to " + "play with know who you are. You may also add a picture of the instrument " + "you play and a flag of the country you are located in. " + "Your city and skill level playing your instrument may also be added." ) + + "
" + + tr ( "What you set here will appear at your fader on the mixer " + "board when you are connected to a Jamulus server. This tag will " + "also be shown at each client which is connected to the same server as " + "you." ); plblAlias->setWhatsThis ( strFaderTag ); pedtAlias->setAccessibleName ( tr ( "Alias or name edit box" ) ); @@ -487,19 +511,31 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, // create a combo box item with text, image and background color QColor InstrColor; - pcbxInstrument->addItem ( QIcon ( CInstPictures::GetResourceReference ( iCurInst ) ), - CInstPictures::GetName ( iCurInst ), - iCurInst ); + pcbxInstrument->addItem ( QIcon ( CInstPictures::GetResourceReference ( iCurInst ) ), CInstPictures::GetName ( iCurInst ), iCurInst ); switch ( CInstPictures::GetCategory ( iCurInst ) ) { - case CInstPictures::IC_OTHER_INSTRUMENT: InstrColor = QColor ( Qt::blue ); break; - case CInstPictures::IC_WIND_INSTRUMENT: InstrColor = QColor ( Qt::green ); break; - case CInstPictures::IC_STRING_INSTRUMENT: InstrColor = QColor ( Qt::red ); break; - case CInstPictures::IC_PLUCKING_INSTRUMENT: InstrColor = QColor ( Qt::cyan ); break; - case CInstPictures::IC_PERCUSSION_INSTRUMENT: InstrColor = QColor ( Qt::white ); break; - case CInstPictures::IC_KEYBOARD_INSTRUMENT: InstrColor = QColor ( Qt::yellow ); break; - case CInstPictures::IC_MULTIPLE_INSTRUMENT: InstrColor = QColor ( Qt::black ); break; + case CInstPictures::IC_OTHER_INSTRUMENT: + InstrColor = QColor ( Qt::blue ); + break; + case CInstPictures::IC_WIND_INSTRUMENT: + InstrColor = QColor ( Qt::green ); + break; + case CInstPictures::IC_STRING_INSTRUMENT: + InstrColor = QColor ( Qt::red ); + break; + case CInstPictures::IC_PLUCKING_INSTRUMENT: + InstrColor = QColor ( Qt::cyan ); + break; + case CInstPictures::IC_PERCUSSION_INSTRUMENT: + InstrColor = QColor ( Qt::white ); + break; + case CInstPictures::IC_KEYBOARD_INSTRUMENT: + InstrColor = QColor ( Qt::yellow ); + break; + case CInstPictures::IC_MULTIPLE_INSTRUMENT: + InstrColor = QColor ( Qt::black ); + break; } InstrColor.setAlpha ( 10 ); @@ -511,8 +547,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, // Country flag icons combo box -------------------------------------------- // add an entry for all known country flags - for ( int iCurCntry = static_cast ( QLocale::AnyCountry ); - iCurCntry < static_cast ( QLocale::LastCountry ); iCurCntry++ ) + for ( int iCurCntry = static_cast ( QLocale::AnyCountry ); iCurCntry < static_cast ( QLocale::LastCountry ); iCurCntry++ ) { // exclude the "None" entry since it is added after the sorting if ( static_cast ( iCurCntry ) != QLocale::AnyCountry ) @@ -528,9 +563,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, if ( !CurFlagIcon.isNull() ) { // create a combo box item with text and image - pcbxCountry->addItem ( QIcon ( CurFlagIcon ), - QLocale::countryToString ( eCountry ), - iCurCntry ); + pcbxCountry->addItem ( QIcon ( CurFlagIcon ), QLocale::countryToString ( eCountry ), iCurCntry ); } } } @@ -541,139 +574,141 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, // the "None" country gets a special icon and is the very first item QIcon FlagNoneIcon; FlagNoneIcon.addFile ( ":/png/flags/res/flags/flagnone.png" ); - pcbxCountry->insertItem ( 0, - FlagNoneIcon, - tr ( "None" ), - static_cast ( QLocale::AnyCountry ) ); - + pcbxCountry->insertItem ( 0, FlagNoneIcon, tr ( "None" ), static_cast ( QLocale::AnyCountry ) ); // Skill level combo box --------------------------------------------------- // create a pixmap showing the skill level colors QPixmap SLPixmap ( 16, 11 ); // same size as the country flags - SLPixmap.fill ( QColor::fromRgb ( RGBCOL_R_SL_NOT_SET, - RGBCOL_G_SL_NOT_SET, - RGBCOL_B_SL_NOT_SET ) ); + SLPixmap.fill ( QColor::fromRgb ( RGBCOL_R_SL_NOT_SET, RGBCOL_G_SL_NOT_SET, RGBCOL_B_SL_NOT_SET ) ); pcbxSkill->addItem ( QIcon ( SLPixmap ), tr ( "None" ), SL_NOT_SET ); - SLPixmap.fill ( QColor::fromRgb ( RGBCOL_R_SL_BEGINNER, - RGBCOL_G_SL_BEGINNER, - RGBCOL_B_SL_BEGINNER ) ); + SLPixmap.fill ( QColor::fromRgb ( RGBCOL_R_SL_BEGINNER, RGBCOL_G_SL_BEGINNER, RGBCOL_B_SL_BEGINNER ) ); pcbxSkill->addItem ( QIcon ( SLPixmap ), tr ( "Beginner" ), SL_BEGINNER ); - SLPixmap.fill ( QColor::fromRgb ( RGBCOL_R_SL_INTERMEDIATE, - RGBCOL_G_SL_INTERMEDIATE, - RGBCOL_B_SL_INTERMEDIATE ) ); + SLPixmap.fill ( QColor::fromRgb ( RGBCOL_R_SL_INTERMEDIATE, RGBCOL_G_SL_INTERMEDIATE, RGBCOL_B_SL_INTERMEDIATE ) ); pcbxSkill->addItem ( QIcon ( SLPixmap ), tr ( "Intermediate" ), SL_INTERMEDIATE ); - SLPixmap.fill ( QColor::fromRgb ( RGBCOL_R_SL_SL_PROFESSIONAL, - RGBCOL_G_SL_SL_PROFESSIONAL, - RGBCOL_B_SL_SL_PROFESSIONAL ) ); + SLPixmap.fill ( QColor::fromRgb ( RGBCOL_R_SL_SL_PROFESSIONAL, RGBCOL_G_SL_SL_PROFESSIONAL, RGBCOL_B_SL_SL_PROFESSIONAL ) ); pcbxSkill->addItem ( QIcon ( SLPixmap ), tr ( "Expert" ), SL_PROFESSIONAL ); - // Connections ------------------------------------------------------------- // timers - QObject::connect ( &TimerStatus, &QTimer::timeout, - this, &CClientSettingsDlg::OnTimerStatus ); + QObject::connect ( &TimerStatus, &QTimer::timeout, this, &CClientSettingsDlg::OnTimerStatus ); // slider controls - QObject::connect ( sldNetBuf, &QSlider::valueChanged, - this, &CClientSettingsDlg::OnNetBufValueChanged ); + QObject::connect ( sldNetBuf, &QSlider::valueChanged, this, &CClientSettingsDlg::OnNetBufValueChanged ); - QObject::connect ( sldNetBufServer, &QSlider::valueChanged, - this, &CClientSettingsDlg::OnNetBufServerValueChanged ); + QObject::connect ( sldNetBufServer, &QSlider::valueChanged, this, &CClientSettingsDlg::OnNetBufServerValueChanged ); // check boxes - QObject::connect ( chbAutoJitBuf, &QCheckBox::stateChanged, - this, &CClientSettingsDlg::OnAutoJitBufStateChanged ); + QObject::connect ( chbAutoJitBuf, &QCheckBox::stateChanged, this, &CClientSettingsDlg::OnAutoJitBufStateChanged ); - QObject::connect ( chbEnableOPUS64, &QCheckBox::stateChanged, - this, &CClientSettingsDlg::OnEnableOPUS64StateChanged ); + QObject::connect ( chbEnableOPUS64, &QCheckBox::stateChanged, this, &CClientSettingsDlg::OnEnableOPUS64StateChanged ); - QObject::connect ( chbDetectFeedback, &QCheckBox::stateChanged, - this, &CClientSettingsDlg::OnFeedbackDetectionChanged ); + QObject::connect ( chbDetectFeedback, &QCheckBox::stateChanged, this, &CClientSettingsDlg::OnFeedbackDetectionChanged ); // line edits - QObject::connect ( edtNewClientLevel, &QLineEdit::editingFinished, - this, &CClientSettingsDlg::OnNewClientLevelEditingFinished ); + QObject::connect ( edtNewClientLevel, &QLineEdit::editingFinished, this, &CClientSettingsDlg::OnNewClientLevelEditingFinished ); // combo boxes - QObject::connect ( cbxSoundcard, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnSoundcardActivated ); - - QObject::connect ( cbxLInChan, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnLInChanActivated ); - - QObject::connect ( cbxRInChan, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnRInChanActivated ); - - QObject::connect ( cbxLOutChan, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnLOutChanActivated ); - - QObject::connect ( cbxROutChan, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnROutChanActivated ); - - QObject::connect ( cbxAudioChannels, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnAudioChannelsActivated ); - - QObject::connect ( cbxAudioQuality, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnAudioQualityActivated ); - - QObject::connect ( cbxSkin, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnGUIDesignActivated ); - - QObject::connect ( cbxCentralServerAddress->lineEdit(), &QLineEdit::editingFinished, - this, &CClientSettingsDlg::OnCentralServerAddressEditingFinished ); - - QObject::connect ( cbxCentralServerAddress, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnCentralServerAddressEditingFinished ); - - QObject::connect ( cbxLanguage, &CLanguageComboBox::LanguageChanged, - this, &CClientSettingsDlg::OnLanguageChanged ); - - QObject::connect ( cbxInputBoost, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnInputBoostChanged ); + QObject::connect ( cbxSoundcard, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnSoundcardActivated ); + + QObject::connect ( cbxLInChan, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnLInChanActivated ); + + QObject::connect ( cbxRInChan, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnRInChanActivated ); + + QObject::connect ( cbxLOutChan, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnLOutChanActivated ); + + QObject::connect ( cbxROutChan, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnROutChanActivated ); + + QObject::connect ( cbxAudioChannels, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnAudioChannelsActivated ); + + QObject::connect ( cbxAudioQuality, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnAudioQualityActivated ); + + QObject::connect ( cbxSkin, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnGUIDesignActivated ); + + QObject::connect ( cbxCentralServerAddress->lineEdit(), + &QLineEdit::editingFinished, + this, + &CClientSettingsDlg::OnCentralServerAddressEditingFinished ); + + QObject::connect ( cbxCentralServerAddress, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnCentralServerAddressEditingFinished ); + + QObject::connect ( cbxLanguage, &CLanguageComboBox::LanguageChanged, this, &CClientSettingsDlg::OnLanguageChanged ); + + QObject::connect ( cbxInputBoost, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnInputBoostChanged ); // buttons - QObject::connect ( butDriverSetup, &QPushButton::clicked, - this, &CClientSettingsDlg::OnDriverSetupClicked ); + QObject::connect ( butDriverSetup, &QPushButton::clicked, this, &CClientSettingsDlg::OnDriverSetupClicked ); // misc // sliders - QObject::connect ( sldAudioPan, &QSlider::valueChanged, - this, &CClientSettingsDlg::OnAudioPanValueChanged ); + QObject::connect ( sldAudioPan, &QSlider::valueChanged, this, &CClientSettingsDlg::OnAudioPanValueChanged ); QObject::connect ( &SndCrdBufferDelayButtonGroup, - static_cast ( &QButtonGroup::buttonClicked ), - this, &CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ); + static_cast ( &QButtonGroup::buttonClicked ), + this, + &CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ); // spinners - QObject::connect ( spnMixerRows, static_cast ( &QSpinBox::valueChanged ), - this, &CClientSettingsDlg::NumMixerPanelRowsChanged ); + QObject::connect ( spnMixerRows, + static_cast ( &QSpinBox::valueChanged ), + this, + &CClientSettingsDlg::NumMixerPanelRowsChanged ); // Musician Profile - QObject::connect ( pedtAlias, &QLineEdit::textChanged, - this, &CClientSettingsDlg::OnAliasTextChanged ); + QObject::connect ( pedtAlias, &QLineEdit::textChanged, this, &CClientSettingsDlg::OnAliasTextChanged ); - QObject::connect ( pcbxInstrument, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnInstrumentActivated ); + QObject::connect ( pcbxInstrument, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnInstrumentActivated ); - QObject::connect ( pcbxCountry, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnCountryActivated ); + QObject::connect ( pcbxCountry, + static_cast ( &QComboBox::activated ), + this, + &CClientSettingsDlg::OnCountryActivated ); - QObject::connect ( pedtCity, &QLineEdit::textChanged, - this, &CClientSettingsDlg::OnCityTextChanged ); + QObject::connect ( pedtCity, &QLineEdit::textChanged, this, &CClientSettingsDlg::OnCityTextChanged ); - QObject::connect ( pcbxSkill, static_cast ( &QComboBox::activated ), - this, &CClientSettingsDlg::OnSkillActivated ); + QObject::connect ( pcbxSkill, static_cast ( &QComboBox::activated ), this, &CClientSettingsDlg::OnSkillActivated ); - QObject::connect ( tabSettings, &QTabWidget::currentChanged, - this, &CClientSettingsDlg::OnTabChanged ); + QObject::connect ( tabSettings, &QTabWidget::currentChanged, this, &CClientSettingsDlg::OnTabChanged ); tabSettings->setCurrentIndex ( pSettings->iSettingsTab ); @@ -691,21 +726,16 @@ void CClientSettingsDlg::showEvent ( QShowEvent* ) pedtAlias->setText ( pClient->ChannelInfo.strName ); // select current instrument - pcbxInstrument->setCurrentIndex ( - pcbxInstrument->findData ( pClient->ChannelInfo.iInstrument ) ); + pcbxInstrument->setCurrentIndex ( pcbxInstrument->findData ( pClient->ChannelInfo.iInstrument ) ); // select current country - pcbxCountry->setCurrentIndex ( - pcbxCountry->findData ( - static_cast ( pClient->ChannelInfo.eCountry ) ) ); + pcbxCountry->setCurrentIndex ( pcbxCountry->findData ( static_cast ( pClient->ChannelInfo.eCountry ) ) ); // set the city pedtCity->setText ( pClient->ChannelInfo.strCity ); // select the skill level - pcbxSkill->setCurrentIndex ( - pcbxSkill->findData ( - static_cast ( pClient->ChannelInfo.eSkillLevel ) ) ); + pcbxSkill->setCurrentIndex ( pcbxSkill->findData ( static_cast ( pClient->ChannelInfo.eSkillLevel ) ) ); } void CClientSettingsDlg::UpdateJitterBufferFrame() @@ -722,23 +752,21 @@ void CClientSettingsDlg::UpdateJitterBufferFrame() // if auto setting is enabled, disable slider control const bool bIsAutoSockBufSize = pClient->GetDoAutoSockBufSize(); - chbAutoJitBuf->setChecked ( bIsAutoSockBufSize ); - sldNetBuf->setEnabled ( !bIsAutoSockBufSize ); - lblNetBuf->setEnabled ( !bIsAutoSockBufSize ); - lblNetBufLabel->setEnabled ( !bIsAutoSockBufSize ); - sldNetBufServer->setEnabled ( !bIsAutoSockBufSize ); - lblNetBufServer->setEnabled ( !bIsAutoSockBufSize ); + chbAutoJitBuf->setChecked ( bIsAutoSockBufSize ); + sldNetBuf->setEnabled ( !bIsAutoSockBufSize ); + lblNetBuf->setEnabled ( !bIsAutoSockBufSize ); + lblNetBufLabel->setEnabled ( !bIsAutoSockBufSize ); + sldNetBufServer->setEnabled ( !bIsAutoSockBufSize ); + lblNetBufServer->setEnabled ( !bIsAutoSockBufSize ); lblNetBufServerLabel->setEnabled ( !bIsAutoSockBufSize ); } -QString CClientSettingsDlg::GenSndCrdBufferDelayString ( const int iFrameSize, - const QString strAddText ) +QString CClientSettingsDlg::GenSndCrdBufferDelayString ( const int iFrameSize, const QString strAddText ) { // use two times the buffer delay for the entire delay since // we have input and output - return QString().setNum ( static_cast ( iFrameSize ) * 2 * - 1000 / SYSTEM_SAMPLE_RATE_HZ, 'f', 2 ) + " ms (" + - QString().setNum ( iFrameSize ) + strAddText + ")"; + return QString().setNum ( static_cast ( iFrameSize ) * 2 * 1000 / SYSTEM_SAMPLE_RATE_HZ, 'f', 2 ) + " ms (" + + QString().setNum ( iFrameSize ) + strAddText + ")"; } void CClientSettingsDlg::UpdateSoundCardFrame() @@ -759,14 +787,14 @@ void CClientSettingsDlg::UpdateSoundCardFrame() // are disabeld and unchecked.). SndCrdBufferDelayButtonGroup.setExclusive ( false ); rbtBufferDelayPreferred->setChecked ( bPreferredChecked ); - rbtBufferDelayDefault->setChecked ( bDefaultChecked ); - rbtBufferDelaySafe->setChecked ( bSafeChecked ); + rbtBufferDelayDefault->setChecked ( bDefaultChecked ); + rbtBufferDelaySafe->setChecked ( bSafeChecked ); SndCrdBufferDelayButtonGroup.setExclusive ( true ); // disable radio buttons which are not supported by audio interface rbtBufferDelayPreferred->setEnabled ( pClient->GetFraSiFactPrefSupported() ); - rbtBufferDelayDefault->setEnabled ( pClient->GetFraSiFactDefSupported() ); - rbtBufferDelaySafe->setEnabled ( pClient->GetFraSiFactSafeSupported() ); + rbtBufferDelayDefault->setEnabled ( pClient->GetFraSiFactDefSupported() ); + rbtBufferDelaySafe->setEnabled ( pClient->GetFraSiFactSafeSupported() ); // If any of our predefined sizes is chosen, use the regular group box // title text. If not, show the actual buffer size. Otherwise the user @@ -779,8 +807,7 @@ void CClientSettingsDlg::UpdateSoundCardFrame() else { // special title text with buffer size information added - grbSoundCrdBufDelay->setTitle ( tr ( "Buffer Delay: " ) + - GenSndCrdBufferDelayString ( iCurActualBufSize ) ); + grbSoundCrdBufDelay->setTitle ( tr ( "Buffer Delay: " ) + GenSndCrdBufferDelayString ( iCurActualBufSize ) ); } } @@ -798,7 +825,7 @@ void CClientSettingsDlg::UpdateSoundDeviceChannelSelectionFrame() cbxSoundcard->setCurrentText ( pClient->GetSndCrdDev() ); // update input/output channel selection -#if defined ( _WIN32 ) || defined ( __APPLE__ ) || defined ( __MACOSX ) +#if defined( _WIN32 ) || defined( __APPLE__ ) || defined( __MACOSX ) int iSndChanIdx; // Definition: The channel selection frame shall only be visible, @@ -853,14 +880,10 @@ void CClientSettingsDlg::UpdateSoundDeviceChannelSelectionFrame() void CClientSettingsDlg::SetEnableFeedbackDetection ( bool enable ) { pSettings->bEnableFeedbackDetection = enable; - chbDetectFeedback->setCheckState ( pSettings->bEnableFeedbackDetection ? - Qt::Checked : Qt::Unchecked ); + chbDetectFeedback->setCheckState ( pSettings->bEnableFeedbackDetection ? Qt::Checked : Qt::Unchecked ); } -void CClientSettingsDlg::OnDriverSetupClicked() -{ - pClient->OpenSndCrdDriverSetup(); -} +void CClientSettingsDlg::OnDriverSetupClicked() { pClient->OpenSndCrdDriverSetup(); } void CClientSettingsDlg::OnNetBufValueChanged ( int value ) { @@ -938,10 +961,7 @@ void CClientSettingsDlg::OnEnableOPUS64StateChanged ( int value ) UpdateDisplay(); } -void CClientSettingsDlg::OnFeedbackDetectionChanged ( int value ) -{ - pSettings->bEnableFeedbackDetection = value == Qt::Checked; -} +void CClientSettingsDlg::OnFeedbackDetectionChanged ( int value ) { pSettings->bEnableFeedbackDetection = value == Qt::Checked; } void CClientSettingsDlg::OnCentralServerAddressEditingFinished() { @@ -983,31 +1003,29 @@ void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton UpdateDisplay(); } -void CClientSettingsDlg::SetPingTimeResult ( const int iPingTime, - const int iOverallDelayMs, - const CMultiColorLED::ELightColor eOverallDelayLEDColor ) +void CClientSettingsDlg::SetPingTimeResult ( const int iPingTime, const int iOverallDelayMs, const CMultiColorLED::ELightColor eOverallDelayLEDColor ) { // apply values to GUI labels, take special care if ping time exceeds // a certain value if ( iPingTime > 500 ) { const QString sErrorText = ">500 ms"; - lblPingTimeValue->setText ( sErrorText ); + lblPingTimeValue->setText ( sErrorText ); lblOverallDelayValue->setText ( sErrorText ); } else { - lblPingTimeValue->setText ( QString().setNum ( iPingTime ) ); - lblPingTimeUnit->setText ( "ms" ); + lblPingTimeValue->setText ( QString().setNum ( iPingTime ) ); + lblPingTimeUnit->setText ( "ms" ); lblOverallDelayValue->setText ( QString().setNum ( iOverallDelayMs ) ); - lblOverallDelayUnit->setText ( "ms" ); + lblOverallDelayUnit->setText ( "ms" ); } // update upstream rate information label (note that we update this together // with the ping time since the network packet sequence number feature might // be enabled at any time which has influence on the upstream rate) lblUpstreamValue->setText ( QString().setNum ( pClient->GetUploadRateKbps() ) ); - lblUpstreamUnit->setText ( "kbps" ); + lblUpstreamUnit->setText ( "kbps" ); // set current LED status ledOverallDelay->SetLight ( eOverallDelayLEDColor ); @@ -1022,12 +1040,12 @@ void CClientSettingsDlg::UpdateDisplay() if ( !pClient->IsRunning() ) { // clear text labels with client parameters - lblPingTimeValue->setText ( "---" ); - lblPingTimeUnit->setText ( "" ); + lblPingTimeValue->setText ( "---" ); + lblPingTimeUnit->setText ( "" ); lblOverallDelayValue->setText ( "---" ); - lblOverallDelayUnit->setText ( "" ); - lblUpstreamValue->setText ( "---" ); - lblUpstreamUnit->setText ( "" ); + lblOverallDelayUnit->setText ( "" ); + lblUpstreamValue->setText ( "---" ); + lblUpstreamUnit->setText ( "" ); } } @@ -1074,8 +1092,7 @@ void CClientSettingsDlg::OnAliasTextChanged ( const QString& strNewName ) void CClientSettingsDlg::OnInstrumentActivated ( int iCntryListItem ) { // set the new value in the data base - pClient->ChannelInfo.iInstrument = - pcbxInstrument->itemData ( iCntryListItem ).toInt(); + pClient->ChannelInfo.iInstrument = pcbxInstrument->itemData ( iCntryListItem ).toInt(); // update channel info at the server pClient->SetRemoteInfo(); @@ -1084,8 +1101,7 @@ void CClientSettingsDlg::OnInstrumentActivated ( int iCntryListItem ) void CClientSettingsDlg::OnCountryActivated ( int iCntryListItem ) { // set the new value in the data base - pClient->ChannelInfo.eCountry = static_cast ( - pcbxCountry->itemData ( iCntryListItem ).toInt() ); + pClient->ChannelInfo.eCountry = static_cast ( pcbxCountry->itemData ( iCntryListItem ).toInt() ); // update channel info at the server pClient->SetRemoteInfo(); @@ -1112,8 +1128,7 @@ void CClientSettingsDlg::OnCityTextChanged ( const QString& strNewCity ) void CClientSettingsDlg::OnSkillActivated ( int iCntryListItem ) { // set the new value in the data base - pClient->ChannelInfo.eSkillLevel = static_cast ( - pcbxSkill->itemData ( iCntryListItem ).toInt() ); + pClient->ChannelInfo.eSkillLevel = static_cast ( pcbxSkill->itemData ( iCntryListItem ).toInt() ); // update channel info at the server pClient->SetRemoteInfo(); @@ -1126,10 +1141,7 @@ void CClientSettingsDlg::OnMakeTabChange ( int iTab ) pSettings->iSettingsTab = iTab; } -void CClientSettingsDlg::OnTabChanged ( void ) -{ - pSettings->iSettingsTab = tabSettings->currentIndex(); -} +void CClientSettingsDlg::OnTabChanged ( void ) { pSettings->iSettingsTab = tabSettings->currentIndex(); } void CClientSettingsDlg::UpdateAudioFaderSlider() { @@ -1148,14 +1160,12 @@ void CClientSettingsDlg::UpdateAudioFaderSlider() if ( iCurAudInFader > AUD_FADER_IN_MIDDLE ) { // attenuation on right channel - lblAudioPanValue->setText ( tr ( "L" ) + " -" + - QString().setNum ( iCurAudInFader - AUD_FADER_IN_MIDDLE ) ); + lblAudioPanValue->setText ( tr ( "L" ) + " -" + QString().setNum ( iCurAudInFader - AUD_FADER_IN_MIDDLE ) ); } else { // attenuation on left channel - lblAudioPanValue->setText ( tr ( "R" ) + " -" + - QString().setNum ( AUD_FADER_IN_MIDDLE - iCurAudInFader ) ); + lblAudioPanValue->setText ( tr ( "R" ) + " -" + QString().setNum ( AUD_FADER_IN_MIDDLE - iCurAudInFader ) ); } } } diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h old mode 100755 new mode 100644 index cf9bd3019b..555923d4d7 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -44,11 +44,9 @@ #include "multicolorled.h" #include "ui_clientsettingsdlgbase.h" - /* Definitions ****************************************************************/ // update time for GUI controls -#define DISPLAY_UPDATE_TIME 1000 // ms - +#define DISPLAY_UPDATE_TIME 1000 // ms /* Classes ********************************************************************/ class CClientSettingsDlg : public CBaseDlg, private Ui_CClientSettingsDlgBase @@ -56,9 +54,7 @@ class CClientSettingsDlg : public CBaseDlg, private Ui_CClientSettingsDlgBase Q_OBJECT public: - CClientSettingsDlg ( CClient* pNCliP, - CClientSettings* pNSetP, - QWidget* parent = nullptr ); + CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSetP, QWidget* parent = nullptr ); void SetStatus ( const CMultiColorLED::ELightColor eStatus ) { ledNetw->SetLight ( eStatus ); } @@ -68,9 +64,7 @@ class CClientSettingsDlg : public CBaseDlg, private Ui_CClientSettingsDlgBase ledOverallDelay->Reset(); } - void SetPingTimeResult ( const int iPingTime, - const int iOverallDelayMs, - const CMultiColorLED::ELightColor eOverallDelayLEDColor ); + void SetPingTimeResult ( const int iPingTime, const int iOverallDelayMs, const CMultiColorLED::ELightColor eOverallDelayLEDColor ); void UpdateDisplay(); void UpdateSoundDeviceChannelSelectionFrame(); @@ -82,8 +76,7 @@ class CClientSettingsDlg : public CBaseDlg, private Ui_CClientSettingsDlgBase void UpdateSoundCardFrame(); void UpdateCustomCentralServerComboBox(); void UpdateAudioFaderSlider(); - QString GenSndCrdBufferDelayString ( const int iFrameSize, - const QString strAddText = "" ); + QString GenSndCrdBufferDelayString ( const int iFrameSize, const QString strAddText = "" ); virtual void showEvent ( QShowEvent* ); diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp old mode 100755 new mode 100644 index 6860bfb00e..4f6d04a59c --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -8,68 +8,65 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ #include "connectdlg.h" - /* Implementation *************************************************************/ -CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, - const bool bNewShowCompleteRegList, - QWidget* parent ) - : CBaseDlg ( parent, Qt::Dialog ), - pSettings ( pNSetP ), - strSelectedAddress ( "" ), - strSelectedServerName ( "" ), - bShowCompleteRegList ( bNewShowCompleteRegList ), - bServerListReceived ( false ), - bReducedServerListReceived ( false ), - bServerListItemWasChosen ( false ), - bListFilterWasActive ( false ), - bShowAllMusicians ( true ) +CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteRegList, QWidget* parent ) : + CBaseDlg ( parent, Qt::Dialog ), + pSettings ( pNSetP ), + strSelectedAddress ( "" ), + strSelectedServerName ( "" ), + bShowCompleteRegList ( bNewShowCompleteRegList ), + bServerListReceived ( false ), + bReducedServerListReceived ( false ), + bServerListItemWasChosen ( false ), + bListFilterWasActive ( false ), + bShowAllMusicians ( true ) { setupUi ( this ); - // Add help text to controls ----------------------------------------------- // server list - lvwServers->setWhatsThis ( "" + tr ( "Server List" ) + ": " + tr ( - "The Connection Setup window shows a list of available servers. " - "Server operators can optionally list their servers by music genre. " - "Use the List dropdown to select a genre, click on the server you want " - "to join and press the Connect button to connect to it. Alternatively, " - "double click on on the server name. Permanent servers (those that have " - "been listed for longer than 48 hours) are shown in bold." ) ); + lvwServers->setWhatsThis ( "" + tr ( "Server List" ) + ": " + + tr ( "The Connection Setup window shows a list of available servers. " + "Server operators can optionally list their servers by music genre. " + "Use the List dropdown to select a genre, click on the server you want " + "to join and press the Connect button to connect to it. Alternatively, " + "double click on on the server name. Permanent servers (those that have " + "been listed for longer than 48 hours) are shown in bold." ) ); lvwServers->setAccessibleName ( tr ( "Server list view" ) ); // server address - QString strServAddrH = "" + tr ( "Server Address" ) + ": " + tr ( - "If you know the IP address or URL of a server, you can connect to it " - "using the Server name/Address field. An optional port number can be added after the IP " - "address or URL using a colon as a separator, e.g, " - "example.org:" ) + - QString().setNum ( DEFAULT_PORT_NUMBER ) + tr ( ". The field will " - "also show a list of the most recently used server addresses."); + QString strServAddrH = "" + tr ( "Server Address" ) + ": " + + tr ( "If you know the IP address or URL of a server, you can connect to it " + "using the Server name/Address field. An optional port number can be added after the IP " + "address or URL using a colon as a separator, e.g, " + "example.org:" ) + + QString().setNum ( DEFAULT_PORT_NUMBER ) + + tr ( ". The field will " + "also show a list of the most recently used server addresses." ); lblServerAddr->setWhatsThis ( strServAddrH ); cbxServerAddr->setWhatsThis ( strServAddrH ); - cbxServerAddr->setAccessibleName ( tr ( "Server address edit box" ) ); + cbxServerAddr->setAccessibleName ( tr ( "Server address edit box" ) ); cbxServerAddr->setAccessibleDescription ( tr ( "Holds the current server " - "IP address or URL. It also stores old URLs in the combo box list." ) ); + "IP address or URL. It also stores old URLs in the combo box list." ) ); // directory server address type combo box cbxCentServAddrType->clear(); @@ -82,23 +79,23 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, cbxCentServAddrType->addItem ( csCentServAddrTypeToString ( AT_GENRE_CHORAL ) ); cbxCentServAddrType->addItem ( csCentServAddrTypeToString ( AT_CUSTOM ) ); - cbxCentServAddrType->setWhatsThis ( "" + tr ( "Server List Selection" ) + ": " + tr ( - "Selects the server list to be shown." ) ); + cbxCentServAddrType->setWhatsThis ( "" + tr ( "Server List Selection" ) + ": " + tr ( "Selects the server list to be shown." ) ); cbxCentServAddrType->setAccessibleName ( tr ( "Server list selection combo box" ) ); // filter - edtFilter->setWhatsThis ( "" + tr ( "Filter" ) + ": " + tr ( "The server " - "list is filtered by the given text. Note that the filter is case insensitive." ) ); + edtFilter->setWhatsThis ( "" + tr ( "Filter" ) + ": " + + tr ( "The server " + "list is filtered by the given text. Note that the filter is case insensitive." ) ); edtFilter->setAccessibleName ( tr ( "Filter edit box" ) ); // show all mucisians - chbExpandAll->setWhatsThis ( "" + tr ( "Show All Musicians" ) + ": " + tr ( - "If you check this check box, the musicians of all servers are shown. If you " - "uncheck the check box, all list view items are collapsed.") ); + chbExpandAll->setWhatsThis ( "" + tr ( "Show All Musicians" ) + ": " + + tr ( "If you check this check box, the musicians of all servers are shown. If you " + "uncheck the check box, all list view items are collapsed." ) ); chbExpandAll->setAccessibleName ( tr ( "Show all musicians check box" ) ); // init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries) - cbxServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS ); + cbxServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS ); cbxServerAddr->setInsertPolicy ( QComboBox::NoInsert ); // set up list view for connected clients (note that the last column size @@ -155,44 +152,36 @@ CConnectDlg::CConnectDlg ( CClientSettings* pNSetP, setWindowState ( Qt::WindowMaximized ); #endif - // Connections ------------------------------------------------------------- // list view - QObject::connect ( lvwServers, &QTreeWidget::itemDoubleClicked, - this, &CConnectDlg::OnServerListItemDoubleClicked ); + QObject::connect ( lvwServers, &QTreeWidget::itemDoubleClicked, this, &CConnectDlg::OnServerListItemDoubleClicked ); // to get default return key behaviour working - QObject::connect ( lvwServers, &QTreeWidget::activated, - this, &CConnectDlg::OnConnectClicked ); + QObject::connect ( lvwServers, &QTreeWidget::activated, this, &CConnectDlg::OnConnectClicked ); // line edit - QObject::connect ( edtFilter, &QLineEdit::textEdited, - this, &CConnectDlg::OnFilterTextEdited ); + QObject::connect ( edtFilter, &QLineEdit::textEdited, this, &CConnectDlg::OnFilterTextEdited ); // combo boxes - QObject::connect ( cbxServerAddr, &QComboBox::editTextChanged, - this, &CConnectDlg::OnServerAddrEditTextChanged ); + QObject::connect ( cbxServerAddr, &QComboBox::editTextChanged, this, &CConnectDlg::OnServerAddrEditTextChanged ); - QObject::connect ( cbxCentServAddrType, static_cast ( &QComboBox::activated ), - this, &CConnectDlg::OnCentServAddrTypeChanged ); + QObject::connect ( cbxCentServAddrType, + static_cast ( &QComboBox::activated ), + this, + &CConnectDlg::OnCentServAddrTypeChanged ); // check boxes - QObject::connect ( chbExpandAll, &QCheckBox::stateChanged, - this, &CConnectDlg::OnExpandAllStateChanged ); + QObject::connect ( chbExpandAll, &QCheckBox::stateChanged, this, &CConnectDlg::OnExpandAllStateChanged ); // buttons - QObject::connect ( butCancel, &QPushButton::clicked, - this, &CConnectDlg::close ); + QObject::connect ( butCancel, &QPushButton::clicked, this, &CConnectDlg::close ); - QObject::connect ( butConnect, &QPushButton::clicked, - this, &CConnectDlg::OnConnectClicked ); + QObject::connect ( butConnect, &QPushButton::clicked, this, &CConnectDlg::OnConnectClicked ); // timers - QObject::connect ( &TimerPing, &QTimer::timeout, - this, &CConnectDlg::OnTimerPing ); + QObject::connect ( &TimerPing, &QTimer::timeout, this, &CConnectDlg::OnTimerPing ); - QObject::connect ( &TimerReRequestServList, &QTimer::timeout, - this, &CConnectDlg::OnTimerReRequestServList ); + QObject::connect ( &TimerReRequestServList, &QTimer::timeout, this, &CConnectDlg::OnTimerReRequestServList ); } void CConnectDlg::showEvent ( QShowEvent* ) @@ -238,9 +227,9 @@ void CConnectDlg::RequestServerList() // function) when the connect dialog is opened, this seems to be the correct // time to do it. Note that in case of custom directory server address we // use the first entry in the vector per definition. - if ( NetworkUtil().ParseNetworkAddress ( NetworkUtil::GetCentralServerAddress ( pSettings->eCentralServerAddressType, - pSettings->vstrCentralServerAddress[0] ), - CentralServerAddress ) ) + if ( NetworkUtil().ParseNetworkAddress ( + NetworkUtil::GetCentralServerAddress ( pSettings->eCentralServerAddressType, pSettings->vstrCentralServerAddress[0] ), + CentralServerAddress ) ) { // send the request for the server list emit ReqServerListQuery ( CentralServerAddress ); @@ -278,17 +267,14 @@ void CConnectDlg::OnTimerReRequestServList() } } -void CConnectDlg::SetServerList ( const CHostAddress& InetAddr, - const CVector& vecServerInfo, - const bool bIsReducedServerList ) +void CConnectDlg::SetServerList ( const CHostAddress& InetAddr, const CVector& vecServerInfo, const bool bIsReducedServerList ) { // If the normal list was received, we do not accept any further list // updates (to avoid the reduced list overwrites the normal list (#657)). Also, // we only accept a server list from the server address we have sent the // request for this to (note that we cannot use the port number since the // receive port and send port might be different at the directory server). - if ( bServerListReceived || - ( InetAddr.InetAddr != CentralServerAddress.InetAddr ) ) + if ( bServerListReceived || ( InetAddr.InetAddr != CentralServerAddress.InetAddr ) ) { return; } @@ -389,8 +375,7 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr, // server location (city and country) QString strLocation = vecServerInfo[iIdx].strCity; - if ( ( !strLocation.isEmpty() ) && - ( vecServerInfo[iIdx].eCountry != QLocale::AnyCountry ) ) + if ( ( !strLocation.isEmpty() ) && ( vecServerInfo[iIdx].eCountry != QLocale::AnyCountry ) ) { strLocation += ", "; } @@ -402,7 +387,7 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr, // Qt countryToString does not use spaces in between country name // parts but they use upper case letters which we can detect and // insert spaces as a post processing -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) if ( !strCountryToString.contains ( " " ) ) { QRegularExpressionMatchIterator reMatchIt = QRegularExpression ( "[A-Z][^A-Z]*" ).globalMatch ( strCountryToString ); @@ -443,8 +428,7 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr, TimerPing.start ( PING_UPDATE_TIME_SERVER_LIST_MS ); } -void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, - const CVector& vecChanInfo ) +void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, const CVector& vecChanInfo ) { // find the server with the correct address QTreeWidgetItem* pCurListViewItem = FindListViewItem ( InetAddr ); @@ -460,8 +444,7 @@ void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, for ( int i = 0; i < iNumConnectedClients; i++ ) { // create new list view item - QTreeWidgetItem* pNewChildListViewItem = - new QTreeWidgetItem ( pCurListViewItem ); + QTreeWidgetItem* pNewChildListViewItem = new QTreeWidgetItem ( pCurListViewItem ); // child items shall use only one column pNewChildListViewItem->setFirstColumnSpanned ( true ); @@ -475,8 +458,7 @@ void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, if ( vecChanInfo[i].eCountry != QLocale::AnyCountry ) { // try to load the country flag icon - QPixmap CountryFlagPixmap ( - CLocale::GetCountryFlagIconsResourceReference ( vecChanInfo[i].eCountry ) ); + QPixmap CountryFlagPixmap ( CLocale::GetCountryFlagIconsResourceReference ( vecChanInfo[i].eCountry ) ); // first check if resource reference was valid if ( !CountryFlagPixmap.isNull() ) @@ -491,12 +473,10 @@ void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, if ( !bCountryFlagIsUsed ) { // get the resource reference string for this instrument - const QString strCurResourceRef = - CInstPictures::GetResourceReference ( vecChanInfo[i].iInstrument ); + const QString strCurResourceRef = CInstPictures::GetResourceReference ( vecChanInfo[i].iInstrument ); // first check if instrument picture is used or not and if it is valid - if ( !( CInstPictures::IsNotUsedInstrument ( vecChanInfo[i].iInstrument ) || - strCurResourceRef.isEmpty() ) ) + if ( !( CInstPictures::IsNotUsedInstrument ( vecChanInfo[i].iInstrument ) || strCurResourceRef.isEmpty() ) ) { // set correct picture pNewChildListViewItem->setIcon ( 0, QIcon ( QPixmap ( strCurResourceRef ) ) ); @@ -506,8 +486,7 @@ void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, // add the instrument information as text if ( !CInstPictures::IsNotUsedInstrument ( vecChanInfo[i].iInstrument ) ) { - sClientText.append ( " (" + - CInstPictures::GetName ( vecChanInfo[i].iInstrument ) + ")" ); + sClientText.append ( " (" + CInstPictures::GetName ( vecChanInfo[i].iInstrument ) + ")" ); } // apply the client text to the list view item @@ -526,8 +505,7 @@ void CConnectDlg::SetConnClientsList ( const CHostAddress& InetAddr, } } -void CConnectDlg::OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, - int ) +void CConnectDlg::OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, int ) { // if a server list item was double clicked, it is the same as if the // connect button was clicked @@ -568,8 +546,7 @@ void CConnectDlg::ShowAllMusicians ( const bool bState ) } // update check box if necessary - if ( ( chbExpandAll->checkState() == Qt::Checked && !bShowAllMusicians ) || - ( chbExpandAll->checkState() == Qt::Unchecked && bShowAllMusicians ) ) + if ( ( chbExpandAll->checkState() == Qt::Checked && !bShowAllMusicians ) || ( chbExpandAll->checkState() == Qt::Unchecked && bShowAllMusicians ) ) { chbExpandAll->setCheckState ( bState ? Qt::Checked : Qt::Unchecked ); } @@ -628,8 +605,7 @@ void CConnectDlg::UpdateListFilter() { // only update hide and expand status if the hide state has to be changed to // preserve if user clicked on expand icon manually - if ( ( pCurListViewItem->isHidden() && bFilterFound ) || - ( !pCurListViewItem->isHidden() && !bFilterFound ) ) + if ( ( pCurListViewItem->isHidden() && bFilterFound ) || ( !pCurListViewItem->isHidden() && !bFilterFound ) ) { pCurListViewItem->setHidden ( !bFilterFound ); pCurListViewItem->setExpanded ( bShowAllMusicians ); @@ -680,12 +656,10 @@ void CConnectDlg::OnConnectClicked() if ( CurSelListItemList.count() > 0 ) { // get the parent list view item - QTreeWidgetItem* pCurSelTopListItem = - GetParentListViewItem ( CurSelListItemList[0] ); + QTreeWidgetItem* pCurSelTopListItem = GetParentListViewItem ( CurSelListItemList[0] ); // get host address from selected list view item as a string - strSelectedAddress = - pCurSelTopListItem->data ( 0, Qt::UserRole ).toString(); + strSelectedAddress = pCurSelTopListItem->data ( 0, Qt::UserRole ).toString(); // store selected server name strSelectedServerName = pCurSelTopListItem->text ( 0 ); @@ -713,15 +687,10 @@ void CConnectDlg::OnTimerPing() // try to parse host address string which is stored as user data // in the server list item GUI control element - if ( NetworkUtil().ParseNetworkAddress ( - lvwServers->topLevelItem ( iIdx )-> - data ( 0, Qt::UserRole ).toString(), - CurServerAddress ) ) + if ( NetworkUtil().ParseNetworkAddress ( lvwServers->topLevelItem ( iIdx )->data ( 0, Qt::UserRole ).toString(), CurServerAddress ) ) { // if address is valid, send ping message using a new thread - QtConcurrent::run ( this, - &CConnectDlg::EmitCLServerListPingMes, - CurServerAddress ); + QtConcurrent::run ( this, &CConnectDlg::EmitCLServerListPingMes, CurServerAddress ); } } } @@ -738,9 +707,7 @@ void CConnectDlg::EmitCLServerListPingMes ( const CHostAddress& CurServerAddress emit CreateCLServerListPingMes ( CurServerAddress ); } -void CConnectDlg::SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr, - const int iPingTime, - const int iNumClients ) +void CConnectDlg::SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr, const int iPingTime, const int iNumClients ) { // apply the received ping time to the correct server list entry QTreeWidgetItem* pCurListViewItem = FindListViewItem ( InetAddr ); @@ -762,8 +729,7 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr, // we pad to a total of 8 characters with zeros to make sure the // sorting is done correctly - pCurListViewItem->setText ( 4, QString ( "%1" ).arg ( - iPingTime, 8, 10, QLatin1Char ( '0' ) ) ); + pCurListViewItem->setText ( 4, QString ( "%1" ).arg ( iPingTime, 8, 10, QLatin1Char ( '0' ) ) ); // update the sorting (lowest number on top) bDoSorting = true; @@ -805,8 +771,7 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr, { // prepend spaces so that we can sort correctly (fieldWidth of // 4 is sufficient since the maximum width is ">500") (#201) - pCurListViewItem-> - setText ( 1, QString ( "%1 ms" ).arg ( iMinPingTime, 4, 10, QLatin1Char ( ' ' ) ) ); + pCurListViewItem->setText ( 1, QString ( "%1 ms" ).arg ( iMinPingTime, 4, 10, QLatin1Char ( ' ' ) ) ); } // update number of clients text @@ -843,7 +808,8 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr, // could lead to connecting an incorrect server) the sorting is disabled // as long as the mouse is over the list (but it is not disabled for the // initial timer of about 2s, see TimerInitialSort) (#293). - if ( bDoSorting && !bShowCompleteRegList && (TimerInitialSort.isActive() || !lvwServers->underMouse()) ) // do not sort if "show all servers" + if ( bDoSorting && !bShowCompleteRegList && + ( TimerInitialSort.isActive() || !lvwServers->underMouse() ) ) // do not sort if "show all servers" { lvwServers->sortByColumn ( 4, Qt::AscendingOrder ); } @@ -880,9 +846,7 @@ QTreeWidgetItem* CConnectDlg::FindListViewItem ( const CHostAddress& InetAddr ) { // compare the received address with the user data string of the // host address by a string compare - if ( !lvwServers->topLevelItem ( iIdx )-> - data ( 0, Qt::UserRole ).toString(). - compare ( InetAddr.toString() ) ) + if ( !lvwServers->topLevelItem ( iIdx )->data ( 0, Qt::UserRole ).toString().compare ( InetAddr.toString() ) ) { return lvwServers->topLevelItem ( iIdx ); } diff --git a/src/connectdlg.h b/src/connectdlg.h old mode 100755 new mode 100644 index bf4e255dde..5a4e975d24 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -37,12 +37,10 @@ #include "multicolorled.h" #include "ui_connectdlgbase.h" - /* Definitions ****************************************************************/ // defines the time interval at which the request server list message is re- // transmitted until it is received -#define SERV_LIST_REQ_UPDATE_TIME_MS 2000 // ms - +#define SERV_LIST_REQ_UPDATE_TIME_MS 2000 // ms /* Classes ********************************************************************/ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase @@ -50,23 +48,16 @@ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase Q_OBJECT public: - CConnectDlg ( CClientSettings* pNSetP, - const bool bNewShowCompleteRegList, - QWidget* parent = nullptr ); + CConnectDlg ( CClientSettings* pNSetP, const bool bNewShowCompleteRegList, QWidget* parent = nullptr ); void SetShowAllMusicians ( const bool bState ) { ShowAllMusicians ( bState ); } bool GetShowAllMusicians() { return bShowAllMusicians; } - void SetServerList ( const CHostAddress& InetAddr, - const CVector& vecServerInfo, - const bool bIsReducedServerList = false ); + void SetServerList ( const CHostAddress& InetAddr, const CVector& vecServerInfo, const bool bIsReducedServerList = false ); - void SetConnClientsList ( const CHostAddress& InetAddr, - const CVector& vecChanInfo ); + void SetConnClientsList ( const CHostAddress& InetAddr, const CVector& vecChanInfo ); - void SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr, - const int iPingTime, - const int iNumClients ); + void SetPingTimeAndNumClientsResult ( const CHostAddress& InetAddr, const int iPingTime, const int iNumClients ); bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; } QString GetSelectedAddress() const { return strSelectedAddress; } @@ -86,18 +77,18 @@ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase CClientSettings* pSettings; - QTimer TimerPing; - QTimer TimerReRequestServList; - QTimer TimerInitialSort; - CHostAddress CentralServerAddress; - QString strSelectedAddress; - QString strSelectedServerName; - bool bShowCompleteRegList; - bool bServerListReceived; - bool bReducedServerListReceived; - bool bServerListItemWasChosen; - bool bListFilterWasActive; - bool bShowAllMusicians; + QTimer TimerPing; + QTimer TimerReRequestServList; + QTimer TimerInitialSort; + CHostAddress CentralServerAddress; + QString strSelectedAddress; + QString strSelectedServerName; + bool bShowCompleteRegList; + bool bServerListReceived; + bool bReducedServerListReceived; + bool bServerListItemWasChosen; + bool bListFilterWasActive; + bool bShowAllMusicians; public slots: void OnServerListItemDoubleClicked ( QTreeWidgetItem* Item, int ); diff --git a/src/global.h b/src/global.h old mode 100755 new mode 100644 index 85f8ef2542..63222b4eee --- a/src/global.h +++ b/src/global.h @@ -33,7 +33,7 @@ LED bar: lbr * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT @@ -50,7 +50,7 @@ LED bar: lbr #pragma once #if _WIN32 -# define _CRT_SECURE_NO_WARNINGS +# define _CRT_SECURE_NO_WARNINGS #endif #include @@ -60,13 +60,12 @@ LED bar: lbr #include #include #ifndef _WIN32 -# include // solves a compile problem on recent Ubuntu +# include // solves a compile problem on recent Ubuntu #endif #ifdef HAVE_CONFIG_H -# include "config.h" +# include "config.h" #endif - /* Definitions ****************************************************************/ // define this macro to get debug output //#define _DEBUG_ @@ -74,18 +73,18 @@ LED bar: lbr // version and application name (use version from qt prject file) #undef VERSION -#define VERSION APP_VERSION -#define APP_NAME "Jamulus" +#define VERSION APP_VERSION +#define APP_NAME "Jamulus" // Windows registry key name of auto run entry for the server -#define AUTORUN_SERVER_REG_NAME "Jamulus server" +#define AUTORUN_SERVER_REG_NAME "Jamulus server" // default names of the ini-file for client and server -#define DEFAULT_INI_FILE_NAME "Jamulus.ini" -#define DEFAULT_INI_FILE_NAME_SERVER "Jamulusserver.ini" +#define DEFAULT_INI_FILE_NAME "Jamulus.ini" +#define DEFAULT_INI_FILE_NAME_SERVER "Jamulusserver.ini" // file name for logging file -#define DEFAULT_LOG_FILE_NAME "Jamulussrvlog.txt" +#define DEFAULT_LOG_FILE_NAME "Jamulussrvlog.txt" // System block size, this is the block size on which the audio coder works. // All other block sizes must be a multiple of this size. @@ -94,201 +93,201 @@ LED bar: lbr #define DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ( 2 * SYSTEM_FRAME_SIZE_SAMPLES ) // additional buffer for delay panning -#define MAX_DELAY_PANNING_SAMPLES 64 +#define MAX_DELAY_PANNING_SAMPLES 64 // default server address and port numbers -#define DEFAULT_QOS_NUMBER 128 // CS4 (Quality of Service) -#define DEFAULT_SERVER_ADDRESS "anygenre1.jamulus.io" -#define DEFAULT_PORT_NUMBER 22124 -#define CENTSERV_ANY_GENRE2 "anygenre2.jamulus.io:22224" -#define CENTSERV_ANY_GENRE3 "anygenre3.jamulus.io:22624" -#define CENTSERV_GENRE_ROCK "rock.jamulus.io:22424" -#define CENTSERV_GENRE_JAZZ "jazz.jamulus.io:22324" -#define CENTSERV_GENRE_CLASSICAL_FOLK "classical.jamulus.io:22524" -#define CENTSERV_GENRE_CHORAL "choral.jamulus.io:22724" +#define DEFAULT_QOS_NUMBER 128 // CS4 (Quality of Service) +#define DEFAULT_SERVER_ADDRESS "anygenre1.jamulus.io" +#define DEFAULT_PORT_NUMBER 22124 +#define CENTSERV_ANY_GENRE2 "anygenre2.jamulus.io:22224" +#define CENTSERV_ANY_GENRE3 "anygenre3.jamulus.io:22624" +#define CENTSERV_GENRE_ROCK "rock.jamulus.io:22424" +#define CENTSERV_GENRE_JAZZ "jazz.jamulus.io:22324" +#define CENTSERV_GENRE_CLASSICAL_FOLK "classical.jamulus.io:22524" +#define CENTSERV_GENRE_CHORAL "choral.jamulus.io:22724" // servers to check for new versions -#define UPDATECHECK1_ADDRESS "updatecheck1.jamulus.io" -#define UPDATECHECK2_ADDRESS "updatecheck2.jamulus.io" +#define UPDATECHECK1_ADDRESS "updatecheck1.jamulus.io" +#define UPDATECHECK2_ADDRESS "updatecheck2.jamulus.io" // getting started and software manual URL -#define CLIENT_GETTING_STARTED_URL "https://jamulus.io/wiki/Getting-Started" -#define SERVER_GETTING_STARTED_URL "https://jamulus.io/wiki/Running-a-Server" -#define SOFTWARE_MANUAL_URL "https://jamulus.io/wiki/Software-Manual" +#define CLIENT_GETTING_STARTED_URL "https://jamulus.io/wiki/Getting-Started" +#define SERVER_GETTING_STARTED_URL "https://jamulus.io/wiki/Running-a-Server" +#define SOFTWARE_MANUAL_URL "https://jamulus.io/wiki/Software-Manual" // determining server internal address uses well-known host and port // We just need a valid, public Internet IP here. We will not send any // traffic there as we will only set up an UDP socket without sending any // data. -#define WELL_KNOWN_HOST "1.1.1.1" // CloudFlare -#define WELL_KNOWN_PORT DEFAULT_PORT_NUMBER -#define IP_LOOKUP_TIMEOUT 500 // ms +#define WELL_KNOWN_HOST "1.1.1.1" // CloudFlare +#define WELL_KNOWN_PORT DEFAULT_PORT_NUMBER +#define IP_LOOKUP_TIMEOUT 500 // ms // system sample rate (the sound card and audio coder works on this sample rate) -#define SYSTEM_SAMPLE_RATE_HZ 48000 // Hz +#define SYSTEM_SAMPLE_RATE_HZ 48000 // Hz // define the allowed audio frame size factors (since the // "SYSTEM_FRAME_SIZE_SAMPLES" is quite small, it may be that on some // computers a larger value is required) -#define FRAME_SIZE_FACTOR_PREFERRED 1 // 64 samples accumulated frame size -#define FRAME_SIZE_FACTOR_DEFAULT 2 // 128 samples accumulated frame size -#define FRAME_SIZE_FACTOR_SAFE 4 // 256 samples accumulated frame size +#define FRAME_SIZE_FACTOR_PREFERRED 1 // 64 samples accumulated frame size +#define FRAME_SIZE_FACTOR_DEFAULT 2 // 128 samples accumulated frame size +#define FRAME_SIZE_FACTOR_SAFE 4 // 256 samples accumulated frame size // define the minimum allowed number of coded bytes for CELT (the encoder // gets in trouble if the value is too low) -#define CELT_MINIMUM_NUM_BYTES 10 +#define CELT_MINIMUM_NUM_BYTES 10 // Maximum block size for network input buffer. It is defined by the longest // protocol message which is PROTMESSID_CLM_SERVER_LIST: Worst case: // (2+2+1+2+2)+200*(4+2+2+1+1+2+20+2+32+2+20)=17609 // We add some headroom to that value. -#define MAX_SIZE_BYTES_NETW_BUF 20000 +#define MAX_SIZE_BYTES_NETW_BUF 20000 // minimum/maximum network buffer size (which can be chosen by slider) -#define MIN_NET_BUF_SIZE_NUM_BL 1 // number of blocks -#define MAX_NET_BUF_SIZE_NUM_BL 20 // number of blocks -#define AUTO_NET_BUF_SIZE_FOR_PROTOCOL ( MAX_NET_BUF_SIZE_NUM_BL + 1 ) // auto set parameter (only used for protocol) +#define MIN_NET_BUF_SIZE_NUM_BL 1 // number of blocks +#define MAX_NET_BUF_SIZE_NUM_BL 20 // number of blocks +#define AUTO_NET_BUF_SIZE_FOR_PROTOCOL ( MAX_NET_BUF_SIZE_NUM_BL + 1 ) // auto set parameter (only used for protocol) // default network buffer size -#define DEF_NET_BUF_SIZE_NUM_BL 10 // number of blocks +#define DEF_NET_BUF_SIZE_NUM_BL 10 // number of blocks // audio mixer fader and panning maximum value -#define AUD_MIX_FADER_MAX 100 -#define AUD_MIX_PAN_MAX 100 +#define AUD_MIX_FADER_MAX 100 +#define AUD_MIX_PAN_MAX 100 // range of audio mixer fader -#define AUD_MIX_FADER_RANGE_DB 35.0f +#define AUD_MIX_FADER_RANGE_DB 35.0f // coefficient for averaging channel levels for automatic fader adjustment -#define AUTO_FADER_ADJUST_ALPHA 0.2f +#define AUTO_FADER_ADJUST_ALPHA 0.2f // target level for auto fader adjustment in decibels -#define AUTO_FADER_TARGET_LEVEL_DB -30.0f +#define AUTO_FADER_TARGET_LEVEL_DB -30.0f // threshold in decibels below which the channel is considered as noise // and not adjusted -#define AUTO_FADER_NOISE_THRESHOLD_DB -40.0f +#define AUTO_FADER_NOISE_THRESHOLD_DB -40.0f // maximum number of fader groups (must be consistent to audiomixerboard implementation) -#define MAX_NUM_FADER_GROUPS 8 +#define MAX_NUM_FADER_GROUPS 8 // maximum number of recognized sound cards installed in the system -#define MAX_NUMBER_SOUND_CARDS 129 // e.g. 16 inputs, 8 outputs + default entry (MacOS) +#define MAX_NUMBER_SOUND_CARDS 129 // e.g. 16 inputs, 8 outputs + default entry (MacOS) // define the maximum number of audio channel for input/output we can store // channel infos for (and therefore this is the maximum number of entries in // the channel selection combo box regardless of the actual available number // of channels by the audio device) -#define MAX_NUM_IN_OUT_CHANNELS 64 +#define MAX_NUM_IN_OUT_CHANNELS 64 // maximum number of elemts in the server address combo box -#define MAX_NUM_SERVER_ADDR_ITEMS 12 +#define MAX_NUM_SERVER_ADDR_ITEMS 12 // maximum number of fader settings to be stored (together with the fader tags) -#define MAX_NUM_STORED_FADER_SETTINGS 250 +#define MAX_NUM_STORED_FADER_SETTINGS 250 // range for signal level meter -#define LOW_BOUND_SIG_METER ( -50.0 ) // dB -#define UPPER_BOUND_SIG_METER ( 0.0 ) // dB +#define LOW_BOUND_SIG_METER ( -50.0 ) // dB +#define UPPER_BOUND_SIG_METER ( 0.0 ) // dB // defines for LED level meter CLevelMeter -#define NUM_STEPS_LED_BAR 8 -#define RED_BOUND_LED_BAR 7 -#define YELLOW_BOUND_LED_BAR 5 +#define NUM_STEPS_LED_BAR 8 +#define RED_BOUND_LED_BAR 7 +#define YELLOW_BOUND_LED_BAR 5 // maximum number of connected clients at the server (must not be larger than 256) -#define MAX_NUM_CHANNELS 150 // max number channels for server +#define MAX_NUM_CHANNELS 150 // max number channels for server // actual number of used channels in the server // this parameter can safely be changed from 1 to MAX_NUM_CHANNELS // without any other changes in the code -#define DEFAULT_USED_NUM_CHANNELS 10 // default used number channels for server +#define DEFAULT_USED_NUM_CHANNELS 10 // default used number channels for server // Maximum number of servers registered in the server list. If you want to // change this parameter, you most probably have to adjust MAX_SIZE_BYTES_NETW_BUF. -#define MAX_NUM_SERVERS_IN_SERVER_LIST 150 // reduced to 150 because we now have genre-based server lists +#define MAX_NUM_SERVERS_IN_SERVER_LIST 150 // reduced to 150 because we now have genre-based server lists // defines the time interval at which the ping time is updated in the GUI -#define PING_UPDATE_TIME_MS 500 // ms +#define PING_UPDATE_TIME_MS 500 // ms // defines the time interval at which the ping time is updated for the server list -#define PING_UPDATE_TIME_SERVER_LIST_MS 2500 // ms +#define PING_UPDATE_TIME_SERVER_LIST_MS 2500 // ms // defines the interval between Channel Level updates from the server -#define CHANNEL_LEVEL_UPDATE_INTERVAL 200 // number of frames at 64 samples frame size +#define CHANNEL_LEVEL_UPDATE_INTERVAL 200 // number of frames at 64 samples frame size // time-out until a registered server is deleted from the server list if no // new registering was made in minutes -#define SERVLIST_TIME_OUT_MINUTES 33 // minutes (should include 3 UDP registration messages) +#define SERVLIST_TIME_OUT_MINUTES 33 // minutes (should include 3 UDP registration messages) // poll time for server list (to check if entries are time-out) -#define SERVLIST_POLL_TIME_MINUTES 1 // minute +#define SERVLIST_POLL_TIME_MINUTES 1 // minute // time interval for sending ping messages to servers in the server list -#define SERVLIST_UPDATE_PING_SERVERS_MS 59000 // ms +#define SERVLIST_UPDATE_PING_SERVERS_MS 59000 // ms // time until a slave server registers in the server list -#define SERVLIST_REGIST_INTERV_MINUTES 15 // minutes +#define SERVLIST_REGIST_INTERV_MINUTES 15 // minutes // defines the minimum time a server must run to be a permanent server -#define SERVLIST_TIME_PERMSERV_MINUTES 2880 // minutes, 2880 = 60 min * 24 h * 2 d +#define SERVLIST_TIME_PERMSERV_MINUTES 2880 // minutes, 2880 = 60 min * 24 h * 2 d // registration response timeout -#define REGISTER_SERVER_TIME_OUT_MS 500 // ms +#define REGISTER_SERVER_TIME_OUT_MS 500 // ms // defines the maximum number of times to retry server registration // when no response is received within the timeout (before reverting // to SERVLIST_REGIST_INTERV_MINUTES) -#define REGISTER_SERVER_RETRY_LIMIT 5 // count - +#define REGISTER_SERVER_RETRY_LIMIT 5 // count // Maximum length of fader tag and text message strings (Since for chat messages // some HTML code is added, we also have to define a second length which includes // this additionl HTML code. Right now the length of the HTML code is approx. 66 // characters. Here, we add some headroom to this number) -#define MAX_LEN_FADER_TAG 16 -#define MAX_LEN_CHAT_TEXT 1600 -#define MAX_LEN_CHAT_TEXT_PLUS_HTML 1800 -#define MAX_LEN_SERVER_NAME 20 -#define MAX_LEN_IP_ADDRESS 15 -#define MAX_LEN_SERVER_CITY 20 -#define MAX_LEN_VERSION_TEXT 30 +#define MAX_LEN_FADER_TAG 16 +#define MAX_LEN_CHAT_TEXT 1600 +#define MAX_LEN_CHAT_TEXT_PLUS_HTML 1800 +#define MAX_LEN_SERVER_NAME 20 +#define MAX_LEN_IP_ADDRESS 15 +#define MAX_LEN_SERVER_CITY 20 +#define MAX_LEN_VERSION_TEXT 30 // define Settings tab indexes -#define SETTING_TAB_USER 0 -#define SETTING_TAB_AUDIONET 1 -#define SETTING_TAB_ADVANCED 2 +#define SETTING_TAB_USER 0 +#define SETTING_TAB_AUDIONET 1 +#define SETTING_TAB_ADVANCED 2 // common tool tip bottom line text -#define TOOLTIP_COM_END_TEXT \ +#define TOOLTIP_COM_END_TEXT \ "
" + \ - QCoreApplication::translate ( "global", "For more information use the \"What's " \ - "This\" help (help menu, right mouse button or Shift+F1)" ) + \ - "
" + QCoreApplication::translate ( "global", \ + "For more information use the \"What's " \ + "This\" help (help menu, right mouse button or Shift+F1)" ) + \ + "" // server welcome message title (do not change for compatibility!) -#define WELCOME_MESSAGE_PREFIX "Server Welcome Message: " +#define WELCOME_MESSAGE_PREFIX "Server Welcome Message: " // mixer settings file name suffix -#define MIX_SETTINGS_FILE_SUFFIX "jch" +#define MIX_SETTINGS_FILE_SUFFIX "jch" -#define _MAXSHORT 32767 -#define _MINSHORT ( -32768 ) -#define INVALID_INDEX -1 // define invalid index as a negative value (a valid index must always be >= 0) +#define _MAXSHORT 32767 +#define _MINSHORT ( -32768 ) +#define INVALID_INDEX -1 // define invalid index as a negative value (a valid index must always be >= 0) #if HAVE_STDINT_H -# include +# include #elif HAVE_INTTYPES_H -# include -#elif defined ( _WIN32 ) -typedef __int64 int64_t; -typedef __int32 int32_t; -typedef __int16 int16_t; -typedef unsigned __int64 uint64_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int8 uint8_t; -#elif defined ( ANDROID ) +# include +#elif defined( _WIN32 ) +typedef __int64 int64_t; +typedef __int32 int32_t; +typedef __int16 int16_t; +typedef unsigned __int64 uint64_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int8 uint8_t; +#elif defined( ANDROID ) // don't redfine types for android as these ones below don't work #else typedef long long int64_t; @@ -302,15 +301,13 @@ typedef unsigned char uint8_t; /* Pseudo enum definitions -------------------------------------------------- */ // definition for custom event -#define MS_PACKET_RECEIVED 0 - +#define MS_PACKET_RECEIVED 0 /* Classes ********************************************************************/ class CGenErr { public: - CGenErr ( QString strNewErrorMsg, QString strNewErrorType = "" ) : - strErrorMsg ( strNewErrorMsg ), strErrorType ( strNewErrorType ) {} + CGenErr ( QString strNewErrorMsg, QString strNewErrorType = "" ) : strErrorMsg ( strNewErrorMsg ), strErrorType ( strNewErrorType ) {} QString GetErrorText() const { @@ -334,36 +331,30 @@ class CCustomEvent : public QEvent { public: CCustomEvent ( int iNewMeTy, int iNewSt, int iNewChN = 0 ) : - QEvent ( QEvent::Type ( QEvent::User + 11 ) ), iMessType ( iNewMeTy ), iStatus ( iNewSt ), - iChanNum ( iNewChN ) {} + QEvent ( QEvent::Type ( QEvent::User + 11 ) ), + iMessType ( iNewMeTy ), + iStatus ( iNewSt ), + iChanNum ( iNewChN ) + {} int iMessType; int iStatus; int iChanNum; }; - /* Prototypes for global functions ********************************************/ // command line parsing, TODO do not declare functions globally but in a class QString UsageArguments ( char** argv ); -bool GetFlagArgument ( char** argv, +bool GetFlagArgument ( char** argv, int& i, QString strShortOpt, QString strLongOpt ); + +bool GetStringArgument ( int argc, char** argv, int& i, QString strShortOpt, QString strLongOpt, QString& strArg ); + +bool GetNumericArgument ( int argc, + char** argv, int& i, QString strShortOpt, - QString strLongOpt ); - -bool GetStringArgument ( int argc, - char** argv, - int& i, - QString strShortOpt, - QString strLongOpt, - QString& strArg ); - -bool GetNumericArgument ( int argc, - char** argv, - int& i, - QString strShortOpt, - QString strLongOpt, - double rRangeStart, - double rRangeStop, - double& rValue); + QString strLongOpt, + double rRangeStart, + double rRangeStop, + double& rValue ); diff --git a/src/levelmeter.cpp b/src/levelmeter.cpp old mode 100755 new mode 100644 index c077efd559..271e10aabe --- a/src/levelmeter.cpp +++ b/src/levelmeter.cpp @@ -27,18 +27,15 @@ #include "levelmeter.h" - /* Implementation *************************************************************/ -CLevelMeter::CLevelMeter ( QWidget* parent ) : - QWidget ( parent ), - eLevelMeterType ( MT_BAR ) +CLevelMeter::CLevelMeter ( QWidget* parent ) : QWidget ( parent ), eLevelMeterType ( MT_BAR ) { // initialize LED meter QWidget* pLEDMeter = new QWidget(); QVBoxLayout* pLEDLayout = new QVBoxLayout ( pLEDMeter ); pLEDLayout->setAlignment ( Qt::AlignHCenter ); - pLEDLayout->setMargin ( 0 ); - pLEDLayout->setSpacing ( 0 ); + pLEDLayout->setMargin ( 0 ); + pLEDLayout->setSpacing ( 0 ); // create LEDs plus the clip LED vecpLEDs.Init ( NUM_LEDS_INCL_CLIP_LED ); @@ -61,7 +58,7 @@ CLevelMeter::CLevelMeter ( QWidget* parent ) : pBarMeter = new QProgressBar(); pBarMeter->setOrientation ( Qt::Vertical ); pBarMeter->setRange ( 0, 100 * NUM_STEPS_LED_BAR ); // use factor 100 to reduce quantization (bar is continuous) - pBarMeter->setFormat ( "" ); // suppress percent numbers + pBarMeter->setFormat ( "" ); // suppress percent numbers // setup stacked layout for meter type switching mechanism pStackedLayout = new QStackedLayout ( this ); @@ -81,10 +78,8 @@ CLevelMeter::CLevelMeter ( QWidget* parent ) : TimerClip.setSingleShot ( true ); TimerClip.setInterval ( CLIP_IND_TIME_OUT_MS ); - // Connections ------------------------------------------------------------- - QObject::connect ( &TimerClip, &QTimer::timeout, - this, &CLevelMeter::ClipReset ); + QObject::connect ( &TimerClip, &QTimer::timeout, this, &CLevelMeter::ClipReset ); } CLevelMeter::~CLevelMeter() @@ -130,51 +125,46 @@ void CLevelMeter::SetLevelMeterType ( const ELevelMeterType eNType ) SetBarMeterStyleAndClipStatus ( eNType, false ); } -void CLevelMeter::SetBarMeterStyleAndClipStatus ( const ELevelMeterType eNType, - const bool bIsClip ) +void CLevelMeter::SetBarMeterStyleAndClipStatus ( const ELevelMeterType eNType, const bool bIsClip ) { switch ( eNType ) { case MT_SLIM_BAR: if ( bIsClip ) { - pBarMeter->setStyleSheet ( - "QProgressBar { border: 0px solid red;" - " margin: 0px;" - " padding: 0px;" - " width: 4px;" - " background: red; }" - "QProgressBar::chunk { background: green; }" ); + pBarMeter->setStyleSheet ( "QProgressBar { border: 0px solid red;" + " margin: 0px;" + " padding: 0px;" + " width: 4px;" + " background: red; }" + "QProgressBar::chunk { background: green; }" ); } else { - pBarMeter->setStyleSheet ( - "QProgressBar { border: 0px;" - " margin: 0px;" - " padding: 0px;" - " width: 4px; }" - "QProgressBar::chunk { background: green; }" ); + pBarMeter->setStyleSheet ( "QProgressBar { border: 0px;" + " margin: 0px;" + " padding: 0px;" + " width: 4px; }" + "QProgressBar::chunk { background: green; }" ); } break; default: /* MT_BAR */ if ( bIsClip ) { - pBarMeter->setStyleSheet ( - "QProgressBar { border: 2px solid red;" - " margin: 1px;" - " padding: 1px;" - " width: 15px;" - " background: transparent; }" - "QProgressBar::chunk { background: green; }" ); + pBarMeter->setStyleSheet ( "QProgressBar { border: 2px solid red;" + " margin: 1px;" + " padding: 1px;" + " width: 15px;" + " background: transparent; }" + "QProgressBar::chunk { background: green; }" ); } else { - pBarMeter->setStyleSheet ( - "QProgressBar { margin: 1px;" - " padding: 1px;" - " width: 15px; }" - "QProgressBar::chunk { background: green; }" ); + pBarMeter->setStyleSheet ( "QProgressBar { margin: 1px;" + " padding: 1px;" + " width: 15px; }" + "QProgressBar::chunk { background: green; }" ); } break; } @@ -267,12 +257,11 @@ void CLevelMeter::ClipReset() } } - CLevelMeter::cLED::cLED ( QWidget* parent ) : - BitmCubeRoundBlack ( QString::fromUtf8 ( ":/png/LEDs/res/HLEDBlackSmall.png" ) ), - BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/HLEDGreenSmall.png" ) ), + BitmCubeRoundBlack ( QString::fromUtf8 ( ":/png/LEDs/res/HLEDBlackSmall.png" ) ), + BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/HLEDGreenSmall.png" ) ), BitmCubeRoundYellow ( QString::fromUtf8 ( ":/png/LEDs/res/HLEDYellowSmall.png" ) ), - BitmCubeRoundRed ( QString::fromUtf8 ( ":/png/LEDs/res/HLEDRedSmall.png" ) ) + BitmCubeRoundRed ( QString::fromUtf8 ( ":/png/LEDs/res/HLEDRedSmall.png" ) ) { // create LED label pLEDLabel = new QLabel ( "", parent ); diff --git a/src/levelmeter.h b/src/levelmeter.h old mode 100755 new mode 100644 index 30f39f35b1..2e53e8ace8 --- a/src/levelmeter.h +++ b/src/levelmeter.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -33,11 +33,9 @@ #include "util.h" #include "global.h" - /* Definitions ****************************************************************/ -#define NUM_LEDS_INCL_CLIP_LED ( NUM_STEPS_LED_BAR + 1 ) -#define CLIP_IND_TIME_OUT_MS 20000 - +#define NUM_LEDS_INCL_CLIP_LED ( NUM_STEPS_LED_BAR + 1 ) +#define CLIP_IND_TIME_OUT_MS 20000 /* Classes ********************************************************************/ class CLevelMeter : public QWidget @@ -78,10 +76,10 @@ class CLevelMeter : public QWidget QLabel* GetLabelPointer() { return pLEDLabel; } protected: - QPixmap BitmCubeRoundBlack; - QPixmap BitmCubeRoundGreen; - QPixmap BitmCubeRoundYellow; - QPixmap BitmCubeRoundRed; + QPixmap BitmCubeRoundBlack; + QPixmap BitmCubeRoundGreen; + QPixmap BitmCubeRoundYellow; + QPixmap BitmCubeRoundRed; ELightColor eCurLightColor; QLabel* pLEDLabel; @@ -89,15 +87,14 @@ class CLevelMeter : public QWidget virtual void mousePressEvent ( QMouseEvent* ) override { ClipReset(); } - void SetBarMeterStyleAndClipStatus ( const ELevelMeterType eNType, - const bool bIsClip ); + void SetBarMeterStyleAndClipStatus ( const ELevelMeterType eNType, const bool bIsClip ); QStackedLayout* pStackedLayout; ELevelMeterType eLevelMeterType; CVector vecpLEDs; QProgressBar* pBarMeter; - QTimer TimerClip; + QTimer TimerClip; public slots: void ClipReset(); diff --git a/src/main.cpp b/src/main.cpp old mode 100755 new mode 100644 index d8c9b150d7..f1ea4f06f6 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,22 +26,21 @@ #include #include "global.h" #ifndef HEADLESS -# include -# include -# include "clientdlg.h" -# include "serverdlg.h" +# include +# include +# include "clientdlg.h" +# include "serverdlg.h" #endif #include "settings.h" #include "testbench.h" #include "util.h" #ifdef ANDROID -# include +# include #endif -#if defined ( Q_OS_MACX ) -# include "mac/activity.h" +#if defined( Q_OS_MACX ) +# include "mac/activity.h" #endif - // Implementation ************************************************************** int main ( int argc, char** argv ) @@ -55,9 +54,9 @@ int main ( int argc, char** argv ) // arguments #if defined( SERVER_BUNDLE ) && ( defined( Q_OS_MACX ) ) // if we are on MacOS and we are building a server bundle, starts Jamulus in server mode - bool bIsClient = false; + bool bIsClient = false; #else - bool bIsClient = true; + bool bIsClient = true; #endif bool bUseGUI = true; bool bStartMinimized = false; @@ -91,10 +90,11 @@ int main ( int argc, char** argv ) QString strWelcomeMessage = ""; QString strClientName = ""; -#if !defined(HEADLESS) && defined(_WIN32) - if (AttachConsole(ATTACH_PARENT_PROCESS)) { - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); +#if !defined( HEADLESS ) && defined( _WIN32 ) + if ( AttachConsole ( ATTACH_PARENT_PROCESS ) ) + { + freopen ( "CONOUT$", "w", stdout ); + freopen ( "CONOUT$", "w", stderr ); } #endif @@ -104,10 +104,7 @@ int main ( int argc, char** argv ) for ( int i = 1; i < argc; i++ ) { // Server mode flag ---------------------------------------------------- - if ( GetFlagArgument ( argv, - i, - "-s", - "--server" ) ) + if ( GetFlagArgument ( argv, i, "-s", "--server" ) ) { bIsClient = false; qInfo() << "- server mode chosen"; @@ -115,12 +112,8 @@ int main ( int argc, char** argv ) continue; } - // Use GUI flag -------------------------------------------------------- - if ( GetFlagArgument ( argv, - i, - "-n", - "--nogui" ) ) + if ( GetFlagArgument ( argv, i, "-n", "--nogui" ) ) { bUseGUI = false; qInfo() << "- no GUI mode chosen"; @@ -128,12 +121,8 @@ int main ( int argc, char** argv ) continue; } - // Use licence flag ---------------------------------------------------- - if ( GetFlagArgument ( argv, - i, - "-L", - "--licence" ) ) + if ( GetFlagArgument ( argv, i, "-L", "--licence" ) ) { // right now only the creative commons licence is supported eLicenceType = LT_CREATIVECOMMONS; @@ -142,26 +131,17 @@ int main ( int argc, char** argv ) continue; } - // Use 64 samples frame size mode -------------------------------------- - if ( GetFlagArgument ( argv, - i, - "-F", - "--fastupdate" ) ) + if ( GetFlagArgument ( argv, i, "-F", "--fastupdate" ) ) { bUseDoubleSystemFrameSize = false; // 64 samples frame size - qInfo() << qUtf8Printable( QString( "- using %1 samples frame size mode" ) - .arg( SYSTEM_FRAME_SIZE_SAMPLES ) ); + qInfo() << qUtf8Printable ( QString ( "- using %1 samples frame size mode" ).arg ( SYSTEM_FRAME_SIZE_SAMPLES ) ); CommandLineOptions << "--fastupdate"; continue; } - // Use multithreading -------------------------------------------------- - if ( GetFlagArgument ( argv, - i, - "-T", - "--multithreading" ) ) + if ( GetFlagArgument ( argv, i, "-T", "--multithreading" ) ) { bUseMultithreading = true; qInfo() << "- using multithreading"; @@ -169,32 +149,19 @@ int main ( int argc, char** argv ) continue; } - // Maximum number of channels ------------------------------------------ - if ( GetNumericArgument ( argc, - argv, - i, - "-u", - "--numchannels", - 1, - MAX_NUM_CHANNELS, - rDbleArgument ) ) + if ( GetNumericArgument ( argc, argv, i, "-u", "--numchannels", 1, MAX_NUM_CHANNELS, rDbleArgument ) ) { iNumServerChannels = static_cast ( rDbleArgument ); - qInfo() << qUtf8Printable( QString("- maximum number of channels: %1") - .arg( iNumServerChannels ) ); + qInfo() << qUtf8Printable ( QString ( "- maximum number of channels: %1" ).arg ( iNumServerChannels ) ); CommandLineOptions << "--numchannels"; continue; } - // Start minimized ----------------------------------------------------- - if ( GetFlagArgument ( argv, - i, - "-z", - "--startminimized" ) ) + if ( GetFlagArgument ( argv, i, "-z", "--startminimized" ) ) { bStartMinimized = true; qInfo() << "- start minimized enabled"; @@ -202,12 +169,8 @@ int main ( int argc, char** argv ) continue; } - // Disconnect all clients on quit -------------------------------------- - if ( GetFlagArgument ( argv, - i, - "-d", - "--discononquit" ) ) + if ( GetFlagArgument ( argv, i, "-d", "--discononquit" ) ) { bDisconnectAllClientsOnQuit = true; qInfo() << "- disconnect all clients on quit"; @@ -215,12 +178,8 @@ int main ( int argc, char** argv ) continue; } - // Disabling auto Jack connections ------------------------------------- - if ( GetFlagArgument ( argv, - i, - "-j", - "--nojackconnect" ) ) + if ( GetFlagArgument ( argv, i, "-j", "--nojackconnect" ) ) { bNoAutoJackConnect = true; qInfo() << "- disable auto Jack connections"; @@ -228,12 +187,8 @@ int main ( int argc, char** argv ) continue; } - // Disable translations ------------------------------------------------ - if ( GetFlagArgument ( argv, - i, - "-t", - "--notranslation" ) ) + if ( GetFlagArgument ( argv, i, "-t", "--notranslation" ) ) { bUseTranslation = false; qInfo() << "- translations disabled"; @@ -241,7 +196,6 @@ int main ( int argc, char** argv ) continue; } - // Show all registered servers in the server list ---------------------- // Undocumented debugging command line argument: Show all registered // servers in the server list regardless if a ping to the server is @@ -257,7 +211,6 @@ int main ( int argc, char** argv ) continue; } - // Show analyzer console ----------------------------------------------- // Undocumented debugging command line argument: Show the analyzer // console to debug network buffer properties. @@ -272,7 +225,6 @@ int main ( int argc, char** argv ) continue; } - // Controller MIDI channel --------------------------------------------- if ( GetStringArgument ( argc, argv, @@ -282,82 +234,48 @@ int main ( int argc, char** argv ) strArgument ) ) { strMIDISetup = strArgument; - qInfo() << qUtf8Printable( QString( "- MIDI controller settings: %1" ) - .arg( strMIDISetup ) ); + qInfo() << qUtf8Printable ( QString ( "- MIDI controller settings: %1" ).arg ( strMIDISetup ) ); CommandLineOptions << "--ctrlmidich"; continue; } - // Use logging --------------------------------------------------------- - if ( GetStringArgument ( argc, - argv, - i, - "-l", - "--log", - strArgument ) ) + if ( GetStringArgument ( argc, argv, i, "-l", "--log", strArgument ) ) { strLoggingFileName = strArgument; - qInfo() << qUtf8Printable( QString( "- logging file name: %1" ) - .arg( strLoggingFileName ) ); + qInfo() << qUtf8Printable ( QString ( "- logging file name: %1" ).arg ( strLoggingFileName ) ); CommandLineOptions << "--log"; continue; } - // Port number --------------------------------------------------------- - if ( GetNumericArgument ( argc, - argv, - i, - "-p", - "--port", - 0, - 65535, - rDbleArgument ) ) + if ( GetNumericArgument ( argc, argv, i, "-p", "--port", 0, 65535, rDbleArgument ) ) { iPortNumber = static_cast ( rDbleArgument ); bCustomPortNumberGiven = true; - qInfo() << qUtf8Printable( QString( "- selected port number: %1" ) - .arg( iPortNumber ) ); + qInfo() << qUtf8Printable ( QString ( "- selected port number: %1" ).arg ( iPortNumber ) ); CommandLineOptions << "--port"; continue; } - // Quality of Service -------------------------------------------------- - if ( GetNumericArgument ( argc, - argv, - i, - "-Q", - "--qos", - 0, - 255, - rDbleArgument ) ) + if ( GetNumericArgument ( argc, argv, i, "-Q", "--qos", 0, 255, rDbleArgument ) ) { - iQosNumber = static_cast ( rDbleArgument ); - qInfo() << qUtf8Printable( QString( "- selected QoS value: %1" ) - .arg( iQosNumber ) ); + iQosNumber = static_cast ( rDbleArgument ); + qInfo() << qUtf8Printable ( QString ( "- selected QoS value: %1" ).arg ( iQosNumber ) ); CommandLineOptions << "--qos"; continue; } - // HTML status file ---------------------------------------------------- - if ( GetStringArgument ( argc, - argv, - i, - "-m", - "--htmlstatus", - strArgument ) ) + if ( GetStringArgument ( argc, argv, i, "-m", "--htmlstatus", strArgument ) ) { strHTMLStatusFileName = strArgument; - qInfo() << qUtf8Printable( QString( "- HTML status file name: %1" ) - .arg( strHTMLStatusFileName ) ); + qInfo() << qUtf8Printable ( QString ( "- HTML status file name: %1" ).arg ( strHTMLStatusFileName ) ); CommandLineOptions << "--htmlstatus"; continue; } - // Client Name --------------------------------------------------------- if ( GetStringArgument ( argc, argv, @@ -367,29 +285,20 @@ int main ( int argc, char** argv ) strArgument ) ) { strClientName = strArgument; - qInfo() << qUtf8Printable( QString( "- client name: %1" ) - .arg( strClientName ) ); + qInfo() << qUtf8Printable ( QString ( "- client name: %1" ).arg ( strClientName ) ); CommandLineOptions << "--clientname"; continue; } - // Recording directory ------------------------------------------------- - if ( GetStringArgument ( argc, - argv, - i, - "-R", - "--recording", - strArgument ) ) + if ( GetStringArgument ( argc, argv, i, "-R", "--recording", strArgument ) ) { strRecordingDirName = strArgument; - qInfo() << qUtf8Printable( QString("- recording directory name: %1" ) - .arg( strRecordingDirName ) ); + qInfo() << qUtf8Printable ( QString ( "- recording directory name: %1" ).arg ( strRecordingDirName ) ); CommandLineOptions << "--recording"; continue; } - // Disable recording on startup ---------------------------------------- if ( GetFlagArgument ( argv, i, @@ -403,10 +312,7 @@ int main ( int argc, char** argv ) } // Enable delay panning on startup ------------------------------------- - if ( GetFlagArgument ( argv, - i, - "-P", - "--delaypan" ) ) + if ( GetFlagArgument ( argv, i, "-P", "--delaypan" ) ) { bDelayPan = true; qInfo() << "- starting with delay panning"; @@ -415,16 +321,10 @@ int main ( int argc, char** argv ) } // Directory server ---------------------------------------------------- - if ( GetStringArgument ( argc, - argv, - i, - "-e", - "--directoryserver", - strArgument ) ) + if ( GetStringArgument ( argc, argv, i, "-e", "--directoryserver", strArgument ) ) { strCentralServer = strArgument; - qInfo() << qUtf8Printable( QString( "- directory server: %1" ) - .arg( strCentralServer ) ); + qInfo() << qUtf8Printable ( QString ( "- directory server: %1" ).arg ( strCentralServer ) ); CommandLineOptions << "--directoryserver"; continue; } @@ -438,13 +338,11 @@ int main ( int argc, char** argv ) strArgument ) ) { strCentralServer = strArgument; - qInfo() << qUtf8Printable( QString( "- directory server: %1" ) - .arg( strCentralServer ) ); + qInfo() << qUtf8Printable ( QString ( "- directory server: %1" ).arg ( strCentralServer ) ); CommandLineOptions << "--directoryserver"; continue; } - // Server Public IP ---------------------------------------------------- if ( GetStringArgument ( argc, argv, @@ -454,13 +352,11 @@ int main ( int argc, char** argv ) strArgument ) ) { strServerPublicIP = strArgument; - qInfo() << qUtf8Printable( QString( "- server public IP: %1" ) - .arg( strServerPublicIP ) ); + qInfo() << qUtf8Printable ( QString ( "- server public IP: %1" ).arg ( strServerPublicIP ) ); CommandLineOptions << "--serverpublicip"; continue; } - // Server Bind IP -------------------------------------------------- if ( GetStringArgument ( argc, argv, @@ -470,98 +366,58 @@ int main ( int argc, char** argv ) strArgument ) ) { strServerBindIP = strArgument; - qInfo() << qUtf8Printable( QString( "- server bind IP: %1" ) - .arg( strServerBindIP ) ); + qInfo() << qUtf8Printable ( QString ( "- server bind IP: %1" ).arg ( strServerBindIP ) ); CommandLineOptions << "--serverbindip"; continue; } - // Server info --------------------------------------------------------- - if ( GetStringArgument ( argc, - argv, - i, - "-o", - "--serverinfo", - strArgument ) ) + if ( GetStringArgument ( argc, argv, i, "-o", "--serverinfo", strArgument ) ) { strServerInfo = strArgument; - qInfo() << qUtf8Printable( QString( "- server info: %1" ) - .arg( strServerInfo ) ); + qInfo() << qUtf8Printable ( QString ( "- server info: %1" ).arg ( strServerInfo ) ); CommandLineOptions << "--serverinfo"; continue; } - // Server list filter -------------------------------------------------- - if ( GetStringArgument ( argc, - argv, - i, - "-f", - "--listfilter", - strArgument ) ) + if ( GetStringArgument ( argc, argv, i, "-f", "--listfilter", strArgument ) ) { strServerListFilter = strArgument; - qInfo() << qUtf8Printable( QString( "- server list filter: %1" ) - .arg( strServerListFilter ) ); + qInfo() << qUtf8Printable ( QString ( "- server list filter: %1" ).arg ( strServerListFilter ) ); CommandLineOptions << "--listfilter"; continue; } - // Server welcome message ---------------------------------------------- - if ( GetStringArgument ( argc, - argv, - i, - "-w", - "--welcomemessage", - strArgument ) ) + if ( GetStringArgument ( argc, argv, i, "-w", "--welcomemessage", strArgument ) ) { strWelcomeMessage = strArgument; - qInfo() << qUtf8Printable( QString( "- welcome message: %1" ) - .arg( strWelcomeMessage ) ); + qInfo() << qUtf8Printable ( QString ( "- welcome message: %1" ).arg ( strWelcomeMessage ) ); CommandLineOptions << "--welcomemessage"; continue; } - // Initialization file ------------------------------------------------- - if ( GetStringArgument ( argc, - argv, - i, - "-i", - "--inifile", - strArgument ) ) + if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) ) { strIniFileName = strArgument; - qInfo() << qUtf8Printable( QString( "- initialization file name: %1" ) - .arg( strIniFileName ) ); + qInfo() << qUtf8Printable ( QString ( "- initialization file name: %1" ).arg ( strIniFileName ) ); CommandLineOptions << "--inifile"; continue; } - // Connect on startup -------------------------------------------------- - if ( GetStringArgument ( argc, - argv, - i, - "-c", - "--connect", - strArgument ) ) + if ( GetStringArgument ( argc, argv, i, "-c", "--connect", strArgument ) ) { strConnOnStartupAddress = NetworkUtil::FixAddress ( strArgument ); - qInfo() << qUtf8Printable( QString( "- connect on startup to address: %1" ) - .arg( strConnOnStartupAddress ) ); + qInfo() << qUtf8Printable ( QString ( "- connect on startup to address: %1" ).arg ( strConnOnStartupAddress ) ); CommandLineOptions << "--connect"; continue; } - // Mute stream on startup ---------------------------------------------- - if ( GetFlagArgument ( argv, - i, - "-M", - "--mutestream" ) ) + if ( GetFlagArgument ( argv, i, "-M", "--mutestream" ) ) { bMuteStream = true; qInfo() << "- mute stream activated"; @@ -569,7 +425,6 @@ int main ( int argc, char** argv ) continue; } - // For headless client mute my own signal in personal mix -------------- if ( GetFlagArgument ( argv, i, @@ -582,39 +437,31 @@ int main ( int argc, char** argv ) continue; } - // Version number ------------------------------------------------------ - if ( ( !strcmp ( argv[i], "--version" ) ) || - ( !strcmp ( argv[i], "-v" ) ) ) + if ( ( !strcmp ( argv[i], "--version" ) ) || ( !strcmp ( argv[i], "-v" ) ) ) { - qCritical() << qUtf8Printable( GetVersionAndNameStr ( false ) ); + qCritical() << qUtf8Printable ( GetVersionAndNameStr ( false ) ); exit ( 1 ); } - // Help (usage) flag --------------------------------------------------- - if ( ( !strcmp ( argv[i], "--help" ) ) || - ( !strcmp ( argv[i], "-h" ) ) || - ( !strcmp ( argv[i], "-?" ) ) ) + if ( ( !strcmp ( argv[i], "--help" ) ) || ( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) ) { const QString strHelp = UsageArguments ( argv ); - qInfo() << qUtf8Printable( strHelp ); + qInfo() << qUtf8Printable ( strHelp ); exit ( 0 ); } - // Unknown option ------------------------------------------------------ - qCritical() << qUtf8Printable( QString( "%1: Unknown option '%2' -- use '--help' for help" ) - .arg( argv[0] ).arg( argv[i] ) ); + qCritical() << qUtf8Printable ( QString ( "%1: Unknown option '%2' -- use '--help' for help" ).arg ( argv[0] ).arg ( argv[i] ) ); // clicking on the Mac application bundle, the actual application // is called with weird command line args -> do not exit on these -#if !( defined ( Q_OS_MACX ) ) +#if !( defined( Q_OS_MACX ) ) exit ( 1 ); #endif } - // Dependencies ------------------------------------------------------------ #ifdef HEADLESS if ( bUseGUI ) @@ -685,22 +532,19 @@ int main ( int argc, char** argv ) iPortNumber += 10; // increment by 10 } - // Application/GUI setup --------------------------------------------------- // Application object #ifdef HEADLESS QCoreApplication* pApp = new QCoreApplication ( argc, argv ); #else -# if defined ( Q_OS_IOS ) - bUseGUI = true; +# if defined( Q_OS_IOS ) + bUseGUI = true; // bUseMultithreading = true; - QApplication* pApp = new QApplication ( argc, argv ); -# else - QCoreApplication* pApp = bUseGUI - ? new QApplication ( argc, argv ) - : new QCoreApplication ( argc, argv ); -# endif + QApplication* pApp = new QApplication ( argc, argv ); +# else + QCoreApplication* pApp = bUseGUI ? new QApplication ( argc, argv ) : new QCoreApplication ( argc, argv ); +# endif #endif #ifdef ANDROID @@ -729,7 +573,7 @@ int main ( int argc, char** argv ) pApp->addLibraryPath ( QString ( ApplDir.absolutePath() ) ); #endif -#if defined ( Q_OS_MACX ) +#if defined( Q_OS_MACX ) // On OSX we need to declare an activity to ensure the process doesn't get // throttled by OS level Nap, Sleep, and Thread Priority systems. CActivity activity; @@ -738,14 +582,12 @@ int main ( int argc, char** argv ) #endif // init resources - Q_INIT_RESOURCE(resources); + Q_INIT_RESOURCE ( resources ); - -// clang-format off + // clang-format off // TEST -> activate the following line to activate the test bench, //CTestbench Testbench ( "127.0.0.1", DEFAULT_PORT_NUMBER ); -// clang-format on - + // clang-format on try { @@ -753,13 +595,8 @@ int main ( int argc, char** argv ) { // Client: // actual client object - CClient Client ( iPortNumber, - iQosNumber, - strConnOnStartupAddress, - strMIDISetup, - bNoAutoJackConnect, - strClientName, - bMuteMeInPersonalMix ); + CClient + Client ( iPortNumber, iQosNumber, strConnOnStartupAddress, strMIDISetup, bNoAutoJackConnect, strClientName, bMuteMeInPersonalMix ); // load settings from init-file (command line options override) CClientSettings Settings ( &Client, strIniFileName ); @@ -793,7 +630,7 @@ int main ( int argc, char** argv ) #endif { // only start application without using the GUI - qInfo() << qUtf8Printable( GetVersionAndNameStr ( false ) ); + qInfo() << qUtf8Printable ( GetVersionAndNameStr ( false ) ); pApp->exec(); } @@ -839,10 +676,7 @@ int main ( int argc, char** argv ) Server.UpdateServerList(); // GUI object for the server - CServerDlg ServerDlg ( &Server, - &Settings, - bStartMinimized, - nullptr ); + CServerDlg ServerDlg ( &Server, &Settings, bStartMinimized, nullptr ); // show dialog (if not the minimized flag is set) if ( !bStartMinimized ) @@ -856,7 +690,7 @@ int main ( int argc, char** argv ) #endif { // only start application without using the GUI - qInfo() << qUtf8Printable( GetVersionAndNameStr ( false ) ); + qInfo() << qUtf8Printable ( GetVersionAndNameStr ( false ) ); // enable server list if a directory server is defined Server.SetServerListEnabled ( !strCentralServer.isEmpty() ); @@ -875,88 +709,79 @@ int main ( int argc, char** argv ) #ifndef HEADLESS if ( bUseGUI ) { - QMessageBox::critical ( nullptr, - APP_NAME, - generr.GetErrorText(), - "Quit", - nullptr ); + QMessageBox::critical ( nullptr, APP_NAME, generr.GetErrorText(), "Quit", nullptr ); } else #endif { - qCritical() << qUtf8Printable( QString( "%1: %2" ) - .arg( APP_NAME ).arg( generr.GetErrorText() ) ); + qCritical() << qUtf8Printable ( QString ( "%1: %2" ).arg ( APP_NAME ).arg ( generr.GetErrorText() ) ); exit ( 1 ); } } -#if defined ( Q_OS_MACX ) +#if defined( Q_OS_MACX ) activity.EndActivity(); #endif return 0; } - /******************************************************************************\ * Command Line Argument Parsing * \******************************************************************************/ -QString UsageArguments ( char **argv ) +QString UsageArguments ( char** argv ) { - return - "Usage: " + QString ( argv[0] ) + " [option] [optional argument]\n" - "\nGeneral options:\n" - " -h, -?, --help display this help text and exit\n" - " -i, --inifile initialization file name (not\n" - " supported for headless server mode)\n" - " -n, --nogui disable GUI\n" - " -p, --port set the local port number\n" - " -Q, --qos set the QoS value. Default is 128. Disable with 0\n" - " (see the Jamulus website to enable QoS on Windows)\n" - " -t, --notranslation disable translation (use English language)\n" - " -v, --version output version information and exit\n" - "\nServer only:\n" - " -d, --discononquit disconnect all clients on quit\n" - " -e, --directoryserver address of the directory server with which to register\n" - " (or 'localhost' to host a server list on this server)\n" - " -f, --listfilter server list whitelist filter in the format:\n" - " [IP address 1];[IP address 2];[IP address 3]; ...\n" - " -F, --fastupdate use 64 samples frame size mode\n" - " -l, --log enable logging, set file name\n" - " -L, --licence show an agreement window before users can connect\n" - " -m, --htmlstatus enable HTML status file, set file name\n" - " -o, --serverinfo infos of this server in the format:\n" - " [name];[city];[country as QLocale ID]\n" - " -P, --delaypan start with delay panning enabled\n" - " -R, --recording sets directory to contain recorded jams\n" - " --norecord disables recording (when enabled by default by -R)\n" - " -s, --server start server\n" - " -T, --multithreading use multithreading to make better use of\n" - " multi-core CPUs and support more clients\n" - " -u, --numchannels maximum number of channels\n" - " -w, --welcomemessage welcome message on connect\n" - " -z, --startminimized start minimizied\n" - " --serverpublicip specify your public IP address when\n" - " running a slave and your own directory server\n" - " behind the same NAT\n" - " --serverbindip specify the IP address the server will bind to\n" - "\nClient only:\n" - " -M, --mutestream starts the application in muted state\n" - " --mutemyown mute me in my personal mix (headless only)\n" - " -c, --connect connect to given server address on startup\n" - " -j, --nojackconnect disable auto Jack connections\n" - " --ctrlmidich MIDI controller channel to listen\n" - " --clientname client name (window title and jack client name)\n" - "\nExample: " + QString ( argv[0] ) + " -s --inifile myinifile.ini\n"; + return "Usage: " + QString ( argv[0] ) + + " [option] [optional argument]\n" + "\nGeneral options:\n" + " -h, -?, --help display this help text and exit\n" + " -i, --inifile initialization file name (not\n" + " supported for headless server mode)\n" + " -n, --nogui disable GUI\n" + " -p, --port set the local port number\n" + " -Q, --qos set the QoS value. Default is 128. Disable with 0\n" + " (see the Jamulus website to enable QoS on Windows)\n" + " -t, --notranslation disable translation (use English language)\n" + " -v, --version output version information and exit\n" + "\nServer only:\n" + " -d, --discononquit disconnect all clients on quit\n" + " -e, --directoryserver address of the directory server with which to register\n" + " (or 'localhost' to host a server list on this server)\n" + " -f, --listfilter server list whitelist filter in the format:\n" + " [IP address 1];[IP address 2];[IP address 3]; ...\n" + " -F, --fastupdate use 64 samples frame size mode\n" + " -l, --log enable logging, set file name\n" + " -L, --licence show an agreement window before users can connect\n" + " -m, --htmlstatus enable HTML status file, set file name\n" + " -o, --serverinfo infos of this server in the format:\n" + " [name];[city];[country as QLocale ID]\n" + " -P, --delaypan start with delay panning enabled\n" + " -R, --recording sets directory to contain recorded jams\n" + " --norecord disables recording (when enabled by default by -R)\n" + " -s, --server start server\n" + " -T, --multithreading use multithreading to make better use of\n" + " multi-core CPUs and support more clients\n" + " -u, --numchannels maximum number of channels\n" + " -w, --welcomemessage welcome message on connect\n" + " -z, --startminimized start minimizied\n" + " --serverpublicip specify your public IP address when\n" + " running a slave and your own directory server\n" + " behind the same NAT\n" + " --serverbindip specify the IP address the server will bind to\n" + "\nClient only:\n" + " -M, --mutestream starts the application in muted state\n" + " --mutemyown mute me in my personal mix (headless only)\n" + " -c, --connect connect to given server address on startup\n" + " -j, --nojackconnect disable auto Jack connections\n" + " --ctrlmidich MIDI controller channel to listen\n" + " --clientname client name (window title and jack client name)\n" + "\nExample: " + + QString ( argv[0] ) + " -s --inifile myinifile.ini\n"; } -bool GetFlagArgument ( char** argv, - int& i, - QString strShortOpt, - QString strLongOpt ) +bool GetFlagArgument ( char** argv, int& i, QString strShortOpt, QString strLongOpt ) { - if ( ( !strShortOpt.compare ( argv[i] ) ) || - ( !strLongOpt.compare ( argv[i] ) ) ) + if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) { return true; } @@ -966,20 +791,13 @@ bool GetFlagArgument ( char** argv, } } -bool GetStringArgument ( int argc, - char** argv, - int& i, - QString strShortOpt, - QString strLongOpt, - QString& strArg ) +bool GetStringArgument ( int argc, char** argv, int& i, QString strShortOpt, QString strLongOpt, QString& strArg ) { - if ( ( !strShortOpt.compare ( argv[i] ) ) || - ( !strLongOpt.compare ( argv[i] ) ) ) + if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) { if ( ++i >= argc ) { - qCritical() << qUtf8Printable( QString( "%1: '%2' needs a string argument." ) - .arg( argv[0] ).arg( strLongOpt ) ); + qCritical() << qUtf8Printable ( QString ( "%1: '%2' needs a string argument." ).arg ( argv[0] ).arg ( strLongOpt ) ); exit ( 1 ); } @@ -993,34 +811,29 @@ bool GetStringArgument ( int argc, } } -bool GetNumericArgument ( int argc, - char** argv, - int& i, - QString strShortOpt, - QString strLongOpt, - double rRangeStart, - double rRangeStop, - double& rValue ) +bool GetNumericArgument ( int argc, + char** argv, + int& i, + QString strShortOpt, + QString strLongOpt, + double rRangeStart, + double rRangeStop, + double& rValue ) { - if ( ( !strShortOpt.compare ( argv[i] ) ) || - ( !strLongOpt.compare ( argv[i] ) ) ) + if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) { QString errmsg = "%1: '%2' needs a numeric argument between '%3' and '%4'."; if ( ++i >= argc ) { - qCritical() << qUtf8Printable( errmsg - .arg( argv[0] ).arg( strLongOpt ).arg( rRangeStart ).arg( rRangeStop ) ); + qCritical() << qUtf8Printable ( errmsg.arg ( argv[0] ).arg ( strLongOpt ).arg ( rRangeStart ).arg ( rRangeStop ) ); exit ( 1 ); } - char *p; + char* p; rValue = strtod ( argv[i], &p ); - if ( *p || - ( rValue < rRangeStart ) || - ( rValue > rRangeStop ) ) + if ( *p || ( rValue < rRangeStart ) || ( rValue > rRangeStop ) ) { - qCritical() << qUtf8Printable( errmsg - .arg( argv[0] ).arg( strLongOpt ).arg( rRangeStart ).arg( rRangeStop ) ); + qCritical() << qUtf8Printable ( errmsg.arg ( argv[0] ).arg ( strLongOpt ).arg ( rRangeStart ).arg ( rRangeStop ) ); exit ( 1 ); } diff --git a/src/multicolorled.cpp b/src/multicolorled.cpp old mode 100755 new mode 100644 index 4fa772c730..2d21fb0270 --- a/src/multicolorled.cpp +++ b/src/multicolorled.cpp @@ -27,18 +27,17 @@ #include "multicolorled.h" - /* Implementation *************************************************************/ -CMultiColorLED::CMultiColorLED ( QWidget* parent ) - : QLabel ( parent ), - BitmCubeDisabled ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDDisabledSmall.png" ) ), - BitmCubeGrey ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreySmall.png" ) ), - BitmCubeGreen ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenSmall.png" ) ), - BitmCubeYellow ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDYellowSmall.png" ) ), - BitmCubeRed ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDRedSmall.png" ) ), - BitmIndicatorGreen ( QString::fromUtf8 ( ":/png/LEDs/res/IndicatorGreen.png" ) ), +CMultiColorLED::CMultiColorLED ( QWidget* parent ) : + QLabel ( parent ), + BitmCubeDisabled ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDDisabledSmall.png" ) ), + BitmCubeGrey ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreySmall.png" ) ), + BitmCubeGreen ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenSmall.png" ) ), + BitmCubeYellow ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDYellowSmall.png" ) ), + BitmCubeRed ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDRedSmall.png" ) ), + BitmIndicatorGreen ( QString::fromUtf8 ( ":/png/LEDs/res/IndicatorGreen.png" ) ), BitmIndicatorYellow ( QString::fromUtf8 ( ":/png/LEDs/res/IndicatorYellow.png" ) ), - BitmIndicatorRed ( QString::fromUtf8 ( ":/png/LEDs/res/IndicatorRed.png" ) ) + BitmIndicatorRed ( QString::fromUtf8 ( ":/png/LEDs/res/IndicatorRed.png" ) ) { // set init bitmap setPixmap ( BitmCubeGrey ); diff --git a/src/multicolorled.h b/src/multicolorled.h old mode 100755 new mode 100644 index 9f5e371fb8..ea5a5d0078 --- a/src/multicolorled.h +++ b/src/multicolorled.h @@ -15,16 +15,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -36,7 +36,6 @@ #include #include "global.h" - /* Classes ********************************************************************/ class CMultiColorLED : public QLabel { @@ -68,7 +67,7 @@ class CMultiColorLED : public QLabel ELightColor eColorFlag; virtual void changeEvent ( QEvent* curEvent ); - void SetColor ( const ELightColor eNewColorFlag ); + void SetColor ( const ELightColor eNewColorFlag ); QPixmap BitmCubeDisabled; QPixmap BitmCubeGrey; @@ -79,10 +78,10 @@ class CMultiColorLED : public QLabel QPixmap BitmIndicatorYellow; QPixmap BitmIndicatorRed; - int iUpdateTime; - EType eType; + int iUpdateTime; + EType eType; - bool bFlagRedLi; - bool bFlagGreenLi; - bool bFlagYellowLi; + bool bFlagRedLi; + bool bFlagGreenLi; + bool bFlagYellowLi; }; diff --git a/src/protocol.cpp b/src/protocol.cpp old mode 100755 new mode 100644 index 5423c9d873..46aac578b3 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -436,7 +436,6 @@ CONNECTION LESS MESSAGES #include "protocol.h" - /* Implementation *************************************************************/ CProtocol::CProtocol() { @@ -445,10 +444,8 @@ CProtocol::CProtocol() Reset(); - // Connections ------------------------------------------------------------- - QObject::connect ( &TimerSendMess, &QTimer::timeout, - this, &CProtocol::OnTimerSendMess ); + QObject::connect ( &TimerSendMess, &QTimer::timeout, this, &CProtocol::OnTimerSendMess ); } void CProtocol::Reset() @@ -467,9 +464,7 @@ void CProtocol::Reset() SendMessQueue.clear(); } -void CProtocol::EnqueueMessage ( CVector& vecMessage, - const int iCnt, - const int iID ) +void CProtocol::EnqueueMessage ( CVector& vecMessage, const int iCnt, const int iID ) { bool bListWasEmpty; @@ -530,8 +525,7 @@ void CProtocol::SendMessage() } } -void CProtocol::CreateAndSendMessage ( const int iID, - const CVector& vecData ) +void CProtocol::CreateAndSendMessage ( const int iID, const CVector& vecData ) { CVector vecNewMessage; int iCurCounter; @@ -544,8 +538,7 @@ void CProtocol::CreateAndSendMessage ( const int iID, int iStartIndexInData = 0; // init index // calculate the number of split parts - const int iNumParts = static_cast ( - std::ceil ( static_cast ( iDataLen ) / MESS_SPLIT_PART_SIZE_BYTES ) ); + const int iNumParts = static_cast ( std::ceil ( static_cast ( iDataLen ) / MESS_SPLIT_PART_SIZE_BYTES ) ); for ( int iSplitCnt = 0; iSplitCnt < iNumParts; iSplitCnt++ ) { @@ -557,13 +550,7 @@ void CProtocol::CreateAndSendMessage ( const int iID, iCurPartSize = iDataLen - iStartIndexInData; } - GenSplitMessageContainer ( vecNewSplitMessage, - iID, - iNumParts, - iSplitCnt, - vecData, - iStartIndexInData, - iCurPartSize ); + GenSplitMessageContainer ( vecNewSplitMessage, iID, iNumParts, iSplitCnt, vecData, iStartIndexInData, iCurPartSize ); // increment the start index of the source data by the last part size iStartIndexInData += iCurPartSize; @@ -605,12 +592,11 @@ void CProtocol::CreateAndSendMessage ( const int iID, } } -void CProtocol::CreateAndImmSendAcknMess ( const int& iID, - const int& iCnt ) +void CProtocol::CreateAndImmSendAcknMess ( const int& iID, const int& iCnt ) { CVector vecAcknMessage; CVector vecData ( 2 ); // 2 bytes of data - int iPos = 0; // init position pointer + int iPos = 0; // init position pointer // build data vector PutValOnStream ( vecData, iPos, static_cast ( iID ), 2 ); @@ -622,9 +608,7 @@ void CProtocol::CreateAndImmSendAcknMess ( const int& iID, emit MessReadyForSending ( vecAcknMessage ); } -void CProtocol::CreateAndImmSendConLessMessage ( const int iID, - const CVector& vecData, - const CHostAddress& InetAddr ) +void CProtocol::CreateAndImmSendConLessMessage ( const int iID, const CVector& vecData, const CHostAddress& InetAddr ) { CVector vecNewMessage; @@ -636,16 +620,14 @@ void CProtocol::CreateAndImmSendConLessMessage ( const int iID, emit CLMessReadyForSending ( InetAddr, vecNewMessage ); } -void CProtocol::ParseMessageBody ( const CVector& vecbyMesBodyData, - const int iRecCounter, - const int iRecID ) +void CProtocol::ParseMessageBody ( const CVector& vecbyMesBodyData, const int iRecCounter, const int iRecID ) { -// clang-format off + // clang-format off /* // TEST channel implementation: randomly delete protocol messages (50 % loss) if ( rand() < ( RAND_MAX / 2 ) ) return false; */ -// clang-format on + // clang-format on // In case we received a message and returned an answer but our answer // did not make it to the receiver, he will resend his message. We check @@ -681,8 +663,7 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false; // check if this is the correct acknowledgment if ( !SendMessQueue.empty() ) { - if ( ( SendMessQueue.front().iCnt == iRecCounter ) && - ( SendMessQueue.front().iID == iData ) ) + if ( ( SendMessQueue.front().iCnt == iRecCounter ) && ( SendMessQueue.front().iID == iData ) ) { // message acknowledged, remove from queue SendMessQueue.pop_front(); @@ -723,8 +704,7 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false; iCurPartSize ) ) { // consistency checks - if ( ( iSplitMessageCnt != iReceivedSplitCnt ) || - ( iSplitMessageCnt >= iReceivedNumParts ) || + if ( ( iSplitMessageCnt != iReceivedSplitCnt ) || ( iSplitMessageCnt >= iReceivedNumParts ) || ( iSplitMessageCnt >= MAX_NUM_MESS_SPLIT_PARTS ) ) { // in case of an error we reset the split message counter @@ -863,16 +843,14 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false; } } -void CProtocol::ParseConnectionLessMessageBody ( const CVector& vecbyMesBodyData, - const int iRecID, - const CHostAddress& InetAddr ) +void CProtocol::ParseConnectionLessMessageBody ( const CVector& vecbyMesBodyData, const int iRecID, const CHostAddress& InetAddr ) { -// clang-format off + // clang-format off /* // TEST channel implementation: randomly delete protocol messages (50 % loss) if ( rand() < ( RAND_MAX / 2 ) ) return false; */ -// clang-format on + // clang-format on // check which type of message we received and do action switch ( iRecID ) @@ -947,7 +925,6 @@ if ( rand() < ( RAND_MAX / 2 ) ) return false; } } - /******************************************************************************\ * Access functions for creating and parsing messages * \******************************************************************************/ @@ -975,9 +952,7 @@ bool CProtocol::EvaluateJitBufMes ( const CVector& vecData ) // extract jitter buffer size const int iData = static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); - if ( ( ( iData < MIN_NET_BUF_SIZE_NUM_BL ) || - ( iData > MAX_NET_BUF_SIZE_NUM_BL ) ) && - ( iData != AUTO_NET_BUF_SIZE_FOR_PROTOCOL ) ) + if ( ( ( iData < MIN_NET_BUF_SIZE_NUM_BL ) || ( iData > MAX_NET_BUF_SIZE_NUM_BL ) ) && ( iData != AUTO_NET_BUF_SIZE_FOR_PROTOCOL ) ) { return true; // return error code } @@ -988,11 +963,7 @@ bool CProtocol::EvaluateJitBufMes ( const CVector& vecData ) return false; // no error } -void CProtocol::CreateReqJitBufMes() -{ - CreateAndSendMessage ( PROTMESSID_REQ_JITT_BUF_SIZE, - CVector ( 0 ) ); -} +void CProtocol::CreateReqJitBufMes() { CreateAndSendMessage ( PROTMESSID_REQ_JITT_BUF_SIZE, CVector ( 0 ) ); } bool CProtocol::EvaluateReqJitBufMes() { @@ -1092,7 +1063,7 @@ void CProtocol::CreateChanPanMes ( const int iChanID, const float fPan ) CreateAndSendMessage ( PROTMESSID_CHANNEL_PAN, vecData ); } -bool CProtocol::EvaluateChanPanMes ( const CVector &vecData ) +bool CProtocol::EvaluateChanPanMes ( const CVector& vecData ) { int iPos = 0; // init position pointer @@ -1132,7 +1103,7 @@ void CProtocol::CreateMuteStateHasChangedMes ( const int iChanID, const bool bIs CreateAndSendMessage ( PROTMESSID_MUTE_STATE_CHANGED, vecData ); } -bool CProtocol::EvaluateMuteStateHasChangedMes ( const CVector &vecData ) +bool CProtocol::EvaluateMuteStateHasChangedMes ( const CVector& vecData ) { int iPos = 0; // init position pointer @@ -1169,33 +1140,28 @@ void CProtocol::CreateConClientListMes ( const CVector& vecChanInf const QByteArray strUTF8City = vecChanInfo[i].strCity.toUtf8(); // size of current list entry - const int iCurListEntrLen = - 1 + // chan ID - 2 + // country - 4 + // instrument - 1 + // skill level - 4 + // IP address - 2 + strUTF8Name.size() + // utf-8 str. size / str. - 2 + strUTF8City.size(); // utf-8 str. size / str. + const int iCurListEntrLen = 1 + // chan ID + 2 + // country + 4 + // instrument + 1 + // skill level + 4 + // IP address + 2 + strUTF8Name.size() + // utf-8 str. size / str. + 2 + strUTF8City.size(); // utf-8 str. size / str. // make space for new data vecData.Enlarge ( iCurListEntrLen ); // channel ID (1 byte) - PutValOnStream ( vecData, iPos, - static_cast ( vecChanInfo[i].iChanID ), 1 ); + PutValOnStream ( vecData, iPos, static_cast ( vecChanInfo[i].iChanID ), 1 ); // country (2 bytes) - PutValOnStream ( vecData, iPos, - static_cast ( vecChanInfo[i].eCountry ), 2 ); + PutValOnStream ( vecData, iPos, static_cast ( vecChanInfo[i].eCountry ), 2 ); // instrument (4 bytes) - PutValOnStream ( vecData, iPos, - static_cast ( vecChanInfo[i].iInstrument ), 4 ); + PutValOnStream ( vecData, iPos, static_cast ( vecChanInfo[i].iInstrument ), 4 ); // skill level (1 byte) - PutValOnStream ( vecData, iPos, - static_cast ( vecChanInfo[i].eSkillLevel ), 1 ); + PutValOnStream ( vecData, iPos, static_cast ( vecChanInfo[i].eSkillLevel ), 1 ); // used to be IP address before #316 (4 bytes) PutValOnStream ( vecData, iPos, 0, 4 ); @@ -1225,51 +1191,36 @@ bool CProtocol::EvaluateConClientListMes ( const CVector& vecData ) } // channel ID (1 byte) - const int iChanID = - static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + const int iChanID = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); // country (2 bytes) - const QLocale::Country eCountry = - static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); + const QLocale::Country eCountry = static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); // instrument (4 bytes) - const int iInstrument = - static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); + const int iInstrument = static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); // skill level (1 byte) - const ESkillLevel eSkillLevel = - static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + const ESkillLevel eSkillLevel = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); // used to be IP address, zero since #316 (4 bytes) iPos += 4; // name QString strCurName; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_FADER_TAG, - strCurName ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_FADER_TAG, strCurName ) ) { return true; // return error code } // city QString strCurCity; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_SERVER_CITY, - strCurCity ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_SERVER_CITY, strCurCity ) ) { return true; // return error code } // add channel information to vector - vecChanInfo.Add ( CChannelInfo ( iChanID, - strCurName, - eCountry, - strCurCity, - iInstrument, - eSkillLevel ) ); + vecChanInfo.Add ( CChannelInfo ( iChanID, strCurName, eCountry, strCurCity, iInstrument, eSkillLevel ) ); } // check size: all data is read, the position must now be at the end @@ -1284,10 +1235,7 @@ bool CProtocol::EvaluateConClientListMes ( const CVector& vecData ) return false; // no error } -void CProtocol::CreateReqConnClientsList() -{ - CreateAndSendMessage ( PROTMESSID_REQ_CONN_CLIENTS_LIST, CVector ( 0 ) ); -} +void CProtocol::CreateReqConnClientsList() { CreateAndSendMessage ( PROTMESSID_REQ_CONN_CLIENTS_LIST, CVector ( 0 ) ); } bool CProtocol::EvaluateReqConnClientsList() { @@ -1306,12 +1254,11 @@ void CProtocol::CreateChanInfoMes ( const CChannelCoreInfo ChanInfo ) const QByteArray strUTF8City = ChanInfo.strCity.toUtf8(); // size of current list entry - const int iEntrLen = - 2 + // country - 4 + // instrument - 1 + // skill level - 2 + strUTF8Name.size() + // utf-8 str. size / str. - 2 + strUTF8City.size(); // utf-8 str. size / str. + const int iEntrLen = 2 + // country + 4 + // instrument + 1 + // skill level + 2 + strUTF8Name.size() + // utf-8 str. size / str. + 2 + strUTF8City.size(); // utf-8 str. size / str. // build data vector CVector vecData ( iEntrLen ); @@ -1356,19 +1303,13 @@ bool CProtocol::EvaluateChanInfoMes ( const CVector& vecData ) ChanInfo.eSkillLevel = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); // name - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_FADER_TAG, - ChanInfo.strName ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_FADER_TAG, ChanInfo.strName ) ) { return true; // return error code } // city - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_SERVER_CITY, - ChanInfo.strCity ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_SERVER_CITY, ChanInfo.strCity ) ) { return true; // return error code } @@ -1385,10 +1326,7 @@ bool CProtocol::EvaluateChanInfoMes ( const CVector& vecData ) return false; // no error } -void CProtocol::CreateReqChanInfoMes() -{ - CreateAndSendMessage ( PROTMESSID_REQ_CHANNEL_INFOS, CVector ( 0 ) ); -} +void CProtocol::CreateReqChanInfoMes() { CreateAndSendMessage ( PROTMESSID_REQ_CHANNEL_INFOS, CVector ( 0 ) ); } bool CProtocol::EvaluateReqChanInfoMes() { @@ -1425,10 +1363,7 @@ bool CProtocol::EvaluateChatTextMes ( const CVector& vecData ) // chat text QString strChatText; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_CHAT_TEXT_PLUS_HTML, - strChatText ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_CHAT_TEXT_PLUS_HTML, strChatText ) ) { return true; // return error code } @@ -1450,14 +1385,13 @@ void CProtocol::CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrPr int iPos = 0; // init position pointer // size of current message body - const int iEntrLen = - 4 + // netw size - 2 + // block size fact - 1 + // num chan - 4 + // sam rate - 2 + // audiocod type - 2 + // version - 4; // audiocod arg + const int iEntrLen = 4 + // netw size + 2 + // block size fact + 1 + // num chan + 4 + // sam rate + 2 + // audiocod type + 2 + // version + 4; // audiocod arg // build data vector CVector vecData ( iEntrLen ); @@ -1492,14 +1426,13 @@ bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector& vecData ) CNetworkTransportProps ReceivedNetwTranspProps; // size of current message body - const int iEntrLen = - 4 + // netw size - 2 + // block size fact - 1 + // num chan - 4 + // sam rate - 2 + // audiocod type - 2 + // flags - 4; // audiocod arg + const int iEntrLen = 4 + // netw size + 2 + // block size fact + 1 + // num chan + 4 + // sam rate + 2 + // audiocod type + 2 + // flags + 4; // audiocod arg // check size if ( vecData.Size() != iEntrLen ) @@ -1508,8 +1441,7 @@ bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector& vecData ) } // length of the base network packet (frame) in bytes (4 bytes) - ReceivedNetwTranspProps.iBaseNetworkPacketSize = - static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); + ReceivedNetwTranspProps.iBaseNetworkPacketSize = static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); // at least CELT_MINIMUM_NUM_BYTES bytes are required for the CELC codec if ( ( ReceivedNetwTranspProps.iBaseNetworkPacketSize < CELT_MINIMUM_NUM_BYTES ) || @@ -1519,8 +1451,7 @@ bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector& vecData ) } // block size factor (2 bytes) - ReceivedNetwTranspProps.iBlockSizeFact = - static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); + ReceivedNetwTranspProps.iBlockSizeFact = static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); if ( ( ReceivedNetwTranspProps.iBlockSizeFact != FRAME_SIZE_FACTOR_PREFERRED ) && ( ReceivedNetwTranspProps.iBlockSizeFact != FRAME_SIZE_FACTOR_DEFAULT ) && @@ -1531,42 +1462,33 @@ bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector& vecData ) // number of channels of the audio signal, only mono (1 channel) or // stereo (2 channels) allowed (1 byte) - ReceivedNetwTranspProps.iNumAudioChannels = - static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + ReceivedNetwTranspProps.iNumAudioChannels = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); - if ( ( ReceivedNetwTranspProps.iNumAudioChannels != 1 ) && - ( ReceivedNetwTranspProps.iNumAudioChannels != 2 ) ) + if ( ( ReceivedNetwTranspProps.iNumAudioChannels != 1 ) && ( ReceivedNetwTranspProps.iNumAudioChannels != 2 ) ) { return true; // return error code } // sample rate of the audio stream (4 bytes) - ReceivedNetwTranspProps.iSampleRate = - static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); + ReceivedNetwTranspProps.iSampleRate = static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); // audio coding type (2 bytes) with error check - const int iRecCodingType = - static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); + const int iRecCodingType = static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); // note that CT_NONE is not a valid setting but only used for server // initialization - if ( ( iRecCodingType != CT_CELT ) && - ( iRecCodingType != CT_OPUS ) && - ( iRecCodingType != CT_OPUS64 ) ) + if ( ( iRecCodingType != CT_CELT ) && ( iRecCodingType != CT_OPUS ) && ( iRecCodingType != CT_OPUS64 ) ) { return true; } - ReceivedNetwTranspProps.eAudioCodingType = - static_cast ( iRecCodingType ); + ReceivedNetwTranspProps.eAudioCodingType = static_cast ( iRecCodingType ); // flags (2 bytes) - ReceivedNetwTranspProps.eFlags = - static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); + ReceivedNetwTranspProps.eFlags = static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); // argument for the audio coder (4 bytes) - ReceivedNetwTranspProps.iAudioCodingArg = - static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); + ReceivedNetwTranspProps.iAudioCodingArg = static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); // invoke message action emit NetTranspPropsReceived ( ReceivedNetwTranspProps ); @@ -1574,11 +1496,7 @@ bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector& vecData ) return false; // no error } -void CProtocol::CreateReqNetwTranspPropsMes() -{ - CreateAndSendMessage ( PROTMESSID_REQ_NETW_TRANSPORT_PROPS, - CVector ( 0 ) ); -} +void CProtocol::CreateReqNetwTranspPropsMes() { CreateAndSendMessage ( PROTMESSID_REQ_NETW_TRANSPORT_PROPS, CVector ( 0 ) ); } bool CProtocol::EvaluateReqNetwTranspPropsMes() { @@ -1588,11 +1506,7 @@ bool CProtocol::EvaluateReqNetwTranspPropsMes() return false; // no error } -void CProtocol::CreateReqSplitMessSupportMes() -{ - CreateAndSendMessage ( PROTMESSID_REQ_SPLIT_MESS_SUPPORT, - CVector ( 0 ) ); -} +void CProtocol::CreateReqSplitMessSupportMes() { CreateAndSendMessage ( PROTMESSID_REQ_SPLIT_MESS_SUPPORT, CVector ( 0 ) ); } bool CProtocol::EvaluateReqSplitMessSupportMes() { @@ -1602,11 +1516,7 @@ bool CProtocol::EvaluateReqSplitMessSupportMes() return false; // no error } -void CProtocol::CreateSplitMessSupportedMes() -{ - CreateAndSendMessage ( PROTMESSID_SPLIT_MESS_SUPPORTED, - CVector ( 0 ) ); -} +void CProtocol::CreateSplitMessSupportedMes() { CreateAndSendMessage ( PROTMESSID_SPLIT_MESS_SUPPORTED, CVector ( 0 ) ); } bool CProtocol::EvaluateSplitMessSupportedMes() { @@ -1638,11 +1548,9 @@ bool CProtocol::EvaluateLicenceRequiredMes ( const CVector& vecData ) } // extract licence type - const ELicenceType eLicenceType = - static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + const ELicenceType eLicenceType = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); - if ( ( eLicenceType != LT_CREATIVECOMMONS ) && - ( eLicenceType != LT_NO_LICENCE ) ) + if ( ( eLicenceType != LT_CREATIVECOMMONS ) && ( eLicenceType != LT_NO_LICENCE ) ) { return true; // return error code } @@ -1653,16 +1561,13 @@ bool CProtocol::EvaluateLicenceRequiredMes ( const CVector& vecData ) return false; // no error } -void CProtocol::CreateOpusSupportedMes() -{ - CreateAndSendMessage ( PROTMESSID_OPUS_SUPPORTED, CVector ( 0 ) ); -} +void CProtocol::CreateOpusSupportedMes() { CreateAndSendMessage ( PROTMESSID_OPUS_SUPPORTED, CVector ( 0 ) ); } // TODO needed for compatibility to old servers >= 3.4.6 and <= 3.5.12 void CProtocol::CreateReqChannelLevelListMes() { CVector vecData ( 1 ); // 1 byte of data - int iPos = 0; // init position pointer + int iPos = 0; // init position pointer PutValOnStream ( vecData, iPos, static_cast ( true ), 1 ); @@ -1680,16 +1585,14 @@ void CProtocol::CreateVersionAndOSMes() const QByteArray strUTF8Version = strVerion.toUtf8(); // size of current message body - const int iEntrLen = - 1 + // operating system - 2 + strUTF8Version.size(); // version utf-8 str. size / string + const int iEntrLen = 1 + // operating system + 2 + strUTF8Version.size(); // version utf-8 str. size / string // build data vector CVector vecData ( iEntrLen ); // operating system (1 byte) - PutValOnStream ( vecData, iPos, - static_cast ( COSUtil::GetOperatingSystem() ), 1 ); + PutValOnStream ( vecData, iPos, static_cast ( COSUtil::GetOperatingSystem() ), 1 ); // version PutStringUTF8OnStream ( vecData, iPos, strUTF8Version ); @@ -1699,7 +1602,7 @@ void CProtocol::CreateVersionAndOSMes() bool CProtocol::EvaluateVersionAndOSMes ( const CVector& vecData ) { - int iPos = 0; // init position pointer + int iPos = 0; // init position pointer const int iDataLen = vecData.Size(); // check size (the first 1 byte) @@ -1709,15 +1612,11 @@ bool CProtocol::EvaluateVersionAndOSMes ( const CVector& vecData ) } // operating system (1 byte) - const COSUtil::EOpSystemType eOSType = - static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + const COSUtil::EOpSystemType eOSType = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); // version text QString strVersion; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_VERSION_TEXT, - strVersion ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_VERSION_TEXT, strVersion ) ) { return true; // return error code } @@ -1746,7 +1645,7 @@ void CProtocol::CreateRecorderStateMes ( const ERecorderState eRecorderState ) CreateAndSendMessage ( PROTMESSID_RECORDER_STATE, vecData ); } -bool CProtocol::EvaluateRecorderStateMes(const CVector& vecData) +bool CProtocol::EvaluateRecorderStateMes ( const CVector& vecData ) { int iPos = 0; // init position pointer @@ -1757,13 +1656,10 @@ bool CProtocol::EvaluateRecorderStateMes(const CVector& vecData) } // server jam recorder state (1 byte) - const int iRecorderState = - static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + const int iRecorderState = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); // note that RS_UNDEFINED is only internally used - if ( ( iRecorderState != RS_NOT_INITIALISED ) && - ( iRecorderState != RS_NOT_ENABLED ) && - ( iRecorderState != RS_RECORDING ) ) + if ( ( iRecorderState != RS_NOT_INITIALISED ) && ( iRecorderState != RS_NOT_ENABLED ) && ( iRecorderState != RS_RECORDING ) ) { return true; } @@ -1774,7 +1670,6 @@ bool CProtocol::EvaluateRecorderStateMes(const CVector& vecData) return false; // no error } - // Connection less messages ---------------------------------------------------- void CProtocol::CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ) { @@ -1786,13 +1681,10 @@ void CProtocol::CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ) // transmit time (4 bytes) PutValOnStream ( vecData, iPos, static_cast ( iMs ), 4 ); - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_PING_MS, - vecData, - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_PING_MS, vecData, InetAddr ); } -bool CProtocol::EvaluateCLPingMes ( const CHostAddress& InetAddr, - const CVector& vecData ) +bool CProtocol::EvaluateCLPingMes ( const CHostAddress& InetAddr, const CVector& vecData ) { int iPos = 0; // init position pointer @@ -1803,15 +1695,12 @@ bool CProtocol::EvaluateCLPingMes ( const CHostAddress& InetAddr, } // invoke message action - emit CLPingReceived ( InetAddr, - static_cast ( GetValFromStream ( vecData, iPos, 4 ) ) ); + emit CLPingReceived ( InetAddr, static_cast ( GetValFromStream ( vecData, iPos, 4 ) ) ); return false; // no error } -void CProtocol::CreateCLPingWithNumClientsMes ( const CHostAddress& InetAddr, - const int iMs, - const int iNumClients ) +void CProtocol::CreateCLPingWithNumClientsMes ( const CHostAddress& InetAddr, const int iMs, const int iNumClients ) { int iPos = 0; // init position pointer @@ -1824,13 +1713,10 @@ void CProtocol::CreateCLPingWithNumClientsMes ( const CHostAddress& InetAddr, // current number of connected clients (1 byte) PutValOnStream ( vecData, iPos, static_cast ( iNumClients ), 1 ); - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_PING_MS_WITHNUMCLIENTS, - vecData, - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_PING_MS_WITHNUMCLIENTS, vecData, InetAddr ); } -bool CProtocol::EvaluateCLPingWithNumClientsMes ( const CHostAddress& InetAddr, - const CVector& vecData ) +bool CProtocol::EvaluateCLPingWithNumClientsMes ( const CHostAddress& InetAddr, const CVector& vecData ) { int iPos = 0; // init position pointer @@ -1854,9 +1740,7 @@ bool CProtocol::EvaluateCLPingWithNumClientsMes ( const CHostAddress& InetAd void CProtocol::CreateCLServerFullMes ( const CHostAddress& InetAddr ) { - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SERVER_FULL, - CVector ( 0 ), - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SERVER_FULL, CVector ( 0 ), InetAddr ); } bool CProtocol::EvaluateCLServerFullMes() @@ -1867,9 +1751,7 @@ bool CProtocol::EvaluateCLServerFullMes() return false; // no error } -void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr, - const CHostAddress& LInetAddr, - const CServerCoreInfo& ServerInfo ) +void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr, const CHostAddress& LInetAddr, const CServerCoreInfo& ServerInfo ) { int iPos = 0; // init position pointer @@ -1879,14 +1761,13 @@ void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr, const QByteArray strUTF8City = ServerInfo.strCity.toUtf8(); // size of current message body - const int iEntrLen = - 2 + // server internal port number - 2 + // country - 1 + // maximum number of connected clients - 1 + // is permanent flag - 2 + strUTF8Name.size() + // name utf-8 str. size / str. - 2 + strUTF8LInetAddr.size() + // server internal address utf-8 str. size / str. - 2 + strUTF8City.size(); // city utf-8 str. size / str. + const int iEntrLen = 2 + // server internal port number + 2 + // country + 1 + // maximum number of connected clients + 1 + // is permanent flag + 2 + strUTF8Name.size() + // name utf-8 str. size / str. + 2 + strUTF8LInetAddr.size() + // server internal address utf-8 str. size / str. + 2 + strUTF8City.size(); // city utf-8 str. size / str. // build data vector CVector vecData ( iEntrLen ); @@ -1912,13 +1793,10 @@ void CProtocol::CreateCLRegisterServerMes ( const CHostAddress& InetAddr, // city PutStringUTF8OnStream ( vecData, iPos, strUTF8City ); - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REGISTER_SERVER, - vecData, - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REGISTER_SERVER, vecData, InetAddr ); } -bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr, - const CVector& vecData ) +bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr, const CVector& vecData ) { int iPos = 0; // init position pointer const int iDataLen = vecData.Size(); @@ -1945,19 +1823,13 @@ bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr, RecServerInfo.bPermanentOnline = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); // server name - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_SERVER_NAME, - RecServerInfo.strName ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_SERVER_NAME, RecServerInfo.strName ) ) { return true; // return error code } // server internal address - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_IP_ADDRESS, - sLocHost ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_IP_ADDRESS, sLocHost ) ) { return true; // return error code } @@ -1973,10 +1845,7 @@ bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr, } // server city - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_SERVER_CITY, - RecServerInfo.strCity ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_SERVER_CITY, RecServerInfo.strCity ) ) { return true; // return error code } @@ -1993,9 +1862,7 @@ bool CProtocol::EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr, return false; // no error } -void CProtocol::CreateCLRegisterServerExMes ( const CHostAddress& InetAddr, - const CHostAddress& LInetAddr, - const CServerCoreInfo& ServerInfo ) +void CProtocol::CreateCLRegisterServerExMes ( const CHostAddress& InetAddr, const CHostAddress& LInetAddr, const CServerCoreInfo& ServerInfo ) { int iPos = 0; // init position pointer @@ -2006,16 +1873,15 @@ void CProtocol::CreateCLRegisterServerExMes ( const CHostAddress& InetAddr, const QByteArray strUTF8Version = QString ( VERSION ).toUtf8(); // size of current message body - const int iEntrLen = - 2 + // server internal port number - 2 + // country - 1 + // maximum number of connected clients - 1 + // is permanent flag - 2 + strUTF8Name.size() + // name utf-8 str. size / str. - 2 + strUTF8LInetAddr.size() + // server internal address utf-8 str. size / str. - 2 + strUTF8City.size() + // city utf-8 str. size / str. - 1 + // operating system - 2 + strUTF8Version.size(); // version utf-8 str. size / str. + const int iEntrLen = 2 + // server internal port number + 2 + // country + 1 + // maximum number of connected clients + 1 + // is permanent flag + 2 + strUTF8Name.size() + // name utf-8 str. size / str. + 2 + strUTF8LInetAddr.size() + // server internal address utf-8 str. size / str. + 2 + strUTF8City.size() + // city utf-8 str. size / str. + 1 + // operating system + 2 + strUTF8Version.size(); // version utf-8 str. size / str. // build data vector CVector vecData ( iEntrLen ); @@ -2042,19 +1908,15 @@ void CProtocol::CreateCLRegisterServerExMes ( const CHostAddress& InetAddr, PutStringUTF8OnStream ( vecData, iPos, strUTF8City ); // operating system (1 byte) - PutValOnStream ( vecData, iPos, - static_cast ( COSUtil::GetOperatingSystem() ), 1 ); + PutValOnStream ( vecData, iPos, static_cast ( COSUtil::GetOperatingSystem() ), 1 ); // version PutStringUTF8OnStream ( vecData, iPos, strUTF8Version ); - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REGISTER_SERVER_EX, - vecData, - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REGISTER_SERVER_EX, vecData, InetAddr ); } -bool CProtocol::EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr, - const CVector& vecData ) +bool CProtocol::EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr, const CVector& vecData ) { int iPos = 0; // init position pointer const int iDataLen = vecData.Size(); @@ -2081,19 +1943,13 @@ bool CProtocol::EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr RecServerInfo.bPermanentOnline = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); // server name - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_SERVER_NAME, - RecServerInfo.strName ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_SERVER_NAME, RecServerInfo.strName ) ) { return true; // return error code } // server internal address - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_IP_ADDRESS, - sLocHost ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_IP_ADDRESS, sLocHost ) ) { return true; // return error code } @@ -2109,10 +1965,7 @@ bool CProtocol::EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr } // server city - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_SERVER_CITY, - RecServerInfo.strCity ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_SERVER_CITY, RecServerInfo.strCity ) ) { return true; // return error code } @@ -2124,15 +1977,11 @@ bool CProtocol::EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr } // operating system (1 byte) - const COSUtil::EOpSystemType eOSType = - static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + const COSUtil::EOpSystemType eOSType = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); // version text QString strVersion; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_VERSION_TEXT, - strVersion ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_VERSION_TEXT, strVersion ) ) { return true; // return error code } @@ -2151,9 +2000,7 @@ bool CProtocol::EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr void CProtocol::CreateCLUnregisterServerMes ( const CHostAddress& InetAddr ) { - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_UNREGISTER_SERVER, - CVector ( 0 ), - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_UNREGISTER_SERVER, CVector ( 0 ), InetAddr ); } bool CProtocol::EvaluateCLUnregisterServerMes ( const CHostAddress& InetAddr ) @@ -2164,8 +2011,7 @@ bool CProtocol::EvaluateCLUnregisterServerMes ( const CHostAddress& InetAddr ) return false; // no error } -void CProtocol::CreateCLServerListMes ( const CHostAddress& InetAddr, - const CVector vecServerInfo ) +void CProtocol::CreateCLServerListMes ( const CHostAddress& InetAddr, const CVector vecServerInfo ) { const int iNumServers = vecServerInfo.Size(); @@ -2181,40 +2027,34 @@ void CProtocol::CreateCLServerListMes ( const CHostAddress& InetAddr, const QByteArray strUTF8City = vecServerInfo[i].strCity.toUtf8(); // size of current list entry - const int iCurListEntrLen = - 4 + // IP address - 2 + // port number - 2 + // country - 1 + // maximum number of connected clients - 1 + // is permanent flag - 2 + strUTF8Name.size() + // name utf-8 str. size / str. - 2 + // empty string - 2 + strUTF8City.size(); // city utf-8 str. size / str. + const int iCurListEntrLen = 4 + // IP address + 2 + // port number + 2 + // country + 1 + // maximum number of connected clients + 1 + // is permanent flag + 2 + strUTF8Name.size() + // name utf-8 str. size / str. + 2 + // empty string + 2 + strUTF8City.size(); // city utf-8 str. size / str. // make space for new data vecData.Enlarge ( iCurListEntrLen ); // IP address (4 bytes) // note the Server List manager has put the internal details in HostAddr where required - PutValOnStream ( vecData, iPos, static_cast ( - vecServerInfo[i].HostAddr.InetAddr.toIPv4Address() ), 4 ); + PutValOnStream ( vecData, iPos, static_cast ( vecServerInfo[i].HostAddr.InetAddr.toIPv4Address() ), 4 ); // port number (2 bytes) // note the Server List manager has put the internal details in HostAddr where required - PutValOnStream ( vecData, iPos, - static_cast ( vecServerInfo[i].HostAddr.iPort ), 2 ); + PutValOnStream ( vecData, iPos, static_cast ( vecServerInfo[i].HostAddr.iPort ), 2 ); // country (2 bytes) - PutValOnStream ( vecData, iPos, - static_cast ( vecServerInfo[i].eCountry ), 2 ); + PutValOnStream ( vecData, iPos, static_cast ( vecServerInfo[i].eCountry ), 2 ); // maximum number of connected clients (1 byte) - PutValOnStream ( vecData, iPos, - static_cast ( vecServerInfo[i].iMaxNumClients ), 1 ); + PutValOnStream ( vecData, iPos, static_cast ( vecServerInfo[i].iMaxNumClients ), 1 ); // "is permanent" flag (1 byte) - PutValOnStream ( vecData, iPos, - static_cast ( vecServerInfo[i].bPermanentOnline ), 1 ); + PutValOnStream ( vecData, iPos, static_cast ( vecServerInfo[i].bPermanentOnline ), 1 ); // name PutStringUTF8OnStream ( vecData, iPos, strUTF8Name ); @@ -2226,13 +2066,10 @@ void CProtocol::CreateCLServerListMes ( const CHostAddress& InetAddr, PutStringUTF8OnStream ( vecData, iPos, strUTF8City ); } - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SERVER_LIST, - vecData, - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SERVER_LIST, vecData, InetAddr ); } -bool CProtocol::EvaluateCLServerListMes ( const CHostAddress& InetAddr, - const CVector& vecData ) +bool CProtocol::EvaluateCLServerListMes ( const CHostAddress& InetAddr, const CVector& vecData ) { int iPos = 0; // init position pointer const int iDataLen = vecData.Size(); @@ -2263,43 +2100,33 @@ bool CProtocol::EvaluateCLServerListMes ( const CHostAddress& InetAddr, // server name QString strName; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_SERVER_NAME, - strName ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_SERVER_NAME, strName ) ) { return true; // return error code } // empty QString strEmpty; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_IP_ADDRESS, - strEmpty ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_IP_ADDRESS, strEmpty ) ) { return true; // return error code } // server city QString strCity; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_SERVER_CITY, - strCity ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_SERVER_CITY, strCity ) ) { return true; // return error code } // add server information to vector - vecServerInfo.Add ( - CServerInfo ( CHostAddress ( QHostAddress ( iIpAddr ), iPort ), - CHostAddress ( QHostAddress ( iIpAddr ), iPort ), - strName, - eCountry, - strCity, - iMaxNumClients, - bPermanentOnline ) ); + vecServerInfo.Add ( CServerInfo ( CHostAddress ( QHostAddress ( iIpAddr ), iPort ), + CHostAddress ( QHostAddress ( iIpAddr ), iPort ), + strName, + eCountry, + strCity, + iMaxNumClients, + bPermanentOnline ) ); } // check size: all data is read, the position must now be at the end @@ -2314,8 +2141,7 @@ bool CProtocol::EvaluateCLServerListMes ( const CHostAddress& InetAddr, return false; // no error } -void CProtocol::CreateCLRedServerListMes ( const CHostAddress& InetAddr, - const CVector vecServerInfo ) +void CProtocol::CreateCLRedServerListMes ( const CHostAddress& InetAddr, const CVector vecServerInfo ) { const int iNumServers = vecServerInfo.Size(); @@ -2329,35 +2155,29 @@ void CProtocol::CreateCLRedServerListMes ( const CHostAddress& InetAddr, const QByteArray strUTF8Name = vecServerInfo[i].strName.toUtf8(); // size of current list entry - const int iCurListEntrLen = - 4 + // IP address - 2 + // port number - 1 + strUTF8Name.size(); // name utf-8 str. size / str. + const int iCurListEntrLen = 4 + // IP address + 2 + // port number + 1 + strUTF8Name.size(); // name utf-8 str. size / str. // make space for new data vecData.Enlarge ( iCurListEntrLen ); // IP address (4 bytes) // note the Server List manager has put the internal details in HostAddr where required - PutValOnStream ( vecData, iPos, static_cast ( - vecServerInfo[i].HostAddr.InetAddr.toIPv4Address() ), 4 ); + PutValOnStream ( vecData, iPos, static_cast ( vecServerInfo[i].HostAddr.InetAddr.toIPv4Address() ), 4 ); // port number (2 bytes) // note the Server List manager has put the internal details in HostAddr where required - PutValOnStream ( vecData, iPos, - static_cast ( vecServerInfo[i].HostAddr.iPort ), 2 ); + PutValOnStream ( vecData, iPos, static_cast ( vecServerInfo[i].HostAddr.iPort ), 2 ); // name (note that the string length indicator is 1 in this special case) PutStringUTF8OnStream ( vecData, iPos, strUTF8Name, 1 ); } - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_RED_SERVER_LIST, - vecData, - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_RED_SERVER_LIST, vecData, InetAddr ); } -bool CProtocol::EvaluateCLRedServerListMes ( const CHostAddress& InetAddr, - const CVector& vecData ) +bool CProtocol::EvaluateCLRedServerListMes ( const CHostAddress& InetAddr, const CVector& vecData ) { int iPos = 0; // init position pointer const int iDataLen = vecData.Size(); @@ -2379,24 +2199,19 @@ bool CProtocol::EvaluateCLRedServerListMes ( const CHostAddress& InetAddr, // server name (note that the string length indicator is 1 in this special case) QString strName; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_SERVER_NAME, - strName, - 1 ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_SERVER_NAME, strName, 1 ) ) { return true; // return error code } // add server information to vector - vecServerInfo.Add ( - CServerInfo ( CHostAddress ( QHostAddress ( iIpAddr ), iPort ), - CHostAddress ( QHostAddress ( iIpAddr ), iPort ), - strName, - QLocale::AnyCountry, // set to any country since the information is not transmitted - "", // empty city name since the information is not transmitted - 0, // per definition: if max. num. client is zero, we ignore the value in the server list - false ) ); // assume not permanent since the information is not transmitted + vecServerInfo.Add ( CServerInfo ( CHostAddress ( QHostAddress ( iIpAddr ), iPort ), + CHostAddress ( QHostAddress ( iIpAddr ), iPort ), + strName, + QLocale::AnyCountry, // set to any country since the information is not transmitted + "", // empty city name since the information is not transmitted + 0, // per definition: if max. num. client is zero, we ignore the value in the server list + false ) ); // assume not permanent since the information is not transmitted } // check size: all data is read, the position must now be at the end @@ -2413,9 +2228,7 @@ bool CProtocol::EvaluateCLRedServerListMes ( const CHostAddress& InetAddr, void CProtocol::CreateCLReqServerListMes ( const CHostAddress& InetAddr ) { - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REQ_SERVER_LIST, - CVector ( 0 ), - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REQ_SERVER_LIST, CVector ( 0 ), InetAddr ); } bool CProtocol::EvaluateCLReqServerListMes ( const CHostAddress& InetAddr ) @@ -2426,8 +2239,7 @@ bool CProtocol::EvaluateCLReqServerListMes ( const CHostAddress& InetAddr ) return false; // no error } -void CProtocol::CreateCLSendEmptyMesMes ( const CHostAddress& InetAddr, - const CHostAddress& TargetInetAddr ) +void CProtocol::CreateCLSendEmptyMesMes ( const CHostAddress& InetAddr, const CHostAddress& TargetInetAddr ) { int iPos = 0; // init position pointer @@ -2435,16 +2247,12 @@ void CProtocol::CreateCLSendEmptyMesMes ( const CHostAddress& InetAddr, CVector vecData ( 6 ); // IP address (4 bytes) - PutValOnStream ( vecData, iPos, static_cast ( - TargetInetAddr.InetAddr.toIPv4Address() ), 4 ); + PutValOnStream ( vecData, iPos, static_cast ( TargetInetAddr.InetAddr.toIPv4Address() ), 4 ); // port number (2 bytes) - PutValOnStream ( vecData, iPos, - static_cast ( TargetInetAddr.iPort ), 2 ); + PutValOnStream ( vecData, iPos, static_cast ( TargetInetAddr.iPort ), 2 ); - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SEND_EMPTY_MESSAGE, - vecData, - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_SEND_EMPTY_MESSAGE, vecData, InetAddr ); } bool CProtocol::EvaluateCLSendEmptyMesMes ( const CVector& vecData ) @@ -2473,16 +2281,12 @@ void CProtocol::CreateCLEmptyMes ( const CHostAddress& InetAddr ) { // special message: for this message there exist no Evaluate // function - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_EMPTY_MESSAGE, - CVector ( 0 ), - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_EMPTY_MESSAGE, CVector ( 0 ), InetAddr ); } void CProtocol::CreateCLDisconnection ( const CHostAddress& InetAddr ) { - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_DISCONNECTION, - CVector ( 0 ), - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_DISCONNECTION, CVector ( 0 ), InetAddr ); } bool CProtocol::EvaluateCLDisconnectionMes ( const CHostAddress& InetAddr ) @@ -2504,29 +2308,24 @@ void CProtocol::CreateCLVersionAndOSMes ( const CHostAddress& InetAddr ) const QByteArray strUTF8Version = strVerion.toUtf8(); // size of current message body - const int iEntrLen = - 1 + // operating system - 2 + strUTF8Version.size(); // version utf-8 str. size / str. + const int iEntrLen = 1 + // operating system + 2 + strUTF8Version.size(); // version utf-8 str. size / str. // build data vector CVector vecData ( iEntrLen ); // operating system (1 byte) - PutValOnStream ( vecData, iPos, - static_cast ( COSUtil::GetOperatingSystem() ), 1 ); + PutValOnStream ( vecData, iPos, static_cast ( COSUtil::GetOperatingSystem() ), 1 ); // version PutStringUTF8OnStream ( vecData, iPos, strUTF8Version ); - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_VERSION_AND_OS, - vecData, - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_VERSION_AND_OS, vecData, InetAddr ); } -bool CProtocol::EvaluateCLVersionAndOSMes ( const CHostAddress& InetAddr, - const CVector& vecData ) +bool CProtocol::EvaluateCLVersionAndOSMes ( const CHostAddress& InetAddr, const CVector& vecData ) { - int iPos = 0; // init position pointer + int iPos = 0; // init position pointer const int iDataLen = vecData.Size(); // check size (the first 1 byte) @@ -2536,15 +2335,11 @@ bool CProtocol::EvaluateCLVersionAndOSMes ( const CHostAddress& InetAddr, } // operating system (1 byte) - const COSUtil::EOpSystemType eOSType = - static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); + const COSUtil::EOpSystemType eOSType = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); // version text QString strVersion; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_VERSION_TEXT, - strVersion ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_VERSION_TEXT, strVersion ) ) { return true; // return error code } @@ -2563,9 +2358,7 @@ bool CProtocol::EvaluateCLVersionAndOSMes ( const CHostAddress& InetAddr, void CProtocol::CreateCLReqVersionAndOSMes ( const CHostAddress& InetAddr ) { - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REQ_VERSION_AND_OS, - CVector ( 0 ), - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REQ_VERSION_AND_OS, CVector ( 0 ), InetAddr ); } bool CProtocol::EvaluateCLReqVersionAndOSMes ( const CHostAddress& InetAddr ) @@ -2576,8 +2369,7 @@ bool CProtocol::EvaluateCLReqVersionAndOSMes ( const CHostAddress& InetAddr ) return false; // no error } -void CProtocol::CreateCLConnClientsListMes ( const CHostAddress& InetAddr, - const CVector& vecChanInfo ) +void CProtocol::CreateCLConnClientsListMes ( const CHostAddress& InetAddr, const CVector& vecChanInfo ) { const int iNumClients = vecChanInfo.Size(); @@ -2592,14 +2384,13 @@ void CProtocol::CreateCLConnClientsListMes ( const CHostAddress& InetAd const QByteArray strUTF8City = vecChanInfo[i].strCity.toUtf8(); // size of current list entry - const int iCurListEntrLen = - 1 + // chan ID - 2 + // country - 4 + // instrument - 1 + // skill level - 4 + // IP address - 2 + strUTF8Name.size() + // utf-8 str. size / str. - 2 + strUTF8City.size(); // utf-8 str. size / str. + const int iCurListEntrLen = 1 + // chan ID + 2 + // country + 4 + // instrument + 1 + // skill level + 4 + // IP address + 2 + strUTF8Name.size() + // utf-8 str. size / str. + 2 + strUTF8City.size(); // utf-8 str. size / str. // make space for new data vecData.Enlarge ( iCurListEntrLen ); @@ -2626,13 +2417,10 @@ void CProtocol::CreateCLConnClientsListMes ( const CHostAddress& InetAd PutStringUTF8OnStream ( vecData, iPos, strUTF8City ); } - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_CONN_CLIENTS_LIST, - vecData, - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_CONN_CLIENTS_LIST, vecData, InetAddr ); } -bool CProtocol::EvaluateCLConnClientsListMes ( const CHostAddress& InetAddr, - const CVector& vecData ) +bool CProtocol::EvaluateCLConnClientsListMes ( const CHostAddress& InetAddr, const CVector& vecData ) { int iPos = 0; // init position pointer const int iDataLen = vecData.Size(); @@ -2663,31 +2451,20 @@ bool CProtocol::EvaluateCLConnClientsListMes ( const CHostAddress& InetAddr, // name QString strCurName; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_FADER_TAG, - strCurName ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_FADER_TAG, strCurName ) ) { return true; // return error code } // city QString strCurCity; - if ( GetStringFromStream ( vecData, - iPos, - MAX_LEN_SERVER_CITY, - strCurCity ) ) + if ( GetStringFromStream ( vecData, iPos, MAX_LEN_SERVER_CITY, strCurCity ) ) { return true; // return error code } // add channel information to vector - vecChanInfo.Add ( CChannelInfo ( iChanID, - strCurName, - eCountry, - strCurCity, - iInstrument, - eSkillLevel ) ); + vecChanInfo.Add ( CChannelInfo ( iChanID, strCurName, eCountry, strCurCity, iInstrument, eSkillLevel ) ); } // check size: all data is read, the position must now be at the end @@ -2704,9 +2481,7 @@ bool CProtocol::EvaluateCLConnClientsListMes ( const CHostAddress& InetAddr, void CProtocol::CreateCLReqConnClientsListMes ( const CHostAddress& InetAddr ) { - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REQ_CONN_CLIENTS_LIST, - CVector ( 0 ), - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REQ_CONN_CLIENTS_LIST, CVector ( 0 ), InetAddr ); } bool CProtocol::EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr ) @@ -2717,13 +2492,11 @@ bool CProtocol::EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr ) return false; // no error } -void CProtocol::CreateCLChannelLevelListMes ( const CHostAddress& InetAddr, - const CVector& vecLevelList, - const int iNumClients ) +void CProtocol::CreateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector& vecLevelList, const int iNumClients ) { // This must be a multiple of bytes at four bits per client const int iNumBytes = ( iNumClients + 1 ) / 2; - CVector vecData( iNumBytes ); + CVector vecData ( iNumBytes ); int iPos = 0; // init position pointer for ( int i = 0, j = 0; i < iNumClients; i += 2 /* pack two per byte */, j++ ) @@ -2735,18 +2508,15 @@ void CProtocol::CreateCLChannelLevelListMes ( const CHostAddress& InetAddr PutValOnStream ( vecData, iPos, static_cast ( byte ), 1 ); } - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_CHANNEL_LEVEL_LIST, - vecData, - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_CHANNEL_LEVEL_LIST, vecData, InetAddr ); } -bool CProtocol::EvaluateCLChannelLevelListMes ( const CHostAddress& InetAddr, - const CVector& vecData ) +bool CProtocol::EvaluateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector& vecData ) { - int iPos = 0; // init position pointer - const int iDataLen = vecData.Size(); // four bits per channel, 2 channels per byte - // may have one too many entries, last being 0xF - int iVecLen = iDataLen * 2; // one ushort per channel + int iPos = 0; // init position pointer + const int iDataLen = vecData.Size(); // four bits per channel, 2 channels per byte + // may have one too many entries, last being 0xF + int iVecLen = iDataLen * 2; // one ushort per channel if ( iVecLen > MAX_NUM_CHANNELS ) { @@ -2755,13 +2525,13 @@ bool CProtocol::EvaluateCLChannelLevelListMes ( const CHostAddress& InetAdd CVector vecLevelList ( iVecLen ); - for (int i = 0, j = 0; i < iDataLen; i++, j += 2 ) + for ( int i = 0, j = 0; i < iDataLen; i++, j += 2 ) { uint8_t byte = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); uint16_t levelLo = byte & 0x0F; uint16_t levelHi = ( byte >> 4 ) & 0x0F; - vecLevelList[j] = levelLo; + vecLevelList[j] = levelLo; if ( levelHi != 0x0F ) { @@ -2780,21 +2550,17 @@ bool CProtocol::EvaluateCLChannelLevelListMes ( const CHostAddress& InetAdd return false; // no error } -void CProtocol::CreateCLRegisterServerResp ( const CHostAddress& InetAddr, - const ESvrRegResult eResult ) +void CProtocol::CreateCLRegisterServerResp ( const CHostAddress& InetAddr, const ESvrRegResult eResult ) { int iPos = 0; // init position pointer - CVector vecData( 1 ); + CVector vecData ( 1 ); PutValOnStream ( vecData, iPos, static_cast ( eResult ), 1 ); - CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REGISTER_SERVER_RESP, - vecData, - InetAddr ); + CreateAndImmSendConLessMessage ( PROTMESSID_CLM_REGISTER_SERVER_RESP, vecData, InetAddr ); } -bool CProtocol::EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, - const CVector& vecData ) +bool CProtocol::EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, const CVector& vecData ) { int iPos = 0; // init position pointer const int iDataLen = vecData.Size(); @@ -2807,16 +2573,14 @@ bool CProtocol::EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, // server registration result (1 byte) const int iSvrRegResult = static_cast ( GetValFromStream ( vecData, iPos, 1 ) ); - if ( ( iSvrRegResult != SRR_REGISTERED ) && - ( iSvrRegResult != SRR_CENTRAL_SVR_FULL ) && - ( iSvrRegResult != SRR_VERSION_TOO_OLD ) && + if ( ( iSvrRegResult != SRR_REGISTERED ) && ( iSvrRegResult != SRR_CENTRAL_SVR_FULL ) && ( iSvrRegResult != SRR_VERSION_TOO_OLD ) && ( iSvrRegResult != SRR_NOT_FULFILL_REQIREMENTS ) ) { return true; } // invoke message action - emit CLRegisterServerResp ( InetAddr, static_cast ( iSvrRegResult ) ); + emit CLRegisterServerResp ( InetAddr, static_cast ( iSvrRegResult ) ); return false; // no error } @@ -2839,7 +2603,6 @@ bool CProtocol::ParseMessageFrame ( const CVector& vecbyData, return true; // return error code } - // Decode header ----------------------------------------------------------- iCurPos = 0; // start from beginning @@ -2867,7 +2630,6 @@ bool CProtocol::ParseMessageFrame ( const CVector& vecbyData, return true; // return error code } - // Now check CRC ----------------------------------------------------------- CCRC CRCObj; @@ -2880,18 +2642,17 @@ bool CProtocol::ParseMessageFrame ( const CVector& vecbyData, CRCObj.AddByte ( static_cast ( GetValFromStream ( vecbyData, iCurPos, 1 ) ) ); } - if ( CRCObj.GetCRC () != GetValFromStream ( vecbyData, iCurPos, 2 ) ) + if ( CRCObj.GetCRC() != GetValFromStream ( vecbyData, iCurPos, 2 ) ) { return true; // return error code } - // Extract actual data ----------------------------------------------------- -// clang-format off + // clang-format off // TODO this memory allocation is done in the real time thread but should be // done in the low priority protocol management thread -// clang-format on + // clang-format on vecbyMesBodyData.Init ( iLenBy ); @@ -2931,7 +2692,6 @@ bool CProtocol::ParseSplitMessageContainer ( const CVector& vecbyData, // 1 byte split cnt iSplitCnt = static_cast ( GetValFromStream ( vecbyData, iPos, 1 ) ); - // Extract actual data ----------------------------------------------------- iCurPartSize = iDataLen - 4; @@ -2949,13 +2709,11 @@ bool CProtocol::ParseSplitMessageContainer ( const CVector& vecbyData, return false; // no error } -uint32_t CProtocol::GetValFromStream ( const CVector& vecIn, - int& iPos, - const int iNumOfBytes ) +uint32_t CProtocol::GetValFromStream ( const CVector& vecIn, int& iPos, const int iNumOfBytes ) { -/* - note: iPos is automatically incremented in this function -*/ + /* + note: iPos is automatically incremented in this function + */ // 4 bytes maximum since we return uint32 Q_ASSERT ( ( iNumOfBytes > 0 ) && ( iNumOfBytes <= 4 ) ); Q_ASSERT ( vecIn.Size() >= iPos + iNumOfBytes ); @@ -2971,15 +2729,11 @@ uint32_t CProtocol::GetValFromStream ( const CVector& vecIn, return iRet; } -bool CProtocol::GetStringFromStream ( const CVector& vecIn, - int& iPos, - const int iMaxStringLen, - QString& strOut, - const int iNumberOfBytsLen ) +bool CProtocol::GetStringFromStream ( const CVector& vecIn, int& iPos, const int iMaxStringLen, QString& strOut, const int iNumberOfBytsLen ) { -/* - note: iPos is automatically incremented in this function -*/ + /* + note: iPos is automatically incremented in this function + */ const int iInLen = vecIn.Size(); // check if at least iNumberOfBytsLen bytes are available @@ -3018,10 +2772,7 @@ bool CProtocol::GetStringFromStream ( const CVector& vecIn, return false; // no error } -void CProtocol::GenMessageFrame ( CVector& vecOut, - const int iCnt, - const int iID, - const CVector& vecData ) +void CProtocol::GenMessageFrame ( CVector& vecOut, const int iCnt, const int iID, const CVector& vecData ) { int i; @@ -3034,7 +2785,6 @@ void CProtocol::GenMessageFrame ( CVector& vecOut, // init message vector vecOut.Init ( iTotLenByte ); - // Encode header ----------------------------------------------------------- int iCurPos = 0; // init position pointer @@ -3056,7 +2806,6 @@ void CProtocol::GenMessageFrame ( CVector& vecOut, PutValOnStream ( vecOut, iCurPos, static_cast ( vecData[i] ), 1 ); } - // Encode CRC -------------------------------------------------------------- CCRC CRCObj; @@ -3072,7 +2821,6 @@ void CProtocol::GenMessageFrame ( CVector& vecOut, PutValOnStream ( vecOut, iCurPos, static_cast ( CRCObj.GetCRC() ), 2 ); } - void CProtocol::GenSplitMessageContainer ( CVector& vecOut, const int iID, const int iNumParts, @@ -3105,14 +2853,11 @@ void CProtocol::GenSplitMessageContainer ( CVector& vecOut, } } -void CProtocol::PutValOnStream ( CVector& vecIn, - int& iPos, - const uint32_t iVal, - const int iNumOfBytes ) +void CProtocol::PutValOnStream ( CVector& vecIn, int& iPos, const uint32_t iVal, const int iNumOfBytes ) { -/* - note: iPos is automatically incremented in this function -*/ + /* + note: iPos is automatically incremented in this function + */ // 4 bytes maximum since we use uint32 Q_ASSERT ( ( iNumOfBytes > 0 ) && ( iNumOfBytes <= 4 ) ); Q_ASSERT ( vecIn.Size() >= iPos + iNumOfBytes ); @@ -3124,10 +2869,7 @@ void CProtocol::PutValOnStream ( CVector& vecIn, } } -void CProtocol::PutStringUTF8OnStream ( CVector& vecIn, - int& iPos, - const QByteArray& sStringUTF8, - const int iNumberOfBytsLen ) +void CProtocol::PutStringUTF8OnStream ( CVector& vecIn, int& iPos, const QByteArray& sStringUTF8, const int iNumberOfBytsLen ) { // get the utf-8 string size const int iStrUTF8Len = sStringUTF8.size(); diff --git a/src/protocol.h b/src/protocol.h old mode 100755 new mode 100644 index 168cbb25d3..5a0d60d788 --- a/src/protocol.h +++ b/src/protocol.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -32,37 +32,36 @@ #include "global.h" #include "util.h" - /* Definitions ****************************************************************/ // protocol message IDs -#define PROTMESSID_ILLEGAL 0 // illegal ID -#define PROTMESSID_ACKN 1 // acknowledge -#define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size -#define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size -#define PROTMESSID_NET_BLSI_FACTOR 12 // OLD (not used anymore) -#define PROTMESSID_CHANNEL_GAIN 13 // set channel gain for mix -#define PROTMESSID_CONN_CLIENTS_LIST_NAME 14 // OLD (not used anymore) -#define PROTMESSID_SERVER_FULL 15 // OLD (not used anymore) -#define PROTMESSID_REQ_CONN_CLIENTS_LIST 16 // request connected client list -#define PROTMESSID_CHANNEL_NAME 17 // OLD (not used anymore) -#define PROTMESSID_CHAT_TEXT 18 // contains a chat text -#define PROTMESSID_PING_MS 19 // OLD (not used anymore) -#define PROTMESSID_NETW_TRANSPORT_PROPS 20 // properties for network transport -#define PROTMESSID_REQ_NETW_TRANSPORT_PROPS 21 // request properties for network transport -#define PROTMESSID_DISCONNECTION 22 // OLD (not used anymore) -#define PROTMESSID_REQ_CHANNEL_INFOS 23 // request channel infos for fader tag -#define PROTMESSID_CONN_CLIENTS_LIST 24 // channel infos for connected clients -#define PROTMESSID_CHANNEL_INFOS 25 // set channel infos -#define PROTMESSID_OPUS_SUPPORTED 26 // tells that OPUS codec is supported -#define PROTMESSID_LICENCE_REQUIRED 27 // licence required -#define PROTMESSID_REQ_CHANNEL_LEVEL_LIST 28 // OLD (not used anymore) // TODO needed for compatibility to old servers >= 3.4.6 and <= 3.5.12 -#define PROTMESSID_VERSION_AND_OS 29 // version number and operating system -#define PROTMESSID_CHANNEL_PAN 30 // set channel pan for mix -#define PROTMESSID_MUTE_STATE_CHANGED 31 // mute state of your signal at another client has changed -#define PROTMESSID_CLIENT_ID 32 // current user ID and server status -#define PROTMESSID_RECORDER_STATE 33 // contains the state of the jam recorder (ERecorderState) -#define PROTMESSID_REQ_SPLIT_MESS_SUPPORT 34 // request support for split messages -#define PROTMESSID_SPLIT_MESS_SUPPORTED 35 // split messages are supported +#define PROTMESSID_ILLEGAL 0 // illegal ID +#define PROTMESSID_ACKN 1 // acknowledge +#define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size +#define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size +#define PROTMESSID_NET_BLSI_FACTOR 12 // OLD (not used anymore) +#define PROTMESSID_CHANNEL_GAIN 13 // set channel gain for mix +#define PROTMESSID_CONN_CLIENTS_LIST_NAME 14 // OLD (not used anymore) +#define PROTMESSID_SERVER_FULL 15 // OLD (not used anymore) +#define PROTMESSID_REQ_CONN_CLIENTS_LIST 16 // request connected client list +#define PROTMESSID_CHANNEL_NAME 17 // OLD (not used anymore) +#define PROTMESSID_CHAT_TEXT 18 // contains a chat text +#define PROTMESSID_PING_MS 19 // OLD (not used anymore) +#define PROTMESSID_NETW_TRANSPORT_PROPS 20 // properties for network transport +#define PROTMESSID_REQ_NETW_TRANSPORT_PROPS 21 // request properties for network transport +#define PROTMESSID_DISCONNECTION 22 // OLD (not used anymore) +#define PROTMESSID_REQ_CHANNEL_INFOS 23 // request channel infos for fader tag +#define PROTMESSID_CONN_CLIENTS_LIST 24 // channel infos for connected clients +#define PROTMESSID_CHANNEL_INFOS 25 // set channel infos +#define PROTMESSID_OPUS_SUPPORTED 26 // tells that OPUS codec is supported +#define PROTMESSID_LICENCE_REQUIRED 27 // licence required +#define PROTMESSID_REQ_CHANNEL_LEVEL_LIST 28 // OLD (not used anymore) // TODO needed for compatibility to old servers >= 3.4.6 and <= 3.5.12 +#define PROTMESSID_VERSION_AND_OS 29 // version number and operating system +#define PROTMESSID_CHANNEL_PAN 30 // set channel pan for mix +#define PROTMESSID_MUTE_STATE_CHANGED 31 // mute state of your signal at another client has changed +#define PROTMESSID_CLIENT_ID 32 // current user ID and server status +#define PROTMESSID_RECORDER_STATE 33 // contains the state of the jam recorder (ERecorderState) +#define PROTMESSID_REQ_SPLIT_MESS_SUPPORT 34 // request support for split messages +#define PROTMESSID_SPLIT_MESS_SUPPORTED 35 // split messages are supported // message IDs of connection less messages (CLM) // DEFINITION -> start at 1000, end at 1999, see IsConnectionLessMessageID @@ -86,19 +85,18 @@ #define PROTMESSID_CLM_RED_SERVER_LIST 1018 // reduced server list // special IDs -#define PROTMESSID_SPECIAL_SPLIT_MESSAGE 2001 // a container for split messages +#define PROTMESSID_SPECIAL_SPLIT_MESSAGE 2001 // a container for split messages // lengths of message as defined in protocol.cpp file -#define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2) -#define MESS_LEN_WITHOUT_DATA_BYTE ( MESS_HEADER_LENGTH_BYTE + 2 /* CRC (2) */ ) +#define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2) +#define MESS_LEN_WITHOUT_DATA_BYTE ( MESS_HEADER_LENGTH_BYTE + 2 /* CRC (2) */ ) // time out for message re-send if no acknowledgement was received -#define SEND_MESS_TIMEOUT_MS 400 // ms +#define SEND_MESS_TIMEOUT_MS 400 // ms // message split parameters -#define MESS_SPLIT_PART_SIZE_BYTES 550 -#define MAX_NUM_MESS_SPLIT_PARTS ( MAX_SIZE_BYTES_NETW_BUF / MESS_SPLIT_PART_SIZE_BYTES ) - +#define MESS_SPLIT_PART_SIZE_BYTES 550 +#define MAX_NUM_MESS_SPLIT_PARTS ( MAX_SIZE_BYTES_NETW_BUF / MESS_SPLIT_PART_SIZE_BYTES ) /* Classes ********************************************************************/ class CProtocol : public QObject @@ -129,45 +127,32 @@ class CProtocol : public QObject void CreateLicenceRequiredMes ( const ELicenceType eLicenceType ); void CreateOpusSupportedMes(); -// clang-format off + // clang-format off // TODO needed for compatibility to old servers >= 3.4.6 and <= 3.5.12 void CreateReqChannelLevelListMes(); -// clang-format on + // clang-format on void CreateVersionAndOSMes(); void CreateRecorderStateMes ( const ERecorderState eRecorderState ); - void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ); - void CreateCLPingWithNumClientsMes ( const CHostAddress& InetAddr, - const int iMs, - const int iNumClients ); - void CreateCLServerFullMes ( const CHostAddress& InetAddr ); - void CreateCLRegisterServerMes ( const CHostAddress& InetAddr, - const CHostAddress& LInetAddr, - const CServerCoreInfo& ServerInfo ); - void CreateCLRegisterServerExMes ( const CHostAddress& InetAddr, - const CHostAddress& LInetAddr, - const CServerCoreInfo& ServerInfo ); - void CreateCLUnregisterServerMes ( const CHostAddress& InetAddr ); - void CreateCLServerListMes ( const CHostAddress& InetAddr, - const CVector vecServerInfo ); - void CreateCLRedServerListMes ( const CHostAddress& InetAddr, - const CVector vecServerInfo ); - void CreateCLReqServerListMes ( const CHostAddress& InetAddr ); - void CreateCLSendEmptyMesMes ( const CHostAddress& InetAddr, - const CHostAddress& TargetInetAddr ); - void CreateCLEmptyMes ( const CHostAddress& InetAddr ); - void CreateCLDisconnection ( const CHostAddress& InetAddr ); - void CreateCLVersionAndOSMes ( const CHostAddress& InetAddr ); - void CreateCLReqVersionAndOSMes ( const CHostAddress& InetAddr ); - void CreateCLConnClientsListMes ( const CHostAddress& InetAddr, - const CVector& vecChanInfo ); + void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ); + void CreateCLPingWithNumClientsMes ( const CHostAddress& InetAddr, const int iMs, const int iNumClients ); + void CreateCLServerFullMes ( const CHostAddress& InetAddr ); + void CreateCLRegisterServerMes ( const CHostAddress& InetAddr, const CHostAddress& LInetAddr, const CServerCoreInfo& ServerInfo ); + void CreateCLRegisterServerExMes ( const CHostAddress& InetAddr, const CHostAddress& LInetAddr, const CServerCoreInfo& ServerInfo ); + void CreateCLUnregisterServerMes ( const CHostAddress& InetAddr ); + void CreateCLServerListMes ( const CHostAddress& InetAddr, const CVector vecServerInfo ); + void CreateCLRedServerListMes ( const CHostAddress& InetAddr, const CVector vecServerInfo ); + void CreateCLReqServerListMes ( const CHostAddress& InetAddr ); + void CreateCLSendEmptyMesMes ( const CHostAddress& InetAddr, const CHostAddress& TargetInetAddr ); + void CreateCLEmptyMes ( const CHostAddress& InetAddr ); + void CreateCLDisconnection ( const CHostAddress& InetAddr ); + void CreateCLVersionAndOSMes ( const CHostAddress& InetAddr ); + void CreateCLReqVersionAndOSMes ( const CHostAddress& InetAddr ); + void CreateCLConnClientsListMes ( const CHostAddress& InetAddr, const CVector& vecChanInfo ); void CreateCLReqConnClientsListMes ( const CHostAddress& InetAddr ); - void CreateCLChannelLevelListMes ( const CHostAddress& InetAddr, - const CVector& vecLevelList, - const int iNumClients ); - void CreateCLRegisterServerResp ( const CHostAddress& InetAddr, - const ESvrRegResult eResult ); + void CreateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector& vecLevelList, const int iNumClients ); + void CreateCLRegisterServerResp ( const CHostAddress& InetAddr, const ESvrRegResult eResult ); static bool ParseMessageFrame ( const CVector& vecbyData, const int iNumBytesIn, @@ -175,30 +160,21 @@ void CreateReqChannelLevelListMes(); int& iRecCounter, int& iRecID ); - void ParseMessageBody ( const CVector& vecbyMesBodyData, - const int iRecCounter, - const int iRecID ); + void ParseMessageBody ( const CVector& vecbyMesBodyData, const int iRecCounter, const int iRecID ); - void ParseConnectionLessMessageBody ( const CVector& vecbyMesBodyData, - const int iRecID, - const CHostAddress& InetAddr ); + void ParseConnectionLessMessageBody ( const CVector& vecbyMesBodyData, const int iRecID, const CHostAddress& InetAddr ); - static bool IsConnectionLessMessageID ( const int iID ) - { return ( iID >= 1000 ) && ( iID < 2000 ); } + static bool IsConnectionLessMessageID ( const int iID ) { return ( iID >= 1000 ) && ( iID < 2000 ); } // this function is public because we need it in the test bench - void CreateAndImmSendAcknMess ( const int& iID, - const int& iCnt ); + void CreateAndImmSendAcknMess ( const int& iID, const int& iCnt ); protected: class CSendMessage { public: - CSendMessage() : vecMessage ( 0 ), iID ( PROTMESSID_ILLEGAL ), - iCnt ( 0 ) {} - CSendMessage ( const CVector& nMess, const int iNCnt, - const int iNID ) : vecMessage ( nMess ), iID ( iNID ), - iCnt ( iNCnt ) {} + CSendMessage() : vecMessage ( 0 ), iID ( PROTMESSID_ILLEGAL ), iCnt ( 0 ) {} + CSendMessage ( const CVector& nMess, const int iNCnt, const int iNID ) : vecMessage ( nMess ), iID ( iNID ), iCnt ( iNCnt ) {} CSendMessage& operator= ( const CSendMessage& NewSendMess ) { @@ -207,21 +183,16 @@ void CreateReqChannelLevelListMes(); iID = NewSendMess.iID; iCnt = NewSendMess.iCnt; - return *this; + return *this; } CVector vecMessage; int iID, iCnt; }; - void EnqueueMessage ( CVector& vecMessage, - const int iCnt, - const int iID ); + void EnqueueMessage ( CVector& vecMessage, const int iCnt, const int iID ); - void GenMessageFrame ( CVector& vecOut, - const int iCnt, - const int iID, - const CVector& vecData ); + void GenMessageFrame ( CVector& vecOut, const int iCnt, const int iID, const CVector& vecData ); void GenSplitMessageContainer ( CVector& vecOut, const int iID, @@ -239,19 +210,14 @@ void CreateReqChannelLevelListMes(); int& iSplitCnt, int& iCurPartSize ); - void PutValOnStream ( CVector& vecIn, - int& iPos, - const uint32_t iVal, - const int iNumOfBytes ); + void PutValOnStream ( CVector& vecIn, int& iPos, const uint32_t iVal, const int iNumOfBytes ); void PutStringUTF8OnStream ( CVector& vecIn, int& iPos, const QByteArray& sStringUTF8, const int iNumberOfBytsLen = 2 ); // default is 2 bytes length indicator - static uint32_t GetValFromStream ( const CVector& vecIn, - int& iPos, - const int iNumOfBytes ); + static uint32_t GetValFromStream ( const CVector& vecIn, int& iPos, const int iNumOfBytes ); bool GetStringFromStream ( const CVector& vecIn, int& iPos, @@ -261,83 +227,69 @@ void CreateReqChannelLevelListMes(); void SendMessage(); - void CreateAndSendMessage ( const int iID, - const CVector& vecData ); + void CreateAndSendMessage ( const int iID, const CVector& vecData ); - void CreateAndImmSendConLessMessage ( const int iID, - const CVector& vecData, - const CHostAddress& InetAddr ); + void CreateAndImmSendConLessMessage ( const int iID, const CVector& vecData, const CHostAddress& InetAddr ); - bool EvaluateJitBufMes ( const CVector& vecData ); + bool EvaluateJitBufMes ( const CVector& vecData ); bool EvaluateReqJitBufMes(); - bool EvaluateClientIDMes ( const CVector& vecData ); - bool EvaluateChanGainMes ( const CVector& vecData ); - bool EvaluateChanPanMes ( const CVector& vecData ); + bool EvaluateClientIDMes ( const CVector& vecData ); + bool EvaluateChanGainMes ( const CVector& vecData ); + bool EvaluateChanPanMes ( const CVector& vecData ); bool EvaluateMuteStateHasChangedMes ( const CVector& vecData ); - bool EvaluateConClientListMes ( const CVector& vecData ); + bool EvaluateConClientListMes ( const CVector& vecData ); bool EvaluateReqConnClientsList(); - bool EvaluateChanInfoMes ( const CVector& vecData ); + bool EvaluateChanInfoMes ( const CVector& vecData ); bool EvaluateReqChanInfoMes(); - bool EvaluateChatTextMes ( const CVector& vecData ); - bool EvaluateNetwTranspPropsMes ( const CVector& vecData ); + bool EvaluateChatTextMes ( const CVector& vecData ); + bool EvaluateNetwTranspPropsMes ( const CVector& vecData ); bool EvaluateReqNetwTranspPropsMes(); bool EvaluateReqSplitMessSupportMes(); bool EvaluateSplitMessSupportedMes(); - bool EvaluateLicenceRequiredMes ( const CVector& vecData ); - bool EvaluateVersionAndOSMes ( const CVector& vecData ); - bool EvaluateRecorderStateMes ( const CVector& vecData ); - - bool EvaluateCLPingMes ( const CHostAddress& InetAddr, - const CVector& vecData ); - bool EvaluateCLPingWithNumClientsMes ( const CHostAddress& InetAddr, - const CVector& vecData ); + bool EvaluateLicenceRequiredMes ( const CVector& vecData ); + bool EvaluateVersionAndOSMes ( const CVector& vecData ); + bool EvaluateRecorderStateMes ( const CVector& vecData ); + + bool EvaluateCLPingMes ( const CHostAddress& InetAddr, const CVector& vecData ); + bool EvaluateCLPingWithNumClientsMes ( const CHostAddress& InetAddr, const CVector& vecData ); bool EvaluateCLServerFullMes(); - bool EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr, - const CVector& vecData ); - bool EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr, - const CVector& vecData ); - bool EvaluateCLUnregisterServerMes ( const CHostAddress& InetAddr ); - bool EvaluateCLServerListMes ( const CHostAddress& InetAddr, - const CVector& vecData ); - bool EvaluateCLRedServerListMes ( const CHostAddress& InetAddr, - const CVector& vecData ); - bool EvaluateCLReqServerListMes ( const CHostAddress& InetAddr ); - bool EvaluateCLSendEmptyMesMes ( const CVector& vecData ); - bool EvaluateCLDisconnectionMes ( const CHostAddress& InetAddr ); - bool EvaluateCLVersionAndOSMes ( const CHostAddress& InetAddr, - const CVector& vecData ); - bool EvaluateCLReqVersionAndOSMes ( const CHostAddress& InetAddr ); - bool EvaluateCLConnClientsListMes ( const CHostAddress& InetAddr, - const CVector& vecData ); - bool EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr ); - bool EvaluateCLChannelLevelListMes ( const CHostAddress& InetAddr, - const CVector& vecData ); - bool EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, - const CVector& vecData ); - - int iOldRecID; - int iOldRecCnt; + bool EvaluateCLRegisterServerMes ( const CHostAddress& InetAddr, const CVector& vecData ); + bool EvaluateCLRegisterServerExMes ( const CHostAddress& InetAddr, const CVector& vecData ); + bool EvaluateCLUnregisterServerMes ( const CHostAddress& InetAddr ); + bool EvaluateCLServerListMes ( const CHostAddress& InetAddr, const CVector& vecData ); + bool EvaluateCLRedServerListMes ( const CHostAddress& InetAddr, const CVector& vecData ); + bool EvaluateCLReqServerListMes ( const CHostAddress& InetAddr ); + bool EvaluateCLSendEmptyMesMes ( const CVector& vecData ); + bool EvaluateCLDisconnectionMes ( const CHostAddress& InetAddr ); + bool EvaluateCLVersionAndOSMes ( const CHostAddress& InetAddr, const CVector& vecData ); + bool EvaluateCLReqVersionAndOSMes ( const CHostAddress& InetAddr ); + bool EvaluateCLConnClientsListMes ( const CHostAddress& InetAddr, const CVector& vecData ); + bool EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr ); + bool EvaluateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector& vecData ); + bool EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, const CVector& vecData ); + + int iOldRecID; + int iOldRecCnt; // these two objects must be sequred by a mutex uint8_t iCounter; std::list SendMessQueue; - QTimer TimerSendMess; - QMutex Mutex; + QTimer TimerSendMess; + QMutex Mutex; - CVector vecbySplitMessageStorage; - int iSplitMessageCnt; - int iSplitMessageDataIndex; - bool bSplitMessageSupported; + CVector vecbySplitMessageStorage; + int iSplitMessageCnt; + int iSplitMessageDataIndex; + bool bSplitMessageSupported; public slots: void OnTimerSendMess() { SendMessage(); } signals: // transmitting - void MessReadyForSending ( CVector vecMessage ); - void CLMessReadyForSending ( CHostAddress InetAddr, - CVector vecMessage ); + void MessReadyForSending ( CVector vecMessage ); + void CLMessReadyForSending ( CHostAddress InetAddr, CVector vecMessage ); // receiving void ChangeJittBufSize ( int iNewJitBufSize ); @@ -361,36 +313,24 @@ public slots: void VersionAndOSReceived ( COSUtil::EOpSystemType eOSType, QString strVersion ); void RecorderStateReceived ( ERecorderState eRecorderState ); - void CLPingReceived ( CHostAddress InetAddr, - int iMs ); - void CLPingWithNumClientsReceived ( CHostAddress InetAddr, - int iMs, - int iNumClients ); - void CLRegisterServerReceived ( CHostAddress InetAddr, - CHostAddress LInetAddr, - CServerCoreInfo ServerInfo ); - void CLRegisterServerExReceived ( CHostAddress InetAddr, - CHostAddress LInetAddr, - CServerCoreInfo ServerInfo, - COSUtil::EOpSystemType eOSType, - QString strVersion ); - void CLUnregisterServerReceived ( CHostAddress InetAddr ); - void CLServerListReceived ( CHostAddress InetAddr, - CVector vecServerInfo ); - void CLRedServerListReceived ( CHostAddress InetAddr, - CVector vecServerInfo ); - void CLReqServerList ( CHostAddress InetAddr ); - void CLSendEmptyMes ( CHostAddress TargetInetAddr ); - void CLDisconnection ( CHostAddress InetAddr ); - void CLVersionAndOSReceived ( CHostAddress InetAddr, - COSUtil::EOpSystemType eOSType, - QString strVersion ); - void CLReqVersionAndOS ( CHostAddress InetAddr ); - void CLConnClientsListMesReceived ( CHostAddress InetAddr, - CVector vecChanInfo ); - void CLReqConnClientsList ( CHostAddress InetAddr ); - void CLChannelLevelListReceived ( CHostAddress InetAddr, - CVector vecLevelList ); - void CLRegisterServerResp ( CHostAddress InetAddr, - ESvrRegResult eStatus ); + void CLPingReceived ( CHostAddress InetAddr, int iMs ); + void CLPingWithNumClientsReceived ( CHostAddress InetAddr, int iMs, int iNumClients ); + void CLRegisterServerReceived ( CHostAddress InetAddr, CHostAddress LInetAddr, CServerCoreInfo ServerInfo ); + void CLRegisterServerExReceived ( CHostAddress InetAddr, + CHostAddress LInetAddr, + CServerCoreInfo ServerInfo, + COSUtil::EOpSystemType eOSType, + QString strVersion ); + void CLUnregisterServerReceived ( CHostAddress InetAddr ); + void CLServerListReceived ( CHostAddress InetAddr, CVector vecServerInfo ); + void CLRedServerListReceived ( CHostAddress InetAddr, CVector vecServerInfo ); + void CLReqServerList ( CHostAddress InetAddr ); + void CLSendEmptyMes ( CHostAddress TargetInetAddr ); + void CLDisconnection ( CHostAddress InetAddr ); + void CLVersionAndOSReceived ( CHostAddress InetAddr, COSUtil::EOpSystemType eOSType, QString strVersion ); + void CLReqVersionAndOS ( CHostAddress InetAddr ); + void CLConnClientsListMesReceived ( CHostAddress InetAddr, CVector vecChanInfo ); + void CLReqConnClientsList ( CHostAddress InetAddr ); + void CLChannelLevelListReceived ( CHostAddress InetAddr, CVector vecLevelList ); + void CLRegisterServerResp ( CHostAddress InetAddr, ESvrRegResult eStatus ); }; diff --git a/src/recorder/creaperproject.cpp b/src/recorder/creaperproject.cpp index e518188696..1c03cdf9c6 100644 --- a/src/recorder/creaperproject.cpp +++ b/src/recorder/creaperproject.cpp @@ -32,7 +32,7 @@ * * Note: unused? */ -QTextStream& operator<<(QTextStream& os, const recorder::STrackItem& trackItem) +QTextStream& operator<< ( QTextStream& os, const recorder::STrackItem& trackItem ) { os << "_track( " << "numAudioChannels(" << trackItem.numAudioChannels << ")" @@ -56,17 +56,17 @@ using namespace recorder; * @param trackItem the details of where the item is in the track, along with the RIFF WAVE filename * @param iid the sequential item id */ -CReaperItem::CReaperItem(const QString& name, const STrackItem& trackItem, const qint32& iid, int frameSize) +CReaperItem::CReaperItem ( const QString& name, const STrackItem& trackItem, const qint32& iid, int frameSize ) { QString wavName = trackItem.fileName; // assume RPP in same location... - QTextStream sOut(&out); + QTextStream sOut ( &out ); sOut << " items, int frameSize) +CReaperTrack::CReaperTrack ( QString name, qint32& iid, QList items, int frameSize ) { - QTextStream sOut(&out); + QTextStream sOut ( &out ); sOut << " items, i * @brief CReaperProject::CReaperProject Construct a Reaper RPP "" for a given list of tracks * @param tracks the list of tracks */ -CReaperProject::CReaperProject(QMap> tracks, int frameSize) +CReaperProject::CReaperProject ( QMap> tracks, int frameSize ) { - QTextStream sOut(&out); + QTextStream sOut ( &out ); sOut << "> tracks, int fram sOut << " TEMPO 120 4 4" << endl; qint32 iid = 0; - foreach(auto trackName, tracks.keys()) + foreach ( auto trackName, tracks.keys() ) { - sOut << CReaperTrack(trackName, iid, tracks[trackName], frameSize).toString() << endl; + sOut << CReaperTrack ( trackName, iid, tracks[trackName], frameSize ).toString() << endl; } sOut << ">"; diff --git a/src/recorder/creaperproject.h b/src/recorder/creaperproject.h index a2a6ac8893..cba5f7d3be 100644 --- a/src/recorder/creaperproject.h +++ b/src/recorder/creaperproject.h @@ -31,20 +31,21 @@ #include "cwavestream.h" -namespace recorder { +namespace recorder +{ class CReaperItem : public QObject { Q_OBJECT public: - CReaperItem( const QString& name, const STrackItem& trackItem, const qint32& iid, int frameSize ); + CReaperItem ( const QString& name, const STrackItem& trackItem, const qint32& iid, int frameSize ); QString toString() { return out; } private: const QUuid iguid = QUuid::createUuid(); - const QUuid guid = QUuid::createUuid(); - QString out; + const QUuid guid = QUuid::createUuid(); + QString out; }; class CReaperTrack : public QObject @@ -52,11 +53,11 @@ class CReaperTrack : public QObject Q_OBJECT public: - CReaperTrack( QString name, qint32 &iid, QList items, int frameSize ); + CReaperTrack ( QString name, qint32& iid, QList items, int frameSize ); QString toString() { return out; } private: - QUuid trackId = QUuid::createUuid(); + QUuid trackId = QUuid::createUuid(); QString out; }; @@ -65,11 +66,11 @@ class CReaperProject : public QObject Q_OBJECT public: - CReaperProject( QMap > tracks, int frameSize ); + CReaperProject ( QMap> tracks, int frameSize ); QString toString() { return out; } private: QString out; }; -} +} // namespace recorder diff --git a/src/recorder/cwavestream.cpp b/src/recorder/cwavestream.cpp index 048483caee..d2f00ca5d1 100644 --- a/src/recorder/cwavestream.cpp +++ b/src/recorder/cwavestream.cpp @@ -34,9 +34,9 @@ * @param obj a hdr_riff object * @return the QDataStream passed */ -recorder::CWaveStream& operator<<(recorder::CWaveStream& os, const recorder::HdrRiff& obj) +recorder::CWaveStream& operator<< ( recorder::CWaveStream& os, const recorder::HdrRiff& obj ) { - (QDataStream&)os << obj.chunkId << obj.chunkSize << obj.format; + (QDataStream&) os << obj.chunkId << obj.chunkSize << obj.format; return os; } @@ -46,17 +46,10 @@ recorder::CWaveStream& operator<<(recorder::CWaveStream& os, const recorder::Hdr * @param obj a fmtSubChunk object * @return the QDataStream passed */ -recorder::CWaveStream& operator<<(recorder::CWaveStream& os, const recorder::FmtSubChunk& obj) +recorder::CWaveStream& operator<< ( recorder::CWaveStream& os, const recorder::FmtSubChunk& obj ) { - (QDataStream&)os << obj.chunkId - << obj.chunkSize - << obj.audioFormat - << obj.numChannels - << obj.sampleRate - << obj.byteRate - << obj.blockAlign - << obj.bitsPerSample - ; + (QDataStream&) os << obj.chunkId << obj.chunkSize << obj.audioFormat << obj.numChannels << obj.sampleRate << obj.byteRate << obj.blockAlign + << obj.bitsPerSample; return os; } @@ -66,9 +59,9 @@ recorder::CWaveStream& operator<<(recorder::CWaveStream& os, const recorder::Fmt * @param obj a dataSubChunkHdr object * @return the QDataStream passed */ -recorder::CWaveStream& operator<<(recorder::CWaveStream& os, const recorder::DataSubChunkHdr& obj) +recorder::CWaveStream& operator<< ( recorder::CWaveStream& os, const recorder::DataSubChunkHdr& obj ) { - (QDataStream&)os << obj.chunkId << obj.chunkSize; + (QDataStream&) os << obj.chunkId << obj.chunkSize; return os; } @@ -78,77 +71,78 @@ recorder::CWaveStream& operator<<(recorder::CWaveStream& os, const recorder::Dat using namespace recorder; -CWaveStream::CWaveStream(const uint16_t numChannels) : +CWaveStream::CWaveStream ( const uint16_t numChannels ) : QDataStream(), - numChannels (numChannels), - initialPos (device()->pos()), - initialByteOrder (byteOrder()) + numChannels ( numChannels ), + initialPos ( device()->pos() ), + initialByteOrder ( byteOrder() ) { waveStreamHeaders(); } -CWaveStream::CWaveStream(QIODevice *iod, const uint16_t numChannels) : - QDataStream(iod), - numChannels (numChannels), - initialPos (device()->pos()), - initialByteOrder (byteOrder()) +CWaveStream::CWaveStream ( QIODevice* iod, const uint16_t numChannels ) : + QDataStream ( iod ), + numChannels ( numChannels ), + initialPos ( device()->pos() ), + initialByteOrder ( byteOrder() ) { waveStreamHeaders(); } -CWaveStream::CWaveStream(QByteArray *iod, QIODevice::OpenMode flags, const uint16_t numChannels) : - QDataStream(iod, flags), - numChannels (numChannels), - initialPos (device()->pos()), - initialByteOrder (byteOrder()) +CWaveStream::CWaveStream ( QByteArray* iod, QIODevice::OpenMode flags, const uint16_t numChannels ) : + QDataStream ( iod, flags ), + numChannels ( numChannels ), + initialPos ( device()->pos() ), + initialByteOrder ( byteOrder() ) { waveStreamHeaders(); } -CWaveStream::CWaveStream(const QByteArray &ba, const uint16_t numChannels) : - QDataStream(ba), - numChannels (numChannels), - initialPos (device()->pos()), - initialByteOrder (byteOrder()) +CWaveStream::CWaveStream ( const QByteArray& ba, const uint16_t numChannels ) : + QDataStream ( ba ), + numChannels ( numChannels ), + initialPos ( device()->pos() ), + initialByteOrder ( byteOrder() ) { waveStreamHeaders(); } void CWaveStream::waveStreamHeaders() { - static const HdrRiff scHdrRiff; - const FmtSubChunk cFmtSubChunk (numChannels); + static const HdrRiff scHdrRiff; + const FmtSubChunk cFmtSubChunk ( numChannels ); static const DataSubChunkHdr scDataSubChunkHdr; - setByteOrder(LittleEndian); + setByteOrder ( LittleEndian ); *this << scHdrRiff << cFmtSubChunk << scDataSubChunkHdr; } void CWaveStream::finalise() { - static const uint64_t hdrRiffChunkSize = sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t); - static const uint64_t fmtSubChunkSize = sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t); + static const uint64_t hdrRiffChunkSize = sizeof ( uint32_t ) + sizeof ( uint32_t ) + sizeof ( uint32_t ); + static const uint64_t fmtSubChunkSize = sizeof ( uint32_t ) + sizeof ( uint32_t ) + sizeof ( uint16_t ) + sizeof ( uint16_t ) + + sizeof ( uint32_t ) + sizeof ( uint32_t ) + sizeof ( uint16_t ) + sizeof ( uint16_t ); - static const uint64_t hdrRiffChunkSizeOffset = sizeof(uint32_t); - static const uint64_t dataSubChunkHdrChunkSizeOffset = hdrRiffChunkSize + fmtSubChunkSize + sizeof (uint32_t); + static const uint64_t hdrRiffChunkSizeOffset = sizeof ( uint32_t ); + static const uint64_t dataSubChunkHdrChunkSizeOffset = hdrRiffChunkSize + fmtSubChunkSize + sizeof ( uint32_t ); - const int64_t currentPos = this->device()->pos(); - const uint64_t fileLengthRiff = static_cast(currentPos - initialPos - (hdrRiffChunkSizeOffset + sizeof (uint32_t))); - const uint64_t fileLengthData = static_cast(currentPos - initialPos - (dataSubChunkHdrChunkSizeOffset + sizeof (uint32_t))); + const int64_t currentPos = this->device()->pos(); + const uint64_t fileLengthRiff = static_cast ( currentPos - initialPos - ( hdrRiffChunkSizeOffset + sizeof ( uint32_t ) ) ); + const uint64_t fileLengthData = static_cast ( currentPos - initialPos - ( dataSubChunkHdrChunkSizeOffset + sizeof ( uint32_t ) ) ); // check if lengths are within the range of the WAV file format - if (fileLengthRiff < 0x100000000ULL && fileLengthData < 0x100000000ULL) + if ( fileLengthRiff < 0x100000000ULL && fileLengthData < 0x100000000ULL ) { - QDataStream& out = static_cast(*this); + QDataStream& out = static_cast ( *this ); // Overwrite hdr_riff.chunkSize - this->device()->seek(initialPos + hdrRiffChunkSizeOffset); - out << static_cast(fileLengthRiff); + this->device()->seek ( initialPos + hdrRiffChunkSizeOffset ); + out << static_cast ( fileLengthRiff ); // Overwrite dataSubChunkHdr.chunkSize - this->device()->seek(initialPos + dataSubChunkHdrChunkSizeOffset); - out << static_cast(fileLengthData); + this->device()->seek ( initialPos + dataSubChunkHdrChunkSizeOffset ); + out << static_cast ( fileLengthData ); // And restore the position - this->device()->seek(currentPos); + this->device()->seek ( currentPos ); } // restore the byte order - setByteOrder(initialByteOrder); + setByteOrder ( initialByteOrder ); } diff --git a/src/recorder/cwavestream.h b/src/recorder/cwavestream.h index 54b91633c6..6f2d69a0ca 100644 --- a/src/recorder/cwavestream.h +++ b/src/recorder/cwavestream.h @@ -26,30 +26,26 @@ #include -namespace recorder { +namespace recorder +{ -inline QString secondsAt48K( const qint64 frames, - const int frameSize ) +inline QString secondsAt48K ( const qint64 frames, const int frameSize ) { - return QString::number( static_cast( frames * frameSize ) / 48000, 'f', 14 ); + return QString::number ( static_cast ( frames * frameSize ) / 48000, 'f', 14 ); } struct STrackItem { - STrackItem ( int numAudioChannels, - qint64 startFrame, - qint64 frameCount, - QString fileName ) : + STrackItem ( int numAudioChannels, qint64 startFrame, qint64 frameCount, QString fileName ) : numAudioChannels ( numAudioChannels ), - startFrame ( startFrame ), - frameCount ( frameCount ), - fileName ( fileName ) - { - } - - int numAudioChannels; - qint64 startFrame; - qint64 frameCount; + startFrame ( startFrame ), + frameCount ( frameCount ), + fileName ( fileName ) + {} + + int numAudioChannels; + qint64 startFrame; + qint64 frameCount; QString fileName; }; @@ -58,27 +54,26 @@ class HdrRiff public: HdrRiff() {} - static const uint32_t chunkId = 0x46464952; // RIFF + static const uint32_t chunkId = 0x46464952; // RIFF static const uint32_t chunkSize = 0x00000000; // unknown - static const uint32_t format = 0x45564157; // WAVE + static const uint32_t format = 0x45564157; // WAVE }; class FmtSubChunk { public: - FmtSubChunk(const uint16_t _numChannels) : - numChannels (_numChannels) - , byteRate (sampleRate * numChannels * bitsPerSample/8) - , blockAlign (numChannels * bitsPerSample/8) - { - } - static const uint32_t chunkId = 0x20746d66; // "fmt " - static const uint32_t chunkSize = 16; // bytes in fmtSubChunk after chunkSize - static const uint16_t audioFormat = 1; // PCM - const uint16_t numChannels; // 1 for mono, 2 for joy... uh, stereo - static const uint32_t sampleRate = 48000; // because it's Jamulus - const uint32_t byteRate; // sampleRate * numChannels * bitsPerSample/8 - const uint16_t blockAlign; // numChannels * bitsPerSample/8 + FmtSubChunk ( const uint16_t _numChannels ) : + numChannels ( _numChannels ), + byteRate ( sampleRate * numChannels * bitsPerSample / 8 ), + blockAlign ( numChannels * bitsPerSample / 8 ) + {} + static const uint32_t chunkId = 0x20746d66; // "fmt " + static const uint32_t chunkSize = 16; // bytes in fmtSubChunk after chunkSize + static const uint16_t audioFormat = 1; // PCM + const uint16_t numChannels; // 1 for mono, 2 for joy... uh, stereo + static const uint32_t sampleRate = 48000; // because it's Jamulus + const uint32_t byteRate; // sampleRate * numChannels * bitsPerSample/8 + const uint16_t blockAlign; // numChannels * bitsPerSample/8 static const uint16_t bitsPerSample = 16; }; @@ -87,30 +82,30 @@ class DataSubChunkHdr public: DataSubChunkHdr() {} - static const uint32_t chunkId = 0x61746164; // "data" + static const uint32_t chunkId = 0x61746164; // "data" static const uint32_t chunkSize = 0x7ffff000; // magic for unspecified length }; class CWaveStream : public QDataStream { public: - CWaveStream(const uint16_t numChannels); - explicit CWaveStream(QIODevice *iod, const uint16_t numChannels); - CWaveStream(QByteArray *iod, QIODevice::OpenMode flags, const uint16_t numChannels); - CWaveStream(const QByteArray &ba, const uint16_t numChannels); + CWaveStream ( const uint16_t numChannels ); + explicit CWaveStream ( QIODevice* iod, const uint16_t numChannels ); + CWaveStream ( QByteArray* iod, QIODevice::OpenMode flags, const uint16_t numChannels ); + CWaveStream ( const QByteArray& ba, const uint16_t numChannels ); void finalise(); private: void waveStreamHeaders(); - const uint16_t numChannels; - const int64_t initialPos; + const uint16_t numChannels; + const int64_t initialPos; const ByteOrder initialByteOrder; }; -} +} // namespace recorder -recorder::CWaveStream& operator<<(recorder::CWaveStream& out, recorder::HdrRiff& hdrRiff); -recorder::CWaveStream& operator<<(recorder::CWaveStream& out, recorder::FmtSubChunk& fmtSubChunk); -recorder::CWaveStream& operator<<(recorder::CWaveStream& out, recorder::DataSubChunkHdr& dataSubChunkHdr); +recorder::CWaveStream& operator<< ( recorder::CWaveStream& out, recorder::HdrRiff& hdrRiff ); +recorder::CWaveStream& operator<< ( recorder::CWaveStream& out, recorder::FmtSubChunk& fmtSubChunk ); +recorder::CWaveStream& operator<< ( recorder::CWaveStream& out, recorder::DataSubChunkHdr& dataSubChunkHdr ); diff --git a/src/recorder/jamcontroller.cpp b/src/recorder/jamcontroller.cpp old mode 100755 new mode 100644 index 36482ddad1..11ea775d47 --- a/src/recorder/jamcontroller.cpp +++ b/src/recorder/jamcontroller.cpp @@ -26,15 +26,14 @@ using namespace recorder; -CJamController::CJamController( CServer* pNServer ) : - pServer ( pNServer ), +CJamController::CJamController ( CServer* pNServer ) : + pServer ( pNServer ), bRecorderInitialised ( false ), - bEnableRecording ( false ), - strRecordingDir ( "" ), - pthJamRecorder ( nullptr ), - pJamRecorder ( nullptr ) -{ -} + bEnableRecording ( false ), + strRecordingDir ( "" ), + pthJamRecorder ( nullptr ), + pJamRecorder ( nullptr ) +{} void CJamController::RequestNewRecording() { @@ -45,7 +44,7 @@ void CJamController::RequestNewRecording() } } -void CJamController::SetEnableRecording ( bool bNewEnableRecording, bool isRunning ) +void CJamController::SetEnableRecording ( bool bNewEnableRecording, bool isRunning ) { if ( bRecorderInitialised ) @@ -54,8 +53,7 @@ void CJamController::SetEnableRecording ( bool bNewEnableRecording, bool isRunn // message only if the state appears to change if ( bEnableRecording != bNewEnableRecording ) { - qInfo() << qUtf8Printable( QString( "Recording state: %1" ) - .arg( bNewEnableRecording ? "enabled" : "disabled" ) ); + qInfo() << qUtf8Printable ( QString ( "Recording state: %1" ).arg ( bNewEnableRecording ? "enabled" : "disabled" ) ); } // note that this block executes regardless of whether @@ -75,9 +73,7 @@ void CJamController::SetEnableRecording ( bool bNewEnableRecording, bool isRunn } } -void CJamController::SetRecordingDir ( QString newRecordingDir, - int iServerFrameSizeSamples, - bool bDisableRecording ) +void CJamController::SetRecordingDir ( QString newRecordingDir, int iServerFrameSizeSamples, bool bDisableRecording ) { if ( bRecorderInitialised && pthJamRecorder != nullptr ) { @@ -93,20 +89,19 @@ void CJamController::SetRecordingDir ( QString newRecordingDir, if ( !newRecordingDir.isEmpty() ) { - pJamRecorder = new recorder::CJamRecorder ( newRecordingDir, iServerFrameSizeSamples ); - strRecorderErrMsg = pJamRecorder->Init(); + pJamRecorder = new recorder::CJamRecorder ( newRecordingDir, iServerFrameSizeSamples ); + strRecorderErrMsg = pJamRecorder->Init(); bRecorderInitialised = ( strRecorderErrMsg == QString::null ); - bEnableRecording = bRecorderInitialised && !bDisableRecording; + bEnableRecording = bRecorderInitialised && !bDisableRecording; - qInfo() << qUtf8Printable( QString( "Recording state: %1" ) - .arg( bEnableRecording ? "enabled" : "disabled" ) ); + qInfo() << qUtf8Printable ( QString ( "Recording state: %1" ).arg ( bEnableRecording ? "enabled" : "disabled" ) ); } else { // This is the only time this is ever true - UI needs to handle it - strRecorderErrMsg = QString::null; + strRecorderErrMsg = QString::null; bRecorderInitialised = false; - bEnableRecording = false; + bEnableRecording = false; qInfo() << "Recording state not initialised"; } @@ -121,45 +116,40 @@ void CJamController::SetRecordingDir ( QString newRecordingDir, pJamRecorder->moveToThread ( pthJamRecorder ); // QT signals - QObject::connect ( pthJamRecorder, &QThread::finished, - pJamRecorder, &QObject::deleteLater ); + QObject::connect ( pthJamRecorder, &QThread::finished, pJamRecorder, &QObject::deleteLater ); - QObject::connect( QCoreApplication::instance(), &QCoreApplication::aboutToQuit, - pJamRecorder, &CJamRecorder::OnAboutToQuit, - Qt::ConnectionType::BlockingQueuedConnection ); + QObject::connect ( QCoreApplication::instance(), + &QCoreApplication::aboutToQuit, + pJamRecorder, + &CJamRecorder::OnAboutToQuit, + Qt::ConnectionType::BlockingQueuedConnection ); // from the controller to the recorder - QObject::connect( this, &CJamController::RestartRecorder, - pJamRecorder, &CJamRecorder::OnTriggerSession ); + QObject::connect ( this, &CJamController::RestartRecorder, pJamRecorder, &CJamRecorder::OnTriggerSession ); - QObject::connect( this, &CJamController::StopRecorder, - pJamRecorder, &CJamRecorder::OnEnd ); + QObject::connect ( this, &CJamController::StopRecorder, pJamRecorder, &CJamRecorder::OnEnd ); - QObject::connect( this, &CJamController::EndRecorderThread, - pJamRecorder, &CJamRecorder::OnAboutToQuit, - Qt::ConnectionType::BlockingQueuedConnection ); + QObject::connect ( this, + &CJamController::EndRecorderThread, + pJamRecorder, + &CJamRecorder::OnAboutToQuit, + Qt::ConnectionType::BlockingQueuedConnection ); // from the server to the recorder - QObject::connect( this, &CJamController::Stopped, - pJamRecorder, &CJamRecorder::OnEnd ); + QObject::connect ( this, &CJamController::Stopped, pJamRecorder, &CJamRecorder::OnEnd ); - QObject::connect( this, &CJamController::ClientDisconnected, - pJamRecorder, &CJamRecorder::OnDisconnected ); + QObject::connect ( this, &CJamController::ClientDisconnected, pJamRecorder, &CJamRecorder::OnDisconnected ); qRegisterMetaType> ( "CVector" ); - QObject::connect( this, &CJamController::AudioFrame, - pJamRecorder, &CJamRecorder::OnFrame ); + QObject::connect ( this, &CJamController::AudioFrame, pJamRecorder, &CJamRecorder::OnFrame ); // from the recorder to the server - QObject::connect ( pJamRecorder, &CJamRecorder::RecordingSessionStarted, - this, &CJamController::RecordingSessionStarted ); + QObject::connect ( pJamRecorder, &CJamRecorder::RecordingSessionStarted, this, &CJamController::RecordingSessionStarted ); // from the recorder to the controller - QObject::connect ( pJamRecorder, &CJamRecorder::RecordingFailed, - this, &CJamController::OnRecordingFailed ); + QObject::connect ( pJamRecorder, &CJamRecorder::RecordingFailed, this, &CJamController::OnRecordingFailed ); pthJamRecorder->start ( QThread::NormalPriority ); - } else { diff --git a/src/recorder/jamcontroller.h b/src/recorder/jamcontroller.h old mode 100755 new mode 100644 index 68fa098253..cf3b67d837 --- a/src/recorder/jamcontroller.h +++ b/src/recorder/jamcontroller.h @@ -28,32 +28,33 @@ #include "jamrecorder.h" -namespace recorder { +namespace recorder +{ class CJamController : public QObject { Q_OBJECT public: - explicit CJamController( CServer* pNServer ); + explicit CJamController ( CServer* pNServer ); - bool GetRecorderInitialised() { return bRecorderInitialised; } - QString GetRecorderErrMsg() { return strRecorderErrMsg; } - bool GetRecordingEnabled() { return bEnableRecording; } - void RequestNewRecording(); - void SetEnableRecording ( bool bNewEnableRecording, bool isRunning ); - QString GetRecordingDir() { return strRecordingDir; } - void SetRecordingDir ( QString newRecordingDir, int iServerFrameSizeSamples, bool bDisableRecording ); + bool GetRecorderInitialised() { return bRecorderInitialised; } + QString GetRecorderErrMsg() { return strRecorderErrMsg; } + bool GetRecordingEnabled() { return bEnableRecording; } + void RequestNewRecording(); + void SetEnableRecording ( bool bNewEnableRecording, bool isRunning ); + QString GetRecordingDir() { return strRecordingDir; } + void SetRecordingDir ( QString newRecordingDir, int iServerFrameSizeSamples, bool bDisableRecording ); ERecorderState GetRecorderState(); private: void OnRecordingFailed ( QString error ); - CServer* pServer; + CServer* pServer; - bool bRecorderInitialised; - bool bEnableRecording; - QString strRecordingDir; - QThread* pthJamRecorder; + bool bRecorderInitialised; + bool bEnableRecording; + QString strRecordingDir; + QThread* pthJamRecorder; CJamRecorder* pJamRecorder; QString strRecorderErrMsg; @@ -70,14 +71,13 @@ class CJamController : public QObject const CHostAddress RecHostAddr, const int iNumAudChan, const CVector vecsData ); - }; -} +} // namespace recorder // This must be included AFTER the above definition of class CJamController, // because server.h defines CServer, which contains an instance of CJamController, // and therefore needs to know the its size. #include "../server.h" -Q_DECLARE_METATYPE(int16_t) +Q_DECLARE_METATYPE ( int16_t ) diff --git a/src/recorder/jamrecorder.cpp b/src/recorder/jamrecorder.cpp old mode 100755 new mode 100644 index 142fe7fd61..9ae17a7d8b --- a/src/recorder/jamrecorder.cpp +++ b/src/recorder/jamrecorder.cpp @@ -41,28 +41,28 @@ using namespace recorder; * Creates a file for the raw PCM data and sets up a QDataStream to which to write received frames. * The data is stored Little Endian. */ -CJamClient::CJamClient(const qint64 frame, const int _numChannels, const QString name, const CHostAddress address, const QDir recordBaseDir) : - startFrame (frame), - numChannels (static_cast(_numChannels)), - name (name), - address (address), - out (nullptr) +CJamClient::CJamClient ( const qint64 frame, const int _numChannels, const QString name, const CHostAddress address, const QDir recordBaseDir ) : + startFrame ( frame ), + numChannels ( static_cast ( _numChannels ) ), + name ( name ), + address ( address ), + out ( nullptr ) { // At this point we may not have much of a name - QString fileName = ClientName() + "-" + QString::number(frame) + "-" + QString::number(_numChannels); - QString affix = ""; - while (recordBaseDir.exists(fileName + affix + ".wav")) + QString fileName = ClientName() + "-" + QString::number ( frame ) + "-" + QString::number ( _numChannels ); + QString affix = ""; + while ( recordBaseDir.exists ( fileName + affix + ".wav" ) ) { - affix = affix.length() == 0 ? "_1" : "_" + QString::number(affix.remove(0, 1).toInt() + 1); + affix = affix.length() == 0 ? "_1" : "_" + QString::number ( affix.remove ( 0, 1 ).toInt() + 1 ); } fileName = fileName + affix + ".wav"; - wavFile = new QFile(recordBaseDir.absoluteFilePath(fileName)); - if (!wavFile->open(QFile::OpenMode(QIODevice::OpenModeFlag::ReadWrite))) // need to allow rewriting headers + wavFile = new QFile ( recordBaseDir.absoluteFilePath ( fileName ) ); + if ( !wavFile->open ( QFile::OpenMode ( QIODevice::OpenModeFlag::ReadWrite ) ) ) // need to allow rewriting headers { - throw CGenErr ( "Could not write to WAV file " + wavFile->fileName() ); + throw CGenErr ( "Could not write to WAV file " + wavFile->fileName() ); } - out = new CWaveStream(wavFile, numChannels); + out = new CWaveStream ( wavFile, numChannels ); filename = wavFile->fileName(); } @@ -72,11 +72,11 @@ CJamClient::CJamClient(const qint64 frame, const int _numChannels, const QString * @param _name The client's current name * @param pcm The PCM data */ -void CJamClient::Frame(const QString _name, const CVector& pcm, int iServerFrameSizeSamples) +void CJamClient::Frame ( const QString _name, const CVector& pcm, int iServerFrameSizeSamples ) { name = _name; - for(int i = 0; i < numChannels * iServerFrameSizeSamples; i++) + for ( int i = 0; i < numChannels * iServerFrameSizeSamples; i++ ) { *out << pcm[i]; } @@ -89,9 +89,9 @@ void CJamClient::Frame(const QString _name, const CVector& pcm, int iSe */ void CJamClient::Disconnect() { - if (out) + if ( out ) { - static_cast(out)->finalise(); + static_cast ( out )->finalise(); delete out; out = nullptr; } @@ -105,7 +105,7 @@ void CJamClient::Disconnect() /** * @brief CJamClient::TranslateChars Replace non-ASCII chars with nearest equivalent, if any, and change all punctuation to _ */ -QString CJamClient::TranslateChars (const QString& input) const +QString CJamClient::TranslateChars ( const QString& input ) const { // Allow letters and numbers // clang-format off @@ -131,13 +131,13 @@ QString CJamClient::TranslateChars (const QString& input) const QByteArray r = input.toLatin1(); - for (auto &c : r) + for ( auto& c : r ) { unsigned char uc = c; - c = charmap[uc]; + c = charmap[uc]; } - return QString::fromLatin1(r); + return QString::fromLatin1 ( r ); } /* ******************************************************************************************************** @@ -150,31 +150,31 @@ QString CJamClient::TranslateChars (const QString& input) const * * Each session is stored into its own subdirectory of the recording base directory. */ -CJamSession::CJamSession(QDir recordBaseDir) : - sessionDir (QDir(recordBaseDir.absoluteFilePath("Jam-" + QDateTime().currentDateTimeUtc().toString("yyyyMMdd-HHmmsszzz")))), - currentFrame (0), - chIdDisconnected (-1), - vecptrJamClients (MAX_NUM_CHANNELS), +CJamSession::CJamSession ( QDir recordBaseDir ) : + sessionDir ( QDir ( recordBaseDir.absoluteFilePath ( "Jam-" + QDateTime().currentDateTimeUtc().toString ( "yyyyMMdd-HHmmsszzz" ) ) ) ), + currentFrame ( 0 ), + chIdDisconnected ( -1 ), + vecptrJamClients ( MAX_NUM_CHANNELS ), jamClientConnections() { - QFileInfo fi(sessionDir.absolutePath()); - fi.setCaching(false); + QFileInfo fi ( sessionDir.absolutePath() ); + fi.setCaching ( false ); - if (!fi.exists() && !QDir().mkpath(sessionDir.absolutePath())) + if ( !fi.exists() && !QDir().mkpath ( sessionDir.absolutePath() ) ) { throw CGenErr ( sessionDir.absolutePath() + " does not exist and could not be created" ); } - if (!fi.isDir()) + if ( !fi.isDir() ) { throw CGenErr ( sessionDir.absolutePath() + " exists but is not a directory" ); } - if (!fi.isWritable()) + if ( !fi.isWritable() ) { throw CGenErr ( sessionDir.absolutePath() + " is a directory but cannot be written to" ); } // Explicitly set all the pointers to "empty" - vecptrJamClients.fill(nullptr); + vecptrJamClients.fill ( nullptr ); } /** @@ -183,7 +183,7 @@ CJamSession::CJamSession(QDir recordBaseDir) : CJamSession::~CJamSession() { // free up any active jamClientConnections - for (int i = 0; i < jamClientConnections.count(); i++ ) + for ( int i = 0; i < jamClientConnections.count(); i++ ) { if ( jamClientConnections[i] ) { @@ -197,19 +197,19 @@ CJamSession::~CJamSession() * @brief CJamSession::DisconnectClient Capture details of the departing client's connection * @param iChID the channel id of the client that disconnected */ -void CJamSession::DisconnectClient(int iChID) +void CJamSession::DisconnectClient ( int iChID ) { vecptrJamClients[iChID]->Disconnect(); - jamClientConnections.append(new CJamClientConnection(vecptrJamClients[iChID]->NumAudioChannels(), - vecptrJamClients[iChID]->StartFrame(), - vecptrJamClients[iChID]->FrameCount(), - vecptrJamClients[iChID]->ClientName(), - vecptrJamClients[iChID]->FileName())); + jamClientConnections.append ( new CJamClientConnection ( vecptrJamClients[iChID]->NumAudioChannels(), + vecptrJamClients[iChID]->StartFrame(), + vecptrJamClients[iChID]->FrameCount(), + vecptrJamClients[iChID]->ClientName(), + vecptrJamClients[iChID]->FileName() ) ); delete vecptrJamClients[iChID]; vecptrJamClients[iChID] = nullptr; - chIdDisconnected = iChID; + chIdDisconnected = iChID; } /** @@ -225,7 +225,12 @@ void CJamSession::DisconnectClient(int iChID) * * Also manages the overall current frame counter for the session. */ -void CJamSession::Frame(const int iChID, const QString name, const CHostAddress address, const int numAudioChannels, const CVector data, int iServerFrameSizeSamples) +void CJamSession::Frame ( const int iChID, + const QString name, + const CHostAddress address, + const int numAudioChannels, + const CVector data, + int iServerFrameSizeSamples ) { if ( iChID == chIdDisconnected ) { @@ -234,36 +239,36 @@ void CJamSession::Frame(const int iChID, const QString name, const CHostAddress return; } - if (vecptrJamClients[iChID] == nullptr) + if ( vecptrJamClients[iChID] == nullptr ) { // then we have not seen this client this session - vecptrJamClients[iChID] = new CJamClient(currentFrame, numAudioChannels, name, address, sessionDir); + vecptrJamClients[iChID] = new CJamClient ( currentFrame, numAudioChannels, name, address, sessionDir ); } - else if (numAudioChannels != vecptrJamClients[iChID]->NumAudioChannels() - || address.InetAddr != vecptrJamClients[iChID]->ClientAddress().InetAddr - || address.iPort != vecptrJamClients[iChID]->ClientAddress().iPort) + else if ( numAudioChannels != vecptrJamClients[iChID]->NumAudioChannels() || + address.InetAddr != vecptrJamClients[iChID]->ClientAddress().InetAddr || + address.iPort != vecptrJamClients[iChID]->ClientAddress().iPort ) { - DisconnectClient(iChID); - if (numAudioChannels == 0) + DisconnectClient ( iChID ); + if ( numAudioChannels == 0 ) { vecptrJamClients[iChID] = nullptr; } else { - vecptrJamClients[iChID] = new CJamClient(currentFrame, numAudioChannels, name, address, sessionDir); + vecptrJamClients[iChID] = new CJamClient ( currentFrame, numAudioChannels, name, address, sessionDir ); } } - if (vecptrJamClients[iChID] == nullptr) + if ( vecptrJamClients[iChID] == nullptr ) { // Frame allegedly from iChID but unable to establish client details return; } - vecptrJamClients[iChID]->Frame(name, data, iServerFrameSizeSamples); + vecptrJamClients[iChID]->Frame ( name, data, iServerFrameSizeSamples ); // If _any_ connected client frame steps past currentFrame, increase currentFrame - if (vecptrJamClients[iChID]->StartFrame() + vecptrJamClients[iChID]->FrameCount() > currentFrame) + if ( vecptrJamClients[iChID]->StartFrame() + vecptrJamClients[iChID]->FrameCount() > currentFrame ) { currentFrame++; } @@ -274,11 +279,11 @@ void CJamSession::Frame(const int iChID, const QString name, const CHostAddress */ void CJamSession::End() { - for (int iChID = 0; iChID < vecptrJamClients.size(); iChID++) + for ( int iChID = 0; iChID < vecptrJamClients.size(); iChID++ ) { - if (vecptrJamClients[iChID] != nullptr) + if ( vecptrJamClients[iChID] != nullptr ) { - DisconnectClient(iChID); + DisconnectClient ( iChID ); vecptrJamClients[iChID] = nullptr; } } @@ -292,21 +297,19 @@ QMap> CJamSession::Tracks() { QMap> tracks; - for (int i = 0; i < jamClientConnections.count(); i++ ) + for ( int i = 0; i < jamClientConnections.count(); i++ ) { - STrackItem track ( - jamClientConnections[i]->Format(), - jamClientConnections[i]->StartFrame(), - jamClientConnections[i]->Length(), - jamClientConnections[i]->FileName() - ); + STrackItem track ( jamClientConnections[i]->Format(), + jamClientConnections[i]->StartFrame(), + jamClientConnections[i]->Length(), + jamClientConnections[i]->FileName() ); - if (!tracks.contains(jamClientConnections[i]->Name())) + if ( !tracks.contains ( jamClientConnections[i]->Name() ) ) { - tracks.insert(jamClientConnections[i]->Name(), { }); + tracks.insert ( jamClientConnections[i]->Name(), {} ); } - tracks[jamClientConnections[i]->Name()].append(track); + tracks[jamClientConnections[i]->Name()].append ( track ); } return tracks; @@ -317,38 +320,33 @@ QMap> CJamSession::Tracks() * @param sessionDirName the directory name to scan * @return a map of (latest) client name to connection items */ -QMap> CJamSession::TracksFromSessionDir(const QString& sessionDirName, int iServerFrameSizeSamples) +QMap> CJamSession::TracksFromSessionDir ( const QString& sessionDirName, int iServerFrameSizeSamples ) { QMap> tracks; - const QDir sessionDir(sessionDirName); - foreach(auto entry, sessionDir.entryList({ "*.pcm" })) + const QDir sessionDir ( sessionDirName ); + foreach ( auto entry, sessionDir.entryList ( { "*.pcm" } ) ) { - auto split = entry.split(".")[0].split("-"); - QString name = split[0]; - QString hostPort = split[1]; - QString frame = split[2]; - QString tail = split[3]; //numChannels may have _nnn - QString numChannels = tail.count("_") > 0 ? tail.split("_")[0] : tail; + auto split = entry.split ( "." )[0].split ( "-" ); + QString name = split[0]; + QString hostPort = split[1]; + QString frame = split[2]; + QString tail = split[3]; // numChannels may have _nnn + QString numChannels = tail.count ( "_" ) > 0 ? tail.split ( "_" )[0] : tail; QString trackName = name + "-" + hostPort; - if (!tracks.contains(trackName)) + if ( !tracks.contains ( trackName ) ) { - tracks.insert(trackName, { }); + tracks.insert ( trackName, {} ); } - QFileInfo fiEntry(sessionDir.absoluteFilePath(entry)); - qint64 length = fiEntry.size() / numChannels.toInt() / iServerFrameSizeSamples; + QFileInfo fiEntry ( sessionDir.absoluteFilePath ( entry ) ); + qint64 length = fiEntry.size() / numChannels.toInt() / iServerFrameSizeSamples; - STrackItem track ( - numChannels.toInt(), - frame.toLongLong(), - length, - sessionDir.absoluteFilePath(entry) - ); + STrackItem track ( numChannels.toInt(), frame.toLongLong(), length, sessionDir.absoluteFilePath ( entry ) ); - tracks[trackName].append(track); + tracks[trackName].append ( track ); } return tracks; @@ -365,26 +363,26 @@ QMap> CJamSession::TracksFromSessionDir(const QString */ QString CJamRecorder::Init() { - QString errmsg = QString::null; + QString errmsg = QString::null; QFileInfo fi ( recordBaseDir.absolutePath() ); fi.setCaching ( false ); if ( !fi.exists() && !QDir().mkpath ( recordBaseDir.absolutePath() ) ) { - errmsg = QString( "'%1' does not exist but could not be created." ).arg( recordBaseDir.absolutePath() ); - qCritical() << qUtf8Printable( errmsg ); + errmsg = QString ( "'%1' does not exist but could not be created." ).arg ( recordBaseDir.absolutePath() ); + qCritical() << qUtf8Printable ( errmsg ); return errmsg; } - if (!fi.isDir()) + if ( !fi.isDir() ) { - errmsg = QString( "'%1' exists but is not a directory" ).arg( recordBaseDir.absolutePath() ); - qCritical() << qUtf8Printable( errmsg ); + errmsg = QString ( "'%1' exists but is not a directory" ).arg ( recordBaseDir.absolutePath() ); + qCritical() << qUtf8Printable ( errmsg ); return errmsg; } - if (!fi.isWritable()) + if ( !fi.isWritable() ) { - errmsg = QString( "'%1' is a directory but cannot be written to" ).arg( recordBaseDir.absolutePath() ); - qCritical() << qUtf8Printable( errmsg ); + errmsg = QString ( "'%1' is a directory but cannot be written to" ).arg ( recordBaseDir.absolutePath() ); + qCritical() << qUtf8Printable ( errmsg ); return errmsg; } @@ -394,7 +392,8 @@ QString CJamRecorder::Init() /** * @brief CJamRecorder::Start Start up tasks for a new session */ -void CJamRecorder::Start() { +void CJamRecorder::Start() +{ // Ensure any previous cleaning up has been done. OnEnd(); @@ -405,13 +404,13 @@ void CJamRecorder::Start() { { try { - currentSession = new CJamSession( recordBaseDir ); - isRecording = true; + currentSession = new CJamSession ( recordBaseDir ); + isRecording = true; } catch ( const CGenErr& err ) { currentSession = nullptr; - error = err.GetErrorText(); + error = err.GetErrorText(); } } ChIdMutex.unlock(); @@ -425,7 +424,6 @@ void CJamRecorder::Start() { emit RecordingSessionStarted ( currentSession->SessionDir().path() ); } - /** * @brief CJamRecorder::OnEnd Finalise the recording and write the Reaper RPP file */ @@ -448,7 +446,6 @@ void CJamRecorder::OnEnd() ChIdMutex.unlock(); } - /** * @brief CJamRecorder::OnTriggerSession End one session and start a new one */ @@ -473,20 +470,20 @@ void CJamRecorder::OnAboutToQuit() void CJamRecorder::ReaperProjectFromCurrentSession() { - QString reaperProjectFileName = currentSession->SessionDir().filePath(currentSession->Name().append(".rpp")); - const QFileInfo fi(reaperProjectFileName); + QString reaperProjectFileName = currentSession->SessionDir().filePath ( currentSession->Name().append ( ".rpp" ) ); + const QFileInfo fi ( reaperProjectFileName ); - if (fi.exists()) + if ( fi.exists() ) { qWarning() << "CJamRecorder::ReaperProjectFromCurrentSession():" << fi.absolutePath() << "exists and will not be overwritten."; } else { - QFile outf (reaperProjectFileName); - if ( outf.open(QFile::WriteOnly) ) + QFile outf ( reaperProjectFileName ); + if ( outf.open ( QFile::WriteOnly ) ) { - QTextStream out(&outf); - out << CReaperProject( currentSession->Tracks(), iServerFrameSizeSamples ).toString() << endl; + QTextStream out ( &outf ); + out << CReaperProject ( currentSession->Tracks(), iServerFrameSizeSamples ).toString() << endl; qDebug() << "Session RPP:" << reaperProjectFileName; } else @@ -498,26 +495,27 @@ void CJamRecorder::ReaperProjectFromCurrentSession() void CJamRecorder::AudacityLofFromCurrentSession() { - QString audacityLofFileName = currentSession->SessionDir().filePath(currentSession->Name().append(".lof")); - const QFileInfo fi(audacityLofFileName); + QString audacityLofFileName = currentSession->SessionDir().filePath ( currentSession->Name().append ( ".lof" ) ); + const QFileInfo fi ( audacityLofFileName ); - if (fi.exists()) + if ( fi.exists() ) { qWarning() << "CJamRecorder::AudacityLofFromCurrentSession():" << fi.absolutePath() << "exists and will not be overwritten."; } else { - QFile outf (audacityLofFileName); - if ( outf.open(QFile::WriteOnly) ) + QFile outf ( audacityLofFileName ); + if ( outf.open ( QFile::WriteOnly ) ) { - QTextStream sOut(&outf); + QTextStream sOut ( &outf ); foreach ( auto trackName, currentSession->Tracks().keys() ) { - foreach ( auto item, currentSession->Tracks()[trackName] ) { + foreach ( auto item, currentSession->Tracks()[trackName] ) + { QFileInfo fi ( item.fileName ); sOut << "file " << '"' << fi.fileName() << '"'; - sOut << " offset " << secondsAt48K( item.startFrame, iServerFrameSizeSamples ) << endl; + sOut << " offset " << secondsAt48K ( item.startFrame, iServerFrameSizeSamples ) << endl; } } @@ -537,30 +535,32 @@ void CJamRecorder::AudacityLofFromCurrentSession() * * This is used for testing and is not called from the regular Jamulus code. */ -void CJamRecorder::SessionDirToReaper(QString& strSessionDirName, int serverFrameSizeSamples) +void CJamRecorder::SessionDirToReaper ( QString& strSessionDirName, int serverFrameSizeSamples ) { - const QFileInfo fiSessionDir(QDir::cleanPath(strSessionDirName)); - if (!fiSessionDir.exists() || !fiSessionDir.isDir()) + const QFileInfo fiSessionDir ( QDir::cleanPath ( strSessionDirName ) ); + if ( !fiSessionDir.exists() || !fiSessionDir.isDir() ) { throw CGenErr ( fiSessionDir.absoluteFilePath() + " does not exist or is not a directory. Aborting." ); } - const QDir dSessionDir(fiSessionDir.absoluteFilePath()); - const QString reaperProjectFileName = dSessionDir.absoluteFilePath(fiSessionDir.baseName().append(".rpp")); - const QFileInfo fiRPP(reaperProjectFileName); - if (fiRPP.exists()) + const QDir dSessionDir ( fiSessionDir.absoluteFilePath() ); + const QString reaperProjectFileName = dSessionDir.absoluteFilePath ( fiSessionDir.baseName().append ( ".rpp" ) ); + const QFileInfo fiRPP ( reaperProjectFileName ); + if ( fiRPP.exists() ) { throw CGenErr ( fiRPP.absoluteFilePath() + " exists and will not be overwritten. Aborting." ); } - QFile outf (fiRPP.absoluteFilePath()); + QFile outf ( fiRPP.absoluteFilePath() ); if ( !outf.open ( QFile::WriteOnly ) ) { throw CGenErr ( fiRPP.absoluteFilePath() + " could not be written. Aborting." ); } - QTextStream out(&outf); + QTextStream out ( &outf ); - out << CReaperProject( CJamSession::TracksFromSessionDir( fiSessionDir.absoluteFilePath(), serverFrameSizeSamples ), serverFrameSizeSamples ).toString() << endl; + out << CReaperProject ( CJamSession::TracksFromSessionDir ( fiSessionDir.absoluteFilePath(), serverFrameSizeSamples ), serverFrameSizeSamples ) + .toString() + << endl; qDebug() << "Session RPP:" << reaperProjectFileName; } @@ -569,7 +569,7 @@ void CJamRecorder::SessionDirToReaper(QString& strSessionDirName, int serverFram * @brief CJamRecorder::OnDisconnected Handle disconnection of a client * @param iChID the client channel id */ -void CJamRecorder::OnDisconnected(int iChID) +void CJamRecorder::OnDisconnected ( int iChID ) { ChIdMutex.lock(); { @@ -598,7 +598,11 @@ void CJamRecorder::OnDisconnected(int iChID) * * Ensures recording has started. */ -void CJamRecorder::OnFrame(const int iChID, const QString name, const CHostAddress address, const int numAudioChannels, const CVector data) +void CJamRecorder::OnFrame ( const int iChID, + const QString name, + const CHostAddress address, + const int numAudioChannels, + const CVector data ) { // Make sure we are ready if ( !isRecording ) diff --git a/src/recorder/jamrecorder.h b/src/recorder/jamrecorder.h old mode 100755 new mode 100644 index 7c53662f8f..a4dedb783e --- a/src/recorder/jamrecorder.h +++ b/src/recorder/jamrecorder.h @@ -35,27 +35,31 @@ #include "creaperproject.h" #include "cwavestream.h" -namespace recorder { +namespace recorder +{ class CJamClientConnection : public QObject { Q_OBJECT public: - CJamClientConnection(const int _numAudioChannels, const qint64 _startFrame, const qint64 _length, const QString _name, const QString _fileName) : - numAudioChannels (_numAudioChannels), - startFrame (_startFrame), - length (_length), - name (_name), - fileName (_fileName) - { - } - - int Format() { return numAudioChannels; } - qint64 StartFrame() { return startFrame; } - qint64 Length() { return length; } - QString Name() { return name; } - QString FileName() { return fileName; } + CJamClientConnection ( const int _numAudioChannels, + const qint64 _startFrame, + const qint64 _length, + const QString _name, + const QString _fileName ) : + numAudioChannels ( _numAudioChannels ), + startFrame ( _startFrame ), + length ( _length ), + name ( _name ), + fileName ( _fileName ) + {} + + int Format() { return numAudioChannels; } + qint64 StartFrame() { return startFrame; } + qint64 Length() { return length; } + QString Name() { return name; } + QString FileName() { return fileName; } private: const int numAudioChannels; @@ -70,36 +74,38 @@ class CJamClient : public QObject Q_OBJECT public: - CJamClient(const qint64 frame, const int numChannels, const QString name, const CHostAddress address, const QDir recordBaseDir); + CJamClient ( const qint64 frame, const int numChannels, const QString name, const CHostAddress address, const QDir recordBaseDir ); - void Frame(const QString name, const CVector& pcm, int iServerFrameSizeSamples); + void Frame ( const QString name, const CVector& pcm, int iServerFrameSizeSamples ); void Disconnect(); - qint64 StartFrame() { return startFrame; } - qint64 FrameCount() { return frameCount; } - uint16_t NumAudioChannels() { return numChannels; } - QString ClientName() { return TranslateChars(name).leftJustified(4, '_', false) - .append("-") - .append(TranslateChars(address.toString(CHostAddress::EStringMode::SM_IP_NO_LAST_BYTE_PORT))) - ; - } - CHostAddress ClientAddress() { return address; } + qint64 StartFrame() { return startFrame; } + qint64 FrameCount() { return frameCount; } + uint16_t NumAudioChannels() { return numChannels; } + QString ClientName() + { + return TranslateChars ( name ) + .leftJustified ( 4, '_', false ) + .append ( "-" ) + .append ( TranslateChars ( address.toString ( CHostAddress::EStringMode::SM_IP_NO_LAST_BYTE_PORT ) ) ); + } + CHostAddress ClientAddress() { return address; } - QString FileName() { return filename; } + QString FileName() { return filename; } private: QString TranslateChars ( const QString& input ) const; const qint64 startFrame; const uint16_t numChannels; - QString name; + QString name; const CHostAddress address; - QString filename; - QFile* wavFile; - QDataStream* out; - qint64 frameCount = 0; + QString filename; + QFile* wavFile; + QDataStream* out; + qint64 frameCount = 0; }; class CJamSession : public QObject @@ -107,12 +113,16 @@ class CJamSession : public QObject Q_OBJECT public: - - CJamSession(QDir recordBaseDir); + CJamSession ( QDir recordBaseDir ); virtual ~CJamSession(); - void Frame(const int iChID, const QString name, const CHostAddress address, const int numAudioChannels, const CVector data, int iServerFrameSizeSamples); + void Frame ( const int iChID, + const QString name, + const CHostAddress address, + const int numAudioChannels, + const CVector data, + int iServerFrameSizeSamples ); void End(); @@ -124,18 +134,18 @@ class CJamSession : public QObject const QDir SessionDir() { return sessionDir; } - void DisconnectClient(int iChID); + void DisconnectClient ( int iChID ); - static QMap> TracksFromSessionDir(const QString& name, int iServerFrameSizeSamples); + static QMap> TracksFromSessionDir ( const QString& name, int iServerFrameSizeSamples ); private: CJamSession(); const QDir sessionDir; - qint64 currentFrame; - int chIdDisconnected; - QVector vecptrJamClients; + qint64 currentFrame; + int chIdDisconnected; + QVector vecptrJamClients; QList jamClientConnections; }; @@ -144,13 +154,11 @@ class CJamRecorder : public QObject Q_OBJECT public: - CJamRecorder ( const QString strRecordingBaseDir, - const int iServerFrameSizeSamples ) : - recordBaseDir ( strRecordingBaseDir ), + CJamRecorder ( const QString strRecordingBaseDir, const int iServerFrameSizeSamples ) : + recordBaseDir ( strRecordingBaseDir ), iServerFrameSizeSamples ( iServerFrameSizeSamples ), - isRecording ( false ) - { - } + isRecording ( false ) + {} /** * @brief Create recording directory, if necessary, and connect signal handlers @@ -163,7 +171,7 @@ class CJamRecorder : public QObject * @param strSessionDirName Where the session wave files are * @param serverFrameSizeSamples What the server frame size was for the session */ - static void SessionDirToReaper( QString& strSessionDirName, int serverFrameSizeSamples ); + static void SessionDirToReaper ( QString& strSessionDirName, int serverFrameSizeSamples ); private: void Start(); @@ -208,4 +216,4 @@ public slots: void OnFrame ( const int iChID, const QString name, const CHostAddress address, const int numAudioChannels, const CVector data ); }; -} +} // namespace recorder diff --git a/src/server.cpp b/src/server.cpp index ac14c790f4..21fe46f0b2 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -8,36 +8,34 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ #include "server.h" - // CHighPrecisionTimer implementation ****************************************** #ifdef _WIN32 -CHighPrecisionTimer::CHighPrecisionTimer ( const bool bNewUseDoubleSystemFrameSize ) : - bUseDoubleSystemFrameSize ( bNewUseDoubleSystemFrameSize ) +CHighPrecisionTimer::CHighPrecisionTimer ( const bool bNewUseDoubleSystemFrameSize ) : bUseDoubleSystemFrameSize ( bNewUseDoubleSystemFrameSize ) { // add some error checking, the high precision timer implementation only // supports 64 and 128 samples frame size at 48 kHz sampling rate -#if ( SYSTEM_FRAME_SIZE_SAMPLES != 64 ) && ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES != 128 ) -# error "Only system frame size of 64 and 128 samples is supported by this module" -#endif -#if ( SYSTEM_SAMPLE_RATE_HZ != 48000 ) -# error "Only a system sample rate of 48 kHz is supported by this module" -#endif +# if ( SYSTEM_FRAME_SIZE_SAMPLES != 64 ) && ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES != 128 ) +# error "Only system frame size of 64 and 128 samples is supported by this module" +# endif +# if ( SYSTEM_SAMPLE_RATE_HZ != 48000 ) +# error "Only a system sample rate of 48 kHz is supported by this module" +# endif // Since QT only supports a minimum timer resolution of 1 ms but for our // server we require a timer interval of 2.333 ms for 128 samples @@ -61,8 +59,7 @@ CHighPrecisionTimer::CHighPrecisionTimer ( const bool bNewUseDoubleSystemFrameSi Timer.setTimerType ( Qt::PreciseTimer ); // connect timer timeout signal - QObject::connect ( &Timer, &QTimer::timeout, - this, &CHighPrecisionTimer::OnTimer ); + QObject::connect ( &Timer, &QTimer::timeout, this, &CHighPrecisionTimer::OnTimer ); } void CHighPrecisionTimer::Start() @@ -116,34 +113,30 @@ void CHighPrecisionTimer::OnTimer() } } #else // Mac and Linux -CHighPrecisionTimer::CHighPrecisionTimer ( const bool bUseDoubleSystemFrameSize ) : - bRun ( false ) +CHighPrecisionTimer::CHighPrecisionTimer ( const bool bUseDoubleSystemFrameSize ) : bRun ( false ) { // calculate delay in ns uint64_t iNsDelay; if ( bUseDoubleSystemFrameSize ) { - iNsDelay = ( (uint64_t) DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES * 1000000000 ) / - (uint64_t) SYSTEM_SAMPLE_RATE_HZ; // in ns + iNsDelay = ( (uint64_t) DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES * 1000000000 ) / (uint64_t) SYSTEM_SAMPLE_RATE_HZ; // in ns } else { - iNsDelay = ( (uint64_t) SYSTEM_FRAME_SIZE_SAMPLES * 1000000000 ) / - (uint64_t) SYSTEM_SAMPLE_RATE_HZ; // in ns + iNsDelay = ( (uint64_t) SYSTEM_FRAME_SIZE_SAMPLES * 1000000000 ) / (uint64_t) SYSTEM_SAMPLE_RATE_HZ; // in ns } -#if defined ( __APPLE__ ) || defined ( __MACOSX ) +# if defined( __APPLE__ ) || defined( __MACOSX ) // calculate delay in mach absolute time struct mach_timebase_info timeBaseInfo; mach_timebase_info ( &timeBaseInfo ); - Delay = ( iNsDelay * (uint64_t) timeBaseInfo.denom ) / - (uint64_t) timeBaseInfo.numer; -#else + Delay = ( iNsDelay * (uint64_t) timeBaseInfo.denom ) / (uint64_t) timeBaseInfo.numer; +# else // set delay Delay = iNsDelay; -#endif +# endif } void CHighPrecisionTimer::Start() @@ -155,9 +148,9 @@ void CHighPrecisionTimer::Start() bRun = true; // set initial end time -#if defined ( __APPLE__ ) || defined ( __MACOSX ) +# if defined( __APPLE__ ) || defined( __MACOSX ) NextEnd = mach_absolute_time() + Delay; -#else +# else clock_gettime ( CLOCK_MONOTONIC, &NextEnd ); NextEnd.tv_nsec += Delay; @@ -166,7 +159,7 @@ void CHighPrecisionTimer::Start() NextEnd.tv_sec++; NextEnd.tv_nsec -= 1000000000L; } -#endif +# endif // start thread QThread::start ( QThread::TimeCriticalPriority ); @@ -189,26 +182,23 @@ void CHighPrecisionTimer::run() { // call processing routine by fireing signal -// clang-format off + // clang-format off // TODO by emit a signal we leave the high priority thread -> maybe use some // other connection type to have something like a true callback, e.g. // "Qt::DirectConnection" -> Can this work? -// clang-format on + // clang-format on emit timeout(); // now wait until the next buffer shall be processed (we // use the "increment method" to make sure we do not introduce // a timing drift) -#if defined ( __APPLE__ ) || defined ( __MACOSX ) +# if defined( __APPLE__ ) || defined( __MACOSX ) mach_wait_until ( NextEnd ); NextEnd += Delay; -#else - clock_nanosleep ( CLOCK_MONOTONIC, - TIMER_ABSTIME, - &NextEnd, - NULL ); +# else + clock_nanosleep ( CLOCK_MONOTONIC, TIMER_ABSTIME, &NextEnd, NULL ); NextEnd.tv_nsec += Delay; if ( NextEnd.tv_nsec >= 1000000000L ) @@ -216,12 +206,11 @@ void CHighPrecisionTimer::run() NextEnd.tv_sec++; NextEnd.tv_nsec -= 1000000000L; } -#endif +# endif } } #endif - // CServer implementation ****************************************************** CServer::CServer ( const int iNewMaxNumChan, const QString& strLoggingFileName, @@ -241,29 +230,23 @@ CServer::CServer ( const int iNewMaxNumChan, const bool bDisableRecording, const bool bNDelayPan, const ELicenceType eNLicenceType ) : - bUseDoubleSystemFrameSize ( bNUseDoubleSystemFrameSize ), - bUseMultithreading ( bNUseMultithreading ), - iMaxNumChannels ( iNewMaxNumChan ), - Socket ( this, iPortNumber, iQosNumber, strServerBindIP ), - Logging ( ), - iFrameCount ( 0 ), - bWriteStatusHTMLFile ( false ), - strServerHTMLFileListName ( strHTMLStatusFileName ), - HighPrecisionTimer ( bNUseDoubleSystemFrameSize ), - ServerListManager ( iPortNumber, - strCentralServer, - strServerInfo, - strServerPublicIP, - strServerListFilter, - iNewMaxNumChan, - &ConnLessProtocol ), - JamController ( this ), - bDisableRecording ( bDisableRecording ), - bAutoRunMinimized ( false ), - bDelayPan ( bNDelayPan ), - eLicenceType ( eNLicenceType ), + bUseDoubleSystemFrameSize ( bNUseDoubleSystemFrameSize ), + bUseMultithreading ( bNUseMultithreading ), + iMaxNumChannels ( iNewMaxNumChan ), + Socket ( this, iPortNumber, iQosNumber, strServerBindIP ), + Logging(), + iFrameCount ( 0 ), + bWriteStatusHTMLFile ( false ), + strServerHTMLFileListName ( strHTMLStatusFileName ), + HighPrecisionTimer ( bNUseDoubleSystemFrameSize ), + ServerListManager ( iPortNumber, strCentralServer, strServerInfo, strServerPublicIP, strServerListFilter, iNewMaxNumChan, &ConnLessProtocol ), + JamController ( this ), + bDisableRecording ( bDisableRecording ), + bAutoRunMinimized ( false ), + bDelayPan ( bNDelayPan ), + eLicenceType ( eNLicenceType ), bDisconnectAllClientsOnQuit ( bNDisconnectAllClientsOnQuit ), - pSignalHandler ( CSignalHandler::getSingletonP() ) + pSignalHandler ( CSignalHandler::getSingletonP() ) { int iOpusError; int i; @@ -274,49 +257,44 @@ CServer::CServer ( const int iNewMaxNumChan, for ( i = 0; i < iMaxNumChannels; i++ ) { // init OPUS ----------------------------------------------------------- - OpusMode[i] = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ, - DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES, - &iOpusError ); + OpusMode[i] = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ, DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES, &iOpusError ); - Opus64Mode[i] = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ, - SYSTEM_FRAME_SIZE_SAMPLES, - &iOpusError ); + Opus64Mode[i] = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ, SYSTEM_FRAME_SIZE_SAMPLES, &iOpusError ); // init audio encoders and decoders - OpusEncoderMono[i] = opus_custom_encoder_create ( OpusMode[i], 1, &iOpusError ); // mono encoder legacy - OpusDecoderMono[i] = opus_custom_decoder_create ( OpusMode[i], 1, &iOpusError ); // mono decoder legacy - OpusEncoderStereo[i] = opus_custom_encoder_create ( OpusMode[i], 2, &iOpusError ); // stereo encoder legacy - OpusDecoderStereo[i] = opus_custom_decoder_create ( OpusMode[i], 2, &iOpusError ); // stereo decoder legacy + OpusEncoderMono[i] = opus_custom_encoder_create ( OpusMode[i], 1, &iOpusError ); // mono encoder legacy + OpusDecoderMono[i] = opus_custom_decoder_create ( OpusMode[i], 1, &iOpusError ); // mono decoder legacy + OpusEncoderStereo[i] = opus_custom_encoder_create ( OpusMode[i], 2, &iOpusError ); // stereo encoder legacy + OpusDecoderStereo[i] = opus_custom_decoder_create ( OpusMode[i], 2, &iOpusError ); // stereo decoder legacy Opus64EncoderMono[i] = opus_custom_encoder_create ( Opus64Mode[i], 1, &iOpusError ); // mono encoder OPUS64 Opus64DecoderMono[i] = opus_custom_decoder_create ( Opus64Mode[i], 1, &iOpusError ); // mono decoder OPUS64 Opus64EncoderStereo[i] = opus_custom_encoder_create ( Opus64Mode[i], 2, &iOpusError ); // stereo encoder OPUS64 Opus64DecoderStereo[i] = opus_custom_decoder_create ( Opus64Mode[i], 2, &iOpusError ); // stereo decoder OPUS64 // we require a constant bit rate - opus_custom_encoder_ctl ( OpusEncoderMono[i], OPUS_SET_VBR ( 0 ) ); - opus_custom_encoder_ctl ( OpusEncoderStereo[i], OPUS_SET_VBR ( 0 ) ); - opus_custom_encoder_ctl ( Opus64EncoderMono[i], OPUS_SET_VBR ( 0 ) ); + opus_custom_encoder_ctl ( OpusEncoderMono[i], OPUS_SET_VBR ( 0 ) ); + opus_custom_encoder_ctl ( OpusEncoderStereo[i], OPUS_SET_VBR ( 0 ) ); + opus_custom_encoder_ctl ( Opus64EncoderMono[i], OPUS_SET_VBR ( 0 ) ); opus_custom_encoder_ctl ( Opus64EncoderStereo[i], OPUS_SET_VBR ( 0 ) ); // for 64 samples frame size we have to adjust the PLC behavior to avoid loud artifacts - opus_custom_encoder_ctl ( Opus64EncoderMono[i], OPUS_SET_PACKET_LOSS_PERC ( 35 ) ); + opus_custom_encoder_ctl ( Opus64EncoderMono[i], OPUS_SET_PACKET_LOSS_PERC ( 35 ) ); opus_custom_encoder_ctl ( Opus64EncoderStereo[i], OPUS_SET_PACKET_LOSS_PERC ( 35 ) ); // we want as low delay as possible - opus_custom_encoder_ctl ( OpusEncoderMono[i], OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); - opus_custom_encoder_ctl ( OpusEncoderStereo[i], OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); - opus_custom_encoder_ctl ( Opus64EncoderMono[i], OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); + opus_custom_encoder_ctl ( OpusEncoderMono[i], OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); + opus_custom_encoder_ctl ( OpusEncoderStereo[i], OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); + opus_custom_encoder_ctl ( Opus64EncoderMono[i], OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); opus_custom_encoder_ctl ( Opus64EncoderStereo[i], OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); // set encoder low complexity for legacy 128 samples frame size - opus_custom_encoder_ctl ( OpusEncoderMono[i], OPUS_SET_COMPLEXITY ( 1 ) ); + opus_custom_encoder_ctl ( OpusEncoderMono[i], OPUS_SET_COMPLEXITY ( 1 ) ); opus_custom_encoder_ctl ( OpusEncoderStereo[i], OPUS_SET_COMPLEXITY ( 1 ) ); - // init double-to-normal frame size conversion buffers ----------------- // use worst case memory initialization to avoid allocating memory in // the time-critical thread - DoubleFrameSizeConvBufIn[i].Init ( 2 /* stereo */ * DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES /* worst case buffer size */ ); + DoubleFrameSizeConvBufIn[i].Init ( 2 /* stereo */ * DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES /* worst case buffer size */ ); DoubleFrameSizeConvBufOut[i].Init ( 2 /* stereo */ * DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES /* worst case buffer size */ ); } @@ -345,23 +323,23 @@ CServer::CServer ( const int iNewMaxNumChan, // the worst case here: // allocate worst case memory for the temporary vectors - vecChanIDsCurConChan.Init ( iMaxNumChannels ); - vecvecfGains.Init ( iMaxNumChannels ); - vecvecfPannings.Init ( iMaxNumChannels ); - vecvecsData.Init ( iMaxNumChannels ); - vecvecsData2.Init ( iMaxNumChannels ); - vecvecsSendData.Init ( iMaxNumChannels ); - vecvecfIntermediateProcBuf.Init ( iMaxNumChannels ); - vecvecbyCodedData.Init ( iMaxNumChannels ); - vecNumAudioChannels.Init ( iMaxNumChannels ); - vecNumFrameSizeConvBlocks.Init ( iMaxNumChannels ); + vecChanIDsCurConChan.Init ( iMaxNumChannels ); + vecvecfGains.Init ( iMaxNumChannels ); + vecvecfPannings.Init ( iMaxNumChannels ); + vecvecsData.Init ( iMaxNumChannels ); + vecvecsData2.Init ( iMaxNumChannels ); + vecvecsSendData.Init ( iMaxNumChannels ); + vecvecfIntermediateProcBuf.Init ( iMaxNumChannels ); + vecvecbyCodedData.Init ( iMaxNumChannels ); + vecNumAudioChannels.Init ( iMaxNumChannels ); + vecNumFrameSizeConvBlocks.Init ( iMaxNumChannels ); vecUseDoubleSysFraSizeConvBuf.Init ( iMaxNumChannels ); - vecAudioComprType.Init ( iMaxNumChannels ); + vecAudioComprType.Init ( iMaxNumChannels ); for ( i = 0; i < iMaxNumChannels; i++ ) { // init vectors storing information of all channels - vecvecfGains[i].Init ( iMaxNumChannels ); + vecvecfGains[i].Init ( iMaxNumChannels ); vecvecfPannings[i].Init ( iMaxNumChannels ); // we always use stereo audio buffers (which is the worst case) @@ -426,7 +404,8 @@ CServer::CServer ( const int iNewMaxNumChan, int iAvailableCores = QThread::idealThreadCount(); // setup QThreadPool if multithreading is active and possible - if ( bUseMultithreading ) { + if ( bUseMultithreading ) + { if ( iAvailableCores == 1 ) { qDebug() << "found only one core, disabling multithreading"; @@ -438,86 +417,61 @@ CServer::CServer ( const int iNewMaxNumChan, iMaxNumThreads = iAvailableCores; qDebug() << "multithreading enabled, setting thread count to" << iMaxNumThreads; - pThreadPool = std::unique_ptr( new CThreadPool{static_cast(iMaxNumThreads)} ); - Futures.reserve( iMaxNumThreads ); + pThreadPool = std::unique_ptr ( new CThreadPool{ static_cast ( iMaxNumThreads ) } ); + Futures.reserve ( iMaxNumThreads ); } } - // Connections ------------------------------------------------------------- // connect timer timeout signal - QObject::connect ( &HighPrecisionTimer, &CHighPrecisionTimer::timeout, - this, &CServer::OnTimer ); + QObject::connect ( &HighPrecisionTimer, &CHighPrecisionTimer::timeout, this, &CServer::OnTimer ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLMessReadyForSending, - this, &CServer::OnSendCLProtMessage ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLMessReadyForSending, this, &CServer::OnSendCLProtMessage ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLPingReceived, - this, &CServer::OnCLPingReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLPingReceived, this, &CServer::OnCLPingReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLPingWithNumClientsReceived, - this, &CServer::OnCLPingWithNumClientsReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLPingWithNumClientsReceived, this, &CServer::OnCLPingWithNumClientsReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLRegisterServerReceived, - this, &CServer::OnCLRegisterServerReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLRegisterServerReceived, this, &CServer::OnCLRegisterServerReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLRegisterServerExReceived, - this, &CServer::OnCLRegisterServerExReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLRegisterServerExReceived, this, &CServer::OnCLRegisterServerExReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLUnregisterServerReceived, - this, &CServer::OnCLUnregisterServerReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLUnregisterServerReceived, this, &CServer::OnCLUnregisterServerReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqServerList, - this, &CServer::OnCLReqServerList ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqServerList, this, &CServer::OnCLReqServerList ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLRegisterServerResp, - this, &CServer::OnCLRegisterServerResp ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLRegisterServerResp, this, &CServer::OnCLRegisterServerResp ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLSendEmptyMes, - this, &CServer::OnCLSendEmptyMes ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLSendEmptyMes, this, &CServer::OnCLSendEmptyMes ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLDisconnection, - this, &CServer::OnCLDisconnection ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLDisconnection, this, &CServer::OnCLDisconnection ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqVersionAndOS, - this, &CServer::OnCLReqVersionAndOS ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqVersionAndOS, this, &CServer::OnCLReqVersionAndOS ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLVersionAndOSReceived, - this, &CServer::CLVersionAndOSReceived ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLVersionAndOSReceived, this, &CServer::CLVersionAndOSReceived ); - QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqConnClientsList, - this, &CServer::OnCLReqConnClientsList ); + QObject::connect ( &ConnLessProtocol, &CProtocol::CLReqConnClientsList, this, &CServer::OnCLReqConnClientsList ); - QObject::connect ( &ServerListManager, &CServerListManager::SvrRegStatusChanged, - this, &CServer::SvrRegStatusChanged ); + QObject::connect ( &ServerListManager, &CServerListManager::SvrRegStatusChanged, this, &CServer::SvrRegStatusChanged ); - QObject::connect ( &JamController, &recorder::CJamController::RestartRecorder, - this, &CServer::RestartRecorder ); + QObject::connect ( &JamController, &recorder::CJamController::RestartRecorder, this, &CServer::RestartRecorder ); - QObject::connect ( &JamController, &recorder::CJamController::StopRecorder, - this, &CServer::StopRecorder ); + QObject::connect ( &JamController, &recorder::CJamController::StopRecorder, this, &CServer::StopRecorder ); - QObject::connect ( &JamController, &recorder::CJamController::RecordingSessionStarted, - this, &CServer::RecordingSessionStarted ); + QObject::connect ( &JamController, &recorder::CJamController::RecordingSessionStarted, this, &CServer::RecordingSessionStarted ); - QObject::connect ( &JamController, &recorder::CJamController::EndRecorderThread, - this, &CServer::EndRecorderThread ); + QObject::connect ( &JamController, &recorder::CJamController::EndRecorderThread, this, &CServer::EndRecorderThread ); - QObject::connect ( this, &CServer::Stopped, - &JamController, &recorder::CJamController::Stopped ); + QObject::connect ( this, &CServer::Stopped, &JamController, &recorder::CJamController::Stopped ); - QObject::connect ( this, &CServer::ClientDisconnected, - &JamController, &recorder::CJamController::ClientDisconnected ); + QObject::connect ( this, &CServer::ClientDisconnected, &JamController, &recorder::CJamController::ClientDisconnected ); qRegisterMetaType> ( "CVector" ); - QObject::connect ( this, &CServer::AudioFrame, - &JamController, &recorder::CJamController::AudioFrame ); + QObject::connect ( this, &CServer::AudioFrame, &JamController, &recorder::CJamController::AudioFrame ); - QObject::connect ( QCoreApplication::instance(), &QCoreApplication::aboutToQuit, - this, &CServer::OnAboutToQuit ); + QObject::connect ( QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CServer::OnAboutToQuit ); - QObject::connect ( pSignalHandler, &CSignalHandler::HandledSignal, - this, &CServer::OnHandledSignal ); + QObject::connect ( pSignalHandler, &CSignalHandler::HandledSignal, this, &CServer::OnHandledSignal ); connectChannelSignalsToServerSlots(); @@ -531,56 +485,42 @@ inline void CServer::connectChannelSignalsToServerSlots() { int iCurChanID = slotId - 1; - void ( CServer::* pOnSendProtMessCh )( CVector ) = - &CServerSlots::OnSendProtMessCh; + void ( CServer::*pOnSendProtMessCh ) ( CVector ) = &CServerSlots::OnSendProtMessCh; - void ( CServer::* pOnReqConnClientsListCh )() = - &CServerSlots::OnReqConnClientsListCh; + void ( CServer::*pOnReqConnClientsListCh )() = &CServerSlots::OnReqConnClientsListCh; - void ( CServer::* pOnChatTextReceivedCh )( QString ) = - &CServerSlots::OnChatTextReceivedCh; + void ( CServer::*pOnChatTextReceivedCh ) ( QString ) = &CServerSlots::OnChatTextReceivedCh; - void ( CServer::* pOnMuteStateHasChangedCh )( int, bool ) = - &CServerSlots::OnMuteStateHasChangedCh; + void ( CServer::*pOnMuteStateHasChangedCh ) ( int, bool ) = &CServerSlots::OnMuteStateHasChangedCh; - void ( CServer::* pOnServerAutoSockBufSizeChangeCh )( int ) = - &CServerSlots::OnServerAutoSockBufSizeChangeCh; + void ( CServer::*pOnServerAutoSockBufSizeChangeCh ) ( int ) = &CServerSlots::OnServerAutoSockBufSizeChangeCh; // send message - QObject::connect ( &vecChannels[iCurChanID], &CChannel::MessReadyForSending, - this, pOnSendProtMessCh ); + QObject::connect ( &vecChannels[iCurChanID], &CChannel::MessReadyForSending, this, pOnSendProtMessCh ); // request connected clients list - QObject::connect ( &vecChannels[iCurChanID], &CChannel::ReqConnClientsList, - this, pOnReqConnClientsListCh ); + QObject::connect ( &vecChannels[iCurChanID], &CChannel::ReqConnClientsList, this, pOnReqConnClientsListCh ); // channel info has changed - QObject::connect ( &vecChannels[iCurChanID], &CChannel::ChanInfoHasChanged, - this, &CServer::CreateAndSendChanListForAllConChannels ); + QObject::connect ( &vecChannels[iCurChanID], &CChannel::ChanInfoHasChanged, this, &CServer::CreateAndSendChanListForAllConChannels ); // chat text received - QObject::connect ( &vecChannels[iCurChanID], &CChannel::ChatTextReceived, - this, pOnChatTextReceivedCh ); + QObject::connect ( &vecChannels[iCurChanID], &CChannel::ChatTextReceived, this, pOnChatTextReceivedCh ); // other mute state has changed - QObject::connect ( &vecChannels[iCurChanID], &CChannel::MuteStateHasChanged, - this, pOnMuteStateHasChangedCh ); + QObject::connect ( &vecChannels[iCurChanID], &CChannel::MuteStateHasChanged, this, pOnMuteStateHasChangedCh ); // auto socket buffer size change - QObject::connect ( &vecChannels[iCurChanID], &CChannel::ServerAutoSockBufSizeChange, - this, pOnServerAutoSockBufSizeChangeCh ); + QObject::connect ( &vecChannels[iCurChanID], &CChannel::ServerAutoSockBufSizeChange, this, pOnServerAutoSockBufSizeChangeCh ); connectChannelSignalsToServerSlots(); } template<> -inline void CServer::connectChannelSignalsToServerSlots<0>() {} +inline void CServer::connectChannelSignalsToServerSlots<0>() +{} -void CServer::CreateAndSendJitBufMessage ( const int iCurChanID, - const int iNNumFra ) -{ - vecChannels[iCurChanID].CreateJitBufMes ( iNNumFra ); -} +void CServer::CreateAndSendJitBufMessage ( const int iCurChanID, const int iNNumFra ) { vecChannels[iCurChanID].CreateJitBufMes ( iNNumFra ); } CServer::~CServer() { @@ -609,8 +549,7 @@ void CServer::SendProtMessage ( int iChID, CVector vecMessage ) Socket.SendPacket ( vecMessage, vecChannels[iChID].GetAddress() ); } -void CServer::OnNewConnection ( int iChID, - CHostAddress RecHostAddr ) +void CServer::OnNewConnection ( int iChID, CHostAddress RecHostAddr ) { QMutexLocker locker ( &Mutex ); @@ -621,7 +560,7 @@ void CServer::OnNewConnection ( int iChID, // Send an empty channel list in order to force clients to reset their // audio mixer state. This is required to trigger clients to re-send their // gain levels upon reconnecting after server restarts. - vecChannels[iChID].CreateConClientListMes ( CVector (0) ); + vecChannels[iChID].CreateConClientListMes ( CVector ( 0 ) ); // query support for split messages in the client vecChannels[iChID].CreateReqSplitMessSupportMes(); @@ -662,8 +601,7 @@ void CServer::OnNewConnection ( int iChID, { // create formatted server welcome message and send it just to // the client which just connected to the server - const QString strWelcomeMessageFormated = - WELCOME_MESSAGE_PREFIX + strWelcomeMessage; + const QString strWelcomeMessageFormated = WELCOME_MESSAGE_PREFIX + strWelcomeMessage; vecChannels[iChID].CreateChatTextMes ( strWelcomeMessageFormated ); } @@ -697,8 +635,7 @@ void CServer::OnServerFull ( CHostAddress RecHostAddr ) ConnLessProtocol.CreateCLServerFullMes ( RecHostAddr ); } -void CServer::OnSendCLProtMessage ( CHostAddress InetAddr, - CVector vecMessage ) +void CServer::OnSendCLProtMessage ( CHostAddress InetAddr, CVector vecMessage ) { // the protocol queries me to call the function to send the message // send it through the network @@ -749,7 +686,7 @@ void CServer::OnAboutToQuit() void CServer::OnHandledSignal ( int sigNum ) { // show the signal number on the console (note that this may not work for Windows) - qDebug() << qUtf8Printable( QString( "OnHandledSignal: %1" ).arg( sigNum ) ); + qDebug() << qUtf8Printable ( QString ( "OnHandledSignal: %1" ).arg ( sigNum ) ); #ifdef _WIN32 // Windows does not actually get OnHandledSignal triggered @@ -812,17 +749,17 @@ void CServer::Stop() void CServer::OnTimer() { -// clang-format off + // clang-format off /* static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TEST do a timer jitter measurement */ -// clang-format on + // clang-format on // Get data from all connected clients ------------------------------------- // some inits int iNumClients = 0; // init connected client counter bool bUseMT = false; - int iNumBlocks = 0; // init number of blocks for multithreading - int iMTBlockSize = 0; // init block size for multithreading + int iNumBlocks = 0; // init number of blocks for multithreading + int iMTBlockSize = 0; // init block size for multithreading bChannelIsNowDisconnected = false; // note that the flag must be a member function since QtConcurrent::run can only take 5 params { @@ -868,15 +805,12 @@ static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TE const int iStartChanCnt = iBlockCnt * iMTBlockSize; const int iStopChanCnt = std::min ( ( iBlockCnt + 1 ) * iMTBlockSize - 1, iNumClients - 1 ); - Futures.push_back ( pThreadPool->enqueue ( CServer::DecodeReceiveDataBlocks, - this, - iStartChanCnt, - iStopChanCnt, - iNumClients ) ); + Futures.push_back ( pThreadPool->enqueue ( CServer::DecodeReceiveDataBlocks, this, iStartChanCnt, iStopChanCnt, iNumClients ) ); } // make sure all concurrent run threads have finished when we leave this function - for ( auto& future : Futures ) { + for ( auto& future : Futures ) + { future.wait(); } Futures.clear(); @@ -890,17 +824,13 @@ static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TE } } - // Process data ------------------------------------------------------------ // Check if at least one client is connected. If not, stop server until // one client is connected. if ( iNumClients > 0 ) { // calculate levels for all connected clients - const bool bSendChannelLevels = CreateLevelsForAllConChannels ( iNumClients, - vecNumAudioChannels, - vecvecsData, - vecChannelLevels ); + const bool bSendChannelLevels = CreateLevelsForAllConChannels ( iNumClients, vecNumAudioChannels, vecvecsData, vecChannelLevels ); for ( int iChanCnt = 0; iChanCnt < iNumClients; iChanCnt++ ) { @@ -913,9 +843,7 @@ static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TE // send channel levels if they are ready if ( bSendChannelLevels ) { - ConnLessProtocol.CreateCLChannelLevelListMes ( vecChannels[iCurChanID].GetAddress(), - vecChannelLevels, - iNumClients ); + ConnLessProtocol.CreateCLChannelLevelListMes ( vecChannels[iCurChanID].GetAddress(), vecChannelLevels, iNumClients ); } // export the audio data for recording purpose @@ -950,15 +878,12 @@ static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TE const int iStartChanCnt = iBlockCnt * iMTBlockSize; const int iStopChanCnt = std::min ( ( iBlockCnt + 1 ) * iMTBlockSize - 1, iNumClients - 1 ); - Futures.push_back ( pThreadPool->enqueue ( CServer::MixEncodeTransmitDataBlocks, - this, - iStartChanCnt, - iStopChanCnt, - iNumClients ) ); + Futures.push_back ( pThreadPool->enqueue ( CServer::MixEncodeTransmitDataBlocks, this, iStartChanCnt, iStopChanCnt, iNumClients ) ); } // make sure all concurrent run threads have finished when we leave this function - for ( auto& fFuture : Futures ) { + for ( auto& fFuture : Futures ) + { fFuture.wait(); } Futures.clear(); @@ -967,7 +892,7 @@ static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TE { for ( int i = 0; i < iNumClients; i++ ) { - for ( int j = 0; j < 2 * (iServerFrameSizeSamples); j++ ) + for ( int j = 0; j < 2 * ( iServerFrameSizeSamples ); j++ ) { vecvecsData2[i][j] = vecvecsData[i][j]; } @@ -984,10 +909,7 @@ static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TE // This is a static method used as a callback, and does not inherit a "this" pointer, // so it is necessary for the server instance to be passed as a parameter. -void CServer::DecodeReceiveDataBlocks ( CServer* pServer, - const int iStartChanCnt, - const int iStopChanCnt, - const int iNumClients ) +void CServer::DecodeReceiveDataBlocks ( CServer* pServer, const int iStartChanCnt, const int iStopChanCnt, const int iNumClients ) { // loop over all channels in the current block, needed for multithreading support for ( int iChanCnt = iStartChanCnt; iChanCnt <= iStopChanCnt; iChanCnt++ ) @@ -998,10 +920,7 @@ void CServer::DecodeReceiveDataBlocks ( CServer* pServer, // This is a static method used as a callback, and does not inherit a "this" pointer, // so it is necessary for the server instance to be passed as a parameter. -void CServer::MixEncodeTransmitDataBlocks ( CServer* pServer, - const int iStartChanCnt, - const int iStopChanCnt, - const int iNumClients ) +void CServer::MixEncodeTransmitDataBlocks ( CServer* pServer, const int iStartChanCnt, const int iStopChanCnt, const int iNumClients ) { // loop over all channels in the current block, needed for multithreading support for ( int iChanCnt = iStartChanCnt; iChanCnt <= iStopChanCnt; iChanCnt++ ) @@ -1010,8 +929,7 @@ void CServer::MixEncodeTransmitDataBlocks ( CServer* pServer, } } -void CServer::DecodeReceiveData ( const int iChanCnt, - const int iNumClients ) +void CServer::DecodeReceiveData ( const int iChanCnt, const int iNumClients ) { int iUnused; int iClientFrameSizeSamples = 0; // initialize to avoid a compiler warning @@ -1040,7 +958,7 @@ void CServer::DecodeReceiveData ( const int iChanCnt, // update conversion buffer size (nothing will happen if the size stays the same) if ( vecUseDoubleSysFraSizeConvBuf[iChanCnt] ) { - DoubleFrameSizeConvBufIn[iCurChanID].SetBufferSize ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES * vecNumAudioChannels[iChanCnt] ); + DoubleFrameSizeConvBufIn[iCurChanID].SetBufferSize ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES * vecNumAudioChannels[iChanCnt] ); DoubleFrameSizeConvBufOut[iCurChanID].SetBufferSize ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES * vecNumAudioChannels[iChanCnt] ); } @@ -1110,7 +1028,7 @@ void CServer::DecodeReceiveData ( const int iChanCnt, // get current number of OPUS coded bytes const int iCeltNumCodedBytes = vecChannels[iCurChanID].GetCeltNumCodedBytes(); - for ( size_t iB = 0; iB < (size_t)vecNumFrameSizeConvBlocks[iChanCnt]; iB++ ) + for ( size_t iB = 0; iB < (size_t) vecNumFrameSizeConvBlocks[iChanCnt]; iB++ ) { // get data const EGetDataStat eGetStat = vecChannels[iCurChanID].GetData ( vecvecbyCodedData[iChanCnt], iCeltNumCodedBytes ); @@ -1166,8 +1084,7 @@ void CServer::DecodeReceiveData ( const int iChanCnt, } /// @brief Mix all audio data from all clients together, encode and transmit -void CServer::MixEncodeTransmitData ( const int iChanCnt, - const int iNumClients ) +void CServer::MixEncodeTransmitData ( const int iChanCnt, const int iNumClients ) { int i, j, k, iUnused; CVector& vecfIntermProcBuf = vecvecfIntermediateProcBuf[iChanCnt]; // use reference for faster access @@ -1205,8 +1122,7 @@ void CServer::MixEncodeTransmitData ( const int iChanCnt, // stereo: apply stereo-to-mono attenuation for ( i = 0, k = 0; i < iServerFrameSizeSamples; i++, k += 2 ) { - vecfIntermProcBuf[i] += - ( static_cast ( vecsData[k] ) + vecsData[k + 1] ) / 2; + vecfIntermProcBuf[i] += ( static_cast ( vecsData[k] ) + vecsData[k + 1] ) / 2; } } } @@ -1225,8 +1141,7 @@ void CServer::MixEncodeTransmitData ( const int iChanCnt, // stereo: apply stereo-to-mono attenuation for ( i = 0, k = 0; i < iServerFrameSizeSamples; i++, k += 2 ) { - vecfIntermProcBuf[i] += fGain * - ( static_cast ( vecsData[k] ) + vecsData[k + 1] ) / 2; + vecfIntermProcBuf[i] += fGain * ( static_cast ( vecsData[k] ) + vecsData[k + 1] ) / 2; } } } @@ -1250,11 +1165,11 @@ void CServer::MixEncodeTransmitData ( const int iChanCnt, for ( j = 0; j < iNumClients; j++ ) { // get a reference to the audio data and gain/pan of the current client - const CVector& vecsData = vecvecsData[j]; + const CVector& vecsData = vecvecsData[j]; const CVector& vecsData2 = vecvecsData2[j]; - const float fGain = vecvecfGains[iChanCnt][j]; - const float fPan = bDelayPan ? 0.5f : vecvecfPannings[iChanCnt][j]; + const float fGain = vecvecfGains[iChanCnt][j]; + const float fPan = bDelayPan ? 0.5f : vecvecfPannings[iChanCnt][j]; // calculate combined gain/pan for each stereo channel where we define // the panning that center equals full gain for both channels @@ -1263,7 +1178,7 @@ void CServer::MixEncodeTransmitData ( const int iChanCnt, if ( bDelayPan ) { - iPanDel = lround( (float)( 2 * maxPanDelay - 2 ) * ( vecvecfPannings[iChanCnt][j] - 0.5f ) ); + iPanDel = lround ( (float) ( 2 * maxPanDelay - 2 ) * ( vecvecfPannings[iChanCnt][j] - 0.5f ) ); iPanDelL = ( iPanDel > 0 ) ? iPanDel : 0; iPanDelR = ( iPanDel < 0 ) ? -iPanDel : 0; } @@ -1320,7 +1235,7 @@ void CServer::MixEncodeTransmitData ( const int iChanCnt, if ( bDelayPan ) { // pan address shift - if ( (i & 1) == 0 ) + if ( ( i & 1 ) == 0 ) { iPan = i - 2 * iPanDelL; // if even : left channel } @@ -1342,7 +1257,7 @@ void CServer::MixEncodeTransmitData ( const int iChanCnt, } else { - if ( (i & 1) == 0 ) + if ( ( i & 1 ) == 0 ) { // if even : left channel vecfIntermProcBuf[i] += vecsData[i] * fGainL; @@ -1415,13 +1330,13 @@ void CServer::MixEncodeTransmitData ( const int iChanCnt, // OPUS encoding if ( pCurOpusEncoder != nullptr ) { -// clang-format off + // clang-format off // TODO find a better place than this: the setting does not change all the time so for speed // optimization it would be better to set it only if the network frame size is changed opus_custom_encoder_ctl ( pCurOpusEncoder, OPUS_SET_BITRATE ( CalcBitRateBitsPerSecFromCodedBytes ( iCeltNumCodedBytes, iClientFrameSizeSamples ) ) ); -// clang-format on + // clang-format on - for ( size_t iB = 0; iB < (size_t)vecNumFrameSizeConvBlocks[iChanCnt]; iB++ ) + for ( size_t iB = 0; iB < (size_t) vecNumFrameSizeConvBlocks[iChanCnt]; iB++ ) { iUnused = opus_custom_encode ( pCurOpusEncoder, &vecsSendData[iB * SYSTEM_FRAME_SIZE_SAMPLES * vecNumAudioChannels[iChanCnt]], @@ -1430,9 +1345,7 @@ opus_custom_encoder_ctl ( pCurOpusEncoder, OPUS_SET_BITRATE ( CalcBitRateBitsPer iCeltNumCodedBytes ); // send separate mix to current clients - vecChannels[iCurChanID].PrepAndSendPacket ( &Socket, - vecvecbyCodedData[iChanCnt], - iCeltNumCodedBytes ); + vecChannels[iCurChanID].PrepAndSendPacket ( &Socket, vecvecbyCodedData[iChanCnt], iCeltNumCodedBytes ); } } } @@ -1449,9 +1362,8 @@ CVector CServer::CreateChannelList() { if ( vecChannels[i].IsConnected() ) { - vecChanInfo.Add ( CChannelInfo ( - i, // ID - vecChannels[i].GetChanInfo() ) ); + vecChanInfo.Add ( CChannelInfo ( i, // ID + vecChannels[i].GetChanInfo() ) ); } } @@ -1489,8 +1401,7 @@ void CServer::CreateAndSendChanListForThisChan ( const int iCurChanID ) vecChannels[iCurChanID].CreateConClientListMes ( vecChanInfo ); } -void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID, - const QString& strChatText ) +void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText ) { // Create message which is sent to all connected clients ------------------- // get client name @@ -1500,12 +1411,8 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID // use different colors QString sCurColor = vstrChatColors[iCurChanID % vstrChatColors.Size()]; - const QString strActualMessageText = - "(" + - QTime::currentTime().toString ( "hh:mm:ss AP" ) + ") " + - ChanName.toHtmlEscaped() + - " " + strChatText.toHtmlEscaped(); - + const QString strActualMessageText = "(" + QTime::currentTime().toString ( "hh:mm:ss AP" ) + ") " + + ChanName.toHtmlEscaped() + " " + strChatText.toHtmlEscaped(); // Send chat text to all connected clients --------------------------------- for ( int i = 0; i < iMaxNumChannels; i++ ) @@ -1534,9 +1441,7 @@ void CServer::CreateAndSendRecorderStateForAllConChannels() } } -void CServer::CreateOtherMuteStateChanged ( const int iCurChanID, - const int iOtherChanID, - const bool bIsMuted ) +void CServer::CreateOtherMuteStateChanged ( const int iCurChanID, const int iOtherChanID, const bool bIsMuted ) { if ( vecChannels[iOtherChanID].IsConnected() ) { @@ -1600,22 +1505,15 @@ int CServer::FindChannel ( const CHostAddress& CheckAddr ) return INVALID_CHANNEL_ID; } -void CServer::OnProtcolCLMessageReceived ( int iRecID, - CVector vecbyMesBodyData, - CHostAddress RecHostAddr ) +void CServer::OnProtcolCLMessageReceived ( int iRecID, CVector vecbyMesBodyData, CHostAddress RecHostAddr ) { QMutexLocker locker ( &Mutex ); // connection less messages are always processed - ConnLessProtocol.ParseConnectionLessMessageBody ( vecbyMesBodyData, - iRecID, - RecHostAddr ); + ConnLessProtocol.ParseConnectionLessMessageBody ( vecbyMesBodyData, iRecID, RecHostAddr ); } -void CServer::OnProtcolMessageReceived ( int iRecCounter, - int iRecID, - CVector vecbyMesBodyData, - CHostAddress RecHostAddr ) +void CServer::OnProtcolMessageReceived ( int iRecCounter, int iRecID, CVector vecbyMesBodyData, CHostAddress RecHostAddr ) { QMutexLocker locker ( &Mutex ); @@ -1625,17 +1523,11 @@ void CServer::OnProtcolMessageReceived ( int iRecCounter, // if the channel exists, apply the protocol message to the channel if ( iCurChanID != INVALID_CHANNEL_ID ) { - vecChannels[iCurChanID].PutProtcolData ( iRecCounter, - iRecID, - vecbyMesBodyData, - RecHostAddr ); + vecChannels[iCurChanID].PutProtcolData ( iRecCounter, iRecID, vecbyMesBodyData, RecHostAddr ); } } -bool CServer::PutAudioData ( const CVector& vecbyRecBuf, - const int iNumBytesRead, - const CHostAddress& HostAdr, - int& iCurChanID ) +bool CServer::PutAudioData ( const CVector& vecbyRecBuf, const int iNumBytesRead, const CHostAddress& HostAdr, int& iCurChanID ) { QMutexLocker locker ( &Mutex ); @@ -1665,12 +1557,12 @@ bool CServer::PutAudioData ( const CVector& vecbyRecBuf, for ( int i = 0; i < iMaxNumChannels; i++ ) { vecChannels[iCurChanID].SetGain ( i, 1.0 ); - vecChannels[iCurChanID].SetPan ( i, 0.5 ); + vecChannels[iCurChanID].SetPan ( i, 0.5 ); // other channels (we do not distinguish the case if // i == iCurChanID for simplicity) vecChannels[i].SetGain ( iCurChanID, 1.0 ); - vecChannels[i].SetPan ( iCurChanID, 0.5 ); + vecChannels[i].SetPan ( iCurChanID, 0.5 ); } } else @@ -1680,14 +1572,11 @@ bool CServer::PutAudioData ( const CVector& vecbyRecBuf, } } - // Put received audio data in jitter buffer ---------------------------- if ( bChanOK ) { // put packet in socket buffer - if ( vecChannels[iCurChanID].PutAudioData ( vecbyRecBuf, - iNumBytesRead, - HostAdr ) == PS_NEW_CONNECTION ) + if ( vecChannels[iCurChanID].PutAudioData ( vecbyRecBuf, iNumBytesRead, HostAdr ) == PS_NEW_CONNECTION ) { // in case we have a new connection return this information bNewConnection = true; @@ -1706,9 +1595,9 @@ void CServer::GetConCliParam ( CVector& vecHostAddresses, CHostAddress InetAddr; // init return values - vecHostAddresses.Init ( iMaxNumChannels ); - vecsName.Init ( iMaxNumChannels ); - veciJitBufNumFrames.Init ( iMaxNumChannels ); + vecHostAddresses.Init ( iMaxNumChannels ); + vecsName.Init ( iMaxNumChannels ); + veciJitBufNumFrames.Init ( iMaxNumChannels ); veciNetwFrameSizeFact.Init ( iMaxNumChannels ); // check all possible channels @@ -1813,10 +1702,10 @@ void CServer::customEvent ( QEvent* pEvent ) } /// @brief Compute frame peak level for each client -bool CServer::CreateLevelsForAllConChannels ( const int iNumClients, - const CVector& vecNumAudioChannels, - const CVector > vecvecsData, - CVector& vecLevelsOut ) +bool CServer::CreateLevelsForAllConChannels ( const int iNumClients, + const CVector& vecNumAudioChannels, + const CVector> vecvecsData, + CVector& vecLevelsOut ) { bool bLevelsWereUpdated = false; @@ -1829,10 +1718,9 @@ bool CServer::CreateLevelsForAllConChannels ( const int i for ( int j = 0; j < iNumClients; j++ ) { // update and get signal level for meter in dB for each channel - const double dCurSigLevelForMeterdB = vecChannels[vecChanIDsCurConChan[j]]. - UpdateAndGetLevelForMeterdB ( vecvecsData[j], - iServerFrameSizeSamples, - vecNumAudioChannels[j] > 1 ); + const double dCurSigLevelForMeterdB = vecChannels[vecChanIDsCurConChan[j]].UpdateAndGetLevelForMeterdB ( vecvecsData[j], + iServerFrameSizeSamples, + vecNumAudioChannels[j] > 1 ); // map value to integer for transmission via the protocol (4 bit available) vecLevelsOut[j] = static_cast ( std::ceil ( dCurSigLevelForMeterdB ) ); diff --git a/src/server.h b/src/server.h index ac9f3eeac9..749694bb4f 100644 --- a/src/server.h +++ b/src/server.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -32,9 +32,9 @@ #include #include #ifdef USE_OPUS_SHARED_LIB -# include "opus/opus_custom.h" +# include "opus/opus_custom.h" #else -# include "opus_custom.h" +# include "opus_custom.h" #endif #include "global.h" #include "buffer.h" @@ -50,11 +50,10 @@ /* Definitions ****************************************************************/ // no valid channel number -#define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 ) - +#define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 ) /* Classes ********************************************************************/ -#if ( defined ( WIN32 ) || defined ( _WIN32 ) ) +#if ( defined( WIN32 ) || defined( _WIN32 ) ) // using QTimer for Windows class CHighPrecisionTimer : public QObject { @@ -82,13 +81,13 @@ public slots: }; #else // using mach timers for Mac and nanosleep for Linux -# if defined ( __APPLE__ ) || defined ( __MACOSX ) -# include -# include -# include -# else -# include -# endif +# if defined( __APPLE__ ) || defined( __MACOSX ) +# include +# include +# include +# else +# include +# endif class CHighPrecisionTimer : public QThread { @@ -104,68 +103,51 @@ class CHighPrecisionTimer : public QThread protected: virtual void run(); - bool bRun; + bool bRun; -# if defined ( __APPLE__ ) || defined ( __MACOSX ) +# if defined( __APPLE__ ) || defined( __MACOSX ) uint64_t Delay; uint64_t NextEnd; -# else +# else long Delay; timespec NextEnd; -# endif +# endif signals: void timeout(); }; #endif - template class CServerSlots : public CServerSlots { public: - void OnSendProtMessCh ( CVector mess ) { SendProtMessage ( slotId - 1, mess ); } - void OnReqConnClientsListCh() { CreateAndSendChanListForThisChan ( slotId - 1 ); } + void OnSendProtMessCh ( CVector mess ) { SendProtMessage ( slotId - 1, mess ); } + void OnReqConnClientsListCh() { CreateAndSendChanListForThisChan ( slotId - 1 ); } - void OnChatTextReceivedCh ( QString strChatText ) - { - CreateAndSendChatTextForAllConChannels ( slotId - 1, strChatText ); - } + void OnChatTextReceivedCh ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( slotId - 1, strChatText ); } - void OnMuteStateHasChangedCh ( int iChanID, bool bIsMuted ) - { - CreateOtherMuteStateChanged ( slotId - 1, iChanID, bIsMuted ); - } + void OnMuteStateHasChangedCh ( int iChanID, bool bIsMuted ) { CreateOtherMuteStateChanged ( slotId - 1, iChanID, bIsMuted ); } - void OnServerAutoSockBufSizeChangeCh ( int iNNumFra ) - { - CreateAndSendJitBufMessage ( slotId - 1, iNNumFra ); - } + void OnServerAutoSockBufSizeChangeCh ( int iNNumFra ) { CreateAndSendJitBufMessage ( slotId - 1, iNNumFra ); } protected: - virtual void SendProtMessage ( int iChID, - CVector vecMessage ) = 0; + virtual void SendProtMessage ( int iChID, CVector vecMessage ) = 0; virtual void CreateAndSendChanListForThisChan ( const int iCurChanID ) = 0; - virtual void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, - const QString& strChatText ) = 0; + virtual void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText ) = 0; - virtual void CreateOtherMuteStateChanged ( const int iCurChanID, - const int iOtherChanID, - const bool bIsMuted ) = 0; + virtual void CreateOtherMuteStateChanged ( const int iCurChanID, const int iOtherChanID, const bool bIsMuted ) = 0; - virtual void CreateAndSendJitBufMessage ( const int iCurChanID, - const int iNNumFra ) = 0; + virtual void CreateAndSendJitBufMessage ( const int iCurChanID, const int iNNumFra ) = 0; }; template<> -class CServerSlots<0> {}; - +class CServerSlots<0> +{}; -class CServer : - public QObject, - public CServerSlots +class CServer : public QObject, public CServerSlots { Q_OBJECT @@ -195,33 +177,30 @@ class CServer : void Stop(); bool IsRunning() { return HighPrecisionTimer.isActive(); } - bool PutAudioData ( const CVector& vecbyRecBuf, - const int iNumBytesRead, - const CHostAddress& HostAdr, - int& iCurChanID ); + bool PutAudioData ( const CVector& vecbyRecBuf, const int iNumBytesRead, const CHostAddress& HostAdr, int& iCurChanID ); void GetConCliParam ( CVector& vecHostAddresses, CVector& vecsName, CVector& veciJitBufNumFrames, CVector& veciNetwFrameSizeFact ); - void CreateCLServerListReqVerAndOSMes ( const CHostAddress& InetAddr ) - { ConnLessProtocol.CreateCLReqVersionAndOSMes ( InetAddr ); } - + void CreateCLServerListReqVerAndOSMes ( const CHostAddress& InetAddr ) { ConnLessProtocol.CreateCLReqVersionAndOSMes ( InetAddr ); } // Jam recorder ------------------------------------------------------------ - bool GetRecorderInitialised() { return JamController.GetRecorderInitialised(); } + bool GetRecorderInitialised() { return JamController.GetRecorderInitialised(); } QString GetRecorderErrMsg() { return JamController.GetRecorderErrMsg(); } - bool GetRecordingEnabled() { return JamController.GetRecordingEnabled(); } - bool GetDisableRecording() { return bDisableRecording; } - void RequestNewRecording() { JamController.RequestNewRecording(); } + bool GetRecordingEnabled() { return JamController.GetRecordingEnabled(); } + bool GetDisableRecording() { return bDisableRecording; } + void RequestNewRecording() { JamController.RequestNewRecording(); } void SetEnableRecording ( bool bNewEnableRecording ); QString GetRecordingDir() { return JamController.GetRecordingDir(); } - void SetRecordingDir( QString newRecordingDir ) - { JamController.SetRecordingDir ( newRecordingDir, iServerFrameSizeSamples, bDisableRecording ); } + void SetRecordingDir ( QString newRecordingDir ) + { + JamController.SetRecordingDir ( newRecordingDir, iServerFrameSizeSamples, bDisableRecording ); + } void CreateAndSendRecorderStateForAllConChannels(); @@ -234,76 +213,60 @@ class CServer : void UnregisterSlaveServer() { ServerListManager.SlaveServerUnregister(); } - void SetServerListEnabled ( const bool bState ) - { ServerListManager.SetEnabled ( bState ); } + void SetServerListEnabled ( const bool bState ) { ServerListManager.SetEnabled ( bState ); } bool GetServerListEnabled() { return ServerListManager.GetEnabled(); } - void SetServerListCentralServerAddress ( const QString& sNCentServAddr ) - { ServerListManager.SetCentralServerAddress ( sNCentServAddr ); } + void SetServerListCentralServerAddress ( const QString& sNCentServAddr ) { ServerListManager.SetCentralServerAddress ( sNCentServAddr ); } - QString GetServerListCentralServerAddress() - { return ServerListManager.GetCentralServerAddress(); } + QString GetServerListCentralServerAddress() { return ServerListManager.GetCentralServerAddress(); } - void SetCentralServerAddressType ( const ECSAddType eNCSAT ) - { ServerListManager.SetCentralServerAddressType ( eNCSAT ); } + void SetCentralServerAddressType ( const ECSAddType eNCSAT ) { ServerListManager.SetCentralServerAddressType ( eNCSAT ); } - ECSAddType GetCentralServerAddressType() - { return ServerListManager.GetCentralServerAddressType(); } + ECSAddType GetCentralServerAddressType() { return ServerListManager.GetCentralServerAddressType(); } - void SetServerName ( const QString& strNewName ) - { ServerListManager.SetServerName ( strNewName ); } + void SetServerName ( const QString& strNewName ) { ServerListManager.SetServerName ( strNewName ); } QString GetServerName() { return ServerListManager.GetServerName(); } - void SetServerCity ( const QString& strNewCity ) - { ServerListManager.SetServerCity ( strNewCity ); } + void SetServerCity ( const QString& strNewCity ) { ServerListManager.SetServerCity ( strNewCity ); } QString GetServerCity() { return ServerListManager.GetServerCity(); } - void SetServerCountry ( const QLocale::Country eNewCountry ) - { ServerListManager.SetServerCountry ( eNewCountry ); } + void SetServerCountry ( const QLocale::Country eNewCountry ) { ServerListManager.SetServerCountry ( eNewCountry ); } - QLocale::Country GetServerCountry() - { return ServerListManager.GetServerCountry(); } + QLocale::Country GetServerCountry() { return ServerListManager.GetServerCountry(); } - void SetWelcomeMessage ( const QString& strNWelcMess ); + void SetWelcomeMessage ( const QString& strNWelcMess ); QString GetWelcomeMessage() { return strWelcomeMessage; } ESvrRegStatus GetSvrRegStatus() { return ServerListManager.GetSvrRegStatus(); } - // GUI settings ------------------------------------------------------------ void SetAutoRunMinimized ( const bool NAuRuMin ) { bAutoRunMinimized = NAuRuMin; } bool GetAutoRunMinimized() { return bAutoRunMinimized; } - int GetClientNumAudioChannels ( const int iChanNum ) - { return vecChannels[iChanNum].GetNumAudioChannels(); } + int GetClientNumAudioChannels ( const int iChanNum ) { return vecChannels[iChanNum].GetNumAudioChannels(); } protected: // access functions for actual channels bool IsConnected ( const int iChanNum ) { return vecChannels[iChanNum].IsConnected(); } - int GetFreeChan(); - int FindChannel ( const CHostAddress& CheckAddr ); - int GetNumberOfConnectedClients(); + int GetFreeChan(); + int FindChannel ( const CHostAddress& CheckAddr ); + int GetNumberOfConnectedClients(); CVector CreateChannelList(); virtual void CreateAndSendChanListForAllConChannels(); virtual void CreateAndSendChanListForThisChan ( const int iCurChanID ); - virtual void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, - const QString& strChatText ); + virtual void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText ); - virtual void CreateOtherMuteStateChanged ( const int iCurChanID, - const int iOtherChanID, - const bool bIsMuted ); + virtual void CreateOtherMuteStateChanged ( const int iCurChanID, const int iOtherChanID, const bool bIsMuted ); - virtual void CreateAndSendJitBufMessage ( const int iCurChanID, - const int iNNumFra ); + virtual void CreateAndSendJitBufMessage ( const int iCurChanID, const int iNNumFra ); - virtual void SendProtMessage ( int iChID, - CVector vecMessage ); + virtual void SendProtMessage ( int iChID, CVector vecMessage ); template inline void connectChannelSignalsToServerSlots(); @@ -311,113 +274,105 @@ class CServer : void WriteHTMLChannelList(); void WriteHTMLServerQuit(); - static void DecodeReceiveDataBlocks ( CServer* pServer, - const int iStartChanCnt, - const int iStopChanCnt, - const int iNumClients ); + static void DecodeReceiveDataBlocks ( CServer* pServer, const int iStartChanCnt, const int iStopChanCnt, const int iNumClients ); - static void MixEncodeTransmitDataBlocks ( CServer* pServer, - const int iStartChanCnt, - const int iStopChanCnt, - const int iNumClients ); + static void MixEncodeTransmitDataBlocks ( CServer* pServer, const int iStartChanCnt, const int iStopChanCnt, const int iNumClients ); - void DecodeReceiveData ( const int iChanCnt, - const int iNumClients ); + void DecodeReceiveData ( const int iChanCnt, const int iNumClients ); - void MixEncodeTransmitData ( const int iChanCnt, - const int iNumClients ); + void MixEncodeTransmitData ( const int iChanCnt, const int iNumClients ); virtual void customEvent ( QEvent* pEvent ); // if server mode is normal or double system frame size - bool bUseDoubleSystemFrameSize; - int iServerFrameSizeSamples; + bool bUseDoubleSystemFrameSize; + int iServerFrameSizeSamples; // variables needed for multithreading support - bool bUseMultithreading; - int iMaxNumThreads; - CVector< std::future > Futures; + bool bUseMultithreading; + int iMaxNumThreads; + CVector> Futures; - bool CreateLevelsForAllConChannels ( const int iNumClients, - const CVector& vecNumAudioChannels, - const CVector< CVector > vecvecsData, - CVector& vecLevelsOut ); + bool CreateLevelsForAllConChannels ( const int iNumClients, + const CVector& vecNumAudioChannels, + const CVector> vecvecsData, + CVector& vecLevelsOut ); // do not use the vector class since CChannel does not have appropriate // copy constructor/operator - CChannel vecChannels[MAX_NUM_CHANNELS]; - int iMaxNumChannels; - CProtocol ConnLessProtocol; - QMutex Mutex; - QMutex MutexWelcomeMessage; - bool bChannelIsNowDisconnected; + CChannel vecChannels[MAX_NUM_CHANNELS]; + int iMaxNumChannels; + CProtocol ConnLessProtocol; + QMutex Mutex; + QMutex MutexWelcomeMessage; + bool bChannelIsNowDisconnected; // audio encoder/decoder - OpusCustomMode* Opus64Mode[MAX_NUM_CHANNELS]; - OpusCustomEncoder* Opus64EncoderMono[MAX_NUM_CHANNELS]; - OpusCustomDecoder* Opus64DecoderMono[MAX_NUM_CHANNELS]; - OpusCustomEncoder* Opus64EncoderStereo[MAX_NUM_CHANNELS]; - OpusCustomDecoder* Opus64DecoderStereo[MAX_NUM_CHANNELS]; - OpusCustomMode* OpusMode[MAX_NUM_CHANNELS]; - OpusCustomEncoder* OpusEncoderMono[MAX_NUM_CHANNELS]; - OpusCustomDecoder* OpusDecoderMono[MAX_NUM_CHANNELS]; - OpusCustomEncoder* OpusEncoderStereo[MAX_NUM_CHANNELS]; - OpusCustomDecoder* OpusDecoderStereo[MAX_NUM_CHANNELS]; - CConvBuf DoubleFrameSizeConvBufIn[MAX_NUM_CHANNELS]; - CConvBuf DoubleFrameSizeConvBufOut[MAX_NUM_CHANNELS]; - - CVector vstrChatColors; - CVector vecChanIDsCurConChan; - - CVector< CVector > vecvecfGains; - CVector< CVector > vecvecfPannings; - CVector< CVector > vecvecsData; - CVector< CVector > vecvecsData2; - CVector vecNumAudioChannels; - CVector vecNumFrameSizeConvBlocks; - CVector vecUseDoubleSysFraSizeConvBuf; - CVector vecAudioComprType; - CVector< CVector > vecvecsSendData; - CVector< CVector > vecvecfIntermediateProcBuf; - CVector< CVector > vecvecbyCodedData; + OpusCustomMode* Opus64Mode[MAX_NUM_CHANNELS]; + OpusCustomEncoder* Opus64EncoderMono[MAX_NUM_CHANNELS]; + OpusCustomDecoder* Opus64DecoderMono[MAX_NUM_CHANNELS]; + OpusCustomEncoder* Opus64EncoderStereo[MAX_NUM_CHANNELS]; + OpusCustomDecoder* Opus64DecoderStereo[MAX_NUM_CHANNELS]; + OpusCustomMode* OpusMode[MAX_NUM_CHANNELS]; + OpusCustomEncoder* OpusEncoderMono[MAX_NUM_CHANNELS]; + OpusCustomDecoder* OpusDecoderMono[MAX_NUM_CHANNELS]; + OpusCustomEncoder* OpusEncoderStereo[MAX_NUM_CHANNELS]; + OpusCustomDecoder* OpusDecoderStereo[MAX_NUM_CHANNELS]; + CConvBuf DoubleFrameSizeConvBufIn[MAX_NUM_CHANNELS]; + CConvBuf DoubleFrameSizeConvBufOut[MAX_NUM_CHANNELS]; + + CVector vstrChatColors; + CVector vecChanIDsCurConChan; + + CVector> vecvecfGains; + CVector> vecvecfPannings; + CVector> vecvecsData; + CVector> vecvecsData2; + CVector vecNumAudioChannels; + CVector vecNumFrameSizeConvBlocks; + CVector vecUseDoubleSysFraSizeConvBuf; + CVector vecAudioComprType; + CVector> vecvecsSendData; + CVector> vecvecfIntermediateProcBuf; + CVector> vecvecbyCodedData; // Channel levels - CVector vecChannelLevels; + CVector vecChannelLevels; // actual working objects - CHighPrioSocket Socket; + CHighPrioSocket Socket; // logging - CServerLogging Logging; + CServerLogging Logging; // channel level update frame interval counter - int iFrameCount; + int iFrameCount; // HTML file server status - bool bWriteStatusHTMLFile; - QString strServerHTMLFileListName; + bool bWriteStatusHTMLFile; + QString strServerHTMLFileListName; - CHighPrecisionTimer HighPrecisionTimer; + CHighPrecisionTimer HighPrecisionTimer; // server list - CServerListManager ServerListManager; + CServerListManager ServerListManager; // jam recorder - recorder::CJamController JamController; - bool bDisableRecording; + recorder::CJamController JamController; + bool bDisableRecording; // GUI settings - bool bAutoRunMinimized; + bool bAutoRunMinimized; // for delay panning - bool bDelayPan; + bool bDelayPan; // messaging - QString strWelcomeMessage; - ELicenceType eLicenceType; - bool bDisconnectAllClientsOnQuit; + QString strWelcomeMessage; + ELicenceType eLicenceType; + bool bDisconnectAllClientsOnQuit; - CSignalHandler* pSignalHandler; + CSignalHandler* pSignalHandler; std::unique_ptr pThreadPool; @@ -432,9 +387,7 @@ class CServer : const int iNumAudChan, const CVector vecsData ); - void CLVersionAndOSReceived ( CHostAddress InetAddr, - COSUtil::EOpSystemType eOSType, - QString strVersion ); + void CLVersionAndOSReceived ( CHostAddress InetAddr, COSUtil::EOpSystemType eOSType, QString strVersion ); // pass through from jam controller void RestartRecorder(); @@ -445,81 +398,56 @@ class CServer : public slots: void OnTimer(); - void OnNewConnection ( int iChID, - CHostAddress RecHostAddr ); + void OnNewConnection ( int iChID, CHostAddress RecHostAddr ); void OnServerFull ( CHostAddress RecHostAddr ); - void OnSendCLProtMessage ( CHostAddress InetAddr, - CVector vecMessage ); + void OnSendCLProtMessage ( CHostAddress InetAddr, CVector vecMessage ); - void OnProtcolCLMessageReceived ( int iRecID, - CVector vecbyMesBodyData, - CHostAddress RecHostAddr ); + void OnProtcolCLMessageReceived ( int iRecID, CVector vecbyMesBodyData, CHostAddress RecHostAddr ); - void OnProtcolMessageReceived ( int iRecCounter, - int iRecID, - CVector vecbyMesBodyData, - CHostAddress RecHostAddr ); + void OnProtcolMessageReceived ( int iRecCounter, int iRecID, CVector vecbyMesBodyData, CHostAddress RecHostAddr ); - void OnCLPingReceived ( CHostAddress InetAddr, int iMs ) - { ConnLessProtocol.CreateCLPingMes ( InetAddr, iMs ); } + void OnCLPingReceived ( CHostAddress InetAddr, int iMs ) { ConnLessProtocol.CreateCLPingMes ( InetAddr, iMs ); } - void OnCLPingWithNumClientsReceived ( CHostAddress InetAddr, - int iMs, - int ) + void OnCLPingWithNumClientsReceived ( CHostAddress InetAddr, int iMs, int ) { - ConnLessProtocol.CreateCLPingWithNumClientsMes ( InetAddr, - iMs, - GetNumberOfConnectedClients() ); + ConnLessProtocol.CreateCLPingWithNumClientsMes ( InetAddr, iMs, GetNumberOfConnectedClients() ); } void OnCLSendEmptyMes ( CHostAddress TargetInetAddr ) { // only send empty message if server list is enabled and this is not // a directory server - if ( ServerListManager.GetEnabled() && - !ServerListManager.GetIsCentralServer() ) + if ( ServerListManager.GetEnabled() && !ServerListManager.GetIsCentralServer() ) { ConnLessProtocol.CreateCLEmptyMes ( TargetInetAddr ); } } - void OnCLReqServerList ( CHostAddress InetAddr ) - { ServerListManager.CentralServerQueryServerList ( InetAddr ); } + void OnCLReqServerList ( CHostAddress InetAddr ) { ServerListManager.CentralServerQueryServerList ( InetAddr ); } - void OnCLReqVersionAndOS ( CHostAddress InetAddr ) - { ConnLessProtocol.CreateCLVersionAndOSMes ( InetAddr ); } + void OnCLReqVersionAndOS ( CHostAddress InetAddr ) { ConnLessProtocol.CreateCLVersionAndOSMes ( InetAddr ); } - void OnCLReqConnClientsList ( CHostAddress InetAddr ) - { ConnLessProtocol.CreateCLConnClientsListMes ( InetAddr, CreateChannelList() ); } + void OnCLReqConnClientsList ( CHostAddress InetAddr ) { ConnLessProtocol.CreateCLConnClientsListMes ( InetAddr, CreateChannelList() ); } - void OnCLRegisterServerReceived ( CHostAddress InetAddr, - CHostAddress LInetAddr, - CServerCoreInfo ServerInfo ) + void OnCLRegisterServerReceived ( CHostAddress InetAddr, CHostAddress LInetAddr, CServerCoreInfo ServerInfo ) { ServerListManager.CentralServerRegisterServer ( InetAddr, LInetAddr, ServerInfo ); } - void OnCLRegisterServerExReceived ( CHostAddress InetAddr, - CHostAddress LInetAddr, - CServerCoreInfo ServerInfo, - COSUtil::EOpSystemType , - QString strVersion ) + void OnCLRegisterServerExReceived ( CHostAddress InetAddr, + CHostAddress LInetAddr, + CServerCoreInfo ServerInfo, + COSUtil::EOpSystemType, + QString strVersion ) { ServerListManager.CentralServerRegisterServer ( InetAddr, LInetAddr, ServerInfo, strVersion ); } - void OnCLRegisterServerResp ( CHostAddress /* unused */, - ESvrRegResult eResult ) - { - ServerListManager.StoreRegistrationResult ( eResult ); - } + void OnCLRegisterServerResp ( CHostAddress /* unused */, ESvrRegResult eResult ) { ServerListManager.StoreRegistrationResult ( eResult ); } - void OnCLUnregisterServerReceived ( CHostAddress InetAddr ) - { - ServerListManager.CentralServerUnregisterServer ( InetAddr ); - } + void OnCLUnregisterServerReceived ( CHostAddress InetAddr ) { ServerListManager.CentralServerUnregisterServer ( InetAddr ); } void OnCLDisconnection ( CHostAddress InetAddr ); @@ -528,4 +456,4 @@ public slots: void OnHandledSignal ( int sigNum ); }; -Q_DECLARE_METATYPE(CVector) +Q_DECLARE_METATYPE ( CVector ) diff --git a/src/serverdlg.cpp b/src/serverdlg.cpp index e29dfa64b1..2d71da7ab1 100644 --- a/src/serverdlg.cpp +++ b/src/serverdlg.cpp @@ -24,71 +24,70 @@ #include "serverdlg.h" - /* Implementation *************************************************************/ -CServerDlg::CServerDlg ( CServer* pNServP, - CServerSettings* pNSetP, - const bool bStartMinimized, - QWidget* parent ) - : CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons - pServer ( pNServP ), - pSettings ( pNSetP ), - BitmapSystemTrayInactive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreyArrow.png" ) ), - BitmapSystemTrayActive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenArrow.png" ) ) +CServerDlg::CServerDlg ( CServer* pNServP, CServerSettings* pNSetP, const bool bStartMinimized, QWidget* parent ) : + CBaseDlg ( parent, Qt::Window ), // use Qt::Window to get min/max window buttons + pServer ( pNServP ), + pSettings ( pNSetP ), + BitmapSystemTrayInactive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreyArrow.png" ) ), + BitmapSystemTrayActive ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenArrow.png" ) ) { // check if system tray icon can be used bSystemTrayIconAvaialbe = SystemTrayIcon.isSystemTrayAvailable(); setupUi ( this ); - // Add help text to controls ----------------------------------------------- // client list - lvwClients->setWhatsThis ( "" + tr ( "Client List" ) + ": " + tr ( - "The client list shows all clients which are currently connected to this " - "server. Some information about the clients like the IP address and name " - "are given for each connected client." ) ); + lvwClients->setWhatsThis ( "" + tr ( "Client List" ) + ": " + + tr ( "The client list shows all clients which are currently connected to this " + "server. Some information about the clients like the IP address and name " + "are given for each connected client." ) ); lvwClients->setAccessibleName ( tr ( "Connected clients list view" ) ); // start minimized on operating system start - chbStartOnOSStart->setWhatsThis ( "" + tr ( "Start Minimized on Operating " - "System Start" ) + ": " + tr ( "If the start minimized on operating system start " - "check box is checked, the server will be " - "started when the operating system starts up and is automatically " - "minimized to a system task bar icon." ) ); + chbStartOnOSStart->setWhatsThis ( "" + + tr ( "Start Minimized on Operating " + "System Start" ) + + ": " + + tr ( "If the start minimized on operating system start " + "check box is checked, the server will be " + "started when the operating system starts up and is automatically " + "minimized to a system task bar icon." ) ); // Make My Server Public flag chbRegisterServer->setWhatsThis ( "" + tr ( "Make My Server Public" ) + ": " + - tr ( "If the Make My Server Public check box is checked, this server registers " - "itself at the directory server so that all users of the application " - "can see the server in the connect dialog server list and " - "connect to it. The registration of the server is renewed periodically " - "to make sure that all servers in the connect dialog server list are " - "actually available." ) ); + tr ( "If the Make My Server Public check box is checked, this server registers " + "itself at the directory server so that all users of the application " + "can see the server in the connect dialog server list and " + "connect to it. The registration of the server is renewed periodically " + "to make sure that all servers in the connect dialog server list are " + "actually available." ) ); // register server status label lblRegSvrStatus->setWhatsThis ( "" + tr ( "Register Server Status" ) + ": " + - tr ( "If the Make My Server Public check box is checked, this will show " - "whether registration with the directory server is successful. If the " - "registration failed, please choose another server list." ) ); + tr ( "If the Make My Server Public check box is checked, this will show " + "whether registration with the directory server is successful. If the " + "registration failed, please choose another server list." ) ); // custom directory server address QString strCentrServAddr = "" + tr ( "Custom Directory Server Address" ) + ": " + - tr ( "The custom directory server address is the IP address or URL of the directory " - "server at which the server list of the connection dialog is managed." ); + tr ( "The custom directory server address is the IP address or URL of the directory " + "server at which the server list of the connection dialog is managed." ); lblCentralServerAddress->setWhatsThis ( strCentrServAddr ); edtCentralServerAddress->setWhatsThis ( strCentrServAddr ); edtCentralServerAddress->setAccessibleName ( tr ( "Directory server address line edit" ) ); - cbxCentServAddrType->setWhatsThis ( "" + tr ( "Server List Selection" ) + ": " + tr ( - "Selects the server list (i.e. directory server address) in which your server will be added." ) ); + cbxCentServAddrType->setWhatsThis ( "" + tr ( "Server List Selection" ) + ": " + + tr ( "Selects the server list (i.e. directory server address) in which your server will be added." ) ); cbxCentServAddrType->setAccessibleName ( tr ( "Server list selection combo box" ) ); // server name - QString strServName = "" + tr ( "Server Name" ) + ": " + tr ( "The server name identifies " - "your server in the connect dialog server list at the clients." ); + QString strServName = "" + tr ( "Server Name" ) + ": " + + tr ( "The server name identifies " + "your server in the connect dialog server list at the clients." ); lblServerName->setWhatsThis ( strServName ); edtServerName->setWhatsThis ( strServName ); @@ -96,9 +95,10 @@ CServerDlg::CServerDlg ( CServer* pNServP, edtServerName->setAccessibleName ( tr ( "Server name line edit" ) ); // location city - QString strLocCity = "" + tr ( "Location City" ) + ": " + tr ( "The city in which this " - "server is located can be set here. If a city name is entered, it " - "will be shown in the connect dialog server list at the clients." ); + QString strLocCity = "" + tr ( "Location City" ) + ": " + + tr ( "The city in which this " + "server is located can be set here. If a city name is entered, it " + "will be shown in the connect dialog server list at the clients." ); lblLocationCity->setWhatsThis ( strLocCity ); edtLocationCity->setWhatsThis ( strLocCity ); @@ -106,81 +106,74 @@ CServerDlg::CServerDlg ( CServer* pNServP, edtLocationCity->setAccessibleName ( tr ( "City where the server is located line edit" ) ); // location country - QString strLocCountry = "" + tr ( "Location country" ) + ": " + tr ( "The country in " - "which this server is located can be set here. If a country is " - "entered, it will be shown in the connect dialog server list at the " - "clients." ); + QString strLocCountry = "" + tr ( "Location country" ) + ": " + + tr ( "The country in " + "which this server is located can be set here. If a country is " + "entered, it will be shown in the connect dialog server list at the " + "clients." ); lblLocationCountry->setWhatsThis ( strLocCountry ); cbxLocationCountry->setWhatsThis ( strLocCountry ); - cbxLocationCountry->setAccessibleName ( tr ( - "Country where the server is located combo box" ) ); + cbxLocationCountry->setAccessibleName ( tr ( "Country where the server is located combo box" ) ); // recording directory pbtRecordingDir->setAccessibleName ( tr ( "Display dialog to select recording directory button" ) ); - pbtRecordingDir->setWhatsThis ( "" + tr ( "Main Recording Directory" ) + ": " - + tr ( "Click the button to open the dialog that allows the main recording directory to be selected." - "The chosen value must exist and be writeable (allow creation of sub-directories " - "by the user Jamulus is running as). " ) ); + pbtRecordingDir->setWhatsThis ( "" + tr ( "Main Recording Directory" ) + ": " + + tr ( "Click the button to open the dialog that allows the main recording directory to be selected." + "The chosen value must exist and be writeable (allow creation of sub-directories " + "by the user Jamulus is running as). " ) ); edtRecordingDir->setAccessibleName ( tr ( "Main recording directory text box (read-only)" ) ); - edtRecordingDir->setWhatsThis ( "" + tr ( "Main Recording Directory" ) + ": " - + tr ( "The current value of the main recording directory. " - "The chosen value must exist and be writeable (allow creation of sub-directories " - "by the user Jamulus is running as). " - "Click the button to open the dialog that allows the main recording directory to be selected." ) ); + edtRecordingDir->setWhatsThis ( "" + tr ( "Main Recording Directory" ) + ": " + + tr ( "The current value of the main recording directory. " + "The chosen value must exist and be writeable (allow creation of sub-directories " + "by the user Jamulus is running as). " + "Click the button to open the dialog that allows the main recording directory to be selected." ) ); tbtClearRecordingDir->setAccessibleName ( tr ( "Clear the recording directory button" ) ); - tbtClearRecordingDir->setWhatsThis ( "" + tr ( "Clear Recording Directory" ) + ": " - + tr ( "Click the button to clear the currently selected recording directory. " - "This will prevent recording until a new value is selected.") ); + tbtClearRecordingDir->setWhatsThis ( "" + tr ( "Clear Recording Directory" ) + ": " + + tr ( "Click the button to clear the currently selected recording directory. " + "This will prevent recording until a new value is selected." ) ); // enable recorder - chbEnableRecorder->setAccessibleName( tr ( "Checkbox to turn on or off server recording" ) ); - chbEnableRecorder->setWhatsThis( "" + tr ( "Enable Recorder" ) + ": " - + tr ( "Checked when the recorder is enabled, otherwise unchecked. " - "The recorder will run when a session is in progress, if (set up correctly and) enabled." ) ); + chbEnableRecorder->setAccessibleName ( tr ( "Checkbox to turn on or off server recording" ) ); + chbEnableRecorder->setWhatsThis ( "" + tr ( "Enable Recorder" ) + ": " + + tr ( "Checked when the recorder is enabled, otherwise unchecked. " + "The recorder will run when a session is in progress, if (set up correctly and) enabled." ) ); // current session directory - edtCurrentSessionDir->setAccessibleName( tr ( "Current session directory text box (read-only)" ) ); - edtCurrentSessionDir->setWhatsThis( "" + tr ( "Current Session Directory" ) + ": " - + tr ( "Enabled during recording and holds the current recording session directory. " - "Disabled after recording or when the recorder is not enabled." ) ); + edtCurrentSessionDir->setAccessibleName ( tr ( "Current session directory text box (read-only)" ) ); + edtCurrentSessionDir->setWhatsThis ( "" + tr ( "Current Session Directory" ) + ": " + + tr ( "Enabled during recording and holds the current recording session directory. " + "Disabled after recording or when the recorder is not enabled." ) ); // recorder status lblRecorderStatus->setAccessibleName ( tr ( "Recorder status label" ) ); - lblRecorderStatus->setWhatsThis ( "" + tr ( "Recorder Status" ) + ": " - + tr ( "Displays the current status of the recorder. The following values are possible:" ) - + "
" - + "
" + SREC_NOT_INITIALISED + "
" - + "
" + tr ( "No recording directory has been set or the value is not useable" ) + "
" - + "
" + SREC_NOT_ENABLED + "
" - + "
" + tr ( "Recording has been switched off" ) + lblRecorderStatus->setWhatsThis ( + "" + tr ( "Recorder Status" ) + ": " + tr ( "Displays the current status of the recorder. The following values are possible:" ) + + "
" + "
" + SREC_NOT_INITIALISED + "
" + "
" + tr ( "No recording directory has been set or the value is not useable" ) + + "
" + "
" + SREC_NOT_ENABLED + "
" + "
" + tr ( "Recording has been switched off" ) #ifdef _WIN32 + tr ( " by the UI checkbox" ) #else + tr ( ", either by the UI checkbox or SIGUSR2 being received" ) #endif - + "
" - + "
" + SREC_NOT_RECORDING + "
" - + "
" + tr ( "There is no one connected to the server to record" ) + "
" - + "
" + SREC_RECORDING + "
" - + "
" + tr ( "The performers are being recorded to the specified session directory" ) + "
" - + "
" - + "
" + tr ( "NOTE" ) + ": " - + tr ( "If the recording directory is not useable, the problem will be displayed in place of the directory." ) ); + + "
" + "
" + SREC_NOT_RECORDING + "
" + "
" + tr ( "There is no one connected to the server to record" ) + "
" + "
" + + SREC_RECORDING + "
" + "
" + tr ( "The performers are being recorded to the specified session directory" ) + "
" + "
" + + "
" + tr ( "NOTE" ) + ": " + + tr ( "If the recording directory is not useable, the problem will be displayed in place of the directory." ) ); // new recording pbtNewRecording->setAccessibleName ( tr ( "Request new recording button" ) ); - pbtNewRecording->setWhatsThis ( "" + tr ( "New Recording" ) + ": " - + tr ( "During a recording session, the button can be used to start a new recording." ) ); + pbtNewRecording->setWhatsThis ( "" + tr ( "New Recording" ) + ": " + + tr ( "During a recording session, the button can be used to start a new recording." ) ); // welcome message tedWelcomeMessage->setAccessibleName ( tr ( "Server welcome message edit box" ) ); - tedWelcomeMessage->setWhatsThis ( "" + tr ( "Server Welcome Message" ) + ": " - + tr ( "A server welcome message text is displayed in the chat window if a " - "musician enters the server. If no message is set, the server welcome is disabled." ) ); + tedWelcomeMessage->setWhatsThis ( "" + tr ( "Server Welcome Message" ) + ": " + + tr ( "A server welcome message text is displayed in the chat window if a " + "musician enters the server. If no message is set, the server welcome is disabled." ) ); // init system tray icon if ( bSystemTrayIconAvaialbe ) @@ -188,18 +181,14 @@ CServerDlg::CServerDlg ( CServer* pNServP, // prepare context menu to be added to the system tray icon pSystemTrayIconMenu = new QMenu ( this ); - pSystemTrayIconMenu->addAction ( tr ( "E&xit" ), - this, SLOT ( OnSysTrayMenuExit() ) ); + pSystemTrayIconMenu->addAction ( tr ( "E&xit" ), this, SLOT ( OnSysTrayMenuExit() ) ); pSystemTrayIconMenu->addSeparator(); - pSystemTrayIconMenu->addAction ( - tr ( "&Hide " ) + APP_NAME + tr ( " server" ), - this, SLOT ( OnSysTrayMenuHide() ) ); + pSystemTrayIconMenu->addAction ( tr ( "&Hide " ) + APP_NAME + tr ( " server" ), this, SLOT ( OnSysTrayMenuHide() ) ); - pSystemTrayIconMenu->setDefaultAction ( pSystemTrayIconMenu->addAction ( - tr ( "&Open " ) + APP_NAME + tr ( " server" ), - this, SLOT ( OnSysTrayMenuOpen() ) ) ); + pSystemTrayIconMenu->setDefaultAction ( + pSystemTrayIconMenu->addAction ( tr ( "&Open " ) + APP_NAME + tr ( " server" ), this, SLOT ( OnSysTrayMenuOpen() ) ) ); SystemTrayIcon.setContextMenu ( pSystemTrayIconMenu ); @@ -219,18 +208,17 @@ CServerDlg::CServerDlg ( CServer* pNServP, } // set up list view for connected clients - lvwClients->setColumnWidth ( 0, 170 ); // 170 // IP:port - lvwClients->setColumnWidth ( 1, 200 ); // 200 // Name - lvwClients->setColumnWidth ( 2, 120 ); // 60 // Buf-Frames - lvwClients->setColumnWidth ( 3, 50 ); // Channels + lvwClients->setColumnWidth ( 0, 170 ); // 170 // IP:port + lvwClients->setColumnWidth ( 1, 200 ); // 200 // Name + lvwClients->setColumnWidth ( 2, 120 ); // 60 // Buf-Frames + lvwClients->setColumnWidth ( 3, 50 ); // Channels lvwClients->clear(); -// clang-format off + // clang-format off // TEST workaround for resize problem of window after iconize in task bar lvwClients->setMinimumWidth ( 170 + 130 + 60 + 205 ); lvwClients->setMinimumHeight ( 140 ); -// clang-format on - + // clang-format on // insert items in reverse order because in Windows all of them are // always visible -> put first item on the top @@ -267,16 +255,14 @@ lvwClients->setMinimumHeight ( 140 ); cbxLocationCountry->setInsertPolicy ( QComboBox::NoInsert ); cbxLocationCountry->clear(); - for ( int iCurCntry = static_cast ( QLocale::AnyCountry ); - iCurCntry < static_cast ( QLocale::LastCountry ); iCurCntry++ ) + for ( int iCurCntry = static_cast ( QLocale::AnyCountry ); iCurCntry < static_cast ( QLocale::LastCountry ); iCurCntry++ ) { // add all countries except of the "Default" country if ( static_cast ( iCurCntry ) != QLocale::AnyCountry ) { // store the country enum index together with the string (this is // important since we sort the combo box items later on) - cbxLocationCountry->addItem ( QLocale::countryToString ( - static_cast ( iCurCntry ) ), iCurCntry ); + cbxLocationCountry->addItem ( QLocale::countryToString ( static_cast ( iCurCntry ) ), iCurCntry ); } } @@ -284,9 +270,7 @@ lvwClients->setMinimumHeight ( 140 ); cbxLocationCountry->model()->sort ( 0, Qt::AscendingOrder ); // select current country - cbxLocationCountry->setCurrentIndex ( - cbxLocationCountry->findData ( - static_cast ( pServer->GetServerCountry() ) ) ); + cbxLocationCountry->setCurrentIndex ( cbxLocationCountry->findData ( static_cast ( pServer->GetServerCountry() ) ) ); // update register server check box if ( pServer->GetServerListEnabled() ) @@ -321,11 +305,11 @@ lvwClients->setMinimumHeight ( 140 ); // update delay panning check box if ( pServer->IsDelayPanningEnabled() ) { - chbEnableDelayPanning->setCheckState(Qt::Checked); + chbEnableDelayPanning->setCheckState ( Qt::Checked ); } else { - chbEnableDelayPanning->setCheckState(Qt::Unchecked); + chbEnableDelayPanning->setCheckState ( Qt::Unchecked ); } // Recorder controls @@ -342,14 +326,12 @@ lvwClients->setMinimumHeight ( 140 ); cbxLanguage->Init ( pSettings->strLanguage ); // setup welcome message GUI control - tedWelcomeMessage->setPlaceholderText ( tr ( - "Type a message here. If no message is set, the server welcome is disabled." ) ); + tedWelcomeMessage->setPlaceholderText ( tr ( "Type a message here. If no message is set, the server welcome is disabled." ) ); tedWelcomeMessage->setText ( pServer->GetWelcomeMessage() ); // prepare update check info label (invisible by default) - lblUpdateCheck->setText ( "" + QString ( APP_NAME ) + " " + - tr ( "software upgrade available" ) + "" ); + lblUpdateCheck->setText ( "" + QString ( APP_NAME ) + " " + tr ( "software upgrade available" ) + "" ); lblUpdateCheck->hide(); // update GUI dependencies @@ -358,13 +340,10 @@ lvwClients->setMinimumHeight ( 140 ); // set window title setWindowTitle ( APP_NAME + tr ( " Server" ) ); - // View menu -------------------------------------------------------------- QMenu* pViewMenu = new QMenu ( tr ( "&Window" ), this ); - pViewMenu->addAction ( tr ( "E&xit" ), this, - SLOT ( close() ), QKeySequence ( Qt::CTRL + Qt::Key_Q ) ); - + pViewMenu->addAction ( tr ( "E&xit" ), this, SLOT ( close() ), QKeySequence ( Qt::CTRL + Qt::Key_Q ) ); // Main menu bar ----------------------------------------------------------- pMenu = new QMenuBar ( this ); @@ -375,7 +354,6 @@ lvwClients->setMinimumHeight ( 140 ); // Now tell the layout about the menu layout()->setMenuBar ( pMenu ); - // Window positions -------------------------------------------------------- // main window if ( !pSettings->vecWindowPosMain.isEmpty() && !pSettings->vecWindowPosMain.isNull() ) @@ -383,82 +361,64 @@ lvwClients->setMinimumHeight ( 140 ); restoreGeometry ( pSettings->vecWindowPosMain ); } - // Connections ------------------------------------------------------------- // check boxes - QObject::connect ( chbRegisterServer, &QCheckBox::stateChanged, - this, &CServerDlg::OnRegisterServerStateChanged ); + QObject::connect ( chbRegisterServer, &QCheckBox::stateChanged, this, &CServerDlg::OnRegisterServerStateChanged ); - QObject::connect ( chbStartOnOSStart, &QCheckBox::stateChanged, - this, &CServerDlg::OnStartOnOSStartStateChanged ); + QObject::connect ( chbStartOnOSStart, &QCheckBox::stateChanged, this, &CServerDlg::OnStartOnOSStartStateChanged ); - QObject::connect ( chbEnableRecorder, &QCheckBox::stateChanged, - this, &CServerDlg::OnEnableRecorderStateChanged ); + QObject::connect ( chbEnableRecorder, &QCheckBox::stateChanged, this, &CServerDlg::OnEnableRecorderStateChanged ); // delay panning - QObject::connect ( chbEnableDelayPanning, &QCheckBox::stateChanged, - this, &CServerDlg::OnEnableDelayPanningStateChanged ); + QObject::connect ( chbEnableDelayPanning, &QCheckBox::stateChanged, this, &CServerDlg::OnEnableDelayPanningStateChanged ); // line edits - QObject::connect ( edtCentralServerAddress, &QLineEdit::editingFinished, - this, &CServerDlg::OnCentralServerAddressEditingFinished ); + QObject::connect ( edtCentralServerAddress, &QLineEdit::editingFinished, this, &CServerDlg::OnCentralServerAddressEditingFinished ); - QObject::connect ( edtServerName, &QLineEdit::textChanged, - this, &CServerDlg::OnServerNameTextChanged ); + QObject::connect ( edtServerName, &QLineEdit::textChanged, this, &CServerDlg::OnServerNameTextChanged ); - QObject::connect ( edtLocationCity, &QLineEdit::textChanged, - this, &CServerDlg::OnLocationCityTextChanged ); + QObject::connect ( edtLocationCity, &QLineEdit::textChanged, this, &CServerDlg::OnLocationCityTextChanged ); // combo boxes - QObject::connect ( cbxLocationCountry, static_cast ( &QComboBox::activated ), - this, &CServerDlg::OnLocationCountryActivated ); + QObject::connect ( cbxLocationCountry, + static_cast ( &QComboBox::activated ), + this, + &CServerDlg::OnLocationCountryActivated ); - QObject::connect ( cbxCentServAddrType, static_cast ( &QComboBox::activated ), - this, &CServerDlg::OnCentServAddrTypeActivated ); + QObject::connect ( cbxCentServAddrType, + static_cast ( &QComboBox::activated ), + this, + &CServerDlg::OnCentServAddrTypeActivated ); - QObject::connect ( cbxLanguage, &CLanguageComboBox::LanguageChanged, - this, &CServerDlg::OnLanguageChanged ); + QObject::connect ( cbxLanguage, &CLanguageComboBox::LanguageChanged, this, &CServerDlg::OnLanguageChanged ); // push buttons - QObject::connect ( pbtRecordingDir, &QPushButton::released, - this, &CServerDlg::OnRecordingDirClicked ); + QObject::connect ( pbtRecordingDir, &QPushButton::released, this, &CServerDlg::OnRecordingDirClicked ); - QObject::connect ( pbtNewRecording, &QPushButton::released, - this, &CServerDlg::OnNewRecordingClicked ); + QObject::connect ( pbtNewRecording, &QPushButton::released, this, &CServerDlg::OnNewRecordingClicked ); // tool buttons - QObject::connect ( tbtClearRecordingDir, &QToolButton::released, - this, &CServerDlg::OnClearRecordingDirClicked ); + QObject::connect ( tbtClearRecordingDir, &QToolButton::released, this, &CServerDlg::OnClearRecordingDirClicked ); // timers - QObject::connect ( &Timer, &QTimer::timeout, - this, &CServerDlg::OnTimer ); + QObject::connect ( &Timer, &QTimer::timeout, this, &CServerDlg::OnTimer ); // other - QObject::connect ( tedWelcomeMessage, &QTextEdit::textChanged, - this, &CServerDlg::OnWelcomeMessageChanged ); + QObject::connect ( tedWelcomeMessage, &QTextEdit::textChanged, this, &CServerDlg::OnWelcomeMessageChanged ); - QObject::connect ( pServer, &CServer::Started, - this, &CServerDlg::OnServerStarted ); + QObject::connect ( pServer, &CServer::Started, this, &CServerDlg::OnServerStarted ); - QObject::connect ( pServer, &CServer::Stopped, - this, &CServerDlg::OnServerStopped ); + QObject::connect ( pServer, &CServer::Stopped, this, &CServerDlg::OnServerStopped ); - QObject::connect ( pServer, &CServer::SvrRegStatusChanged, - this, &CServerDlg::OnSvrRegStatusChanged ); + QObject::connect ( pServer, &CServer::SvrRegStatusChanged, this, &CServerDlg::OnSvrRegStatusChanged ); - QObject::connect ( pServer, &CServer::RecordingSessionStarted, - this, &CServerDlg::OnRecordingSessionStarted ); + QObject::connect ( pServer, &CServer::RecordingSessionStarted, this, &CServerDlg::OnRecordingSessionStarted ); - QObject::connect ( pServer, &CServer::StopRecorder, - this, &CServerDlg::OnStopRecorder ); + QObject::connect ( pServer, &CServer::StopRecorder, this, &CServerDlg::OnStopRecorder ); - QObject::connect ( pServer, &CServer::CLVersionAndOSReceived, - this, &CServerDlg::OnCLVersionAndOSReceived ); - - QObject::connect ( &SystemTrayIcon, &QSystemTrayIcon::activated, - this, &CServerDlg::OnSysTrayActivated ); + QObject::connect ( pServer, &CServer::CLVersionAndOSReceived, this, &CServerDlg::OnCLVersionAndOSReceived ); + QObject::connect ( &SystemTrayIcon, &QSystemTrayIcon::activated, this, &CServerDlg::OnSysTrayActivated ); // Initializations which have to be done after the signals are connected --- // start timer for GUI controls @@ -499,7 +459,7 @@ void CServerDlg::OnStartOnOSStartStateChanged ( int value ) // update registry and server setting (for ini file) pServer->SetAutoRunMinimized ( bCurAutoStartMinState ); - ModifyAutoStartEntry ( bCurAutoStartMinState ); + ModifyAutoStartEntry ( bCurAutoStartMinState ); } void CServerDlg::OnRegisterServerStateChanged ( int value ) @@ -524,8 +484,7 @@ void CServerDlg::OnRegisterServerStateChanged ( int value ) void CServerDlg::OnCentralServerAddressEditingFinished() { // apply new setting to the server and update it - pServer->SetServerListCentralServerAddress ( - edtCentralServerAddress->text() ); + pServer->SetServerListCentralServerAddress ( edtCentralServerAddress->text() ); pServer->UpdateServerList(); } @@ -565,8 +524,7 @@ void CServerDlg::OnLocationCityTextChanged ( const QString& strNewCity ) void CServerDlg::OnLocationCountryActivated ( int iCntryListItem ) { // apply new setting to the server and update it - pServer->SetServerCountry ( static_cast ( - cbxLocationCountry->itemData ( iCntryListItem ).toInt() ) ); + pServer->SetServerCountry ( static_cast ( cbxLocationCountry->itemData ( iCntryListItem ).toInt() ) ); pServer->UpdateServerList(); } @@ -599,9 +557,12 @@ void CServerDlg::OnStopRecorder() UpdateRecorderStatus ( QString::null ); if ( pServer->GetRecorderErrMsg() != QString::null ) { - QMessageBox::warning ( this, APP_NAME, tr ( "Recorder failed to start. " - "Please check available disk space and permissions and try again. " - "Error: " ) + pServer->GetRecorderErrMsg() ); + QMessageBox::warning ( this, + APP_NAME, + tr ( "Recorder failed to start. " + "Please check available disk space and permissions and try again. " + "Error: " ) + + pServer->GetRecorderErrMsg() ); } } @@ -639,16 +600,14 @@ void CServerDlg::OnSysTrayActivated ( QSystemTrayIcon::ActivationReason ActReaso } } -void CServerDlg::OnCLVersionAndOSReceived ( CHostAddress , - COSUtil::EOpSystemType , - QString strVersion ) +void CServerDlg::OnCLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString strVersion ) { // update check -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) - int mySuffixIndex; +#if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) + int mySuffixIndex; QVersionNumber myVersion = QVersionNumber::fromString ( VERSION, &mySuffixIndex ); - int serverSuffixIndex; + int serverSuffixIndex; QVersionNumber serverVersion = QVersionNumber::fromString ( strVersion, &serverSuffixIndex ); // only compare if the server version has no suffix (such as dev or beta) @@ -668,10 +627,7 @@ void CServerDlg::OnTimer() ListViewMutex.lock(); { - pServer->GetConCliParam ( vecHostAddresses, - vecsName, - veciJitBufNumFrames, - veciNetwFrameSizeFact ); + pServer->GetConCliParam ( vecHostAddresses, vecsName, veciJitBufNumFrames, veciNetwFrameSizeFact ); // we assume that all vectors have the same length const int iNumChannels = vecHostAddresses.Size(); @@ -682,15 +638,13 @@ void CServerDlg::OnTimer() if ( !( vecHostAddresses[i].InetAddr == QHostAddress ( static_cast ( 0 ) ) ) ) { // IP, port number - vecpListViewItems[i]->setText ( 0, - vecHostAddresses[i].toString ( CHostAddress::SM_IP_PORT ) ); + vecpListViewItems[i]->setText ( 0, vecHostAddresses[i].toString ( CHostAddress::SM_IP_PORT ) ); // name vecpListViewItems[i]->setText ( 1, vecsName[i] ); // jitter buffer size (polling for updates) - vecpListViewItems[i]->setText ( 2, - QString().setNum ( veciJitBufNumFrames[i] ) ); + vecpListViewItems[i]->setText ( 2, QString().setNum ( veciJitBufNumFrames[i] ) ); // show num of audio channels int iNumAudioChs = pServer->GetClientNumAudioChannels ( i ); @@ -716,7 +670,7 @@ void CServerDlg::UpdateGUIDependencies() // if register server is not enabled, we disable all the configuration // controls for the server list cbxCentServAddrType->setEnabled ( bCurSerListEnabled ); - grbServerInfo->setEnabled ( bCurSerListEnabled ); + grbServerInfo->setEnabled ( bCurSerListEnabled ); QString strStatus = svrRegStatusToString ( eSvrRegStatus ); @@ -762,21 +716,17 @@ void CServerDlg::ModifyAutoStartEntry ( const bool bDoAutoStart ) #ifdef _WIN32 // init settings object so that it points to the correct place in the // Windows registry for the auto run entry - QSettings RegSettings ( "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", - QSettings::NativeFormat ); + QSettings RegSettings ( "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat ); // create start string of auto run entry - QString strRegValue = - QCoreApplication::applicationFilePath().replace ( "/", "\\" ) + - " -s --startminimized"; + QString strRegValue = QCoreApplication::applicationFilePath().replace ( "/", "\\" ) + " -s --startminimized"; #endif if ( bDoAutoStart ) { #ifdef _WIN32 // ckeck if registry entry is correctly present, if not, correct - const bool bWriteRegValue = strRegValue.compare ( - RegSettings.value ( AUTORUN_SERVER_REG_NAME ).toString() ); + const bool bWriteRegValue = strRegValue.compare ( RegSettings.value ( AUTORUN_SERVER_REG_NAME ).toString() ); if ( bWriteRegValue ) { @@ -863,8 +813,7 @@ void CServerDlg::changeEvent ( QEvent* pEvent ) { // if we have a system tray icon, we make the window invisible if it is // minimized - if ( bSystemTrayIconAvaialbe && - ( pEvent->type() == QEvent::WindowStateChange ) ) + if ( bSystemTrayIconAvaialbe && ( pEvent->type() == QEvent::WindowStateChange ) ) { if ( isMinimized() ) { diff --git a/src/serverdlg.h b/src/serverdlg.h old mode 100755 new mode 100644 index d11c98e9cf..af88a9cc5c --- a/src/serverdlg.h +++ b/src/serverdlg.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -36,8 +36,8 @@ #include #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) -# include +#if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) +# include #endif #include "global.h" #include "util.h" @@ -45,10 +45,9 @@ #include "settings.h" #include "ui_serverdlgbase.h" - /* Definitions ****************************************************************/ // update time for GUI controls -#define GUI_CONTRL_UPDATE_TIME 1000 // ms +#define GUI_CONTRL_UPDATE_TIME 1000 // ms // Strings used in multiple places #define SREC_NOT_INITIALISED CServerDlg::tr ( "Not initialised" ) @@ -56,48 +55,47 @@ #define SREC_NOT_RECORDING CServerDlg::tr ( "Not recording" ) #define SREC_RECORDING CServerDlg::tr ( "Recording" ) - /* Classes ********************************************************************/ class CServerDlg : public CBaseDlg, private Ui_CServerDlgBase { Q_OBJECT public: - CServerDlg ( CServer* pNServP, - CServerSettings* pNSetP, - const bool bStartMinimized, - QWidget* parent = nullptr ); + CServerDlg ( CServer* pNServP, CServerSettings* pNSetP, const bool bStartMinimized, QWidget* parent = nullptr ); protected: virtual void changeEvent ( QEvent* pEvent ); virtual void closeEvent ( QCloseEvent* Event ); - void UpdateGUIDependencies(); - void UpdateSystemTrayIcon ( const bool bIsActive ); - void ShowWindowInForeground() { showNormal(); raise(); } - void ModifyAutoStartEntry ( const bool bDoAutoStart ); - void UpdateRecorderStatus( QString sessionDir ); + void UpdateGUIDependencies(); + void UpdateSystemTrayIcon ( const bool bIsActive ); + void ShowWindowInForeground() + { + showNormal(); + raise(); + } + void ModifyAutoStartEntry ( const bool bDoAutoStart ); + void UpdateRecorderStatus ( QString sessionDir ); - QTimer Timer; - CServer* pServer; - CServerSettings* pSettings; + QTimer Timer; + CServer* pServer; + CServerSettings* pSettings; CVector vecpListViewItems; QMutex ListViewMutex; - QMenuBar* pMenu; + QMenuBar* pMenu; - bool bSystemTrayIconAvaialbe; - QSystemTrayIcon SystemTrayIcon; - QPixmap BitmapSystemTrayInactive; - QPixmap BitmapSystemTrayActive; - QMenu* pSystemTrayIconMenu; + bool bSystemTrayIconAvaialbe; + QSystemTrayIcon SystemTrayIcon; + QPixmap BitmapSystemTrayInactive; + QPixmap BitmapSystemTrayActive; + QMenu* pSystemTrayIconMenu; public slots: void OnRegisterServerStateChanged ( int value ); void OnStartOnOSStartStateChanged ( int value ); - void OnEnableRecorderStateChanged ( int value ) - { pServer->SetEnableRecording ( Qt::CheckState::Checked == value ); } + void OnEnableRecorderStateChanged ( int value ) { pServer->SetEnableRecording ( Qt::CheckState::Checked == value ); } void OnCentralServerAddressEditingFinished(); void OnServerNameTextChanged ( const QString& strNewName ); @@ -119,10 +117,7 @@ public slots: void OnNewRecordingClicked() { pServer->RequestNewRecording(); } void OnRecordingDirClicked(); void OnClearRecordingDirClicked(); - void OnRecordingSessionStarted ( QString sessionDir ) - { UpdateRecorderStatus ( sessionDir ); } + void OnRecordingSessionStarted ( QString sessionDir ) { UpdateRecorderStatus ( sessionDir ); } - void OnCLVersionAndOSReceived ( CHostAddress , - COSUtil::EOpSystemType , - QString strVersion ); + void OnCLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString strVersion ); }; diff --git a/src/serverlist.cpp b/src/serverlist.cpp old mode 100755 new mode 100644 index 0d1eca19a1..97cb1e53e5 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -31,12 +31,12 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum, const QString& strServerListFilter, const QString& strServerPublicIP, const int iNumChannels, - CProtocol* pNConLProt ) - : eCentralServerAddressType ( AT_CUSTOM ), // must be AT_CUSTOM for the "no GUI" case - strMinServerVersion ( "" ), // disable version check with empty version - pConnLessProtocol ( pNConLProt ), - eSvrRegStatus ( SRS_UNREGISTERED ), - iSvrRegRetries ( 0 ) + CProtocol* pNConLProt ) : + eCentralServerAddressType ( AT_CUSTOM ), // must be AT_CUSTOM for the "no GUI" case + strMinServerVersion ( "" ), // disable version check with empty version + pConnLessProtocol ( pNConLProt ), + eSvrRegStatus ( SRS_UNREGISTERED ), + iSvrRegRetries ( 0 ) { // set the directory server address SetCentralServerAddress ( sNCentServAddr ); @@ -77,13 +77,8 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum, // definition the client substitutes the IP address of the directory server // itself for his server list. If we are the directory server, we assume that // we have a permanent server. - CServerListEntry ThisServerListEntry ( CHostAddress(), - SlaveCurLocalHostAddress, - "", - QLocale::system().country(), - "", - iNumChannels, - GetIsCentralServer() ); + CServerListEntry + ThisServerListEntry ( CHostAddress(), SlaveCurLocalHostAddress, "", QLocale::system().country(), "", iNumChannels, GetIsCentralServer() ); // parse the server info string according to definition: // [this server name];[this server city]; ... @@ -119,8 +114,7 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum, for ( int iIdx = 0; iIdx < slWhitelistAddresses.size(); iIdx++ ) { // check for special case: [version] - if ( ( slWhitelistAddresses.at ( iIdx ).length() > 2 ) && - ( slWhitelistAddresses.at ( iIdx ).left ( 1 ) == "[" ) && + if ( ( slWhitelistAddresses.at ( iIdx ).length() > 2 ) && ( slWhitelistAddresses.at ( iIdx ).left ( 1 ) == "[" ) && ( slWhitelistAddresses.at ( iIdx ).right ( 1 ) == "]" ) ) { strMinServerVersion = slWhitelistAddresses.at ( iIdx ).mid ( 1, slWhitelistAddresses.at ( iIdx ).length() - 2 ); @@ -128,8 +122,7 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum, else if ( CurWhiteListAddress.setAddress ( slWhitelistAddresses.at ( iIdx ) ) ) { vWhiteList << CurWhiteListAddress; - qInfo() << qUtf8Printable( QString( "Whitelist entry added: %1" ) - .arg( CurWhiteListAddress.toString() ) ); + qInfo() << qUtf8Printable ( QString ( "Whitelist entry added: %1" ).arg ( CurWhiteListAddress.toString() ) ); } } } @@ -139,30 +132,23 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum, if ( !GetIsCentralServer() ) { // 1 minute = 60 * 1000 ms - QTimer::singleShot ( SERVLIST_TIME_PERMSERV_MINUTES * 60000, - this, SLOT ( OnTimerIsPermanent() ) ); + QTimer::singleShot ( SERVLIST_TIME_PERMSERV_MINUTES * 60000, this, SLOT ( OnTimerIsPermanent() ) ); } // prepare the register server response timer (single shot timer) TimerCLRegisterServerResp.setSingleShot ( true ); TimerCLRegisterServerResp.setInterval ( REGISTER_SERVER_TIME_OUT_MS ); - // Connections ------------------------------------------------------------- - QObject::connect ( &TimerPollList, &QTimer::timeout, - this, &CServerListManager::OnTimerPollList ); + QObject::connect ( &TimerPollList, &QTimer::timeout, this, &CServerListManager::OnTimerPollList ); - QObject::connect ( &TimerPingServerInList, &QTimer::timeout, - this, &CServerListManager::OnTimerPingServerInList ); + QObject::connect ( &TimerPingServerInList, &QTimer::timeout, this, &CServerListManager::OnTimerPingServerInList ); - QObject::connect ( &TimerPingCentralServer, &QTimer::timeout, - this, &CServerListManager::OnTimerPingCentralServer ); + QObject::connect ( &TimerPingCentralServer, &QTimer::timeout, this, &CServerListManager::OnTimerPingCentralServer ); - QObject::connect ( &TimerRegistering, &QTimer::timeout, - this, &CServerListManager::OnTimerRegistering ); + QObject::connect ( &TimerRegistering, &QTimer::timeout, this, &CServerListManager::OnTimerRegistering ); - QObject::connect ( &TimerCLRegisterServerResp, &QTimer::timeout, - this, &CServerListManager::OnTimerCLRegisterServerResp ); + QObject::connect ( &TimerCLRegisterServerResp, &QTimer::timeout, this, &CServerListManager::OnTimerCLRegisterServerResp ); } void CServerListManager::SetCentralServerAddress ( const QString sNCentServAddr ) @@ -186,13 +172,8 @@ void CServerListManager::SetCentralServerAddress ( const QString sNCentServAddr // per definition: If we are in server mode and the directory server address // is the localhost address, and set to Custom, we are in directory server mode. - bIsCentralServer = - ( - ( !strCentralServerAddress.toLower().compare ( "localhost" ) || - !strCentralServerAddress.compare ( "127.0.0.1" ) ) && - ( eCentralServerAddressType == AT_CUSTOM ) - ); - + bIsCentralServer = ( ( !strCentralServerAddress.toLower().compare ( "localhost" ) || !strCentralServerAddress.compare ( "127.0.0.1" ) ) && + ( eCentralServerAddressType == AT_CUSTOM ) ); } void CServerListManager::SetCentralServerAddressType ( const ECSAddType eNCSAT ) @@ -210,12 +191,8 @@ void CServerListManager::SetCentralServerAddressType ( const ECSAddType eNCSAT ) // per definition: If we are in server mode and the directory server address // is the localhost address, and set to Custom, we are in directory server mode. - bIsCentralServer = - ( - ( !strCentralServerAddress.toLower().compare ( "localhost" ) || - !strCentralServerAddress.compare ( "127.0.0.1" ) ) && - ( eCentralServerAddressType == AT_CUSTOM ) - ); + bIsCentralServer = ( ( !strCentralServerAddress.toLower().compare ( "localhost" ) || !strCentralServerAddress.compare ( "127.0.0.1" ) ) && + ( eCentralServerAddressType == AT_CUSTOM ) ); } void CServerListManager::Update() @@ -282,7 +259,6 @@ void CServerListManager::Update() } } - /* Directory server list functionality ****************************************/ void CServerListManager::OnTimerPingServerInList() { @@ -329,8 +305,7 @@ void CServerListManager::OnTimerPollList() foreach ( const CHostAddress HostAddr, vecRemovedHostAddr ) { - qInfo() << qUtf8Printable( QString( "Expired entry for %1" ) - .arg( HostAddr.toString() ) ); + qInfo() << qUtf8Printable ( QString ( "Expired entry for %1" ).arg ( HostAddr.toString() ) ); } } @@ -341,13 +316,15 @@ void CServerListManager::CentralServerRegisterServer ( const CHostAddress& In { if ( bIsCentralServer && bEnabled ) { - qInfo() << qUtf8Printable( QString( "Requested to register entry for %1 (%2): %3") - .arg( InetAddr.toString() ).arg( LInetAddr.toString() ).arg( ServerInfo.strName ) ); + qInfo() << qUtf8Printable ( QString ( "Requested to register entry for %1 (%2): %3" ) + .arg ( InetAddr.toString() ) + .arg ( LInetAddr.toString() ) + .arg ( ServerInfo.strName ) ); // check for minimum server version if ( !strMinServerVersion.isEmpty() ) { -#if ( QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) ) +#if ( QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) ) if ( strVersion.isEmpty() || QVersionNumber::compare ( QVersionNumber::fromString ( strMinServerVersion ), QVersionNumber::fromString ( strVersion ) ) > 0 ) { @@ -414,9 +391,9 @@ void CServerListManager::CentralServerRegisterServer ( const CHostAddress& In ServerList[iSelIdx].UpdateRegistration(); } - pConnLessProtocol->CreateCLRegisterServerResp ( InetAddr, iSelIdx == INVALID_INDEX - ? ESvrRegResult::SRR_CENTRAL_SVR_FULL - : ESvrRegResult::SRR_REGISTERED ); + pConnLessProtocol->CreateCLRegisterServerResp ( InetAddr, + iSelIdx == INVALID_INDEX ? ESvrRegResult::SRR_CENTRAL_SVR_FULL + : ESvrRegResult::SRR_REGISTERED ); } } @@ -424,8 +401,7 @@ void CServerListManager::CentralServerUnregisterServer ( const CHostAddress& Ine { if ( bIsCentralServer && bEnabled ) { - qInfo() << qUtf8Printable( QString( "Requested to unregister entry for %1" ) - .arg( InetAddr.toString() ) ); + qInfo() << qUtf8Printable ( QString ( "Requested to unregister entry for %1" ).arg ( InetAddr.toString() ) ); QMutexLocker locker ( &Mutex ); @@ -501,9 +477,7 @@ void CServerListManager::CentralServerQueryServerList ( const CHostAddress& Inet // server (directory server) per definition) and also it is // not required to send this message, if the server is on // the same computer - pConnLessProtocol->CreateCLSendEmptyMesMes ( - vecServerInfo[iIdx].HostAddr, - InetAddr ); + pConnLessProtocol->CreateCLSendEmptyMesMes ( vecServerInfo[iIdx].HostAddr, InetAddr ); } } } @@ -516,7 +490,6 @@ void CServerListManager::CentralServerQueryServerList ( const CHostAddress& Inet } } - /* Slave server functionality *************************************************/ void CServerListManager::StoreRegistrationResult ( ESvrRegResult eResult ) { @@ -597,9 +570,7 @@ void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister ) QMutexLocker locker ( &Mutex ); // get the correct directory server address - const QString strCurCentrServAddr = - NetworkUtil::GetCentralServerAddress ( eCentralServerAddressType, - strCentralServerAddress ); + const QString strCurCentrServAddr = NetworkUtil::GetCentralServerAddress ( eCentralServerAddressType, strCentralServerAddress ); // For the slave server, the slave server properties are stored in the // very first item in the server list (which is actually no server list @@ -607,17 +578,14 @@ void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister ) // Note that we always have to parse the server address again since if // it is an URL of a dynamic IP address, the IP address might have // changed in the meanwhile. - if ( NetworkUtil().ParseNetworkAddress ( strCurCentrServAddr, - SlaveCurCentServerHostAddress ) ) + if ( NetworkUtil().ParseNetworkAddress ( strCurCentrServAddr, SlaveCurCentServerHostAddress ) ) { if ( bIsRegister ) { // register server - SetSvrRegStatus ( SRS_REQUESTED ); + SetSvrRegStatus ( SRS_REQUESTED ); - pConnLessProtocol->CreateCLRegisterServerExMes ( SlaveCurCentServerHostAddress, - SlaveCurLocalHostAddress, - ServerList[0] ); + pConnLessProtocol->CreateCLRegisterServerExMes ( SlaveCurCentServerHostAddress, SlaveCurLocalHostAddress, ServerList[0] ); } else { @@ -636,8 +604,7 @@ void CServerListManager::SlaveServerRegisterServer ( const bool bIsRegister ) void CServerListManager::SetSvrRegStatus ( ESvrRegStatus eNSvrRegStatus ) { // output regirstation result/update on the console - qInfo() << qUtf8Printable( QString( "Server Registration Status update: %1" ) - .arg( svrRegStatusToString ( eNSvrRegStatus ) ) ); + qInfo() << qUtf8Printable ( QString ( "Server Registration Status update: %1" ).arg ( svrRegStatusToString ( eNSvrRegStatus ) ) ); // store the state and inform the GUI about the new status eSvrRegStatus = eNSvrRegStatus; diff --git a/src/serverlist.h b/src/serverlist.h old mode 100755 new mode 100644 index 6ce612f310..6e635157b5 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -47,16 +47,16 @@ Note: this mechanism will not work in a private network. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -68,26 +68,18 @@ Note: this mechanism will not work in a private network. #include #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) -# include +#if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 ) +# include #endif #include "global.h" #include "util.h" #include "protocol.h" - /* Classes ********************************************************************/ class CServerListEntry : public CServerInfo { public: - CServerListEntry() : - CServerInfo ( CHostAddress(), - CHostAddress(), - "", - QLocale::AnyCountry, - "", - 0, - false ) { UpdateRegistration(); } + CServerListEntry() : CServerInfo ( CHostAddress(), CHostAddress(), "", QLocale::AnyCountry, "", 0, false ) { UpdateRegistration(); } CServerListEntry ( const CHostAddress& NHAddr, const CHostAddress& NLHAddr, @@ -95,26 +87,23 @@ class CServerListEntry : public CServerInfo const QLocale::Country& NeCountry, const QString& NsCity, const int NiMaxNumClients, - const bool NbPermOnline) - : CServerInfo ( NHAddr, - NLHAddr, - NsName, - NeCountry, - NsCity, - NiMaxNumClients, - NbPermOnline ) { UpdateRegistration(); } - - CServerListEntry ( const CHostAddress& NHAddr, - const CHostAddress& NLHAddr, - const CServerCoreInfo& NewCoreServerInfo ) - : CServerInfo ( NHAddr, - NLHAddr, - NewCoreServerInfo.strName, - NewCoreServerInfo.eCountry, - NewCoreServerInfo.strCity, - NewCoreServerInfo.iMaxNumClients, - NewCoreServerInfo.bPermanentOnline ) - { UpdateRegistration(); } + const bool NbPermOnline ) : + CServerInfo ( NHAddr, NLHAddr, NsName, NeCountry, NsCity, NiMaxNumClients, NbPermOnline ) + { + UpdateRegistration(); + } + + CServerListEntry ( const CHostAddress& NHAddr, const CHostAddress& NLHAddr, const CServerCoreInfo& NewCoreServerInfo ) : + CServerInfo ( NHAddr, + NLHAddr, + NewCoreServerInfo.strName, + NewCoreServerInfo.eCountry, + NewCoreServerInfo.strCity, + NewCoreServerInfo.iMaxNumClients, + NewCoreServerInfo.bPermanentOnline ) + { + UpdateRegistration(); + } void UpdateRegistration() { RegisterTime.start(); } @@ -143,10 +132,10 @@ class CServerListManager : public QObject void SetEnabled ( const bool bState ) { bEnabled = bState; } bool GetEnabled() const { return bEnabled; } - void SetCentralServerAddress ( const QString sNCentServAddr ); + void SetCentralServerAddress ( const QString sNCentServAddr ); QString GetCentralServerAddress() { return strCentralServerAddress; } - void SetCentralServerAddressType ( const ECSAddType eNCSAT ); + void SetCentralServerAddressType ( const ECSAddType eNCSAT ); ECSAddType GetCentralServerAddressType() { return eCentralServerAddressType; } bool GetIsCentralServer() const { return bIsCentralServer; } @@ -165,18 +154,15 @@ class CServerListManager : public QObject // set server infos -> per definition the server info of this server is // stored in the first entry of the list, we assume here that the first // entry is correctly created in the constructor of the class - void SetServerName ( const QString& strNewName ) - { ServerList[0].strName = strNewName; } + void SetServerName ( const QString& strNewName ) { ServerList[0].strName = strNewName; } QString GetServerName() { return ServerList[0].strName; } - void SetServerCity ( const QString& strNewCity ) - { ServerList[0].strCity = strNewCity; } + void SetServerCity ( const QString& strNewCity ) { ServerList[0].strCity = strNewCity; } QString GetServerCity() { return ServerList[0].strCity; } - void SetServerCountry ( const QLocale::Country eNewCountry ) - { ServerList[0].eCountry = eNewCountry; } + void SetServerCountry ( const QLocale::Country eNewCountry ) { ServerList[0].eCountry = eNewCountry; } QLocale::Country GetServerCountry() { return ServerList[0].eCountry; } @@ -188,34 +174,34 @@ class CServerListManager : public QObject void SlaveServerRegisterServer ( const bool bIsRegister ); void SetSvrRegStatus ( ESvrRegStatus eNSvrRegStatus ); - QTimer TimerPollList; - QTimer TimerRegistering; - QTimer TimerPingServerInList; - QTimer TimerPingCentralServer; - QTimer TimerCLRegisterServerResp; + QTimer TimerPollList; + QTimer TimerRegistering; + QTimer TimerPingServerInList; + QTimer TimerPingCentralServer; + QTimer TimerCLRegisterServerResp; - QMutex Mutex; + QMutex Mutex; QList ServerList; - QString strCentralServerAddress; - bool bEnabled; - bool bIsCentralServer; - ECSAddType eCentralServerAddressType; + QString strCentralServerAddress; + bool bEnabled; + bool bIsCentralServer; + ECSAddType eCentralServerAddressType; - CHostAddress SlaveCurCentServerHostAddress; - CHostAddress SlaveCurLocalHostAddress; + CHostAddress SlaveCurCentServerHostAddress; + CHostAddress SlaveCurLocalHostAddress; - QList vWhiteList; - QString strMinServerVersion; + QList vWhiteList; + QString strMinServerVersion; - CProtocol* pConnLessProtocol; + CProtocol* pConnLessProtocol; // server registration status - ESvrRegStatus eSvrRegStatus; + ESvrRegStatus eSvrRegStatus; // count of registration retries - int iSvrRegRetries; + int iSvrRegRetries; public slots: void OnTimerPollList(); diff --git a/src/serverlogging.cpp b/src/serverlogging.cpp old mode 100755 new mode 100644 index 9867b80128..094f236c04 --- a/src/serverlogging.cpp +++ b/src/serverlogging.cpp @@ -45,24 +45,23 @@ void CServerLogging::Start ( const QString& strLoggingFileName ) } } -void CServerLogging::AddNewConnection ( const QHostAddress& ClientInetAddr, - const int iNumberOfConnectedClients ) +void CServerLogging::AddNewConnection ( const QHostAddress& ClientInetAddr, const int iNumberOfConnectedClients ) { // logging of new connected channel - const QString strLogStr = CurTimeDatetoLogString() + ", " + - ClientInetAddr.toString() + ", connected (" + QString::number ( iNumberOfConnectedClients ) + ")"; + const QString strLogStr = + CurTimeDatetoLogString() + ", " + ClientInetAddr.toString() + ", connected (" + QString::number ( iNumberOfConnectedClients ) + ")"; - qInfo() << qUtf8Printable( strLogStr ); // on console - *this << strLogStr; // in log file + qInfo() << qUtf8Printable ( strLogStr ); // on console + *this << strLogStr; // in log file } void CServerLogging::AddServerStopped() { const QString strLogStr = CurTimeDatetoLogString() + ",, server idling " - "-------------------------------------"; + "-------------------------------------"; - qInfo() << qUtf8Printable( strLogStr ); // on console - *this << strLogStr; // in log file + qInfo() << qUtf8Printable ( strLogStr ); // on console + *this << strLogStr; // in log file } void CServerLogging::operator<< ( const QString& sNewStr ) @@ -82,5 +81,5 @@ QString CServerLogging::CurTimeDatetoLogString() const QDateTime curDateTime = QDateTime::currentDateTime(); // format date and time output according to "2006-09-30 11:38:08" - return curDateTime.toString("yyyy-MM-dd HH:mm:ss"); + return curDateTime.toString ( "yyyy-MM-dd HH:mm:ss" ); } diff --git a/src/serverlogging.h b/src/serverlogging.h old mode 100755 new mode 100644 index 749d0e848a..acf573e088 --- a/src/serverlogging.h +++ b/src/serverlogging.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -32,25 +32,21 @@ #include "global.h" #include "util.h" - /* Classes ********************************************************************/ class CServerLogging { public: - CServerLogging() : - bDoLogging ( false ), - File ( DEFAULT_LOG_FILE_NAME ) {} + CServerLogging() : bDoLogging ( false ), File ( DEFAULT_LOG_FILE_NAME ) {} virtual ~CServerLogging(); void Start ( const QString& strLoggingFileName ); void AddServerStopped(); - void AddNewConnection ( const QHostAddress& ClientInetAddr, - const int iNumberOfConnectedClients ); + void AddNewConnection ( const QHostAddress& ClientInetAddr, const int iNumberOfConnectedClients ); protected: - void operator<< ( const QString& sNewStr ); + void operator<< ( const QString& sNewStr ); QString CurTimeDatetoLogString(); bool bDoLogging; diff --git a/src/settings.cpp b/src/settings.cpp old mode 100755 new mode 100644 index 61cba7fbff..41da81b5f0 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -8,7 +8,7 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT @@ -24,7 +24,6 @@ #include "settings.h" - /* Implementation *************************************************************/ void CSettings::Load ( const QList CommandLineOptions ) { @@ -50,8 +49,7 @@ void CSettings::Save() WriteToFile ( strFileName, IniXMLDocument ); } -void CSettings::ReadFromFile ( const QString& strCurFileName, - QDomDocument& XMLDocument ) +void CSettings::ReadFromFile ( const QString& strCurFileName, QDomDocument& XMLDocument ) { QFile file ( strCurFileName ); @@ -62,8 +60,7 @@ void CSettings::ReadFromFile ( const QString& strCurFileName, } } -void CSettings::WriteToFile ( const QString& strCurFileName, - const QDomDocument& XMLDocument ) +void CSettings::WriteToFile ( const QString& strCurFileName, const QDomDocument& XMLDocument ) { QFile file ( strCurFileName ); @@ -74,8 +71,7 @@ void CSettings::WriteToFile ( const QString& strCurFileName, } } -void CSettings::SetFileName ( const QString& sNFiName, - const QString& sDefaultFileName ) +void CSettings::SetFileName ( const QString& sNFiName, const QString& sDefaultFileName ) { // return the file name with complete path, take care if given file name is empty strFileName = sNFiName; @@ -84,10 +80,8 @@ void CSettings::SetFileName ( const QString& sNFiName, { // we use the Qt default setting file paths for the different OSs by // utilizing the QSettings class - const QString sConfigDir = QFileInfo ( QSettings ( QSettings::IniFormat, - QSettings::UserScope, - APP_NAME, - APP_NAME ).fileName() ).absolutePath(); + const QString sConfigDir = + QFileInfo ( QSettings ( QSettings::IniFormat, QSettings::UserScope, APP_NAME, APP_NAME ).fileName() ).absolutePath(); // make sure the directory exists if ( !QFile::exists ( sConfigDir ) ) @@ -100,10 +94,7 @@ void CSettings::SetFileName ( const QString& sNFiName, } } -void CSettings::SetNumericIniSet ( QDomDocument& xmlFile, - const QString& strSection, - const QString& strKey, - const int iValue ) +void CSettings::SetNumericIniSet ( QDomDocument& xmlFile, const QString& strSection, const QString& strKey, const int iValue ) { // convert input parameter which is an integer to string and store PutIniSetting ( xmlFile, strSection, strKey, QString::number ( iValue ) ); @@ -137,19 +128,13 @@ bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile, return bReturn; } -void CSettings::SetFlagIniSet ( QDomDocument& xmlFile, - const QString& strSection, - const QString& strKey, - const bool bValue ) +void CSettings::SetFlagIniSet ( QDomDocument& xmlFile, const QString& strSection, const QString& strKey, const bool bValue ) { // we encode true -> "1" and false -> "0" PutIniSetting ( xmlFile, strSection, strKey, bValue ? "1" : "0" ); } -bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile, - const QString& strSection, - const QString& strKey, - bool& bValue ) +bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile, const QString& strSection, const QString& strKey, bool& bValue ) { // init return value bool bReturn = false; @@ -165,12 +150,8 @@ bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile, return bReturn; } - // Init-file routines using XML *********************************************** -QString CSettings::GetIniSetting ( const QDomDocument& xmlFile, - const QString& sSection, - const QString& sKey, - const QString& sDefaultVal ) +QString CSettings::GetIniSetting ( const QDomDocument& xmlFile, const QString& sSection, const QString& sKey, const QString& sDefaultVal ) { // init return parameter with default value QString sResult ( sDefaultVal ); @@ -193,10 +174,7 @@ QString CSettings::GetIniSetting ( const QDomDocument& xmlFile, return sResult; } -void CSettings::PutIniSetting ( QDomDocument& xmlFile, - const QString& sSection, - const QString& sKey, - const QString& sValue ) +void CSettings::PutIniSetting ( QDomDocument& xmlFile, const QString& sSection, const QString& sKey, const QString& sValue ) { // check if section is already there, if not then create it QDomElement xmlSection = xmlFile.firstChildElement ( sSection ); @@ -222,7 +200,6 @@ void CSettings::PutIniSetting ( QDomDocument& xmlFile, xmlKey.appendChild ( currentValue ); } - // Client settings ------------------------------------------------------------- void CClientSettings::LoadFaderSettings ( const QString& strCurFileName ) { @@ -248,8 +225,7 @@ void CClientSettings::SaveFaderSettings ( const QString& strCurFileName ) WriteToFile ( strCurFileName, IniXMLDocument ); } -void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, - const QList& ) +void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, const QList& ) { int iIdx; int iValue; @@ -258,21 +234,17 @@ void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument // IP addresses for ( iIdx = 0; iIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIdx++ ) { - vstrIPAddress[iIdx] = - GetIniSetting ( IniXMLDocument, "client", - QString ( "ipaddress%1" ).arg ( iIdx ), "" ); + vstrIPAddress[iIdx] = GetIniSetting ( IniXMLDocument, "client", QString ( "ipaddress%1" ).arg ( iIdx ), "" ); } // new client level - if ( GetNumericIniSet ( IniXMLDocument, "client", "newclientlevel", - 0, 100, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "newclientlevel", 0, 100, iValue ) ) { iNewClientFaderLevel = iValue; } // input boost - if ( GetNumericIniSet ( IniXMLDocument, "client", "inputboost", - 1, 10, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "inputboost", 1, 10, iValue ) ) { iInputBoost = iValue; } @@ -289,38 +261,33 @@ void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument } // language - strLanguage = GetIniSetting ( IniXMLDocument, "client", "language", - CLocale::FindSysLangTransFileName ( CLocale::GetAvailableTranslations() ).first ); + strLanguage = + GetIniSetting ( IniXMLDocument, "client", "language", CLocale::FindSysLangTransFileName ( CLocale::GetAvailableTranslations() ).first ); // fader channel sorting - if ( GetNumericIniSet ( IniXMLDocument, "client", "channelsort", - 0, 4 /* ST_BY_CITY */, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "channelsort", 0, 4 /* ST_BY_CITY */, iValue ) ) { eChannelSortType = static_cast ( iValue ); } // number of mixer panel rows - if ( GetNumericIniSet ( IniXMLDocument, "client", "numrowsmixpan", - 1, 8, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "numrowsmixpan", 1, 8, iValue ) ) { iNumMixerPanelRows = iValue; } // name pClient->ChannelInfo.strName = FromBase64ToString ( - GetIniSetting ( IniXMLDocument, "client", "name_base64", - ToBase64 ( QCoreApplication::translate ( "CMusProfDlg", "No Name" ) ) ) ); + GetIniSetting ( IniXMLDocument, "client", "name_base64", ToBase64 ( QCoreApplication::translate ( "CMusProfDlg", "No Name" ) ) ) ); // instrument - if ( GetNumericIniSet ( IniXMLDocument, "client", "instrument", - 0, CInstPictures::GetNumAvailableInst() - 1, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "instrument", 0, CInstPictures::GetNumAvailableInst() - 1, iValue ) ) { pClient->ChannelInfo.iInstrument = iValue; } // country - if ( GetNumericIniSet ( IniXMLDocument, "client", "country", - 0, static_cast ( QLocale::LastCountry ), iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "country", 0, static_cast ( QLocale::LastCountry ), iValue ) ) { pClient->ChannelInfo.eCountry = static_cast ( iValue ); } @@ -331,26 +298,22 @@ void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument } // city - pClient->ChannelInfo.strCity = FromBase64ToString ( - GetIniSetting ( IniXMLDocument, "client", "city_base64" ) ); + pClient->ChannelInfo.strCity = FromBase64ToString ( GetIniSetting ( IniXMLDocument, "client", "city_base64" ) ); // skill level - if ( GetNumericIniSet ( IniXMLDocument, "client", "skill", - 0, 3 /* SL_PROFESSIONAL */, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "skill", 0, 3 /* SL_PROFESSIONAL */, iValue ) ) { pClient->ChannelInfo.eSkillLevel = static_cast ( iValue ); } // audio fader - if ( GetNumericIniSet ( IniXMLDocument, "client", "audfad", - AUD_FADER_IN_MIN, AUD_FADER_IN_MAX, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "audfad", AUD_FADER_IN_MIN, AUD_FADER_IN_MAX, iValue ) ) { pClient->SetAudioInFader ( iValue ); } // reverberation level - if ( GetNumericIniSet ( IniXMLDocument, "client", "revlev", - 0, AUD_REVERB_MAX, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "revlev", 0, AUD_REVERB_MAX, iValue ) ) { pClient->SetReverbLevel ( iValue ); } @@ -378,42 +341,35 @@ void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument // overwritten by the defaults // // sound card left input channel mapping - if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdinlch", - 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdinlch", 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) { pClient->SetSndCrdLeftInputChannel ( iValue ); } // sound card right input channel mapping - if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdinrch", - 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdinrch", 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) { pClient->SetSndCrdRightInputChannel ( iValue ); } // sound card left output channel mapping - if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutlch", - 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutlch", 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) { pClient->SetSndCrdLeftOutputChannel ( iValue ); } // sound card right output channel mapping - if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutrch", - 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutrch", 0, MAX_NUM_IN_OUT_CHANNELS - 1, iValue ) ) { pClient->SetSndCrdRightOutputChannel ( iValue ); } // sound card preferred buffer size index - if ( GetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx", - FRAME_SIZE_FACTOR_PREFERRED, FRAME_SIZE_FACTOR_SAFE, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx", FRAME_SIZE_FACTOR_PREFERRED, FRAME_SIZE_FACTOR_SAFE, iValue ) ) { // additional check required since only a subset of factors are // defined - if ( ( iValue == FRAME_SIZE_FACTOR_PREFERRED ) || - ( iValue == FRAME_SIZE_FACTOR_DEFAULT ) || - ( iValue == FRAME_SIZE_FACTOR_SAFE ) ) + if ( ( iValue == FRAME_SIZE_FACTOR_PREFERRED ) || ( iValue == FRAME_SIZE_FACTOR_DEFAULT ) || ( iValue == FRAME_SIZE_FACTOR_SAFE ) ) { pClient->SetSndCrdPrefFrameSizeFactor ( iValue ); } @@ -426,15 +382,13 @@ void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument } // network jitter buffer size - if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbuf", - MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbuf", MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL, iValue ) ) { pClient->SetSockBufNumFrames ( iValue ); } // network jitter buffer size for server - if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbufserver", - MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbufserver", MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL, iValue ) ) { pClient->SetServerSockBufNumFrames ( iValue ); } @@ -446,37 +400,33 @@ void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument } // GUI design - if ( GetNumericIniSet ( IniXMLDocument, "client", "guidesign", - 0, 2 /* GD_SLIMFADER */, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "guidesign", 0, 2 /* GD_SLIMFADER */, iValue ) ) { pClient->SetGUIDesign ( static_cast ( iValue ) ); } // audio channels - if ( GetNumericIniSet ( IniXMLDocument, "client", "audiochannels", - 0, 2 /* CC_STEREO */, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "audiochannels", 0, 2 /* CC_STEREO */, iValue ) ) { pClient->SetAudioChannels ( static_cast ( iValue ) ); } // audio quality - if ( GetNumericIniSet ( IniXMLDocument, "client", "audioquality", - 0, 2 /* AQ_HIGH */, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "audioquality", 0, 2 /* AQ_HIGH */, iValue ) ) { pClient->SetAudioQuality ( static_cast ( iValue ) ); } -// clang-format off + // clang-format off // TODO compatibility to old version (< 3.6.1) // NOTE that the strCurAddr and "check for empty" can be removed if compatibility mode is removed vstrCentralServerAddress[0] = GetIniSetting ( IniXMLDocument, "client", "centralservaddr" ); -// clang-format on + // clang-format on // directory server addresses for ( iIdx = 0; iIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIdx++ ) { - const QString strCurAddr = GetIniSetting ( IniXMLDocument, "client", - QString ( "centralservaddr%1" ).arg ( iIdx ), "" ); + const QString strCurAddr = GetIniSetting ( IniXMLDocument, "client", QString ( "centralservaddr%1" ).arg ( iIdx ), "" ); if ( !strCurAddr.isEmpty() ) { @@ -485,8 +435,7 @@ vstrCentralServerAddress[0] = GetIniSetting ( IniXMLDocument, "client", "central } // directory server address type - if ( GetNumericIniSet ( IniXMLDocument, "client", "centservaddrtype", - 0, static_cast ( AT_CUSTOM ), iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "centservaddrtype", 0, static_cast ( AT_CUSTOM ), iValue ) ) { eCentralServerAddressType = static_cast ( iValue ); } @@ -496,7 +445,7 @@ vstrCentralServerAddress[0] = GetIniSetting ( IniXMLDocument, "client", "central eCentralServerAddressType = AT_DEFAULT; } -// clang-format off + // clang-format off // TODO compatibility to old version (<3.4.7) if ( GetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr", bValue ) ) { @@ -506,23 +455,19 @@ if ( GetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr", bValue ) ) eCentralServerAddressType = AT_CUSTOM; } } -// clang-format on + // clang-format on // window position of the main window - vecWindowPosMain = FromBase64ToByteArray ( - GetIniSetting ( IniXMLDocument, "client", "winposmain_base64" ) ); + vecWindowPosMain = FromBase64ToByteArray ( GetIniSetting ( IniXMLDocument, "client", "winposmain_base64" ) ); // window position of the settings window - vecWindowPosSettings = FromBase64ToByteArray ( - GetIniSetting ( IniXMLDocument, "client", "winposset_base64" ) ); + vecWindowPosSettings = FromBase64ToByteArray ( GetIniSetting ( IniXMLDocument, "client", "winposset_base64" ) ); // window position of the chat window - vecWindowPosChat = FromBase64ToByteArray ( - GetIniSetting ( IniXMLDocument, "client", "winposchat_base64" ) ); + vecWindowPosChat = FromBase64ToByteArray ( GetIniSetting ( IniXMLDocument, "client", "winposchat_base64" ) ); // window position of the connect window - vecWindowPosConnect = FromBase64ToByteArray ( - GetIniSetting ( IniXMLDocument, "client", "winposcon_base64" ) ); + vecWindowPosConnect = FromBase64ToByteArray ( GetIniSetting ( IniXMLDocument, "client", "winposcon_base64" ) ); // visibility state of the settings window if ( GetFlagIniSet ( IniXMLDocument, "client", "winvisset", bValue ) ) @@ -543,8 +488,7 @@ if ( GetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr", bValue ) ) } // selected Settings Tab - if ( GetNumericIniSet ( IniXMLDocument, "client", "settingstab", - 0, 2, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", "settingstab", 0, 2, iValue ) ) { iSettingsTab = iValue; } @@ -562,46 +506,40 @@ void CClientSettings::ReadFaderSettingsFromXML ( const QDomDocument& IniXMLDocum for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_SETTINGS; iIdx++ ) { // stored fader tags - vecStoredFaderTags[iIdx] = FromBase64ToString ( - GetIniSetting ( IniXMLDocument, "client", - QString ( "storedfadertag%1_base64" ).arg ( iIdx ), "" ) ); + vecStoredFaderTags[iIdx] = + FromBase64ToString ( GetIniSetting ( IniXMLDocument, "client", QString ( "storedfadertag%1_base64" ).arg ( iIdx ), "" ) ); // stored fader levels - if ( GetNumericIniSet ( IniXMLDocument, "client", - QString ( "storedfaderlevel%1" ).arg ( iIdx ), - 0, AUD_MIX_FADER_MAX, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", QString ( "storedfaderlevel%1" ).arg ( iIdx ), 0, AUD_MIX_FADER_MAX, iValue ) ) { vecStoredFaderLevels[iIdx] = iValue; } // stored pan values - if ( GetNumericIniSet ( IniXMLDocument, "client", - QString ( "storedpanvalue%1" ).arg ( iIdx ), - 0, AUD_MIX_PAN_MAX, iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "client", QString ( "storedpanvalue%1" ).arg ( iIdx ), 0, AUD_MIX_PAN_MAX, iValue ) ) { vecStoredPanValues[iIdx] = iValue; } // stored fader solo state - if ( GetFlagIniSet ( IniXMLDocument, "client", - QString ( "storedfaderissolo%1" ).arg ( iIdx ), - bValue ) ) + if ( GetFlagIniSet ( IniXMLDocument, "client", QString ( "storedfaderissolo%1" ).arg ( iIdx ), bValue ) ) { vecStoredFaderIsSolo[iIdx] = bValue; } // stored fader muted state - if ( GetFlagIniSet ( IniXMLDocument, "client", - QString ( "storedfaderismute%1" ).arg ( iIdx ), - bValue ) ) + if ( GetFlagIniSet ( IniXMLDocument, "client", QString ( "storedfaderismute%1" ).arg ( iIdx ), bValue ) ) { vecStoredFaderIsMute[iIdx] = bValue; } // stored fader group ID - if ( GetNumericIniSet ( IniXMLDocument, "client", + if ( GetNumericIniSet ( IniXMLDocument, + "client", QString ( "storedgroupid%1" ).arg ( iIdx ), - INVALID_INDEX, MAX_NUM_FADER_GROUPS - 1, iValue ) ) + INVALID_INDEX, + MAX_NUM_FADER_GROUPS - 1, + iValue ) ) { vecStoredFaderGroupID[iIdx] = iValue; } @@ -615,166 +553,125 @@ void CClientSettings::WriteSettingsToXML ( QDomDocument& IniXMLDocument ) // IP addresses for ( iIdx = 0; iIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIdx++ ) { - PutIniSetting ( IniXMLDocument, "client", - QString ( "ipaddress%1" ).arg ( iIdx ), - vstrIPAddress[iIdx] ); + PutIniSetting ( IniXMLDocument, "client", QString ( "ipaddress%1" ).arg ( iIdx ), vstrIPAddress[iIdx] ); } // new client level - SetNumericIniSet ( IniXMLDocument, "client", "newclientlevel", - iNewClientFaderLevel ); + SetNumericIniSet ( IniXMLDocument, "client", "newclientlevel", iNewClientFaderLevel ); // input boost - SetNumericIniSet ( IniXMLDocument, "client", "inputboost", - iInputBoost ); + SetNumericIniSet ( IniXMLDocument, "client", "inputboost", iInputBoost ); // feedback detection - SetFlagIniSet ( IniXMLDocument, "client", "enablefeedbackdetection", - bEnableFeedbackDetection ); + SetFlagIniSet ( IniXMLDocument, "client", "enablefeedbackdetection", bEnableFeedbackDetection ); // connect dialog show all musicians - SetFlagIniSet ( IniXMLDocument, "client", "connectdlgshowallmusicians", - bConnectDlgShowAllMusicians ); + SetFlagIniSet ( IniXMLDocument, "client", "connectdlgshowallmusicians", bConnectDlgShowAllMusicians ); // language - PutIniSetting ( IniXMLDocument, "client", "language", - strLanguage ); + PutIniSetting ( IniXMLDocument, "client", "language", strLanguage ); // fader channel sorting - SetNumericIniSet ( IniXMLDocument, "client", "channelsort", - static_cast ( eChannelSortType ) ); + SetNumericIniSet ( IniXMLDocument, "client", "channelsort", static_cast ( eChannelSortType ) ); // number of mixer panel rows - SetNumericIniSet ( IniXMLDocument, "client", "numrowsmixpan", - iNumMixerPanelRows ); + SetNumericIniSet ( IniXMLDocument, "client", "numrowsmixpan", iNumMixerPanelRows ); // name - PutIniSetting ( IniXMLDocument, "client", "name_base64", - ToBase64 ( pClient->ChannelInfo.strName ) ); + PutIniSetting ( IniXMLDocument, "client", "name_base64", ToBase64 ( pClient->ChannelInfo.strName ) ); // instrument - SetNumericIniSet ( IniXMLDocument, "client", "instrument", - pClient->ChannelInfo.iInstrument ); + SetNumericIniSet ( IniXMLDocument, "client", "instrument", pClient->ChannelInfo.iInstrument ); // country - SetNumericIniSet ( IniXMLDocument, "client", "country", - static_cast ( pClient->ChannelInfo.eCountry ) ); + SetNumericIniSet ( IniXMLDocument, "client", "country", static_cast ( pClient->ChannelInfo.eCountry ) ); // city - PutIniSetting ( IniXMLDocument, "client", "city_base64", - ToBase64 ( pClient->ChannelInfo.strCity ) ); + PutIniSetting ( IniXMLDocument, "client", "city_base64", ToBase64 ( pClient->ChannelInfo.strCity ) ); // skill level - SetNumericIniSet ( IniXMLDocument, "client", "skill", - static_cast ( pClient->ChannelInfo.eSkillLevel ) ); + SetNumericIniSet ( IniXMLDocument, "client", "skill", static_cast ( pClient->ChannelInfo.eSkillLevel ) ); // audio fader - SetNumericIniSet ( IniXMLDocument, "client", "audfad", - pClient->GetAudioInFader() ); + SetNumericIniSet ( IniXMLDocument, "client", "audfad", pClient->GetAudioInFader() ); // reverberation level - SetNumericIniSet ( IniXMLDocument, "client", "revlev", - pClient->GetReverbLevel() ); + SetNumericIniSet ( IniXMLDocument, "client", "revlev", pClient->GetReverbLevel() ); // reverberation channel assignment - SetFlagIniSet ( IniXMLDocument, "client", "reverblchan", - pClient->IsReverbOnLeftChan() ); + SetFlagIniSet ( IniXMLDocument, "client", "reverblchan", pClient->IsReverbOnLeftChan() ); // sound card selection - PutIniSetting ( IniXMLDocument, "client", "auddev_base64", - ToBase64 ( pClient->GetSndCrdDev() ) ); + PutIniSetting ( IniXMLDocument, "client", "auddev_base64", ToBase64 ( pClient->GetSndCrdDev() ) ); // sound card left input channel mapping - SetNumericIniSet ( IniXMLDocument, "client", "sndcrdinlch", - pClient->GetSndCrdLeftInputChannel() ); + SetNumericIniSet ( IniXMLDocument, "client", "sndcrdinlch", pClient->GetSndCrdLeftInputChannel() ); // sound card right input channel mapping - SetNumericIniSet ( IniXMLDocument, "client", "sndcrdinrch", - pClient->GetSndCrdRightInputChannel() ); + SetNumericIniSet ( IniXMLDocument, "client", "sndcrdinrch", pClient->GetSndCrdRightInputChannel() ); // sound card left output channel mapping - SetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutlch", - pClient->GetSndCrdLeftOutputChannel() ); + SetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutlch", pClient->GetSndCrdLeftOutputChannel() ); // sound card right output channel mapping - SetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutrch", - pClient->GetSndCrdRightOutputChannel() ); + SetNumericIniSet ( IniXMLDocument, "client", "sndcrdoutrch", pClient->GetSndCrdRightOutputChannel() ); // sound card preferred buffer size index - SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx", - pClient->GetSndCrdPrefFrameSizeFactor() ); + SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx", pClient->GetSndCrdPrefFrameSizeFactor() ); // automatic network jitter buffer size setting - SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", - pClient->GetDoAutoSockBufSize() ); + SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", pClient->GetDoAutoSockBufSize() ); // network jitter buffer size - SetNumericIniSet ( IniXMLDocument, "client", "jitbuf", - pClient->GetSockBufNumFrames() ); + SetNumericIniSet ( IniXMLDocument, "client", "jitbuf", pClient->GetSockBufNumFrames() ); // network jitter buffer size for server - SetNumericIniSet ( IniXMLDocument, "client", "jitbufserver", - pClient->GetServerSockBufNumFrames() ); + SetNumericIniSet ( IniXMLDocument, "client", "jitbufserver", pClient->GetServerSockBufNumFrames() ); // enable OPUS64 setting - SetFlagIniSet ( IniXMLDocument, "client", "enableopussmall", - pClient->GetEnableOPUS64() ); + SetFlagIniSet ( IniXMLDocument, "client", "enableopussmall", pClient->GetEnableOPUS64() ); // GUI design - SetNumericIniSet ( IniXMLDocument, "client", "guidesign", - static_cast ( pClient->GetGUIDesign() ) ); + SetNumericIniSet ( IniXMLDocument, "client", "guidesign", static_cast ( pClient->GetGUIDesign() ) ); // audio channels - SetNumericIniSet ( IniXMLDocument, "client", "audiochannels", - static_cast ( pClient->GetAudioChannels() ) ); + SetNumericIniSet ( IniXMLDocument, "client", "audiochannels", static_cast ( pClient->GetAudioChannels() ) ); // audio quality - SetNumericIniSet ( IniXMLDocument, "client", "audioquality", - static_cast ( pClient->GetAudioQuality() ) ); + SetNumericIniSet ( IniXMLDocument, "client", "audioquality", static_cast ( pClient->GetAudioQuality() ) ); // directory server addresses for ( iIdx = 0; iIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIdx++ ) { - PutIniSetting ( IniXMLDocument, "client", - QString ( "centralservaddr%1" ).arg ( iIdx ), - vstrCentralServerAddress[iIdx] ); + PutIniSetting ( IniXMLDocument, "client", QString ( "centralservaddr%1" ).arg ( iIdx ), vstrCentralServerAddress[iIdx] ); } // directory server address type - SetNumericIniSet ( IniXMLDocument, "client", "centservaddrtype", - static_cast ( eCentralServerAddressType ) ); + SetNumericIniSet ( IniXMLDocument, "client", "centservaddrtype", static_cast ( eCentralServerAddressType ) ); // window position of the main window - PutIniSetting ( IniXMLDocument, "client", "winposmain_base64", - ToBase64 ( vecWindowPosMain ) ); + PutIniSetting ( IniXMLDocument, "client", "winposmain_base64", ToBase64 ( vecWindowPosMain ) ); // window position of the settings window - PutIniSetting ( IniXMLDocument, "client", "winposset_base64", - ToBase64 ( vecWindowPosSettings ) ); + PutIniSetting ( IniXMLDocument, "client", "winposset_base64", ToBase64 ( vecWindowPosSettings ) ); // window position of the chat window - PutIniSetting ( IniXMLDocument, "client", "winposchat_base64", - ToBase64 ( vecWindowPosChat ) ); + PutIniSetting ( IniXMLDocument, "client", "winposchat_base64", ToBase64 ( vecWindowPosChat ) ); // window position of the connect window - PutIniSetting ( IniXMLDocument, "client", "winposcon_base64", - ToBase64 ( vecWindowPosConnect ) ); + PutIniSetting ( IniXMLDocument, "client", "winposcon_base64", ToBase64 ( vecWindowPosConnect ) ); // visibility state of the settings window - SetFlagIniSet ( IniXMLDocument, "client", "winvisset", - bWindowWasShownSettings ); + SetFlagIniSet ( IniXMLDocument, "client", "winvisset", bWindowWasShownSettings ); // visibility state of the chat window - SetFlagIniSet ( IniXMLDocument, "client", "winvischat", - bWindowWasShownChat ); + SetFlagIniSet ( IniXMLDocument, "client", "winvischat", bWindowWasShownChat ); // visibility state of the connect window - SetFlagIniSet ( IniXMLDocument, "client", "winviscon", - bWindowWasShownConnect ); + SetFlagIniSet ( IniXMLDocument, "client", "winviscon", bWindowWasShownConnect ); // Settings Tab - SetNumericIniSet ( IniXMLDocument, "client", "settingstab", - iSettingsTab ); + SetNumericIniSet ( IniXMLDocument, "client", "settingstab", iSettingsTab ); // fader settings WriteFaderSettingsToXML ( IniXMLDocument ); @@ -787,49 +684,34 @@ void CClientSettings::WriteFaderSettingsToXML ( QDomDocument& IniXMLDocument ) for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_SETTINGS; iIdx++ ) { // stored fader tags - PutIniSetting ( IniXMLDocument, "client", - QString ( "storedfadertag%1_base64" ).arg ( iIdx ), - ToBase64 ( vecStoredFaderTags[iIdx] ) ); + PutIniSetting ( IniXMLDocument, "client", QString ( "storedfadertag%1_base64" ).arg ( iIdx ), ToBase64 ( vecStoredFaderTags[iIdx] ) ); // stored fader levels - SetNumericIniSet ( IniXMLDocument, "client", - QString ( "storedfaderlevel%1" ).arg ( iIdx ), - vecStoredFaderLevels[iIdx] ); + SetNumericIniSet ( IniXMLDocument, "client", QString ( "storedfaderlevel%1" ).arg ( iIdx ), vecStoredFaderLevels[iIdx] ); // stored pan values - SetNumericIniSet ( IniXMLDocument, "client", - QString ( "storedpanvalue%1" ).arg ( iIdx ), - vecStoredPanValues[iIdx] ); + SetNumericIniSet ( IniXMLDocument, "client", QString ( "storedpanvalue%1" ).arg ( iIdx ), vecStoredPanValues[iIdx] ); // stored fader solo states - SetFlagIniSet ( IniXMLDocument, "client", - QString ( "storedfaderissolo%1" ).arg ( iIdx ), - vecStoredFaderIsSolo[iIdx] != 0 ); + SetFlagIniSet ( IniXMLDocument, "client", QString ( "storedfaderissolo%1" ).arg ( iIdx ), vecStoredFaderIsSolo[iIdx] != 0 ); // stored fader muted states - SetFlagIniSet ( IniXMLDocument, "client", - QString ( "storedfaderismute%1" ).arg ( iIdx ), - vecStoredFaderIsMute[iIdx] != 0 ); + SetFlagIniSet ( IniXMLDocument, "client", QString ( "storedfaderismute%1" ).arg ( iIdx ), vecStoredFaderIsMute[iIdx] != 0 ); // stored fader group ID - SetNumericIniSet ( IniXMLDocument, "client", - QString ( "storedgroupid%1" ).arg ( iIdx ), - vecStoredFaderGroupID[iIdx] ); + SetNumericIniSet ( IniXMLDocument, "client", QString ( "storedgroupid%1" ).arg ( iIdx ), vecStoredFaderGroupID[iIdx] ); } } - // Server settings ------------------------------------------------------------- -void CServerSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, - const QList& CommandLineOptions ) +void CServerSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, const QList& CommandLineOptions ) { int iValue; bool bValue; // directory server address type (note that it is important // to set this setting prior to the "directory server address") - if ( GetNumericIniSet ( IniXMLDocument, "server", "centservaddrtype", - 0, static_cast ( AT_CUSTOM ), iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "server", "centservaddrtype", 0, static_cast ( AT_CUSTOM ), iValue ) ) { pServer->SetCentralServerAddressType ( static_cast ( iValue ) ); } @@ -839,7 +721,7 @@ void CServerSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument pServer->SetCentralServerAddressType ( AT_DEFAULT ); } -// clang-format off + // clang-format off // TODO compatibility to old version if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) ) { @@ -849,15 +731,13 @@ if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) ) pServer->SetCentralServerAddressType ( AT_CUSTOM ); } } -// clang-format on + // clang-format on - if ( !CommandLineOptions.contains ( "--centralserver" ) && - !CommandLineOptions.contains ( "--directoryserver" ) ) + if ( !CommandLineOptions.contains ( "--centralserver" ) && !CommandLineOptions.contains ( "--directoryserver" ) ) { // directory server address (to be set after the "use default directory // server" address) - pServer->SetServerListCentralServerAddress ( - GetIniSetting ( IniXMLDocument, "server", "centralservaddr" ) ); + pServer->SetServerListCentralServerAddress ( GetIniSetting ( IniXMLDocument, "server", "centralservaddr" ) ); } // server list enabled flag @@ -867,8 +747,8 @@ if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) ) } // language - strLanguage = GetIniSetting ( IniXMLDocument, "server", "language", - CLocale::FindSysLangTransFileName ( CLocale::GetAvailableTranslations() ).first ); + strLanguage = + GetIniSetting ( IniXMLDocument, "server", "language", CLocale::FindSysLangTransFileName ( CLocale::GetAvailableTranslations() ).first ); // name/city/country if ( !CommandLineOptions.contains ( "--serverinfo" ) ) @@ -880,8 +760,7 @@ if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) ) pServer->SetServerCity ( GetIniSetting ( IniXMLDocument, "server", "city" ) ); // country - if ( GetNumericIniSet ( IniXMLDocument, "server", "country", - 0, static_cast ( QLocale::LastCountry ), iValue ) ) + if ( GetNumericIniSet ( IniXMLDocument, "server", "country", 0, static_cast ( QLocale::LastCountry ), iValue ) ) { pServer->SetServerCountry ( static_cast ( iValue ) ); } @@ -890,10 +769,10 @@ if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) ) // start minimized on OS start if ( !CommandLineOptions.contains ( "--startminimized" ) ) { - if ( GetFlagIniSet ( IniXMLDocument, "server", "autostartmin", bValue ) ) - { - pServer->SetAutoRunMinimized ( bValue ); - } + if ( GetFlagIniSet ( IniXMLDocument, "server", "autostartmin", bValue ) ) + { + pServer->SetAutoRunMinimized ( bValue ); + } } // welcome message @@ -903,8 +782,7 @@ if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) ) } // window position of the main window - vecWindowPosMain = FromBase64ToByteArray ( - GetIniSetting ( IniXMLDocument, "server", "winposmain_base64" ) ); + vecWindowPosMain = FromBase64ToByteArray ( GetIniSetting ( IniXMLDocument, "server", "winposmain_base64" ) ); // base recording directory if ( !CommandLineOptions.contains ( "--recording" ) ) @@ -915,60 +793,48 @@ if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) ) // norecord flag if ( !CommandLineOptions.contains ( "--norecord" ) ) { - if ( GetFlagIniSet ( IniXMLDocument, "server", "norecord", bValue ) ) - { - pServer->SetEnableRecording ( !bValue ); - } + if ( GetFlagIniSet ( IniXMLDocument, "server", "norecord", bValue ) ) + { + pServer->SetEnableRecording ( !bValue ); + } } } void CServerSettings::WriteSettingsToXML ( QDomDocument& IniXMLDocument ) { // directory server address - PutIniSetting ( IniXMLDocument, "server", "centralservaddr", - pServer->GetServerListCentralServerAddress() ); + PutIniSetting ( IniXMLDocument, "server", "centralservaddr", pServer->GetServerListCentralServerAddress() ); // directory server address type - SetNumericIniSet ( IniXMLDocument, "server", "centservaddrtype", - static_cast ( pServer->GetCentralServerAddressType() ) ); + SetNumericIniSet ( IniXMLDocument, "server", "centservaddrtype", static_cast ( pServer->GetCentralServerAddressType() ) ); // server list enabled flag - SetFlagIniSet ( IniXMLDocument, "server", "servlistenabled", - pServer->GetServerListEnabled() ); + SetFlagIniSet ( IniXMLDocument, "server", "servlistenabled", pServer->GetServerListEnabled() ); // language - PutIniSetting ( IniXMLDocument, "server", "language", - strLanguage ); + PutIniSetting ( IniXMLDocument, "server", "language", strLanguage ); // name - PutIniSetting ( IniXMLDocument, "server", "name", - pServer->GetServerName() ); + PutIniSetting ( IniXMLDocument, "server", "name", pServer->GetServerName() ); // city - PutIniSetting ( IniXMLDocument, "server", "city", - pServer->GetServerCity() ); + PutIniSetting ( IniXMLDocument, "server", "city", pServer->GetServerCity() ); // country - SetNumericIniSet ( IniXMLDocument, "server", "country", - static_cast ( pServer->GetServerCountry() ) ); + SetNumericIniSet ( IniXMLDocument, "server", "country", static_cast ( pServer->GetServerCountry() ) ); // start minimized on OS start - SetFlagIniSet ( IniXMLDocument, "server", "autostartmin", - pServer->GetAutoRunMinimized() ); + SetFlagIniSet ( IniXMLDocument, "server", "autostartmin", pServer->GetAutoRunMinimized() ); // welcome message - PutIniSetting ( IniXMLDocument, "server", "welcome", - ToBase64 ( pServer->GetWelcomeMessage() ) ); + PutIniSetting ( IniXMLDocument, "server", "welcome", ToBase64 ( pServer->GetWelcomeMessage() ) ); // window position of the main window - PutIniSetting ( IniXMLDocument, "server", "winposmain_base64", - ToBase64 ( vecWindowPosMain ) ); + PutIniSetting ( IniXMLDocument, "server", "winposmain_base64", ToBase64 ( vecWindowPosMain ) ); // base recording directory - PutIniSetting ( IniXMLDocument, "server", "recordingdir_base64", - ToBase64 ( pServer->GetRecordingDir() ) ); + PutIniSetting ( IniXMLDocument, "server", "recordingdir_base64", ToBase64 ( pServer->GetRecordingDir() ) ); // norecord flag - SetFlagIniSet ( IniXMLDocument, "server", "norecord", - pServer->GetDisableRecording() ); + SetFlagIniSet ( IniXMLDocument, "server", "norecord", pServer->GetDisableRecording() ); } diff --git a/src/settings.h b/src/settings.h old mode 100755 new mode 100644 index 3e5ae1328b..765b6ee115 --- a/src/settings.h +++ b/src/settings.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -29,14 +29,13 @@ #include #include #ifndef HEADLESS -# include +# include #endif #include "global.h" #include "client.h" #include "server.h" #include "util.h" - /* Classes ********************************************************************/ class CSettings : public QObject { @@ -44,12 +43,11 @@ class CSettings : public QObject public: CSettings() : - vecWindowPosMain ( ), // empty array - strLanguage ( "" ), - strFileName ( "" ) + vecWindowPosMain(), // empty array + strLanguage ( "" ), + strFileName ( "" ) { - QObject::connect ( QCoreApplication::instance(), &QCoreApplication::aboutToQuit, - this, &CSettings::OnAboutToQuit ); + QObject::connect ( QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CSettings::OnAboutToQuit ); } void Load ( const QList CommandLineOptions ); @@ -60,18 +58,14 @@ class CSettings : public QObject QString strLanguage; protected: - virtual void WriteSettingsToXML ( QDomDocument& IniXMLDocument ) = 0; - virtual void ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, - const QList& CommandLineOptions ) = 0; + virtual void WriteSettingsToXML ( QDomDocument& IniXMLDocument ) = 0; + virtual void ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, const QList& CommandLineOptions ) = 0; - void ReadFromFile ( const QString& strCurFileName, - QDomDocument& XMLDocument ); + void ReadFromFile ( const QString& strCurFileName, QDomDocument& XMLDocument ); - void WriteToFile ( const QString& strCurFileName, - const QDomDocument& XMLDocument ); + void WriteToFile ( const QString& strCurFileName, const QDomDocument& XMLDocument ); - void SetFileName ( const QString& sNFiName, - const QString& sDefaultFileName ); + void SetFileName ( const QString& sNFiName, const QString& sDefaultFileName ); // The following functions implement the conversion from the general string // to base64 (which should be used for binary data in XML files). This @@ -82,20 +76,13 @@ class CSettings : public QObject // assign the stored value to a QString, this is incorrect but // will not generate a compile error since there is a default // conversion available for QByteArray to QString. - QString ToBase64 ( const QByteArray strIn ) const - { return QString::fromLatin1 ( strIn.toBase64() ); } - QString ToBase64 ( const QString strIn ) const - { return ToBase64 ( strIn.toUtf8() ); } - QByteArray FromBase64ToByteArray ( const QString strIn ) const - { return QByteArray::fromBase64 ( strIn.toLatin1() ); } - QString FromBase64ToString ( const QString strIn ) const - { return QString::fromUtf8 ( FromBase64ToByteArray ( strIn ) ); } + QString ToBase64 ( const QByteArray strIn ) const { return QString::fromLatin1 ( strIn.toBase64() ); } + QString ToBase64 ( const QString strIn ) const { return ToBase64 ( strIn.toUtf8() ); } + QByteArray FromBase64ToByteArray ( const QString strIn ) const { return QByteArray::fromBase64 ( strIn.toLatin1() ); } + QString FromBase64ToString ( const QString strIn ) const { return QString::fromUtf8 ( FromBase64ToByteArray ( strIn ) ); } // init file access function for read/write - void SetNumericIniSet ( QDomDocument& xmlFile, - const QString& strSection, - const QString& strKey, - const int iValue = 0 ); + void SetNumericIniSet ( QDomDocument& xmlFile, const QString& strSection, const QString& strKey, const int iValue = 0 ); bool GetNumericIniSet ( const QDomDocument& xmlFile, const QString& strSection, @@ -104,26 +91,14 @@ class CSettings : public QObject const int iRangeStop, int& iValue ); - void SetFlagIniSet ( QDomDocument& xmlFile, - const QString& strSection, - const QString& strKey, - const bool bValue = false ); + void SetFlagIniSet ( QDomDocument& xmlFile, const QString& strSection, const QString& strKey, const bool bValue = false ); - bool GetFlagIniSet ( const QDomDocument& xmlFile, - const QString& strSection, - const QString& strKey, - bool& bValue ); + bool GetFlagIniSet ( const QDomDocument& xmlFile, const QString& strSection, const QString& strKey, bool& bValue ); // actual working function for init-file access - QString GetIniSetting( const QDomDocument& xmlFile, - const QString& sSection, - const QString& sKey, - const QString& sDefaultVal = "" ); + QString GetIniSetting ( const QDomDocument& xmlFile, const QString& sSection, const QString& sKey, const QString& sDefaultVal = "" ); - void PutIniSetting ( QDomDocument& xmlFile, - const QString& sSection, - const QString& sKey, - const QString& sValue = "" ); + void PutIniSetting ( QDomDocument& xmlFile, const QString& sSection, const QString& sKey, const QString& sValue = "" ); QString strFileName; @@ -131,36 +106,37 @@ public slots: void OnAboutToQuit() { Save(); } }; - class CClientSettings : public CSettings { public: CClientSettings ( CClient* pNCliP, const QString& sNFiName ) : - CSettings ( ), - vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ), - vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ), - vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX / 2 ), - vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ), - vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ), - vecStoredFaderGroupID ( MAX_NUM_STORED_FADER_SETTINGS, INVALID_INDEX ), - vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), - iNewClientFaderLevel ( 100 ), - iInputBoost ( 1 ), - iSettingsTab ( SETTING_TAB_AUDIONET ), + CSettings(), + vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ), + vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ), + vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX / 2 ), + vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ), + vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ), + vecStoredFaderGroupID ( MAX_NUM_STORED_FADER_SETTINGS, INVALID_INDEX ), + vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), + iNewClientFaderLevel ( 100 ), + iInputBoost ( 1 ), + iSettingsTab ( SETTING_TAB_AUDIONET ), bConnectDlgShowAllMusicians ( true ), - eChannelSortType ( ST_NO_SORT ), - iNumMixerPanelRows ( 1 ), - vstrCentralServerAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), - eCentralServerAddressType ( AT_DEFAULT ), - bEnableFeedbackDetection ( true ), - vecWindowPosSettings ( ), // empty array - vecWindowPosChat ( ), // empty array - vecWindowPosConnect ( ), // empty array - bWindowWasShownSettings ( false ), - bWindowWasShownChat ( false ), - bWindowWasShownConnect ( false ), - pClient ( pNCliP ) - { SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME ); } + eChannelSortType ( ST_NO_SORT ), + iNumMixerPanelRows ( 1 ), + vstrCentralServerAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), + eCentralServerAddressType ( AT_DEFAULT ), + bEnableFeedbackDetection ( true ), + vecWindowPosSettings(), // empty array + vecWindowPosChat(), // empty array + vecWindowPosConnect(), // empty array + bWindowWasShownSettings ( false ), + bWindowWasShownChat ( false ), + bWindowWasShownConnect ( false ), + pClient ( pNCliP ) + { + SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME ); + } void LoadFaderSettings ( const QString& strCurFileName ); void SaveFaderSettings ( const QString& strCurFileName ); @@ -194,8 +170,7 @@ class CClientSettings : public CSettings protected: // No CommandLineOptions used when reading Client inifile virtual void WriteSettingsToXML ( QDomDocument& IniXMLDocument ) override; - virtual void ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, - const QList& ) override; + virtual void ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, const QList& ) override; void ReadFaderSettingsFromXML ( const QDomDocument& IniXMLDocument ); void WriteFaderSettingsToXML ( QDomDocument& IniXMLDocument ); @@ -203,19 +178,17 @@ class CClientSettings : public CSettings CClient* pClient; }; - class CServerSettings : public CSettings { public: - CServerSettings ( CServer* pNSerP, const QString& sNFiName ) : - CSettings ( ), - pServer ( pNSerP ) - { SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME_SERVER); } + CServerSettings ( CServer* pNSerP, const QString& sNFiName ) : CSettings(), pServer ( pNSerP ) + { + SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME_SERVER ); + } protected: virtual void WriteSettingsToXML ( QDomDocument& IniXMLDocument ) override; - virtual void ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, - const QList& CommandLineOptions ) override; + virtual void ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, const QList& CommandLineOptions ) override; CServer* pServer; }; diff --git a/src/signalhandler.cpp b/src/signalhandler.cpp old mode 100755 new mode 100644 index 5c41014166..b30767002f --- a/src/signalhandler.cpp +++ b/src/signalhandler.cpp @@ -61,7 +61,8 @@ #include "signalhandler.h" -class CSignalHandlerSingleton : public CSignalHandler { +class CSignalHandlerSingleton : public CSignalHandler +{ public: inline CSignalHandlerSingleton() : CSignalHandler() {} }; @@ -75,11 +76,11 @@ CSignalHandler* CSignalHandler::getSingletonP() { return singleton; } bool CSignalHandler::emitSignal ( int sigNum ) { - return QMetaObject::invokeMethod( singleton, "HandledSignal", Qt::QueuedConnection, Q_ARG( int, sigNum ) ); + return QMetaObject::invokeMethod ( singleton, "HandledSignal", Qt::QueuedConnection, Q_ARG ( int, sigNum ) ); } #ifndef _WIN32 -void CSignalHandler::OnSocketNotify( int socket ) +void CSignalHandler::OnSocketNotify ( int socket ) { int sigNum; // The following read() triggers a Codacy/flawfinder finding: @@ -94,10 +95,7 @@ void CSignalHandler::OnSocketNotify( int socket ) // ---------------------------------------------------------- -CSignalBase::CSignalBase ( CSignalHandler* pSignalHandler ) : - pSignalHandler ( pSignalHandler ) -{ -} +CSignalBase::CSignalBase ( CSignalHandler* pSignalHandler ) : pSignalHandler ( pSignalHandler ) {} CSignalBase::~CSignalBase() = default; @@ -111,25 +109,18 @@ CSignalBase* CSignalBase::withSignalHandler ( CSignalHandler* pSignalHandler ) } #ifdef _WIN32 -CSignalWin::CSignalWin ( CSignalHandler* nPSignalHandler ) : - CSignalBase ( nPSignalHandler ), - lock ( QReadWriteLock::Recursive ) +CSignalWin::CSignalWin ( CSignalHandler* nPSignalHandler ) : CSignalBase ( nPSignalHandler ), lock ( QReadWriteLock::Recursive ) { SetConsoleCtrlHandler ( signalHandler, true ); } -CSignalWin::~CSignalWin() { - SetConsoleCtrlHandler ( signalHandler, false ); -} +CSignalWin::~CSignalWin() { SetConsoleCtrlHandler ( signalHandler, false ); } -QReadWriteLock* CSignalWin::getLock() const -{ - return &lock; -} +QReadWriteLock* CSignalWin::getLock() const { return &lock; } BOOL WINAPI CSignalWin::signalHandler ( _In_ DWORD ) { - auto self = getSelf(); + auto self = getSelf(); QReadLocker lock ( self->getLock() ); return self->pSignalHandler->emitSignal ( -1 ); } @@ -137,12 +128,11 @@ BOOL WINAPI CSignalWin::signalHandler ( _In_ DWORD ) #else int CSignalUnix::socketPair[2]; -CSignalUnix::CSignalUnix ( CSignalHandler* nPSignalHandler ) : - CSignalBase ( nPSignalHandler ) +CSignalUnix::CSignalUnix ( CSignalHandler* nPSignalHandler ) : CSignalBase ( nPSignalHandler ) { if ( ::socketpair ( AF_UNIX, SOCK_STREAM, 0, socketPair ) == 0 ) { - socketNotifier = new QSocketNotifier ( socketPair[ 1 ], QSocketNotifier::Read ); + socketNotifier = new QSocketNotifier ( socketPair[1], QSocketNotifier::Read ); QObject::connect ( socketNotifier, &QSocketNotifier::activated, nPSignalHandler, &CSignalHandler::OnSocketNotify ); @@ -155,7 +145,8 @@ CSignalUnix::CSignalUnix ( CSignalHandler* nPSignalHandler ) : } } -CSignalUnix::~CSignalUnix() { +CSignalUnix::~CSignalUnix() +{ setSignalHandled ( SIGUSR1, false ); setSignalHandled ( SIGUSR2, false ); setSignalHandled ( SIGINT, false ); @@ -185,7 +176,7 @@ bool CSignalUnix::setSignalHandled ( int sigNum, bool state ) void CSignalUnix::signalHandler ( int sigNum ) { - const auto res = ::write ( socketPair[ 0 ], &sigNum, sizeof ( int ) ); + const auto res = ::write ( socketPair[0], &sigNum, sizeof ( int ) ); Q_UNUSED ( res ); } #endif diff --git a/src/signalhandler.h b/src/signalhandler.h old mode 100755 new mode 100644 index f214e63166..dc52a14b6e --- a/src/signalhandler.h +++ b/src/signalhandler.h @@ -69,19 +69,19 @@ #include #ifdef _WIN32 -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include #else -#include -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include +# include #endif class CSignalBase; @@ -132,12 +132,11 @@ class CSignalBase CSignalHandler* pSignalHandler; - template - static T *getSelf() + template + static T* getSelf() { - return static_cast( CSignalHandler::getSingletonP()->pSignalBase.data() ); + return static_cast ( CSignalHandler::getSingletonP()->pSignalBase.data() ); } - }; #ifdef _WIN32 @@ -168,9 +167,9 @@ class CSignalUnix : public CSignalBase private: QSocketNotifier* socketNotifier = nullptr; - bool setSignalHandled ( int sigNum, bool state ); + bool setSignalHandled ( int sigNum, bool state ); - static int socketPair[2]; + static int socketPair[2]; static void signalHandler ( int sigNum ); }; diff --git a/src/socket.cpp b/src/socket.cpp old mode 100755 new mode 100644 index 4c68b5aed5..94d254920f --- a/src/socket.cpp +++ b/src/socket.cpp @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -25,26 +25,25 @@ #include "socket.h" #include "server.h" - /* Implementation *************************************************************/ void CSocket::Init ( const quint16 iPortNumber, const quint16 iQosNumber, const QString& strServerBindIP ) { #ifdef _WIN32 // for the Windows socket usage we have to start it up first -// clang-format off + // clang-format off // TODO check for error and exit application on error -// clang-format on + // clang-format on WSADATA wsa; - WSAStartup ( MAKEWORD(1, 0), &wsa ); + WSAStartup ( MAKEWORD ( 1, 0 ), &wsa ); #endif // create the UDP socket UdpSocket = socket ( AF_INET, SOCK_DGRAM, 0 ); // - const char tos = (char) iQosNumber; // Quality of Service - setsockopt ( UdpSocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos) ); + const char tos = (char) iQosNumber; // Quality of Service + setsockopt ( UdpSocket, IPPROTO_IP, IP_TOS, &tos, sizeof ( tos ) ); // allocate memory for network receive and send buffer in samples vecbyRecBuf.Init ( MAX_SIZE_BYTES_NETW_BUF ); @@ -52,11 +51,13 @@ void CSocket::Init ( const quint16 iPortNumber, const quint16 iQosNumber, const // preinitialize socket in address (only the port number is missing) sockaddr_in UdpSocketInAddr; UdpSocketInAddr.sin_family = AF_INET; - if (strServerBindIP.isEmpty()) { - UdpSocketInAddr.sin_addr.s_addr = INADDR_ANY; + if ( strServerBindIP.isEmpty() ) + { + UdpSocketInAddr.sin_addr.s_addr = INADDR_ANY; } - else { - UdpSocketInAddr.sin_addr.s_addr = htonl ( QHostAddress( strServerBindIP ).toIPv4Address() ); + else + { + UdpSocketInAddr.sin_addr.s_addr = htonl ( QHostAddress ( strServerBindIP ).toIPv4Address() ); } // initialize the listening socket @@ -69,9 +70,7 @@ void CSocket::Init ( const quint16 iPortNumber, const quint16 iQosNumber, const // if port number is 0, bind the client to a random available port UdpSocketInAddr.sin_port = htons ( 0 ); - bSuccess = ( ::bind ( UdpSocket , - (sockaddr*) &UdpSocketInAddr, - sizeof ( sockaddr_in ) ) == 0 ); + bSuccess = ( ::bind ( UdpSocket, (sockaddr*) &UdpSocketInAddr, sizeof ( sockaddr_in ) ) == 0 ); } else { @@ -89,9 +88,7 @@ void CSocket::Init ( const quint16 iPortNumber, const quint16 iQosNumber, const { UdpSocketInAddr.sin_port = htons ( startingPortNumber + iClientPortIncrement ); - bSuccess = ( ::bind ( UdpSocket , - (sockaddr*) &UdpSocketInAddr, - sizeof ( sockaddr_in ) ) == 0 ); + bSuccess = ( ::bind ( UdpSocket, (sockaddr*) &UdpSocketInAddr, sizeof ( sockaddr_in ) ) == 0 ); iClientPortIncrement++; } @@ -104,19 +101,17 @@ void CSocket::Init ( const quint16 iPortNumber, const quint16 iQosNumber, const // gets the desired port number UdpSocketInAddr.sin_port = htons ( iPortNumber ); - bSuccess = ( ::bind ( UdpSocket , - (sockaddr*) &UdpSocketInAddr, - sizeof ( sockaddr_in ) ) == 0 ); + bSuccess = ( ::bind ( UdpSocket, (sockaddr*) &UdpSocketInAddr, sizeof ( sockaddr_in ) ) == 0 ); } if ( !bSuccess ) { // we cannot bind socket, throw error throw CGenErr ( "Cannot bind the socket (maybe " - "the software is already running).", "Network Error" ); + "the software is already running).", + "Network Error" ); } - // Connections ------------------------------------------------------------- // it is important to do the following connections in this class since we // have a thread transition @@ -126,30 +121,26 @@ void CSocket::Init ( const quint16 iPortNumber, const quint16 iQosNumber, const { // client connections: - QObject::connect ( this, &CSocket::ProtcolMessageReceived, - pChannel, &CChannel::OnProtcolMessageReceived ); + QObject::connect ( this, &CSocket::ProtcolMessageReceived, pChannel, &CChannel::OnProtcolMessageReceived ); - QObject::connect ( this, &CSocket::ProtcolCLMessageReceived, - pChannel, &CChannel::OnProtcolCLMessageReceived ); + QObject::connect ( this, &CSocket::ProtcolCLMessageReceived, pChannel, &CChannel::OnProtcolCLMessageReceived ); - QObject::connect ( this, static_cast ( &CSocket::NewConnection ), - pChannel, &CChannel::OnNewConnection ); + QObject::connect ( this, static_cast ( &CSocket::NewConnection ), pChannel, &CChannel::OnNewConnection ); } else { // server connections: - QObject::connect ( this, &CSocket::ProtcolMessageReceived, - pServer, &CServer::OnProtcolMessageReceived ); + QObject::connect ( this, &CSocket::ProtcolMessageReceived, pServer, &CServer::OnProtcolMessageReceived ); - QObject::connect ( this, &CSocket::ProtcolCLMessageReceived, - pServer, &CServer::OnProtcolCLMessageReceived ); + QObject::connect ( this, &CSocket::ProtcolCLMessageReceived, pServer, &CServer::OnProtcolCLMessageReceived ); - QObject::connect ( this, static_cast ( &CSocket::NewConnection ), - pServer, &CServer::OnNewConnection ); + QObject::connect ( this, + static_cast ( &CSocket::NewConnection ), + pServer, + &CServer::OnNewConnection ); - QObject::connect ( this, &CSocket::ServerFull, - pServer, &CServer::OnServerFull ); + QObject::connect ( this, &CSocket::ServerFull, pServer, &CServer::OnServerFull ); } } @@ -159,7 +150,7 @@ void CSocket::Close() // closesocket will cause recvfrom to return with an error because the // socket is closed -> then the thread can safely be shut down closesocket ( UdpSocket ); -#elif defined ( __APPLE__ ) || defined ( __MACOSX ) +#elif defined( __APPLE__ ) || defined( __MACOSX ) // on Mac the general close has the same effect as closesocket on Windows close ( UdpSocket ); #else @@ -179,8 +170,7 @@ CSocket::~CSocket() #endif } -void CSocket::SendPacket ( const CVector& vecbySendBuf, - const CHostAddress& HostAddr ) +void CSocket::SendPacket ( const CVector& vecbySendBuf, const CHostAddress& HostAddr ) { QMutexLocker locker ( &Mutex ); @@ -224,13 +214,13 @@ bool CSocket::GetAndResetbJitterBufferOKFlag() void CSocket::OnDataReceived() { -/* - The strategy of this function is that only the "put audio" function is - called directly (i.e. the high thread priority is used) and all other less - important things like protocol parsing and acting on protocol messages is - done in the low priority thread. To get a thread transition, we have to - use the signal/slot mechanism (i.e. we use messages for that). -*/ + /* + The strategy of this function is that only the "put audio" function is + called directly (i.e. the high thread priority is used) and all other less + important things like protocol parsing and acting on protocol messages is + done in the low priority thread. To get a thread transition, we have to + use the signal/slot mechanism (i.e. we use messages for that). + */ // read block from network interface and query address of sender sockaddr_in SenderAddr; @@ -240,12 +230,7 @@ void CSocket::OnDataReceived() socklen_t SenderAddrSize = sizeof ( sockaddr_in ); #endif - const long iNumBytesRead = recvfrom ( UdpSocket, - (char*) &vecbyRecBuf[0], - MAX_SIZE_BYTES_NETW_BUF, - 0, - (sockaddr*) &SenderAddr, - &SenderAddrSize ); + const long iNumBytesRead = recvfrom ( UdpSocket, (char*) &vecbyRecBuf[0], MAX_SIZE_BYTES_NETW_BUF, 0, (sockaddr*) &SenderAddr, &SenderAddrSize ); // check if an error occurred or no data could be read if ( iNumBytesRead <= 0 ) @@ -257,34 +242,29 @@ void CSocket::OnDataReceived() RecHostAddr.InetAddr.setAddress ( ntohl ( SenderAddr.sin_addr.s_addr ) ); RecHostAddr.iPort = ntohs ( SenderAddr.sin_port ); - // check if this is a protocol message int iRecCounter; int iRecID; CVector vecbyMesBodyData; - if ( !CProtocol::ParseMessageFrame ( vecbyRecBuf, - iNumBytesRead, - vecbyMesBodyData, - iRecCounter, - iRecID ) ) + if ( !CProtocol::ParseMessageFrame ( vecbyRecBuf, iNumBytesRead, vecbyMesBodyData, iRecCounter, iRecID ) ) { // this is a protocol message, check the type of the message if ( CProtocol::IsConnectionLessMessageID ( iRecID ) ) { -// clang-format off + // clang-format off // TODO a copy of the vector is used -> avoid malloc in real-time routine -// clang-format on + // clang-format on emit ProtcolCLMessageReceived ( iRecID, vecbyMesBodyData, RecHostAddr ); } else { -// clang-format off + // clang-format off // TODO a copy of the vector is used -> avoid malloc in real-time routine -// clang-format on + // clang-format on emit ProtcolMessageReceived ( iRecCounter, iRecID, vecbyMesBodyData, RecHostAddr ); } @@ -333,8 +313,7 @@ void CSocket::OnDataReceived() if ( !pServer->IsRunning() ) { // (note that Qt will delete the event object when done) - QCoreApplication::postEvent ( pServer, - new CCustomEvent ( MS_PACKET_RECEIVED, 0, 0 ) ); + QCoreApplication::postEvent ( pServer, new CCustomEvent ( MS_PACKET_RECEIVED, 0, 0 ) ); } } diff --git a/src/socket.h b/src/socket.h old mode 100755 new mode 100644 index 7686284a29..bbf6c49880 --- a/src/socket.h +++ b/src/socket.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -32,22 +32,19 @@ #include "protocol.h" #include "util.h" #ifndef _WIN32 -# include -# include +# include +# include #endif - // The header files channel.h and server.h require to include this header file // so we get a cyclic dependency. To solve this issue, a prototype of the // channel class and server class is defined here. class CServer; // forward declaration of CServer class CChannel; // forward declaration of CChannel - /* Definitions ****************************************************************/ // number of ports we try to bind until we give up -#define NUM_SOCKET_PORTS_TO_TRY 100 - +#define NUM_SOCKET_PORTS_TO_TRY 100 /* Classes ********************************************************************/ /* Base socket class -------------------------------------------------------- */ @@ -56,22 +53,25 @@ class CSocket : public QObject Q_OBJECT public: - CSocket ( CChannel* pNewChannel, - const quint16 iPortNumber, const quint16 iQosNumber, const QString& strServerBindIP ) - : pChannel ( pNewChannel ), - bIsClient ( true ), - bJitterBufferOK ( true ) { Init ( iPortNumber, iQosNumber, strServerBindIP ); } - - CSocket ( CServer* pNServP, - const quint16 iPortNumber, const quint16 iQosNumber, const QString& strServerBindIP ) - : pServer ( pNServP ), - bIsClient ( false ), - bJitterBufferOK ( true ) { Init ( iPortNumber, iQosNumber, strServerBindIP ); } + CSocket ( CChannel* pNewChannel, const quint16 iPortNumber, const quint16 iQosNumber, const QString& strServerBindIP ) : + pChannel ( pNewChannel ), + bIsClient ( true ), + bJitterBufferOK ( true ) + { + Init ( iPortNumber, iQosNumber, strServerBindIP ); + } + + CSocket ( CServer* pNServP, const quint16 iPortNumber, const quint16 iQosNumber, const QString& strServerBindIP ) : + pServer ( pNServP ), + bIsClient ( false ), + bJitterBufferOK ( true ) + { + Init ( iPortNumber, iQosNumber, strServerBindIP ); + } virtual ~CSocket(); - void SendPacket ( const CVector& vecbySendBuf, - const CHostAddress& HostAddr ); + void SendPacket ( const CVector& vecbySendBuf, const CHostAddress& HostAddr ); bool GetAndResetbJitterBufferOKFlag(); void Close(); @@ -80,24 +80,24 @@ class CSocket : public QObject void Init ( const quint16 iPortNumber, const quint16 iQosNumber, const QString& strServerBindIP ); #ifdef _WIN32 - SOCKET UdpSocket; + SOCKET UdpSocket; #else - int UdpSocket; + int UdpSocket; #endif - QMutex Mutex; + QMutex Mutex; CVector vecbyRecBuf; CHostAddress RecHostAddr; QHostAddress SenderAddress; quint16 SenderPort; - CChannel* pChannel; // for client - CServer* pServer; // for server + CChannel* pChannel; // for client + CServer* pServer; // for server - bool bIsClient; + bool bIsClient; - bool bJitterBufferOK; + bool bJitterBufferOK; public: void OnDataReceived(); @@ -112,17 +112,11 @@ class CSocket : public QObject void InvalidPacketReceived ( CHostAddress RecHostAddr ); - void ProtcolMessageReceived ( int iRecCounter, - int iRecID, - CVector vecbyMesBodyData, - CHostAddress HostAdr ); + void ProtcolMessageReceived ( int iRecCounter, int iRecID, CVector vecbyMesBodyData, CHostAddress HostAdr ); - void ProtcolCLMessageReceived ( int iRecID, - CVector vecbyMesBodyData, - CHostAddress HostAdr ); + void ProtcolCLMessageReceived ( int iRecID, CVector vecbyMesBodyData, CHostAddress HostAdr ); }; - /* Socket which runs in a separate high priority thread --------------------- */ // The receive socket should be put in a high priority thread to ensure the GUI // does not effect the stability of the audio stream (e.g. if the GUI is on @@ -133,23 +127,26 @@ class CHighPrioSocket : public QObject Q_OBJECT public: - CHighPrioSocket ( CChannel* pNewChannel, - const quint16 iPortNumber, const quint16 iQosNumber, const QString& strServerBindIP ) - : Socket ( pNewChannel, iPortNumber, iQosNumber, strServerBindIP ) { Init(); } - - CHighPrioSocket ( CChannel* pNewChannel, - const quint16 iPortNumber, const quint16 iQosNumber ) - : Socket ( pNewChannel, iPortNumber, iQosNumber, "" ) { Init(); } + CHighPrioSocket ( CChannel* pNewChannel, const quint16 iPortNumber, const quint16 iQosNumber, const QString& strServerBindIP ) : + Socket ( pNewChannel, iPortNumber, iQosNumber, strServerBindIP ) + { + Init(); + } - CHighPrioSocket ( CServer* pNewServer, - const quint16 iPortNumber, const quint16 iQosNumber, const QString& strServerBindIP ) - : Socket ( pNewServer, iPortNumber, iQosNumber, strServerBindIP ) { Init(); } + CHighPrioSocket ( CChannel* pNewChannel, const quint16 iPortNumber, const quint16 iQosNumber ) : + Socket ( pNewChannel, iPortNumber, iQosNumber, "" ) + { + Init(); + } - virtual ~CHighPrioSocket() + CHighPrioSocket ( CServer* pNewServer, const quint16 iPortNumber, const quint16 iQosNumber, const QString& strServerBindIP ) : + Socket ( pNewServer, iPortNumber, iQosNumber, strServerBindIP ) { - NetworkWorkerThread.Stop(); + Init(); } + virtual ~CHighPrioSocket() { NetworkWorkerThread.Stop(); } + void Start() { // starts the high priority socket receive thread (with using blocking @@ -157,23 +154,18 @@ class CHighPrioSocket : public QObject NetworkWorkerThread.start ( QThread::TimeCriticalPriority ); } - void SendPacket ( const CVector& vecbySendBuf, - const CHostAddress& HostAddr ) - { - Socket.SendPacket ( vecbySendBuf, HostAddr ); - } + void SendPacket ( const CVector& vecbySendBuf, const CHostAddress& HostAddr ) { Socket.SendPacket ( vecbySendBuf, HostAddr ); } - bool GetAndResetbJitterBufferOKFlag() - { - return Socket.GetAndResetbJitterBufferOKFlag(); - } + bool GetAndResetbJitterBufferOKFlag() { return Socket.GetAndResetbJitterBufferOKFlag(); } protected: class CSocketThread : public QThread { public: - CSocketThread ( CSocket* pNewSocket = nullptr, QObject* parent = nullptr ) : - QThread ( parent ), pSocket ( pNewSocket ), bRun ( true ) { setObjectName ( "CSocketThread" ); } + CSocketThread ( CSocket* pNewSocket = nullptr, QObject* parent = nullptr ) : QThread ( parent ), pSocket ( pNewSocket ), bRun ( true ) + { + setObjectName ( "CSocketThread" ); + } void Stop() { @@ -190,7 +182,8 @@ class CHighPrioSocket : public QObject void SetSocket ( CSocket* pNewSocket ) { pSocket = pNewSocket; } protected: - void run() { + void run() + { // make sure the socket pointer is initialized (should be always the // case) if ( pSocket != nullptr ) @@ -220,8 +213,7 @@ class CHighPrioSocket : public QObject NetworkWorkerThread.SetSocket ( &Socket ); // connect the "InvalidPacketReceived" signal - QObject::connect ( &Socket, &CSocket::InvalidPacketReceived, - this, &CHighPrioSocket::InvalidPacketReceived ); + QObject::connect ( &Socket, &CSocket::InvalidPacketReceived, this, &CHighPrioSocket::InvalidPacketReceived ); } CSocketThread NetworkWorkerThread; diff --git a/src/soundbase.cpp b/src/soundbase.cpp old mode 100755 new mode 100644 index 50a3b9d283..1ea5079f64 --- a/src/soundbase.cpp +++ b/src/soundbase.cpp @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -26,29 +26,26 @@ // This is used as a lookup table for parsing option letters, mapping // a single character to an EMidiCtlType -char const sMidiCtlChar[] = -{ - // Has to follow order of EMidiCtlType - /* [EMidiCtlType::Fader] = */ 'f', - /* [EMidiCtlType::Pan] = */ 'p', - /* [EMidiCtlType::Solo] = */ 's', - /* [EMidiCtlType::Mute] = */ 'm', - /* [EMidiCtlType::None] = */ '\0' -}; - +char const sMidiCtlChar[] = { + // Has to follow order of EMidiCtlType + /* [EMidiCtlType::Fader] = */ 'f', + /* [EMidiCtlType::Pan] = */ 'p', + /* [EMidiCtlType::Solo] = */ 's', + /* [EMidiCtlType::Mute] = */ 'm', + /* [EMidiCtlType::None] = */ '\0' }; /* Implementation *************************************************************/ CSoundBase::CSoundBase ( const QString& strNewSystemDriverTechniqueName, - void (*fpNewProcessCallback) ( CVector& psData, void* pParg ), + void ( *fpNewProcessCallback ) ( CVector& psData, void* pParg ), void* pParg, const QString& strMIDISetup ) : - fpProcessCallback ( fpNewProcessCallback ), - pProcessCallbackArg ( pParg ), - bRun ( false ), - bCallbackEntered ( false ), + fpProcessCallback ( fpNewProcessCallback ), + pProcessCallbackArg ( pParg ), + bRun ( false ), + bCallbackEntered ( false ), strSystemDriverTechniqueName ( strNewSystemDriverTechniqueName ), - iCtrlMIDIChannel ( INVALID_MIDI_CH ), - aMidiCtls ( 128 ) + iCtrlMIDIChannel ( INVALID_MIDI_CH ), + aMidiCtls ( 128 ) { // parse the MIDI setup command line argument string ParseCommandLineArgument ( strMIDISetup ); @@ -70,7 +67,6 @@ void CSoundBase::Stop() QMutexLocker locker ( &MutexAudioProcessCallback ); } - /******************************************************************************\ * Device handling * \******************************************************************************/ @@ -89,7 +85,6 @@ QStringList CSoundBase::GetDevNames() return slDevNames; } - QString CSoundBase::SetDev ( const QString strDevName ) { QMutexLocker locker ( &MutexDevProperties ); @@ -119,8 +114,8 @@ QString CSoundBase::SetDev ( const QString strDevName ) // store error return message strReturn = QString ( tr ( "The selected audio device could not be used " - "because of the following error: " ) ) + strErrorMessage + - QString ( tr ( " The previous driver will be selected." ) ); + "because of the following error: " ) ) + + strErrorMessage + QString ( tr ( " The previous driver will be selected." ) ); } else { @@ -159,10 +154,10 @@ QString CSoundBase::SetDev ( const QString strDevName ) if ( !strDevName.isEmpty() ) { strReturn = tr ( "The previously selected audio device " - "is no longer available or the audio driver properties have changed to a state which " - "is incompatible with this software. We now try to find a valid audio device. This new " - "audio device might cause audio feedback. So, before connecting to a server, please " - "check the audio device setting." ); + "is no longer available or the audio driver properties have changed to a state which " + "is incompatible with this software. We now try to find a valid audio device. This new " + "audio device might cause audio feedback. So, before connecting to a server, please " + "check the audio device setting." ); } // try to load and initialize any valid driver @@ -171,11 +166,13 @@ QString CSoundBase::SetDev ( const QString strDevName ) if ( !vsErrorList.isEmpty() ) { // create error message with all details - QString sErrorMessage = "" + tr ( "No usable " ) + - strSystemDriverTechniqueName + tr ( " audio device " - "(driver) found." ) + "

" + tr ( - "In the following there is a list of all available drivers " - "with the associated error message:" ) + "
    "; + QString sErrorMessage = "" + tr ( "No usable " ) + strSystemDriverTechniqueName + + tr ( " audio device " + "(driver) found." ) + + "

    " + + tr ( "In the following there is a list of all available drivers " + "with the associated error message:" ) + + "
      "; for ( int i = 0; i < lNumDevs; i++ ) { @@ -189,7 +186,7 @@ QString CSoundBase::SetDev ( const QString strDevName ) // ASIO drivers sErrorMessage = sErrorMessage + "
      " + tr ( "Do you want to open the ASIO driver setups?" ); - if ( QMessageBox::Yes == QMessageBox::information ( nullptr, APP_NAME, sErrorMessage, QMessageBox::Yes|QMessageBox::No ) ) + if ( QMessageBox::Yes == QMessageBox::information ( nullptr, APP_NAME, sErrorMessage, QMessageBox::Yes | QMessageBox::No ) ) { LoadAndInitializeFirstValidDriver ( true ); } @@ -239,8 +236,6 @@ QVector CSoundBase::LoadAndInitializeFirstValidDriver ( const bool bOpe return vsErrorList; } - - /******************************************************************************\ * MIDI handling * \******************************************************************************/ @@ -282,7 +277,6 @@ void CSoundBase::ParseCommandLineArgument ( const QString& strMIDISetup ) // the fader controller offset without an // indication of the count of controllers - // [offset for level] if ( slMIDIParams.count() >= 2 ) { @@ -295,9 +289,9 @@ void CSoundBase::ParseCommandLineArgument ( const QString& strMIDISetup ) if ( bSimple ) { - // For the legacy specification, we consider every controller - // up to the maximum number of channels (or the maximum - // controller number) a fader. + // For the legacy specification, we consider every controller + // up to the maximum number of channels (or the maximum + // controller number) a fader. for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { if ( i + iMIDIOffsetFader > 127 ) @@ -320,9 +314,9 @@ void CSoundBase::ParseCommandLineArgument ( const QString& strMIDISetup ) continue; EMidiCtlType eTyp = static_cast ( iCtrl ); - const QStringList slP = sParm.mid ( 1 ).split ( '*' ); - int iFirst = slP[0].toUInt(); - int iNum = ( slP.count() > 1 ) ? slP[1].toUInt() : 1; + const QStringList slP = sParm.mid ( 1 ).split ( '*' ); + int iFirst = slP[0].toUInt(); + int iNum = ( slP.count() > 1 ) ? slP[1].toUInt() : 1; for ( int iOff = 0; iOff < iNum; iOff++ ) { if ( iOff >= MAX_NUM_CHANNELS ) @@ -347,15 +341,15 @@ void CSoundBase::ParseMIDIMessage ( const CVector& vMIDIPaketBytes ) // zero-based MIDI channel number (i.e. range 0-15) const int iMIDIChannelZB = iStatusByte & 0x0F; -/* -// debugging -printf ( "%02X: ", iMIDIChannelZB ); -for ( int i = 0; i < vMIDIPaketBytes.Size(); i++ ) -{ - printf ( "%02X ", vMIDIPaketBytes[i] ); -} -printf ( "\n" ); -*/ + /* + // debugging + printf ( "%02X: ", iMIDIChannelZB ); + for ( int i = 0; i < vMIDIPaketBytes.Size(); i++ ) + { + printf ( "%02X ", vMIDIPaketBytes[i] ); + } + printf ( "\n" ); + */ // per definition if MIDI channel is 0, we listen to all channels // note that iCtrlMIDIChannel is one-based channel number @@ -365,50 +359,44 @@ printf ( "\n" ); if ( ( iStatusByte >= 0xB0 ) && ( iStatusByte < 0xC0 ) ) { // make sure packet is long enough - if ( vMIDIPaketBytes.Size() > 2 - && vMIDIPaketBytes[1] <= uint8_t ( 127 ) - && vMIDIPaketBytes[2] <= uint8_t ( 127 ) ) + if ( vMIDIPaketBytes.Size() > 2 && vMIDIPaketBytes[1] <= uint8_t ( 127 ) && vMIDIPaketBytes[2] <= uint8_t ( 127 ) ) { - const CMidiCtlEntry &cCtrl = aMidiCtls[vMIDIPaketBytes[1]]; - const int iValue = vMIDIPaketBytes[2];; + const CMidiCtlEntry& cCtrl = aMidiCtls[vMIDIPaketBytes[1]]; + const int iValue = vMIDIPaketBytes[2]; + ; switch ( cCtrl.eType ) { case Fader: - { - // we are assuming that the controller number is the same - // as the audio fader index and the range is 0-127 - const int iFaderLevel = static_cast ( - static_cast ( iValue ) / 127 * AUD_MIX_FADER_MAX ); + { + // we are assuming that the controller number is the same + // as the audio fader index and the range is 0-127 + const int iFaderLevel = static_cast ( static_cast ( iValue ) / 127 * AUD_MIX_FADER_MAX ); - // consider offset for the faders + // consider offset for the faders - emit ControllerInFaderLevel ( cCtrl.iChannel, iFaderLevel ); - } - break; + emit ControllerInFaderLevel ( cCtrl.iChannel, iFaderLevel ); + } + break; case Pan: - { - // Pan levels need to be symmetric between 1 and 127 - const int iPanValue = static_cast ( - static_cast ( - qMax ( iValue, 1 ) - 1) / 126 * AUD_MIX_PAN_MAX ); - - emit ControllerInPanValue ( cCtrl.iChannel, iPanValue ); - } - break; + { + // Pan levels need to be symmetric between 1 and 127 + const int iPanValue = static_cast ( static_cast ( qMax ( iValue, 1 ) - 1 ) / 126 * AUD_MIX_PAN_MAX ); + + emit ControllerInPanValue ( cCtrl.iChannel, iPanValue ); + } + break; case Solo: - { - // We depend on toggles reflecting the desired state - emit ControllerInFaderIsSolo ( cCtrl.iChannel, - iValue >= 0x40); - } - break; + { + // We depend on toggles reflecting the desired state + emit ControllerInFaderIsSolo ( cCtrl.iChannel, iValue >= 0x40 ); + } + break; case Mute: - { - // We depend on toggles reflecting the desired state - emit ControllerInFaderIsMute ( cCtrl.iChannel, - iValue >= 0x40); - } - break; + { + // We depend on toggles reflecting the desired state + emit ControllerInFaderIsMute ( cCtrl.iChannel, iValue >= 0x40 ); + } + break; default: break; } diff --git a/src/soundbase.h b/src/soundbase.h old mode 100755 new mode 100644 index 06c0538464..50fd790d34 --- a/src/soundbase.h +++ b/src/soundbase.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -28,12 +28,11 @@ #include #include #ifndef HEADLESS -# include +# include #endif #include "global.h" #include "util.h" - // TODO better solution with enum definition // problem: in signals it seems not to work to use CSoundBase::ESndCrdResetType enum ESndCrdResetType @@ -52,13 +51,12 @@ enum EMidiCtlType None }; -class CMidiCtlEntry { +class CMidiCtlEntry +{ public: - CMidiCtlEntry ( EMidiCtlType eT = EMidiCtlType::None, int iC = 0 ) - : eType ( eT ), iChannel ( iC ) - { } + CMidiCtlEntry ( EMidiCtlType eT = EMidiCtlType::None, int iC = 0 ) : eType ( eT ), iChannel ( iC ) {} EMidiCtlType eType; - int iChannel; + int iChannel; }; /* Classes ********************************************************************/ @@ -68,44 +66,51 @@ class CSoundBase : public QThread public: CSoundBase ( const QString& strNewSystemDriverTechniqueName, - void (*fpNewProcessCallback) ( CVector& psData, void* pParg ), + void ( *fpNewProcessCallback ) ( CVector& psData, void* pParg ), void* pParg, const QString& strMIDISetup ); virtual int Init ( const int iNewPrefMonoBufferSize ) { return iNewPrefMonoBufferSize; } - virtual void Start() { bRun = true; bCallbackEntered = false; } + virtual void Start() + { + bRun = true; + bCallbackEntered = false; + } virtual void Stop(); // device selection QStringList GetDevNames(); QString SetDev ( const QString strDevName ); - QString GetDev() { QMutexLocker locker ( &MutexDevProperties ); return strCurDevName; } + QString GetDev() + { + QMutexLocker locker ( &MutexDevProperties ); + return strCurDevName; + } virtual int GetNumInputChannels() { return 2; } virtual QString GetInputChannelName ( const int ) { return "Default"; } - virtual void SetLeftInputChannel ( const int ) {} + virtual void SetLeftInputChannel ( const int ) {} virtual void SetRightInputChannel ( const int ) {} - virtual int GetLeftInputChannel() { return 0; } + virtual int GetLeftInputChannel() { return 0; } virtual int GetRightInputChannel() { return 1; } virtual int GetNumOutputChannels() { return 2; } virtual QString GetOutputChannelName ( const int ) { return "Default"; } - virtual void SetLeftOutputChannel ( const int ) {} + virtual void SetLeftOutputChannel ( const int ) {} virtual void SetRightOutputChannel ( const int ) {} - virtual int GetLeftOutputChannel() { return 0; } + virtual int GetLeftOutputChannel() { return 0; } virtual int GetRightOutputChannel() { return 1; } - virtual float GetInOutLatencyMs() { return 0.0f; } // "0.0" means no latency is available + virtual float GetInOutLatencyMs() { return 0.0f; } // "0.0" means no latency is available - virtual void OpenDriverSetup() {} + virtual void OpenDriverSetup() {} bool IsRunning() const { return bRun; } bool IsCallbackEntered() const { return bCallbackEntered; } // TODO this should be protected but since it is used // in a callback function it has to be public -> better solution - void EmitReinitRequestSignal ( const ESndCrdResetType eSndCrdResetType ) - { emit ReinitRequest ( eSndCrdResetType ); } + void EmitReinitRequestSignal ( const ESndCrdResetType eSndCrdResetType ) { emit ReinitRequest ( eSndCrdResetType ); } protected: virtual QString LoadAndInitializeDriver ( QString, bool ) { return ""; } @@ -114,8 +119,7 @@ class CSoundBase : public QThread void ParseCommandLineArgument ( const QString& strMIDISetup ); QString GetDeviceName ( const int iDiD ) { return strDriverNames[iDiD]; } - static void GetSelCHAndAddCH ( const int iSelCH, const int iNumInChan, - int& iSelCHOut, int& iSelAddCHOut ) + static void GetSelCHAndAddCH ( const int iSelCH, const int iNumInChan, int& iSelCHOut, int& iSelAddCHOut ) { // we have a mixed channel setup, definitions: // - mixed channel setup only for 4 physical inputs: @@ -136,25 +140,25 @@ class CSoundBase : public QThread } // function pointer to callback function - void (*fpProcessCallback) ( CVector& psData, void* arg ); + void ( *fpProcessCallback ) ( CVector& psData, void* arg ); void* pProcessCallbackArg; // callback function call for derived classes void ProcessCallback ( CVector& psData ) { bCallbackEntered = true; - (*fpProcessCallback) ( psData, pProcessCallbackArg ); + ( *fpProcessCallback ) ( psData, pProcessCallbackArg ); } void ParseMIDIMessage ( const CVector& vMIDIPaketBytes ); - bool bRun; - bool bCallbackEntered; - QMutex MutexAudioProcessCallback; - QMutex MutexDevProperties; + bool bRun; + bool bCallbackEntered; + QMutex MutexAudioProcessCallback; + QMutex MutexDevProperties; - QString strSystemDriverTechniqueName; - int iCtrlMIDIChannel; + QString strSystemDriverTechniqueName; + int iCtrlMIDIChannel; QVector aMidiCtls; long lNumDevs; diff --git a/src/testbench.h b/src/testbench.h old mode 100755 new mode 100644 index 3ecc76992e..e52573c2ea --- a/src/testbench.h +++ b/src/testbench.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -34,16 +34,13 @@ #include "protocol.h" #include "util.h" - /* Classes ********************************************************************/ class CTestbench : public QObject { Q_OBJECT public: - CTestbench ( QString sNewAddress, quint16 iNewPort ) : - sAddress ( sNewAddress ), - iPort ( iNewPort ) + CTestbench ( QString sNewAddress, quint16 iNewPort ) : sAddress ( sNewAddress ), iPort ( iNewPort ) { sLAddress = GenRandomIPv4Address().toString(); iLPort = static_cast ( GenRandomIntInRange ( -2, 10000 ) ); @@ -54,22 +51,18 @@ class CTestbench : public QObject while ( !bSuccess && ( iPortIncrement <= 100 ) ) { - bSuccess = UdpSocket.bind ( QHostAddress( QHostAddress::Any ), - 22222 + iPortIncrement ); + bSuccess = UdpSocket.bind ( QHostAddress ( QHostAddress::Any ), 22222 + iPortIncrement ); iPortIncrement++; } // connect protocol signals - QObject::connect ( &Protocol, &CProtocol::MessReadyForSending, - this, &CTestbench::OnSendProtMessage ); + QObject::connect ( &Protocol, &CProtocol::MessReadyForSending, this, &CTestbench::OnSendProtMessage ); - QObject::connect ( &Protocol, &CProtocol::CLMessReadyForSending, - this, &CTestbench::OnSendCLMessage ); + QObject::connect ( &Protocol, &CProtocol::CLMessReadyForSending, this, &CTestbench::OnSendCLMessage ); // connect and start the timer (testbench heartbeat) - QObject::connect ( &Timer, &QTimer::timeout, - this, &CTestbench::OnTimer ); + QObject::connect ( &Timer, &QTimer::timeout, this, &CTestbench::OnTimer ); Timer.start ( 1 ); // 1 ms } @@ -77,8 +70,7 @@ class CTestbench : public QObject protected: int GenRandomIntInRange ( const int iStart, const int iEnd ) const { - return static_cast ( iStart + - ( ( static_cast ( iEnd - iStart + 1 ) * rand() ) / RAND_MAX ) ); + return static_cast ( iStart + ( ( static_cast ( iEnd - iStart + 1 ) * rand() ) / RAND_MAX ) ); } QString GenRandomString() const @@ -100,7 +92,7 @@ class CTestbench : public QObject quint32 b = static_cast ( 168 ); quint32 c = static_cast ( GenRandomIntInRange ( 1, 253 ) ); quint32 d = static_cast ( GenRandomIntInRange ( 1, 253 ) ); - return QHostAddress( a << 24 | b << 16 | c << 8 | d ); + return QHostAddress ( a << 24 | b << 16 | c << 8 | d ); } QString sAddress; @@ -137,8 +129,7 @@ public slots: break; case 2: // PROTMESSID_CHANNEL_GAIN - Protocol.CreateChanGainMes ( GenRandomIntInRange ( 0, 20 ), - GenRandomIntInRange ( -100, 100 ) ); + Protocol.CreateChanGainMes ( GenRandomIntInRange ( 0, 20 ), GenRandomIntInRange ( -100, 100 ) ); break; case 4: // PROTMESSID_CONN_CLIENTS_LIST @@ -171,8 +162,7 @@ public slots: break; case 10: // PROTMESSID_LICENCE_REQUIRED - eLicenceType = - static_cast ( GenRandomIntInRange ( 0, 1 ) ); + eLicenceType = static_cast ( GenRandomIntInRange ( 0, 1 ) ); Protocol.CreateLicenceRequiredMes ( eLicenceType ); break; @@ -194,14 +184,11 @@ public slots: break; case 14: // PROTMESSID_CLM_PING_MS - Protocol.CreateCLPingMes ( CurHostAddress, - GenRandomIntInRange ( -2, 1000 ) ); + Protocol.CreateCLPingMes ( CurHostAddress, GenRandomIntInRange ( -2, 1000 ) ); break; case 15: // PROTMESSID_CLM_PING_MS_WITHNUMCLIENTS - Protocol.CreateCLPingWithNumClientsMes ( CurHostAddress, - GenRandomIntInRange ( -2, 1000 ), - GenRandomIntInRange ( -2, 1000 ) ); + Protocol.CreateCLPingWithNumClientsMes ( CurHostAddress, GenRandomIntInRange ( -2, 1000 ), GenRandomIntInRange ( -2, 1000 ) ); break; case 16: // PROTMESSID_CLM_SERVER_FULL @@ -215,9 +202,7 @@ public slots: ServerInfo.strCity = GenRandomString(); ServerInfo.strName = GenRandomString(); - Protocol.CreateCLRegisterServerMes ( CurHostAddress, - CurLocalAddress, - ServerInfo ); + Protocol.CreateCLRegisterServerMes ( CurHostAddress, CurLocalAddress, ServerInfo ); break; case 18: // PROTMESSID_CLM_UNREGISTER_SERVER @@ -233,8 +218,7 @@ public slots: vecServerInfo[0].strCity = GenRandomString(); vecServerInfo[0].strName = GenRandomString(); - Protocol.CreateCLServerListMes ( CurHostAddress, - vecServerInfo ); + Protocol.CreateCLServerListMes ( CurHostAddress, vecServerInfo ); break; case 20: // PROTMESSID_CLM_REQ_SERVER_LIST @@ -242,8 +226,7 @@ public slots: break; case 21: // PROTMESSID_CLM_SEND_EMPTY_MESSAGE - Protocol.CreateCLSendEmptyMesMes ( CurHostAddress, - CurHostAddress ); + Protocol.CreateCLSendEmptyMesMes ( CurHostAddress, CurHostAddress ); break; case 22: // PROTMESSID_CLM_EMPTY_MESSAGE @@ -263,8 +246,7 @@ public slots: break; case 26: // PROTMESSID_ACKN - Protocol.CreateAndImmSendAcknMess ( GenRandomIntInRange ( -10, 100 ), - GenRandomIntInRange ( -100, 100 ) ); + Protocol.CreateAndImmSendAcknMess ( GenRandomIntInRange ( -10, 100 ), GenRandomIntInRange ( -100, 100 ) ); break; case 27: @@ -289,27 +271,21 @@ public slots: case 30: // PROTMESSID_CLM_CHANNEL_LEVEL_LIST vecLevelList[0] = GenRandomIntInRange ( 0, 0xF ); - Protocol.CreateCLChannelLevelListMes ( CurHostAddress, - vecLevelList, - 1 ); + Protocol.CreateCLChannelLevelListMes ( CurHostAddress, vecLevelList, 1 ); break; case 31: // PROTMESSID_CLM_REGISTER_SERVER_RESP - eSvrRegResult = - static_cast ( GenRandomIntInRange ( 0, 1 ) ); + eSvrRegResult = static_cast ( GenRandomIntInRange ( 0, 1 ) ); - Protocol.CreateCLRegisterServerResp ( CurHostAddress, - eSvrRegResult ); + Protocol.CreateCLRegisterServerResp ( CurHostAddress, eSvrRegResult ); break; case 32: // PROTMESSID_CHANNEL_PAN - Protocol.CreateChanPanMes ( GenRandomIntInRange ( -2, 20 ), - GenRandomIntInRange ( 0, 32767 ) ); + Protocol.CreateChanPanMes ( GenRandomIntInRange ( -2, 20 ), GenRandomIntInRange ( 0, 32767 ) ); break; case 33: // PROTMESSID_MUTE_STATE_CHANGED - Protocol.CreateMuteStateHasChangedMes ( GenRandomIntInRange ( -2, 20 ), - GenRandomIntInRange ( 0, 1 ) ); + Protocol.CreateMuteStateHasChangedMes ( GenRandomIntInRange ( -2, 20 ), GenRandomIntInRange ( 0, 1 ) ); break; case 34: // PROTMESSID_CLIENT_ID @@ -320,17 +296,12 @@ public slots: void OnSendProtMessage ( CVector vecMessage ) { - UdpSocket.writeDatagram ( - (const char*) &( (CVector) vecMessage )[0], - vecMessage.Size(), QHostAddress ( sAddress ), iPort ); + UdpSocket.writeDatagram ( (const char*) &( (CVector) vecMessage )[0], vecMessage.Size(), QHostAddress ( sAddress ), iPort ); // reset protocol so that we do not have to wait for an acknowledge to // send the next message Protocol.Reset(); } - void OnSendCLMessage ( CHostAddress, CVector vecMessage ) - { - OnSendProtMessage ( vecMessage ); - } + void OnSendCLMessage ( CHostAddress, CVector vecMessage ) { OnSendProtMessage ( vecMessage ); } }; diff --git a/src/threadpool.h b/src/threadpool.h index 38128102c8..5e98aef1f0 100644 --- a/src/threadpool.h +++ b/src/threadpool.h @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -39,64 +39,59 @@ class CThreadPool { public: CThreadPool() = default; - CThreadPool(size_t); + CThreadPool ( size_t ); template - auto enqueue(F&& f, Args&&... args) - -> std::future::type>; + auto enqueue ( F&& f, Args&&... args ) -> std::future::type>; ~CThreadPool(); private: // need to keep track of threads so we can join them - std::vector< std::thread > workers; + std::vector workers; // the task queue - std::queue< std::function > tasks; + std::queue> tasks; // synchronization - std::mutex queue_mutex; - std::condition_variable condition; - bool stop; + std::mutex queue_mutex; + std::condition_variable condition; + bool stop; }; // the constructor just launches some amount of workers -inline CThreadPool::CThreadPool(size_t threads) - : stop(false) +inline CThreadPool::CThreadPool ( size_t threads ) : stop ( false ) { - for ( size_t i = 0; i < threads; ++i ) { + for ( size_t i = 0; i < threads; ++i ) + { workers.emplace_back ( [this] { - for (;;) + for ( ;; ) + { + std::function task; + { - std::function task; + std::unique_lock lock ( this->queue_mutex ); + this->condition.wait ( lock, [this] { return this->stop || !this->tasks.empty(); } ); + if ( this->stop && this->tasks.empty() ) { - std::unique_lock lock ( this->queue_mutex ); - this->condition.wait ( lock, - [this] { return this->stop || !this->tasks.empty(); } ); - - if ( this->stop && this->tasks.empty() ) { - return; - } - - task = std::move ( this->tasks.front() ); - this->tasks.pop(); + return; } - task(); + task = std::move ( this->tasks.front() ); + this->tasks.pop(); } + + task(); } - ); + } ); } } // add new work item to the pool template -auto CThreadPool::enqueue(F&& f, Args&&... args) - -> std::future::type> +auto CThreadPool::enqueue ( F&& f, Args&&... args ) -> std::future::type> { - using return_type = typename std::result_of::type; + using return_type = typename std::result_of::type; - auto task = std::make_shared< std::packaged_task > ( - std::bind(std::forward(f), std::forward(args)...) - ); + auto task = std::make_shared> ( std::bind ( std::forward ( f ), std::forward ( args )... ) ); std::future res = task->get_future(); { @@ -104,9 +99,9 @@ auto CThreadPool::enqueue(F&& f, Args&&... args) // don't allow enqueueing after stopping the pool if ( stop ) - throw std::runtime_error( "enqueue on stopped CThreadPool" ); + throw std::runtime_error ( "enqueue on stopped CThreadPool" ); - tasks.emplace ( [task] () { (*task)(); } ); + tasks.emplace ( [task]() { ( *task )(); } ); } condition.notify_one(); return res; @@ -120,7 +115,7 @@ inline CThreadPool::~CThreadPool() stop = true; } condition.notify_all(); - for ( std::thread &worker: workers ) + for ( std::thread& worker : workers ) worker.join(); } diff --git a/src/util.cpp b/src/util.cpp old mode 100755 new mode 100644 index f4b815d89d..3ca37589d0 --- a/src/util.cpp +++ b/src/util.cpp @@ -8,16 +8,16 @@ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later + * Foundation; either version 2 of the License, or (at your option) any later * version. * - * This program is distributed in the hope that it will be useful, but WITHOUT + * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., + * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * \******************************************************************************/ @@ -25,12 +25,9 @@ #include "util.h" #include "client.h" - /* Implementation *************************************************************/ // Input level meter implementation -------------------------------------------- -void CStereoSignalLevelMeter::Update ( const CVector& vecsAudio, - const int iMonoBlockSizeSam, - const bool bIsStereoIn ) +void CStereoSignalLevelMeter::Update ( const CVector& vecsAudio, const int iMonoBlockSizeSam, const bool bIsStereoIn ) { // Get maximum of current block // @@ -52,7 +49,7 @@ void CStereoSignalLevelMeter::Update ( const CVector& vecsAudio, { // left (or mono) and right channel sMinLOrMono = std::min ( sMinLOrMono, vecsAudio[i] ); - sMinR = std::min ( sMinR, vecsAudio[i + 1] ); + sMinR = std::min ( sMinR, vecsAudio[i + 1] ); } // in case of mono out use minimum of both channels @@ -79,8 +76,7 @@ void CStereoSignalLevelMeter::Update ( const CVector& vecsAudio, } } -double CStereoSignalLevelMeter::UpdateCurLevel ( double dCurLevel, - const double dMax ) +double CStereoSignalLevelMeter::UpdateCurLevel ( double dCurLevel, const double dMax ) { // decrease max with time if ( dCurLevel >= METER_FLY_BACK ) @@ -128,7 +124,6 @@ double CStereoSignalLevelMeter::CalcLogResultForMeter ( const double& dLinearLev return dLevelForMeterdB; } - // CRC ------------------------------------------------------------------------- void CCRC::Reset() { @@ -147,7 +142,7 @@ void CCRC::AddByte ( const uint8_t byNewInput ) // take bit, which was shifted out of the register-size and place it // at the beginning (LSB) // (If condition is not satisfied, implicitly a "0" is added) - if ( ( iStateShiftReg & iBitOutMask) > 0 ) + if ( ( iStateShiftReg & iBitOutMask ) > 0 ) { iStateShiftReg |= 1; } @@ -175,7 +170,6 @@ uint32_t CCRC::GetCRC() return iStateShiftReg & ( iBitOutMask - 1 ); } - /******************************************************************************\ * Audio Reverberation * \******************************************************************************/ @@ -191,10 +185,7 @@ uint32_t CCRC::GetCRC() three series allpass units, followed by four parallel comb filters, and two decorrelation delay lines in parallel at the output. */ -void CAudioReverb::Init ( const EAudChanConf eNAudioChannelConf, - const int iNStereoBlockSizeSam, - const int iSampleRate, - const float fT60 ) +void CAudioReverb::Init ( const EAudChanConf eNAudioChannelConf, const int iNStereoBlockSizeSam, const int iSampleRate, const float fT60 ) { // store parameters eAudioChannelConf = eNAudioChannelConf; @@ -244,10 +235,10 @@ void CAudioReverb::Init ( const EAudChanConf eNAudioChannelConf, bool CAudioReverb::isPrime ( const int number ) { -/* - Returns true if argument value is prime. Taken from "class Effect" in - "STK abstract effects parent class". -*/ + /* + Returns true if argument value is prime. Taken from "class Effect" in + "STK abstract effects parent class". + */ if ( number == 2 ) { return true; @@ -289,14 +280,12 @@ void CAudioReverb::Clear() outLeftDelay.Reset ( 0 ); } -void CAudioReverb::setT60 ( const float fT60, - const int iSampleRate ) +void CAudioReverb::setT60 ( const float fT60, const int iSampleRate ) { // set the reverberation T60 decay time for ( int i = 0; i < 4; i++ ) { - combCoefficient[i] = powf ( 10.0f, static_cast ( -3.0f * - combDelays[i].Size() / ( fT60 * iSampleRate ) ) ); + combCoefficient[i] = powf ( 10.0f, static_cast ( -3.0f * combDelays[i].Size() / ( fT60 * iSampleRate ) ) ); } } @@ -315,9 +304,7 @@ float CAudioReverb::COnePole::Calc ( const float fIn ) return fLastSample; } -void CAudioReverb::Process ( CVector& vecsStereoInOut, - const bool bReverbOnLeftChan, - const float fAttenuation ) +void CAudioReverb::Process ( CVector& vecsStereoInOut, const bool bReverbOnLeftChan, const float fAttenuation ) { float fMixedInput, temp, temp0, temp1, temp2; @@ -341,23 +328,23 @@ void CAudioReverb::Process ( CVector& vecsStereoInOut, } } - temp = allpassDelays[0].Get(); - temp0 = allpassCoefficient * temp; + temp = allpassDelays[0].Get(); + temp0 = allpassCoefficient * temp; temp0 += fMixedInput; allpassDelays[0].Add ( temp0 ); - temp0 = - ( allpassCoefficient * temp0 ) + temp; + temp0 = -( allpassCoefficient * temp0 ) + temp; - temp = allpassDelays[1].Get(); - temp1 = allpassCoefficient * temp; + temp = allpassDelays[1].Get(); + temp1 = allpassCoefficient * temp; temp1 += temp0; allpassDelays[1].Add ( temp1 ); - temp1 = - ( allpassCoefficient * temp1 ) + temp; + temp1 = -( allpassCoefficient * temp1 ) + temp; - temp = allpassDelays[2].Get(); - temp2 = allpassCoefficient * temp; + temp = allpassDelays[2].Get(); + temp2 = allpassCoefficient * temp; temp2 += temp1; allpassDelays[2].Add ( temp2 ); - temp2 = - ( allpassCoefficient * temp2 ) + temp; + temp2 = -( allpassCoefficient * temp2 ) + temp; const float temp3 = temp2 + combFilters[0].Calc ( combCoefficient[0] * combDelays[0].Get() ); const float temp4 = temp2 + combFilters[1].Calc ( combCoefficient[1] * combDelays[1].Get() ); @@ -371,28 +358,23 @@ void CAudioReverb::Process ( CVector& vecsStereoInOut, const float filtout = temp3 + temp4 + temp5 + temp6; - outLeftDelay.Add ( filtout ); + outLeftDelay.Add ( filtout ); outRightDelay.Add ( filtout ); // inplace apply the attenuated reverb signal (for stereo always apply // reverberation effect on both channels) if ( ( eAudioChannelConf == CC_STEREO ) || bReverbOnLeftChan ) { - vecsStereoInOut[i] = Float2Short ( - ( 1.0f - fAttenuation ) * vecsStereoInOut[i] + - 0.5f * fAttenuation * outLeftDelay.Get() ); + vecsStereoInOut[i] = Float2Short ( ( 1.0f - fAttenuation ) * vecsStereoInOut[i] + 0.5f * fAttenuation * outLeftDelay.Get() ); } if ( ( eAudioChannelConf == CC_STEREO ) || !bReverbOnLeftChan ) { - vecsStereoInOut[i + 1] = Float2Short ( - ( 1.0f - fAttenuation ) * vecsStereoInOut[i + 1] + - 0.5f * fAttenuation * outRightDelay.Get() ); + vecsStereoInOut[i + 1] = Float2Short ( ( 1.0f - fAttenuation ) * vecsStereoInOut[i + 1] + 0.5f * fAttenuation * outRightDelay.Get() ); } } } - /******************************************************************************\ * GUI Utilities * \******************************************************************************/ @@ -403,131 +385,153 @@ CAboutDlg::CAboutDlg ( QWidget* parent ) : CBaseDlg ( parent ) setupUi ( this ); // general description of software - txvAbout->setText ( - "

      " + tr ( "This app enables musicians to perform real-time jam sessions " - "over the internet." ) + "
      " + tr ( "There is a server which collects " - " the audio data from each client, mixes the audio data and sends the mix " - " back to each client." ) + "

      " - "

      " // GPL header text - "This program is free software; you can redistribute it and/or modify " - "it under the terms of the GNU General Public License as published by " - "the Free Software Foundation; either version 2 of the License, or " - "(at your option) any later version.
      This program is distributed in " - "the hope that it will be useful, but WITHOUT ANY WARRANTY; without " - "even the implied warranty of MERCHANTABILITY or FITNESS FOR A " - "PARTICULAR PURPOSE. See the GNU General Public License for more " - "details.
      You should have received a copy of the GNU General Public " - "License along with his program; if not, write to the Free Software " - "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 " - "USA" - "

      " ); + txvAbout->setText ( "

      " + + tr ( "This app enables musicians to perform real-time jam sessions " + "over the internet." ) + + "
      " + + tr ( "There is a server which collects " + " the audio data from each client, mixes the audio data and sends the mix " + " back to each client." ) + + "

      " + "

      " // GPL header text + "This program is free software; you can redistribute it and/or modify " + "it under the terms of the GNU General Public License as published by " + "the Free Software Foundation; either version 2 of the License, or " + "(at your option) any later version.
      This program is distributed in " + "the hope that it will be useful, but WITHOUT ANY WARRANTY; without " + "even the implied warranty of MERCHANTABILITY or FITNESS FOR A " + "PARTICULAR PURPOSE. See the GNU General Public License for more " + "details.
      You should have received a copy of the GNU General Public " + "License along with his program; if not, write to the Free Software " + "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 " + "USA" + "

      " ); // libraries used by this compilation txvLibraries->setText ( - tr ( "This app uses the following libraries, resources or code snippets:" ) + - "

      " + tr ( "Qt cross-platform application framework" ) + + tr ( "This app uses the following libraries, resources or code snippets:" ) + "

      " + tr ( "Qt cross-platform application framework" ) + ", http://www.qt.io

      " "

      Opus Interactive Audio Codec" ", http://www.opus-codec.org

      " - "

      " + tr ( "Audio reverberation code by Perry R. Cook and Gary P. Scavone" ) + + "

      " + + tr ( "Audio reverberation code by Perry R. Cook and Gary P. Scavone" ) + ", 1995 - 2004, " "The Synthesis ToolKit in C++ (STK)

      " - "

      " + tr ( "Some pixmaps are from the" ) + " Open Clip Art Library (OCAL), " + "

      " + + tr ( "Some pixmaps are from the" ) + + " Open Clip Art Library (OCAL), " "http://openclipart.org

      " - "

      " + tr ( "Country flag icons by Mark James" ) + - ", http://www.famfamfam.com

      " ); + "

      " + + tr ( "Country flag icons by Mark James" ) + ", http://www.famfamfam.com

      " ); // contributors list - txvContributors->setText ( - "

      Volker Fischer (corrados)

      " - "

      Peter L. Jones (pljones)

      " - "

      Jonathan Baker-Bates (gilgongo)

      " - "

      ann0see (ann0see)

      " - "

      Daniele Masato (doloopuntil)

      " - "

      Martin Schilde (geheimerEichkater)

      " - "

      Simon Tomlinson (sthenos)

      " - "

      Marc jr. Landolt (braindef)

      " - "

      Olivier Humbert (trebmuh)

      " - "

      Tarmo Johannes (tarmoj)

      " - "

      mirabilos (mirabilos)

      " - "

      Hector Martin (marcan)

      " - "

      newlaurent62 (newlaurent62)

      " - "

      AronVietti (AronVietti)

      " - "

      Emlyn Bolton (emlynmac)

      " - "

      Jos van den Oever (vandenoever)

      " - "

      Tormod Volden (tormodvolden)

      " - "

      Alberstein8 (Alberstein8)

      " - "

      Gauthier Fleutot Östervall (fleutot)

      " - "

      Tony Mountifield (softins)

      " - "

      HPS (hselasky)

      " - "

      Stanislas Michalak (stanislas-m)

      " - "

      JP Cimalando (jpcima)

      " - "

      Adam Sampson (atsampson)

      " - "

      Jakob Jarmar (jarmar)

      " - "

      Stefan Weil (stweil)

      " - "

      Nils Brederlow (dingodoppelt)

      " - "

      Sebastian Krzyszkowiak (dos1)

      " - "

      Bryan Flamig (bflamig)

      " - "

      Kris Raney (kraney)

      " - "

      dszgit (dszgit)

      " - "

      nefarius2001 (nefarius2001)

      " - "

      jc-Rosichini (jc-Rosichini)

      " - "

      Julian Santander (j-santander)

      " - "

      chigkim (chigkim)

      " - "

      Bodo (bomm)

      " - "

      Christian Hoffmann (hoffie)

      " - "

      jp8 (jp8)

      " - "

      James (jdrage)

      " - "

      ranfdev (ranfdev)

      " - "

      bspeer (bspeer)

      " - "

      Martin Passing (passing)

      " - "

      DonC (dcorson-ticino-com)

      " - "

      David Kastrup (dakhubgit)

      " - "

      Jordan Lum (mulyaj)

      " - "

      Noam Postavsky (npostavs)

      " - "

      David Savinkoff (DavidSavinkoff)

      " - "

      Johannes Brauers (JohannesBrx)

      " - "

      Henk De Groot (henkdegroot)

      " - "

      Ferenc Wágner (wferi)

      " - "

      Martin Kaistra (djfun)

      " - "

      Burkhard Volkemer (buv)

      " - "

      Magnus Groß (vimpostor)

      " - "

      Julien Taverna (jujudusud)

      " - "

      Detlef Hennings (DetlefHennings)

      " - "

      drummer1154 (drummer1154)

      " - "

      helgeerbe (helgeerbe)

      " - "

      Hk1020 (Hk1020)

      " - "

      Jeroen van Veldhuizen (jeroenvv)

      " - "

      Reinhard (reinhardwh)

      " - "

      Stefan Menzel (menzels)

      " - "
      " + tr ( "For details on the contributions check out the " ) + - "" + tr ( "Github Contributors list" ) + "." ); + txvContributors->setText ( "

      Volker Fischer (corrados)

      " + "

      Peter L. Jones (pljones)

      " + "

      Jonathan Baker-Bates (gilgongo)

      " + "

      ann0see (ann0see)

      " + "

      Daniele Masato (doloopuntil)

      " + "

      Martin Schilde (geheimerEichkater)

      " + "

      Simon Tomlinson (sthenos)

      " + "

      Marc jr. Landolt (braindef)

      " + "

      Olivier Humbert (trebmuh)

      " + "

      Tarmo Johannes (tarmoj)

      " + "

      mirabilos (mirabilos)

      " + "

      Hector Martin (marcan)

      " + "

      newlaurent62 (newlaurent62)

      " + "

      AronVietti (AronVietti)

      " + "

      Emlyn Bolton (emlynmac)

      " + "

      Jos van den Oever (vandenoever)

      " + "

      Tormod Volden (tormodvolden)

      " + "

      Alberstein8 (Alberstein8)

      " + "

      Gauthier Fleutot Östervall (fleutot)

      " + "

      Tony Mountifield (softins)

      " + "

      HPS (hselasky)

      " + "

      Stanislas Michalak (stanislas-m)

      " + "

      JP Cimalando (jpcima)

      " + "

      Adam Sampson (atsampson)

      " + "

      Jakob Jarmar (jarmar)

      " + "

      Stefan Weil (stweil)

      " + "

      Nils Brederlow (dingodoppelt)

      " + "

      Sebastian Krzyszkowiak (dos1)

      " + "

      Bryan Flamig (bflamig)

      " + "

      Kris Raney (kraney)

      " + "

      dszgit (dszgit)

      " + "

      nefarius2001 (nefarius2001)

      " + "

      jc-Rosichini (jc-Rosichini)

      " + "

      Julian Santander (j-santander)

      " + "

      chigkim (chigkim)

      " + "

      Bodo (bomm)

      " + "

      Christian Hoffmann (hoffie)

      " + "

      jp8 (jp8)

      " + "

      James (jdrage)

      " + "

      ranfdev (ranfdev)

      " + "

      bspeer (bspeer)

      " + "

      Martin Passing (passing)

      " + "

      DonC (dcorson-ticino-com)

      " + "

      David Kastrup (dakhubgit)

      " + "

      Jordan Lum (mulyaj)

      " + "

      Noam Postavsky (npostavs)

      " + "

      David Savinkoff (DavidSavinkoff)

      " + "

      Johannes Brauers (JohannesBrx)

      " + "

      Henk De Groot (henkdegroot)

      " + "

      Ferenc Wágner (wferi)

      " + "

      Martin Kaistra (djfun)

      " + "

      Burkhard Volkemer (buv)

      " + "

      Magnus Groß (vimpostor)

      " + "

      Julien Taverna (jujudusud)

      " + "

      Detlef Hennings (DetlefHennings)

      " + "

      drummer1154 (drummer1154)

      " + "

      helgeerbe (helgeerbe)

      " + "

      Hk1020 (Hk1020)

      " + "

      Jeroen van Veldhuizen (jeroenvv)

      " + "

      Reinhard (reinhardwh)

      " + "

      Stefan Menzel (menzels)

      " + "
      " + + tr ( "For details on the contributions check out the " ) + + "" + tr ( "Github Contributors list" ) + + "." ); // translators - txvTranslation->setText ( - "

      " + tr ( "Spanish" ) + "

      " - "

      Daryl Hanlon (ignotus666)

      " - "

      " + tr ( "French" ) + "

      " - "

      Olivier Humbert (trebmuh)

      " - "

      Julien Taverna (jujudusud)

      " - "

      " + tr ( "Portuguese" ) + "

      " - "

      Miguel de Matos (Snayler)

      " - "

      Melcon Moraes (melcon)

      " - "

      " + tr ( "Dutch" ) + "

      " - "

      Jeroen Geertzen (jerogee)

      " - "

      Henk De Groot (henkdegroot)

      " - "

      " + tr ( "Italian" ) + "

      " - "

      Giuseppe Sapienza (dzpex)

      " - "

      " + tr ( "German" ) + "

      " - "

      Volker Fischer (corrados)

      " - "

      Roland Moschel (rolamos)

      " - "

      " + tr ( "Polish" ) + "

      " - "

      Martyna Danysz (Martyna27)

      " - "

      Tomasz Bojczuk (SeeLook)

      " - "

      " + tr ( "Swedish" ) + "

      " - "

      Daniel (genesisproject2020)

      " - "

      " + tr ( "Slovak" ) + "

      " - "

      Jose Riha (jose1711)

      " ); + txvTranslation->setText ( "

      " + tr ( "Spanish" ) + + "

      " + "

      Daryl Hanlon (ignotus666)

      " + "

      " + + tr ( "French" ) + + "

      " + "

      Olivier Humbert (trebmuh)

      " + "

      Julien Taverna (jujudusud)

      " + "

      " + + tr ( "Portuguese" ) + + "

      " + "

      Miguel de Matos (Snayler)

      " + "

      Melcon Moraes (melcon)

      " + "

      " + + tr ( "Dutch" ) + + "

      " + "

      Jeroen Geertzen (jerogee)

      " + "

      Henk De Groot (henkdegroot)

      " + "

      " + + tr ( "Italian" ) + + "

      " + "

      Giuseppe Sapienza (dzpex)

      " + "

      " + + tr ( "German" ) + + "

      " + "

      Volker Fischer (corrados)

      " + "

      Roland Moschel (rolamos)

      " + "

      " + + tr ( "Polish" ) + + "

      " + "

      Martyna Danysz (Martyna27)

      " + "

      Tomasz Bojczuk (SeeLook)

      " + "

      " + + tr ( "Swedish" ) + + "

      " + "

      Daniel (genesisproject2020)

      " + "

      " + + tr ( "Slovak" ) + + "

      " + "

      Jose Riha (jose1711)

      " ); // set version number in about dialog lblVersion->setText ( GetVersionAndNameStr() ); @@ -536,48 +540,44 @@ CAboutDlg::CAboutDlg ( QWidget* parent ) : CBaseDlg ( parent ) setWindowTitle ( tr ( "About " ) + APP_NAME ); } - // Licence dialog -------------------------------------------------------------- CLicenceDlg::CLicenceDlg ( QWidget* parent ) : CBaseDlg ( parent ) { -/* - The licence dialog is structured as follows: - - text box with the licence text on the top - - check box: I &agree to the above licence terms - - Accept button (disabled if check box not checked) - - Decline button -*/ + /* + The licence dialog is structured as follows: + - text box with the licence text on the top + - check box: I &agree to the above licence terms + - Accept button (disabled if check box not checked) + - Decline button + */ setWindowIcon ( QIcon ( QString::fromUtf8 ( ":/png/main/res/fronticon.png" ) ) ); - QVBoxLayout* pLayout = new QVBoxLayout ( this ); - QHBoxLayout* pSubLayout = new QHBoxLayout; - QLabel* lblLicence = new QLabel ( tr ( "This server requires you accept conditions before you can join. Please read these in the chat window." ), this ); - QCheckBox* chbAgree = new QCheckBox ( tr ( "I have read the conditions and &agree." ), this ); - butAccept = new QPushButton ( tr ( "Accept" ), this ); - QPushButton* butDecline = new QPushButton ( tr ( "Decline" ), this ); + QVBoxLayout* pLayout = new QVBoxLayout ( this ); + QHBoxLayout* pSubLayout = new QHBoxLayout; + QLabel* lblLicence = + new QLabel ( tr ( "This server requires you accept conditions before you can join. Please read these in the chat window." ), this ); + QCheckBox* chbAgree = new QCheckBox ( tr ( "I have read the conditions and &agree." ), this ); + butAccept = new QPushButton ( tr ( "Accept" ), this ); + QPushButton* butDecline = new QPushButton ( tr ( "Decline" ), this ); pSubLayout->addStretch(); pSubLayout->addWidget ( chbAgree ); pSubLayout->addWidget ( butAccept ); pSubLayout->addWidget ( butDecline ); - pLayout->addWidget ( lblLicence ); - pLayout->addLayout ( pSubLayout ); + pLayout->addWidget ( lblLicence ); + pLayout->addLayout ( pSubLayout ); // set some properties butAccept->setEnabled ( false ); butAccept->setDefault ( true ); - QObject::connect ( chbAgree, &QCheckBox::stateChanged, - this, &CLicenceDlg::OnAgreeStateChanged ); + QObject::connect ( chbAgree, &QCheckBox::stateChanged, this, &CLicenceDlg::OnAgreeStateChanged ); - QObject::connect ( butAccept, &QPushButton::clicked, - this, &CLicenceDlg::accept ); + QObject::connect ( butAccept, &QPushButton::clicked, this, &CLicenceDlg::accept ); - QObject::connect ( butDecline, &QPushButton::clicked, - this, &CLicenceDlg::reject ); + QObject::connect ( butDecline, &QPushButton::clicked, this, &CLicenceDlg::reject ); } - // Help menu ------------------------------------------------------------------- CHelpMenu::CHelpMenu ( const bool bIsClient, QWidget* parent ) : QMenu ( tr ( "&Help" ), parent ) { @@ -597,19 +597,15 @@ CHelpMenu::CHelpMenu ( const bool bIsClient, QWidget* parent ) : QMenu ( tr ( "& addAction ( tr ( "What's &This" ), this, SLOT ( OnHelpWhatsThis() ), QKeySequence ( Qt::SHIFT + Qt::Key_F1 ) ); addSeparator(); pAction = addAction ( tr ( "&About Jamulus..." ), this, SLOT ( OnHelpAbout() ) ); - pAction->setMenuRole(QAction::AboutRole); // required for Mac + pAction->setMenuRole ( QAction::AboutRole ); // required for Mac pAction = addAction ( tr ( "About &Qt..." ), this, SLOT ( OnHelpAboutQt() ) ); - pAction->setMenuRole(QAction::AboutQtRole); // required for Mac + pAction->setMenuRole ( QAction::AboutQtRole ); // required for Mac } - // Language combo box ---------------------------------------------------------- -CLanguageComboBox::CLanguageComboBox ( QWidget* parent ) : - QComboBox ( parent ), - iIdxSelectedLanguage ( INVALID_INDEX ) +CLanguageComboBox::CLanguageComboBox ( QWidget* parent ) : QComboBox ( parent ), iIdxSelectedLanguage ( INVALID_INDEX ) { - QObject::connect ( this, static_cast ( &QComboBox::activated ), - this, &CLanguageComboBox::OnLanguageActivated ); + QObject::connect ( this, static_cast ( &QComboBox::activated ), this, &CLanguageComboBox::OnLanguageActivated ); } void CLanguageComboBox::Init ( QString& strSelLanguage ) @@ -659,22 +655,18 @@ void CLanguageComboBox::OnLanguageActivated ( int iLanguageIdx ) // only update if the language selection is different from the current selected language if ( iIdxSelectedLanguage != iLanguageIdx ) { - QMessageBox::information ( this, - tr ( "Restart Required" ), - tr ( "Please restart the application for the language change to take effect." ) ); + QMessageBox::information ( this, tr ( "Restart Required" ), tr ( "Please restart the application for the language change to take effect." ) ); emit LanguageChanged ( itemData ( iLanguageIdx ).toString() ); } } #endif - /******************************************************************************\ * Other Classes * \******************************************************************************/ // Network utility functions --------------------------------------------------- -bool NetworkUtil::ParseNetworkAddress ( QString strAddress, - CHostAddress& HostAddress ) +bool NetworkUtil::ParseNetworkAddress ( QString strAddress, CHostAddress& HostAddress ) { QHostAddress InetAddr; quint16 iNetPort = DEFAULT_PORT_NUMBER; @@ -731,9 +723,9 @@ bool NetworkUtil::ParseNetworkAddress ( QString strAddress, { if ( HostAddr.protocol() == QAbstractSocket::IPv4Protocol ) { - InetAddr = HostAddr; - bFoundIPv4 = true; - break; + InetAddr = HostAddr; + bFoundIPv4 = true; + break; } } @@ -763,27 +755,32 @@ CHostAddress NetworkUtil::GetLocalAddress() } else { - qWarning() << "could not determine local IPv4 address:" - << socket.errorString() - << "- using localhost"; + qWarning() << "could not determine local IPv4 address:" << socket.errorString() << "- using localhost"; - return CHostAddress( QHostAddress::LocalHost, 0 ); + return CHostAddress ( QHostAddress::LocalHost, 0 ); } } -QString NetworkUtil::GetCentralServerAddress ( const ECSAddType eCentralServerAddressType, - const QString& strCentralServerAddress ) +QString NetworkUtil::GetCentralServerAddress ( const ECSAddType eCentralServerAddressType, const QString& strCentralServerAddress ) { switch ( eCentralServerAddressType ) { - case AT_CUSTOM: return strCentralServerAddress; - case AT_ANY_GENRE2: return CENTSERV_ANY_GENRE2; - case AT_ANY_GENRE3: return CENTSERV_ANY_GENRE3; - case AT_GENRE_ROCK: return CENTSERV_GENRE_ROCK; - case AT_GENRE_JAZZ: return CENTSERV_GENRE_JAZZ; - case AT_GENRE_CLASSICAL_FOLK: return CENTSERV_GENRE_CLASSICAL_FOLK; - case AT_GENRE_CHORAL: return CENTSERV_GENRE_CHORAL; - default: return DEFAULT_SERVER_ADDRESS; // AT_DEFAULT + case AT_CUSTOM: + return strCentralServerAddress; + case AT_ANY_GENRE2: + return CENTSERV_ANY_GENRE2; + case AT_ANY_GENRE3: + return CENTSERV_ANY_GENRE3; + case AT_GENRE_ROCK: + return CENTSERV_GENRE_ROCK; + case AT_GENRE_JAZZ: + return CENTSERV_GENRE_JAZZ; + case AT_GENRE_CLASSICAL_FOLK: + return CENTSERV_GENRE_CLASSICAL_FOLK; + case AT_GENRE_CHORAL: + return CENTSERV_GENRE_CHORAL; + default: + return DEFAULT_SERVER_ADDRESS; // AT_DEFAULT } } @@ -795,27 +792,27 @@ QString NetworkUtil::FixAddress ( const QString& strAddress ) // Return whether the given HostAdress is within a private IP range // as per RFC 1918 & RFC 5735. -bool NetworkUtil::IsPrivateNetworkIP ( const QHostAddress &qhAddr ) +bool NetworkUtil::IsPrivateNetworkIP ( const QHostAddress& qhAddr ) { // https://www.rfc-editor.org/rfc/rfc1918 // https://www.rfc-editor.org/rfc/rfc5735 - static QList> addresses = - { + static QList> addresses = { QPair ( QHostAddress ( "10.0.0.0" ), 8 ), QPair ( QHostAddress ( "127.0.0.0" ), 8 ), QPair ( QHostAddress ( "172.16.0.0" ), 12 ), QPair ( QHostAddress ( "192.168.0.0" ), 16 ), }; - foreach ( auto item, addresses ) { - if ( qhAddr.isInSubnet ( item ) ) { + foreach ( auto item, addresses ) + { + if ( qhAddr.isInSubnet ( item ) ) + { return true; } } return false; } - // Instrument picture data base ------------------------------------------------ CVector& CInstPictures::GetTable ( const bool bReGenerateTable ) { @@ -830,54 +827,150 @@ CVector& CInstPictures::GetTable ( const bool bRe // NOTE: Do not change the order of any instrument in the future! // NOTE: The very first entry is the "not used" element per definition. vecDataBase.Init ( 0 ); // first clear all existing data since we create the list be adding entries - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "None" ), ":/png/instr/res/instruments/none.png", IC_OTHER_INSTRUMENT ) ); // special first element - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Drum Set" ), ":/png/instr/res/instruments/drumset.png", IC_PERCUSSION_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Djembe" ), ":/png/instr/res/instruments/djembe.png", IC_PERCUSSION_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Electric Guitar" ), ":/png/instr/res/instruments/eguitar.png", IC_PLUCKING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Acoustic Guitar" ), ":/png/instr/res/instruments/aguitar.png", IC_PLUCKING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Bass Guitar" ), ":/png/instr/res/instruments/bassguitar.png", IC_PLUCKING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Keyboard" ), ":/png/instr/res/instruments/keyboard.png", IC_KEYBOARD_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Synthesizer" ), ":/png/instr/res/instruments/synthesizer.png", IC_KEYBOARD_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Grand Piano" ), ":/png/instr/res/instruments/grandpiano.png", IC_KEYBOARD_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Accordion" ), ":/png/instr/res/instruments/accordeon.png", IC_KEYBOARD_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal" ), ":/png/instr/res/instruments/vocal.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Microphone" ), ":/png/instr/res/instruments/microphone.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Harmonica" ), ":/png/instr/res/instruments/harmonica.png", IC_WIND_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Trumpet" ), ":/png/instr/res/instruments/trumpet.png", IC_WIND_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Trombone" ), ":/png/instr/res/instruments/trombone.png", IC_WIND_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "French Horn" ), ":/png/instr/res/instruments/frenchhorn.png", IC_WIND_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Tuba" ), ":/png/instr/res/instruments/tuba.png", IC_WIND_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Saxophone" ), ":/png/instr/res/instruments/saxophone.png", IC_WIND_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Clarinet" ), ":/png/instr/res/instruments/clarinet.png", IC_WIND_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Flute" ), ":/png/instr/res/instruments/flute.png", IC_WIND_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Violin" ), ":/png/instr/res/instruments/violin.png", IC_STRING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Cello" ), ":/png/instr/res/instruments/cello.png", IC_STRING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Double Bass" ), ":/png/instr/res/instruments/doublebass.png", IC_STRING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Recorder" ), ":/png/instr/res/instruments/recorder.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Streamer" ), ":/png/instr/res/instruments/streamer.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Listener" ), ":/png/instr/res/instruments/listener.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Guitar+Vocal" ), ":/png/instr/res/instruments/guitarvocal.png", IC_MULTIPLE_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Keyboard+Vocal" ), ":/png/instr/res/instruments/keyboardvocal.png", IC_MULTIPLE_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Bodhran" ), ":/png/instr/res/instruments/bodhran.png", IC_PERCUSSION_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Bassoon" ), ":/png/instr/res/instruments/bassoon.png", IC_WIND_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Oboe" ), ":/png/instr/res/instruments/oboe.png", IC_WIND_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Harp" ), ":/png/instr/res/instruments/harp.png", IC_STRING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Viola" ), ":/png/instr/res/instruments/viola.png", IC_STRING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Congas" ), ":/png/instr/res/instruments/congas.png", IC_PERCUSSION_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Bongo" ), ":/png/instr/res/instruments/bongo.png", IC_PERCUSSION_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Bass" ), ":/png/instr/res/instruments/vocalbass.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Tenor" ), ":/png/instr/res/instruments/vocaltenor.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Alto" ), ":/png/instr/res/instruments/vocalalto.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Soprano" ), ":/png/instr/res/instruments/vocalsoprano.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Banjo" ), ":/png/instr/res/instruments/banjo.png", IC_PLUCKING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Mandolin" ), ":/png/instr/res/instruments/mandolin.png", IC_PLUCKING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Ukulele" ), ":/png/instr/res/instruments/ukulele.png", IC_PLUCKING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Bass Ukulele" ), ":/png/instr/res/instruments/bassukulele.png", IC_PLUCKING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Baritone" ), ":/png/instr/res/instruments/vocalbaritone.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Lead" ), ":/png/instr/res/instruments/vocallead.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Mountain Dulcimer" ), ":/png/instr/res/instruments/mountaindulcimer.png", IC_STRING_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Scratching" ), ":/png/instr/res/instruments/scratching.png", IC_OTHER_INSTRUMENT ) ); - vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Rapping" ), ":/png/instr/res/instruments/rapping.png", IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "None" ), + ":/png/instr/res/instruments/none.png", + IC_OTHER_INSTRUMENT ) ); // special first element + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Drum Set" ), + ":/png/instr/res/instruments/drumset.png", + IC_PERCUSSION_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Djembe" ), + ":/png/instr/res/instruments/djembe.png", + IC_PERCUSSION_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Electric Guitar" ), + ":/png/instr/res/instruments/eguitar.png", + IC_PLUCKING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Acoustic Guitar" ), + ":/png/instr/res/instruments/aguitar.png", + IC_PLUCKING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Bass Guitar" ), + ":/png/instr/res/instruments/bassguitar.png", + IC_PLUCKING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Keyboard" ), + ":/png/instr/res/instruments/keyboard.png", + IC_KEYBOARD_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Synthesizer" ), + ":/png/instr/res/instruments/synthesizer.png", + IC_KEYBOARD_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Grand Piano" ), + ":/png/instr/res/instruments/grandpiano.png", + IC_KEYBOARD_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Accordion" ), + ":/png/instr/res/instruments/accordeon.png", + IC_KEYBOARD_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal" ), + ":/png/instr/res/instruments/vocal.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Microphone" ), + ":/png/instr/res/instruments/microphone.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Harmonica" ), + ":/png/instr/res/instruments/harmonica.png", + IC_WIND_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Trumpet" ), + ":/png/instr/res/instruments/trumpet.png", + IC_WIND_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Trombone" ), + ":/png/instr/res/instruments/trombone.png", + IC_WIND_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "French Horn" ), + ":/png/instr/res/instruments/frenchhorn.png", + IC_WIND_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Tuba" ), + ":/png/instr/res/instruments/tuba.png", + IC_WIND_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Saxophone" ), + ":/png/instr/res/instruments/saxophone.png", + IC_WIND_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Clarinet" ), + ":/png/instr/res/instruments/clarinet.png", + IC_WIND_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Flute" ), + ":/png/instr/res/instruments/flute.png", + IC_WIND_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Violin" ), + ":/png/instr/res/instruments/violin.png", + IC_STRING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Cello" ), + ":/png/instr/res/instruments/cello.png", + IC_STRING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Double Bass" ), + ":/png/instr/res/instruments/doublebass.png", + IC_STRING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Recorder" ), + ":/png/instr/res/instruments/recorder.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Streamer" ), + ":/png/instr/res/instruments/streamer.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Listener" ), + ":/png/instr/res/instruments/listener.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Guitar+Vocal" ), + ":/png/instr/res/instruments/guitarvocal.png", + IC_MULTIPLE_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Keyboard+Vocal" ), + ":/png/instr/res/instruments/keyboardvocal.png", + IC_MULTIPLE_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Bodhran" ), + ":/png/instr/res/instruments/bodhran.png", + IC_PERCUSSION_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Bassoon" ), + ":/png/instr/res/instruments/bassoon.png", + IC_WIND_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Oboe" ), + ":/png/instr/res/instruments/oboe.png", + IC_WIND_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Harp" ), + ":/png/instr/res/instruments/harp.png", + IC_STRING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Viola" ), + ":/png/instr/res/instruments/viola.png", + IC_STRING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Congas" ), + ":/png/instr/res/instruments/congas.png", + IC_PERCUSSION_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Bongo" ), + ":/png/instr/res/instruments/bongo.png", + IC_PERCUSSION_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Bass" ), + ":/png/instr/res/instruments/vocalbass.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Tenor" ), + ":/png/instr/res/instruments/vocaltenor.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Alto" ), + ":/png/instr/res/instruments/vocalalto.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Soprano" ), + ":/png/instr/res/instruments/vocalsoprano.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Banjo" ), + ":/png/instr/res/instruments/banjo.png", + IC_PLUCKING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Mandolin" ), + ":/png/instr/res/instruments/mandolin.png", + IC_PLUCKING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Ukulele" ), + ":/png/instr/res/instruments/ukulele.png", + IC_PLUCKING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Bass Ukulele" ), + ":/png/instr/res/instruments/bassukulele.png", + IC_PLUCKING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Baritone" ), + ":/png/instr/res/instruments/vocalbaritone.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Vocal Lead" ), + ":/png/instr/res/instruments/vocallead.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Mountain Dulcimer" ), + ":/png/instr/res/instruments/mountaindulcimer.png", + IC_STRING_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Scratching" ), + ":/png/instr/res/instruments/scratching.png", + IC_OTHER_INSTRUMENT ) ); + vecDataBase.Add ( CInstPictProps ( QCoreApplication::translate ( "CClientSettingsDlg", "Rapping" ), + ":/png/instr/res/instruments/rapping.png", + IC_OTHER_INSTRUMENT ) ); // now the table is initialized TableIsInitialized = true; @@ -934,7 +1027,6 @@ CInstPictures::EInstCategory CInstPictures::GetCategory ( const int iInstrument } } - // Locale management class ----------------------------------------------------- QString CLocale::GetCountryFlagIconsResourceReference ( const QLocale::Country eCountry ) { @@ -947,197 +1039,561 @@ QString CLocale::GetCountryFlagIconsResourceReference ( const QLocale::Country e } else { -// NOTE: The following code was introduced to support old QT versions. The problem -// is that the number of countries displayed is less than the one displayed -// with the new code below (which is disabled). Therefore, as soon as the -// compatibility to the very old versions of QT is not required anymore, use -// the new code. -// COMPATIBLE FOR OLD QT VERSIONS -> use a table: + // NOTE: The following code was introduced to support old QT versions. The problem + // is that the number of countries displayed is less than the one displayed + // with the new code below (which is disabled). Therefore, as soon as the + // compatibility to the very old versions of QT is not required anymore, use + // the new code. + // COMPATIBLE FOR OLD QT VERSIONS -> use a table: QString strISO3166 = ""; switch ( static_cast ( eCountry ) ) { - case 1: strISO3166 = "af"; break; - case 2: strISO3166 = "al"; break; - case 3: strISO3166 = "dz"; break; - case 5: strISO3166 = "ad"; break; - case 6: strISO3166 = "ao"; break; - case 10: strISO3166 = "ar"; break; - case 11: strISO3166 = "am"; break; - case 12: strISO3166 = "aw"; break; - case 13: strISO3166 = "au"; break; - case 14: strISO3166 = "at"; break; - case 15: strISO3166 = "az"; break; - case 17: strISO3166 = "bh"; break; - case 18: strISO3166 = "bd"; break; - case 20: strISO3166 = "by"; break; - case 21: strISO3166 = "be"; break; - case 23: strISO3166 = "bj"; break; - case 25: strISO3166 = "bt"; break; - case 26: strISO3166 = "bo"; break; - case 27: strISO3166 = "ba"; break; - case 28: strISO3166 = "bw"; break; - case 30: strISO3166 = "br"; break; - case 32: strISO3166 = "bn"; break; - case 33: strISO3166 = "bg"; break; - case 34: strISO3166 = "bf"; break; - case 35: strISO3166 = "bi"; break; - case 36: strISO3166 = "kh"; break; - case 37: strISO3166 = "cm"; break; - case 38: strISO3166 = "ca"; break; - case 39: strISO3166 = "cv"; break; - case 41: strISO3166 = "cf"; break; - case 42: strISO3166 = "td"; break; - case 43: strISO3166 = "cl"; break; - case 44: strISO3166 = "cn"; break; - case 47: strISO3166 = "co"; break; - case 48: strISO3166 = "km"; break; - case 49: strISO3166 = "cd"; break; - case 50: strISO3166 = "cg"; break; - case 52: strISO3166 = "cr"; break; - case 53: strISO3166 = "ci"; break; - case 54: strISO3166 = "hr"; break; - case 55: strISO3166 = "cu"; break; - case 56: strISO3166 = "cy"; break; - case 57: strISO3166 = "cz"; break; - case 58: strISO3166 = "dk"; break; - case 59: strISO3166 = "dj"; break; - case 61: strISO3166 = "do"; break; - case 62: strISO3166 = "tl"; break; - case 63: strISO3166 = "ec"; break; - case 64: strISO3166 = "eg"; break; - case 65: strISO3166 = "sv"; break; - case 66: strISO3166 = "gq"; break; - case 67: strISO3166 = "er"; break; - case 68: strISO3166 = "ee"; break; - case 69: strISO3166 = "et"; break; - case 71: strISO3166 = "fo"; break; - case 73: strISO3166 = "fi"; break; - case 74: strISO3166 = "fr"; break; - case 76: strISO3166 = "gf"; break; - case 77: strISO3166 = "pf"; break; - case 79: strISO3166 = "ga"; break; - case 81: strISO3166 = "ge"; break; - case 82: strISO3166 = "de"; break; - case 83: strISO3166 = "gh"; break; - case 85: strISO3166 = "gr"; break; - case 86: strISO3166 = "gl"; break; - case 88: strISO3166 = "gp"; break; - case 90: strISO3166 = "gt"; break; - case 91: strISO3166 = "gn"; break; - case 92: strISO3166 = "gw"; break; - case 93: strISO3166 = "gy"; break; - case 96: strISO3166 = "hn"; break; - case 97: strISO3166 = "hk"; break; - case 98: strISO3166 = "hu"; break; - case 99: strISO3166 = "is"; break; - case 100: strISO3166 = "in"; break; - case 101: strISO3166 = "id"; break; - case 102: strISO3166 = "ir"; break; - case 103: strISO3166 = "iq"; break; - case 104: strISO3166 = "ie"; break; - case 105: strISO3166 = "il"; break; - case 106: strISO3166 = "it"; break; - case 108: strISO3166 = "jp"; break; - case 109: strISO3166 = "jo"; break; - case 110: strISO3166 = "kz"; break; - case 111: strISO3166 = "ke"; break; - case 113: strISO3166 = "kp"; break; - case 114: strISO3166 = "kr"; break; - case 115: strISO3166 = "kw"; break; - case 116: strISO3166 = "kg"; break; - case 117: strISO3166 = "la"; break; - case 118: strISO3166 = "lv"; break; - case 119: strISO3166 = "lb"; break; - case 120: strISO3166 = "ls"; break; - case 122: strISO3166 = "ly"; break; - case 123: strISO3166 = "li"; break; - case 124: strISO3166 = "lt"; break; - case 125: strISO3166 = "lu"; break; - case 126: strISO3166 = "mo"; break; - case 127: strISO3166 = "mk"; break; - case 128: strISO3166 = "mg"; break; - case 130: strISO3166 = "my"; break; - case 132: strISO3166 = "ml"; break; - case 133: strISO3166 = "mt"; break; - case 135: strISO3166 = "mq"; break; - case 136: strISO3166 = "mr"; break; - case 137: strISO3166 = "mu"; break; - case 138: strISO3166 = "yt"; break; - case 139: strISO3166 = "mx"; break; - case 141: strISO3166 = "md"; break; - case 142: strISO3166 = "mc"; break; - case 143: strISO3166 = "mn"; break; - case 145: strISO3166 = "ma"; break; - case 146: strISO3166 = "mz"; break; - case 147: strISO3166 = "mm"; break; - case 148: strISO3166 = "na"; break; - case 150: strISO3166 = "np"; break; - case 151: strISO3166 = "nl"; break; - case 153: strISO3166 = "nc"; break; - case 154: strISO3166 = "nz"; break; - case 155: strISO3166 = "ni"; break; - case 156: strISO3166 = "ne"; break; - case 157: strISO3166 = "ng"; break; - case 161: strISO3166 = "no"; break; - case 162: strISO3166 = "om"; break; - case 163: strISO3166 = "pk"; break; - case 165: strISO3166 = "ps"; break; - case 166: strISO3166 = "pa"; break; - case 167: strISO3166 = "pg"; break; - case 168: strISO3166 = "py"; break; - case 169: strISO3166 = "pe"; break; - case 170: strISO3166 = "ph"; break; - case 172: strISO3166 = "pl"; break; - case 173: strISO3166 = "pt"; break; - case 174: strISO3166 = "pr"; break; - case 175: strISO3166 = "qa"; break; - case 176: strISO3166 = "re"; break; - case 177: strISO3166 = "ro"; break; - case 178: strISO3166 = "ru"; break; - case 179: strISO3166 = "rw"; break; - case 184: strISO3166 = "sm"; break; - case 185: strISO3166 = "st"; break; - case 186: strISO3166 = "sa"; break; - case 187: strISO3166 = "sn"; break; - case 188: strISO3166 = "sc"; break; - case 189: strISO3166 = "sl"; break; - case 190: strISO3166 = "sg"; break; - case 191: strISO3166 = "sk"; break; - case 192: strISO3166 = "si"; break; - case 194: strISO3166 = "so"; break; - case 195: strISO3166 = "za"; break; - case 197: strISO3166 = "es"; break; - case 198: strISO3166 = "lk"; break; - case 201: strISO3166 = "sd"; break; - case 202: strISO3166 = "sr"; break; - case 204: strISO3166 = "sz"; break; - case 205: strISO3166 = "se"; break; - case 206: strISO3166 = "ch"; break; - case 207: strISO3166 = "sy"; break; - case 208: strISO3166 = "tw"; break; - case 209: strISO3166 = "tj"; break; - case 210: strISO3166 = "tz"; break; - case 211: strISO3166 = "th"; break; - case 212: strISO3166 = "tg"; break; - case 214: strISO3166 = "to"; break; - case 216: strISO3166 = "tn"; break; - case 217: strISO3166 = "tr"; break; - case 221: strISO3166 = "ug"; break; - case 222: strISO3166 = "ua"; break; - case 223: strISO3166 = "ae"; break; - case 224: strISO3166 = "gb"; break; - case 225: strISO3166 = "us"; break; - case 227: strISO3166 = "uy"; break; - case 228: strISO3166 = "uz"; break; - case 231: strISO3166 = "ve"; break; - case 232: strISO3166 = "vn"; break; - case 236: strISO3166 = "eh"; break; - case 237: strISO3166 = "ye"; break; - case 239: strISO3166 = "zm"; break; - case 240: strISO3166 = "zw"; break; - case 242: strISO3166 = "me"; break; - case 243: strISO3166 = "rs"; break; - case 248: strISO3166 = "ax"; break; + case 1: + strISO3166 = "af"; + break; + case 2: + strISO3166 = "al"; + break; + case 3: + strISO3166 = "dz"; + break; + case 5: + strISO3166 = "ad"; + break; + case 6: + strISO3166 = "ao"; + break; + case 10: + strISO3166 = "ar"; + break; + case 11: + strISO3166 = "am"; + break; + case 12: + strISO3166 = "aw"; + break; + case 13: + strISO3166 = "au"; + break; + case 14: + strISO3166 = "at"; + break; + case 15: + strISO3166 = "az"; + break; + case 17: + strISO3166 = "bh"; + break; + case 18: + strISO3166 = "bd"; + break; + case 20: + strISO3166 = "by"; + break; + case 21: + strISO3166 = "be"; + break; + case 23: + strISO3166 = "bj"; + break; + case 25: + strISO3166 = "bt"; + break; + case 26: + strISO3166 = "bo"; + break; + case 27: + strISO3166 = "ba"; + break; + case 28: + strISO3166 = "bw"; + break; + case 30: + strISO3166 = "br"; + break; + case 32: + strISO3166 = "bn"; + break; + case 33: + strISO3166 = "bg"; + break; + case 34: + strISO3166 = "bf"; + break; + case 35: + strISO3166 = "bi"; + break; + case 36: + strISO3166 = "kh"; + break; + case 37: + strISO3166 = "cm"; + break; + case 38: + strISO3166 = "ca"; + break; + case 39: + strISO3166 = "cv"; + break; + case 41: + strISO3166 = "cf"; + break; + case 42: + strISO3166 = "td"; + break; + case 43: + strISO3166 = "cl"; + break; + case 44: + strISO3166 = "cn"; + break; + case 47: + strISO3166 = "co"; + break; + case 48: + strISO3166 = "km"; + break; + case 49: + strISO3166 = "cd"; + break; + case 50: + strISO3166 = "cg"; + break; + case 52: + strISO3166 = "cr"; + break; + case 53: + strISO3166 = "ci"; + break; + case 54: + strISO3166 = "hr"; + break; + case 55: + strISO3166 = "cu"; + break; + case 56: + strISO3166 = "cy"; + break; + case 57: + strISO3166 = "cz"; + break; + case 58: + strISO3166 = "dk"; + break; + case 59: + strISO3166 = "dj"; + break; + case 61: + strISO3166 = "do"; + break; + case 62: + strISO3166 = "tl"; + break; + case 63: + strISO3166 = "ec"; + break; + case 64: + strISO3166 = "eg"; + break; + case 65: + strISO3166 = "sv"; + break; + case 66: + strISO3166 = "gq"; + break; + case 67: + strISO3166 = "er"; + break; + case 68: + strISO3166 = "ee"; + break; + case 69: + strISO3166 = "et"; + break; + case 71: + strISO3166 = "fo"; + break; + case 73: + strISO3166 = "fi"; + break; + case 74: + strISO3166 = "fr"; + break; + case 76: + strISO3166 = "gf"; + break; + case 77: + strISO3166 = "pf"; + break; + case 79: + strISO3166 = "ga"; + break; + case 81: + strISO3166 = "ge"; + break; + case 82: + strISO3166 = "de"; + break; + case 83: + strISO3166 = "gh"; + break; + case 85: + strISO3166 = "gr"; + break; + case 86: + strISO3166 = "gl"; + break; + case 88: + strISO3166 = "gp"; + break; + case 90: + strISO3166 = "gt"; + break; + case 91: + strISO3166 = "gn"; + break; + case 92: + strISO3166 = "gw"; + break; + case 93: + strISO3166 = "gy"; + break; + case 96: + strISO3166 = "hn"; + break; + case 97: + strISO3166 = "hk"; + break; + case 98: + strISO3166 = "hu"; + break; + case 99: + strISO3166 = "is"; + break; + case 100: + strISO3166 = "in"; + break; + case 101: + strISO3166 = "id"; + break; + case 102: + strISO3166 = "ir"; + break; + case 103: + strISO3166 = "iq"; + break; + case 104: + strISO3166 = "ie"; + break; + case 105: + strISO3166 = "il"; + break; + case 106: + strISO3166 = "it"; + break; + case 108: + strISO3166 = "jp"; + break; + case 109: + strISO3166 = "jo"; + break; + case 110: + strISO3166 = "kz"; + break; + case 111: + strISO3166 = "ke"; + break; + case 113: + strISO3166 = "kp"; + break; + case 114: + strISO3166 = "kr"; + break; + case 115: + strISO3166 = "kw"; + break; + case 116: + strISO3166 = "kg"; + break; + case 117: + strISO3166 = "la"; + break; + case 118: + strISO3166 = "lv"; + break; + case 119: + strISO3166 = "lb"; + break; + case 120: + strISO3166 = "ls"; + break; + case 122: + strISO3166 = "ly"; + break; + case 123: + strISO3166 = "li"; + break; + case 124: + strISO3166 = "lt"; + break; + case 125: + strISO3166 = "lu"; + break; + case 126: + strISO3166 = "mo"; + break; + case 127: + strISO3166 = "mk"; + break; + case 128: + strISO3166 = "mg"; + break; + case 130: + strISO3166 = "my"; + break; + case 132: + strISO3166 = "ml"; + break; + case 133: + strISO3166 = "mt"; + break; + case 135: + strISO3166 = "mq"; + break; + case 136: + strISO3166 = "mr"; + break; + case 137: + strISO3166 = "mu"; + break; + case 138: + strISO3166 = "yt"; + break; + case 139: + strISO3166 = "mx"; + break; + case 141: + strISO3166 = "md"; + break; + case 142: + strISO3166 = "mc"; + break; + case 143: + strISO3166 = "mn"; + break; + case 145: + strISO3166 = "ma"; + break; + case 146: + strISO3166 = "mz"; + break; + case 147: + strISO3166 = "mm"; + break; + case 148: + strISO3166 = "na"; + break; + case 150: + strISO3166 = "np"; + break; + case 151: + strISO3166 = "nl"; + break; + case 153: + strISO3166 = "nc"; + break; + case 154: + strISO3166 = "nz"; + break; + case 155: + strISO3166 = "ni"; + break; + case 156: + strISO3166 = "ne"; + break; + case 157: + strISO3166 = "ng"; + break; + case 161: + strISO3166 = "no"; + break; + case 162: + strISO3166 = "om"; + break; + case 163: + strISO3166 = "pk"; + break; + case 165: + strISO3166 = "ps"; + break; + case 166: + strISO3166 = "pa"; + break; + case 167: + strISO3166 = "pg"; + break; + case 168: + strISO3166 = "py"; + break; + case 169: + strISO3166 = "pe"; + break; + case 170: + strISO3166 = "ph"; + break; + case 172: + strISO3166 = "pl"; + break; + case 173: + strISO3166 = "pt"; + break; + case 174: + strISO3166 = "pr"; + break; + case 175: + strISO3166 = "qa"; + break; + case 176: + strISO3166 = "re"; + break; + case 177: + strISO3166 = "ro"; + break; + case 178: + strISO3166 = "ru"; + break; + case 179: + strISO3166 = "rw"; + break; + case 184: + strISO3166 = "sm"; + break; + case 185: + strISO3166 = "st"; + break; + case 186: + strISO3166 = "sa"; + break; + case 187: + strISO3166 = "sn"; + break; + case 188: + strISO3166 = "sc"; + break; + case 189: + strISO3166 = "sl"; + break; + case 190: + strISO3166 = "sg"; + break; + case 191: + strISO3166 = "sk"; + break; + case 192: + strISO3166 = "si"; + break; + case 194: + strISO3166 = "so"; + break; + case 195: + strISO3166 = "za"; + break; + case 197: + strISO3166 = "es"; + break; + case 198: + strISO3166 = "lk"; + break; + case 201: + strISO3166 = "sd"; + break; + case 202: + strISO3166 = "sr"; + break; + case 204: + strISO3166 = "sz"; + break; + case 205: + strISO3166 = "se"; + break; + case 206: + strISO3166 = "ch"; + break; + case 207: + strISO3166 = "sy"; + break; + case 208: + strISO3166 = "tw"; + break; + case 209: + strISO3166 = "tj"; + break; + case 210: + strISO3166 = "tz"; + break; + case 211: + strISO3166 = "th"; + break; + case 212: + strISO3166 = "tg"; + break; + case 214: + strISO3166 = "to"; + break; + case 216: + strISO3166 = "tn"; + break; + case 217: + strISO3166 = "tr"; + break; + case 221: + strISO3166 = "ug"; + break; + case 222: + strISO3166 = "ua"; + break; + case 223: + strISO3166 = "ae"; + break; + case 224: + strISO3166 = "gb"; + break; + case 225: + strISO3166 = "us"; + break; + case 227: + strISO3166 = "uy"; + break; + case 228: + strISO3166 = "uz"; + break; + case 231: + strISO3166 = "ve"; + break; + case 232: + strISO3166 = "vn"; + break; + case 236: + strISO3166 = "eh"; + break; + case 237: + strISO3166 = "ye"; + break; + case 239: + strISO3166 = "zm"; + break; + case 240: + strISO3166 = "zw"; + break; + case 242: + strISO3166 = "me"; + break; + case 243: + strISO3166 = "rs"; + break; + case 248: + strISO3166 = "ax"; + break; } strReturn = ":/png/flags/res/flags/" + strISO3166 + ".png"; @@ -1147,41 +1603,41 @@ QString CLocale::GetCountryFlagIconsResourceReference ( const QLocale::Country e strReturn = ""; } -// AT LEAST QT 4.8 IS REQUIRED: -/* - // There is no direct query of the country code in Qt, therefore we use a - // workaround: Get the matching locales properties and split the name of - // that since the second part is the country code - QList vCurLocaleList = QLocale::matchingLocales ( QLocale::AnyLanguage, - QLocale::AnyScript, - eCountry ); - - // check if the matching locales query was successful - if ( vCurLocaleList.size() > 0 ) - { - QStringList vstrLocParts = vCurLocaleList.at ( 0 ).name().split("_"); - - // the second split contains the name we need - if ( vstrLocParts.size() > 1 ) - { - strReturn = ":/png/flags/res/flags/" + vstrLocParts.at ( 1 ).toLower() + ".png"; - - // check if file actually exists, if not then invalidate reference - if ( !QFile::exists ( strReturn ) ) + // AT LEAST QT 4.8 IS REQUIRED: + /* + // There is no direct query of the country code in Qt, therefore we use a + // workaround: Get the matching locales properties and split the name of + // that since the second part is the country code + QList vCurLocaleList = QLocale::matchingLocales ( QLocale::AnyLanguage, + QLocale::AnyScript, + eCountry ); + + // check if the matching locales query was successful + if ( vCurLocaleList.size() > 0 ) { - strReturn = ""; + QStringList vstrLocParts = vCurLocaleList.at ( 0 ).name().split("_"); + + // the second split contains the name we need + if ( vstrLocParts.size() > 1 ) + { + strReturn = ":/png/flags/res/flags/" + vstrLocParts.at ( 1 ).toLower() + ".png"; + + // check if file actually exists, if not then invalidate reference + if ( !QFile::exists ( strReturn ) ) + { + strReturn = ""; + } + //else + //{ + //// TEST generate table + //static FILE* pFile = fopen ( "test.dat", "w" ); + //fprintf ( pFile, " case %d: strISO3166 = \"%s\"; break;\n", + // static_cast ( eCountry ), vstrLocParts.at ( 1 ).toLower().toStdString().c_str() ); + //fflush ( pFile ); + //} + } } -//else -//{ -//// TEST generate table -//static FILE* pFile = fopen ( "test.dat", "w" ); -//fprintf ( pFile, " case %d: strISO3166 = \"%s\"; break;\n", -// static_cast ( eCountry ), vstrLocParts.at ( 1 ).toLower().toStdString().c_str() ); -//fflush ( pFile ); -//} - } - } -*/ + */ } return strReturn; @@ -1241,8 +1697,7 @@ QPair CLocale::FindSysLangTransFileName ( const QMap #include #ifndef HEADLESS -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include "ui_aboutdlgbase.h" +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include "ui_aboutdlgbase.h" #endif #include #include @@ -53,26 +53,23 @@ #include #include "global.h" #ifdef _WIN32 -# include -# include -# include -# include -#elif defined ( __APPLE__ ) || defined ( __MACOSX ) -# include -# include -# include +# include +# include +# include +# include +#elif defined( __APPLE__ ) || defined( __MACOSX ) +# include +# include +# include #else -# include +# include #endif - -class CClient; // forward declaration of CClient - +class CClient; // forward declaration of CClient /* Definitions ****************************************************************/ -#define METER_FLY_BACK 2 -#define INVALID_MIDI_CH -1 // invalid MIDI channel definition - +#define METER_FLY_BACK 2 +#define INVALID_MIDI_CH -1 // invalid MIDI channel definition /* Global functions ***********************************************************/ // converting float to short @@ -94,8 +91,7 @@ inline short Float2Short ( const float fInput ) } // calculate the bit rate in bits per second from the number of coded bytes -inline int CalcBitRateBitsPerSecFromCodedBytes ( const int iCeltNumCodedBytes, - const int iFrameSize ) +inline int CalcBitRateBitsPerSecFromCodedBytes ( const int iCeltNumCodedBytes, const int iFrameSize ) { return ( SYSTEM_SAMPLE_RATE_HZ * iCeltNumCodedBytes * 8 ) / iFrameSize; } @@ -103,36 +99,28 @@ inline int CalcBitRateBitsPerSecFromCodedBytes ( const int iCeltNumCodedBytes, QString GetVersionAndNameStr ( const bool bWithHtml = true ); QString MakeClientNameTitle ( QString win, QString client ); - /******************************************************************************\ * CVector Base Class * \******************************************************************************/ -template class CVector : public std::vector +template +class CVector : public std::vector { public: CVector() {} CVector ( const int iNeSi ) { Init ( iNeSi ); } - CVector ( const int iNeSi, - const TData tInVa ) { Init ( iNeSi, tInVa ); } + CVector ( const int iNeSi, const TData tInVa ) { Init ( iNeSi, tInVa ); } CVector ( CVector const& ) = default; void Init ( const int iNewSize ); // use this init to give all elements a defined value - void Init ( const int iNewSize, - const TData tIniVal ); + void Init ( const int iNewSize, const TData tIniVal ); // set all values to the given reset value - void Reset ( const TData tResetVal ) - { - std::fill ( this->begin(), this->end(), tResetVal ); - } + void Reset ( const TData tResetVal ) { std::fill ( this->begin(), this->end(), tResetVal ); } - void Enlarge ( const int iAddedSize ) - { - std::vector::resize ( std::vector::size() + iAddedSize ); - } + void Enlarge ( const int iAddedSize ) { std::vector::resize ( std::vector::size() + iAddedSize ); } void Add ( const TData& tI ) { @@ -140,24 +128,23 @@ template class CVector : public std::vector std::vector::back() = tI; } - int StringFiFoWithCompare ( const QString strNewValue, - const bool bDoAdding = true ); + int StringFiFoWithCompare ( const QString strNewValue, const bool bDoAdding = true ); // this function simply converts the type of size to integer inline int Size() const { return static_cast ( std::vector::size() ); } }; - /* Implementation *************************************************************/ -template void CVector::Init ( const int iNewSize ) +template +void CVector::Init ( const int iNewSize ) { // clear old buffer and reserve memory for new buffer std::vector::clear(); std::vector::resize ( iNewSize ); } -template void CVector::Init ( const int iNewSize, - const TData tIniVal ) +template +void CVector::Init ( const int iNewSize, const TData tIniVal ) { // call actual init routine and reset all values to the given value Init ( iNewSize ); @@ -165,8 +152,8 @@ template void CVector::Init ( const int iNewSize, } // note: this is only supported for string vectors -template int CVector::StringFiFoWithCompare ( const QString strNewValue, - const bool bDoAdding ) +template +int CVector::StringFiFoWithCompare ( const QString strNewValue, const bool bDoAdding ) { const int iVectorSize = Size(); @@ -213,45 +200,44 @@ template int CVector::StringFiFoWithCompare ( const QString return iOldIndex; } - - /******************************************************************************\ * CFIFO Class (First In, First Out) * \******************************************************************************/ -template class CFIFO : public CVector +template +class CFIFO : public CVector { public: CFIFO() : iCurIdx ( 0 ) {} CFIFO ( const int iNeSi ) : CVector ( iNeSi ), iCurIdx ( 0 ) {} - CFIFO ( const int iNeSi, const TData tInVa ) : - CVector ( iNeSi, tInVa ), iCurIdx ( 0 ) {} + CFIFO ( const int iNeSi, const TData tInVa ) : CVector ( iNeSi, tInVa ), iCurIdx ( 0 ) {} - void Add ( const TData tNewD ); + void Add ( const TData tNewD ); inline TData Get() { return CVector::operator[] ( iCurIdx ); } virtual void Init ( const int iNewSize ); - virtual void Init ( const int iNewSize, - const TData tIniVal ); + virtual void Init ( const int iNewSize, const TData tIniVal ); protected: int iCurIdx; }; -template void CFIFO::Init ( const int iNewSize ) +template +void CFIFO::Init ( const int iNewSize ) { iCurIdx = 0; CVector::Init ( iNewSize ); } -template void CFIFO::Init ( const int iNewSize, - const TData tIniVal ) +template +void CFIFO::Init ( const int iNewSize, const TData tIniVal ) { iCurIdx = 0; CVector::Init ( iNewSize, tIniVal ); } -template void CFIFO::Add ( const TData tNewD ) +template +void CFIFO::Add ( const TData tNewD ) { CVector::operator[] ( iCurIdx ) = tNewD; @@ -264,24 +250,18 @@ template void CFIFO::Add ( const TData tNewD ) } } - /******************************************************************************\ * CMovingAv Class (Moving Average) * \******************************************************************************/ -template class CMovingAv : public CVector +template +class CMovingAv : public CVector { public: - CMovingAv() : - CVector(), - iCurIdx ( 0 ), - iNorm ( 0 ), - dCurAvResult ( 0 ), - dNoDataResult ( 0 ) {} + CMovingAv() : CVector(), iCurIdx ( 0 ), iNorm ( 0 ), dCurAvResult ( 0 ), dNoDataResult ( 0 ) {} void Add ( const TData tNewD ); - - void Init ( const int iNewSize, - const double dNNoDRes = 0 ); + + void Init ( const int iNewSize, const double dNNoDRes = 0 ); void Reset(); @@ -309,7 +289,7 @@ template class CMovingAv : public CVector { return 0; } - } + } protected: int iCurIdx; @@ -318,8 +298,8 @@ template class CMovingAv : public CVector double dNoDataResult; }; -template void CMovingAv::Init ( const int iNewSize, - const double dNNoDRes ) +template +void CMovingAv::Init ( const int iNewSize, const double dNNoDRes ) { iNorm = 0; iCurIdx = 0; @@ -328,7 +308,8 @@ template void CMovingAv::Init ( const int iNewSize, CVector::Init ( iNewSize ); } -template void CMovingAv::Reset() +template +void CMovingAv::Reset() { iNorm = 0; iCurIdx = 0; @@ -336,13 +317,14 @@ template void CMovingAv::Reset() CVector::Reset ( TData ( 0 ) ); } -template void CMovingAv::Add ( const TData tNewD ) +template +void CMovingAv::Add ( const TData tNewD ) { -/* - Optimized calculation of the moving average. We only add a new value and - subtract the old value from the result. We only need one addition and a - history buffer. -*/ + /* + Optimized calculation of the moving average. We only add a new value and + subtract the old value from the result. We only need one addition and a + history buffer. + */ // subtract oldest value dCurAvResult -= CVector::operator[] ( iCurIdx ); @@ -365,7 +347,6 @@ template void CMovingAv::Add ( const TData tNewD ) } } - /******************************************************************************\ * GUI Utilities * \******************************************************************************/ @@ -376,8 +357,7 @@ class CBaseDlg : public QDialog Q_OBJECT public: - CBaseDlg ( QWidget* parent = nullptr, - Qt::WindowFlags flags = Qt::WindowFlags() ) : QDialog ( parent, flags ) {} + CBaseDlg ( QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() ) : QDialog ( parent, flags ) {} public slots: void keyPressEvent ( QKeyEvent* pEvent ) @@ -385,19 +365,18 @@ public slots: // block escape key if ( pEvent->key() != Qt::Key_Escape ) { -#ifdef ANDROID +# ifdef ANDROID if ( pEvent->key() == Qt::Key_Back ) { close(); // otherwise, dialog does not show properly again in android (nefarius2001, #832) return; } -#endif +# endif QDialog::keyPressEvent ( pEvent ); } } }; - // About dialog ---------------------------------------------------------------- class CAboutDlg : public CBaseDlg, private Ui_CAboutDlgBase { @@ -407,7 +386,6 @@ class CAboutDlg : public CBaseDlg, private Ui_CAboutDlgBase CAboutDlg ( QWidget* parent = nullptr ); }; - // Licence dialog -------------------------------------------------------------- class CLicenceDlg : public CBaseDlg { @@ -423,7 +401,6 @@ public slots: void OnAgreeStateChanged ( int value ) { butAccept->setEnabled ( value == Qt::Checked ); } }; - // Help menu ------------------------------------------------------------------- class CHelpMenu : public QMenu { @@ -436,15 +413,14 @@ class CHelpMenu : public QMenu CAboutDlg AboutDlg; public slots: - void OnHelpWhatsThis() { QWhatsThis::enterWhatsThisMode(); } - void OnHelpAbout() { AboutDlg.exec(); } - void OnHelpAboutQt() { QMessageBox::aboutQt ( nullptr, QString ( tr ( "About Qt" ) ) ); } + void OnHelpWhatsThis() { QWhatsThis::enterWhatsThisMode(); } + void OnHelpAbout() { AboutDlg.exec(); } + void OnHelpAboutQt() { QMessageBox::aboutQt ( nullptr, QString ( tr ( "About Qt" ) ) ); } void OnHelpClientGetStarted() { QDesktopServices::openUrl ( QUrl ( CLIENT_GETTING_STARTED_URL ) ); } void OnHelpServerGetStarted() { QDesktopServices::openUrl ( QUrl ( SERVER_GETTING_STARTED_URL ) ); } - void OnHelpSoftwareMan() { QDesktopServices::openUrl ( QUrl ( SOFTWARE_MANUAL_URL ) ); } + void OnHelpSoftwareMan() { QDesktopServices::openUrl ( QUrl ( SOFTWARE_MANUAL_URL ) ); } }; - // Language combo box ---------------------------------------------------------- class CLanguageComboBox : public QComboBox { @@ -466,7 +442,6 @@ public slots: }; #endif - /******************************************************************************\ * Other Classes/Enums * \******************************************************************************/ @@ -474,42 +449,38 @@ public slots: enum EAudChanConf { // used for settings -> enum values should be fixed - CC_MONO = 0, + CC_MONO = 0, CC_MONO_IN_STEREO_OUT = 1, - CC_STEREO = 2 + CC_STEREO = 2 }; - // Audio compression type enum ------------------------------------------------- enum EAudComprType { // used for protocol -> enum values must be fixed! - CT_NONE = 0, - CT_CELT = 1, - CT_OPUS = 2, + CT_NONE = 0, + CT_CELT = 1, + CT_OPUS = 2, CT_OPUS64 = 3 // using OPUS with 64 samples frame size }; - // Network transport flags ----------------------------------------------------- enum ENetwFlags { // used for protocol -> enum values must be fixed! - NF_NONE = 0, + NF_NONE = 0, NF_WITH_COUNTER = 1 // using a network counter to correctly order UDP packets in jitter buffer }; - // Audio quality enum ---------------------------------------------------------- enum EAudioQuality { // used for settings and the comobo box index -> enum values must be fixed! - AQ_LOW = 0, + AQ_LOW = 0, AQ_NORMAL = 1, - AQ_HIGH = 2 + AQ_HIGH = 2 }; - // Get data status enum -------------------------------------------------------- enum EGetDataStat { @@ -519,61 +490,56 @@ enum EGetDataStat GS_CHAN_NOT_CONNECTED }; - // GUI design enum ------------------------------------------------------------- enum EGUIDesign { // used for settings -> enum values should be fixed - GD_STANDARD = 0, - GD_ORIGINAL = 1, + GD_STANDARD = 0, + GD_ORIGINAL = 1, GD_SLIMFADER = 2 }; - // Server licence type enum ---------------------------------------------------- enum ELicenceType { // used for protocol -> enum values must be fixed! - LT_NO_LICENCE = 0, + LT_NO_LICENCE = 0, LT_CREATIVECOMMONS = 1 }; - // Server jam recorder state enum ---------------------------------------------- enum ERecorderState { // used for protocol -> enum values must be fixed! - RS_UNDEFINED = 0, + RS_UNDEFINED = 0, RS_NOT_INITIALISED = 1, - RS_NOT_ENABLED = 2, - RS_RECORDING = 3 + RS_NOT_ENABLED = 2, + RS_RECORDING = 3 }; - // Channel sort type ----------------------------------------------------------- enum EChSortType { // used for settings -> enum values should be fixed - ST_NO_SORT = 0, - ST_BY_NAME = 1, + ST_NO_SORT = 0, + ST_BY_NAME = 1, ST_BY_INSTRUMENT = 2, - ST_BY_GROUPID = 3, - ST_BY_CITY = 4 + ST_BY_GROUPID = 3, + ST_BY_CITY = 4 }; - // Directory server address type ----------------------------------------------- enum ECSAddType { // used for settings -> enum values should be fixed - AT_DEFAULT = 0, - AT_ANY_GENRE2 = 1, - AT_ANY_GENRE3 = 2, - AT_GENRE_ROCK = 3, - AT_GENRE_JAZZ = 4, + AT_DEFAULT = 0, + AT_ANY_GENRE2 = 1, + AT_ANY_GENRE3 = 2, + AT_GENRE_ROCK = 3, + AT_GENRE_JAZZ = 4, AT_GENRE_CLASSICAL_FOLK = 5, - AT_GENRE_CHORAL = 6, - AT_CUSTOM = 7 // Must be the last entry! + AT_GENRE_CHORAL = 6, + AT_CUSTOM = 7 // Must be the last entry! }; inline QString csCentServAddrTypeToString ( ECSAddType eAddrType ) @@ -606,7 +572,6 @@ inline QString csCentServAddrTypeToString ( ECSAddType eAddrType ) } } - // Slave server registration state --------------------------------------------- enum ESvrRegStatus { @@ -656,24 +621,22 @@ inline QString svrRegStatusToString ( ESvrRegStatus eSvrRegStatus ) return QString ( QCoreApplication::translate ( "CServerDlg", "Unknown value " ) ).append ( eSvrRegStatus ); } - // Directory server registration outcome --------------------------------------- enum ESvrRegResult { // used for protocol -> enum values must be fixed! - SRR_REGISTERED = 0, - SRR_CENTRAL_SVR_FULL = 1, - SRR_VERSION_TOO_OLD = 2, + SRR_REGISTERED = 0, + SRR_CENTRAL_SVR_FULL = 1, + SRR_VERSION_TOO_OLD = 2, SRR_NOT_FULFILL_REQIREMENTS = 3 }; - // Skill level enum ------------------------------------------------------------ enum ESkillLevel { // used for protocol -> enum values must be fixed! - SL_NOT_SET = 0, - SL_BEGINNER = 1, + SL_NOT_SET = 0, + SL_BEGINNER = 1, SL_INTERMEDIATE = 2, SL_PROFESSIONAL = 3 }; @@ -692,26 +655,26 @@ enum ESkillLevel #define RGBCOL_G_SL_SL_PROFESSIONAL 225 #define RGBCOL_B_SL_SL_PROFESSIONAL 225 - // Stereo signal level meter --------------------------------------------------- class CStereoSignalLevelMeter { public: -// clang-format off + // clang-format off // TODO Calculate smoothing factor from sample rate and frame size (64 or 128 samples frame size). // But tests with 128 and 64 samples frame size have shown that the meter fly back // is ok for both numbers of samples frame size with a factor of 0.99. -// clang-format on - CStereoSignalLevelMeter ( const bool bNIsStereoOut = true, - const double dNSmoothingFactor = 0.99 ) : - dSmoothingFactor ( dNSmoothingFactor ), bIsStereoOut ( bNIsStereoOut ) { Reset(); } + // clang-format on + CStereoSignalLevelMeter ( const bool bNIsStereoOut = true, const double dNSmoothingFactor = 0.99 ) : + dSmoothingFactor ( dNSmoothingFactor ), + bIsStereoOut ( bNIsStereoOut ) + { + Reset(); + } - void Update ( const CVector& vecsAudio, - const int iInSize, - const bool bIsStereoIn ); + void Update ( const CVector& vecsAudio, const int iInSize, const bool bIsStereoIn ); double GetLevelForMeterdBLeftOrMono() { return CalcLogResultForMeter ( dCurLevelLOrMono ); } - double GetLevelForMeterdBRight() { return CalcLogResultForMeter ( dCurLevelR ); } + double GetLevelForMeterdBRight() { return CalcLogResultForMeter ( dCurLevelR ); } static double CalcLogResultForMeter ( const double& dLinearLevel ); void Reset() @@ -721,8 +684,7 @@ class CStereoSignalLevelMeter } protected: - double UpdateCurLevel ( double dCurLevel, - const double dMax ); + double UpdateCurLevel ( double dCurLevel, const double dMax ); double dCurLevelLOrMono; double dCurLevelR; @@ -730,7 +692,6 @@ class CStereoSignalLevelMeter bool bIsStereoOut; }; - // Host address ---------------------------------------------------------------- class CHostAddress { @@ -742,18 +703,11 @@ class CHostAddress SM_IP_NO_LAST_BYTE_PORT }; - CHostAddress() : - InetAddr ( static_cast ( 0 ) ), - iPort ( 0 ) {} + CHostAddress() : InetAddr ( static_cast ( 0 ) ), iPort ( 0 ) {} - CHostAddress ( const QHostAddress NInetAddr, - const quint16 iNPort ) : - InetAddr ( NInetAddr ), - iPort ( iNPort ) {} + CHostAddress ( const QHostAddress NInetAddr, const quint16 iNPort ) : InetAddr ( NInetAddr ), iPort ( iNPort ) {} - CHostAddress ( const CHostAddress& NHAddr ) : - InetAddr ( NHAddr.InetAddr ), - iPort ( NHAddr.iPort ) {} + CHostAddress ( const CHostAddress& NHAddr ) : InetAddr ( NHAddr.InetAddr ), iPort ( NHAddr.iPort ) {} // copy operator CHostAddress& operator= ( const CHostAddress& NHAddr ) @@ -764,27 +718,21 @@ class CHostAddress } // compare operator - bool operator== ( const CHostAddress& CompAddr ) const - { - return ( ( CompAddr.InetAddr == InetAddr ) && - ( CompAddr.iPort == iPort ) ); - } + bool operator== ( const CHostAddress& CompAddr ) const { return ( ( CompAddr.InetAddr == InetAddr ) && ( CompAddr.iPort == iPort ) ); } QString toString ( const EStringMode eStringMode = SM_IP_PORT ) const { QString strReturn = InetAddr.toString(); // special case: for local host address, we do not replace the last byte - if ( ( ( eStringMode == SM_IP_NO_LAST_BYTE ) || - ( eStringMode == SM_IP_NO_LAST_BYTE_PORT ) ) && + if ( ( ( eStringMode == SM_IP_NO_LAST_BYTE ) || ( eStringMode == SM_IP_NO_LAST_BYTE_PORT ) ) && ( InetAddr != QHostAddress ( QHostAddress::LocalHost ) ) ) { // replace last byte by an "x" strReturn = strReturn.section ( ".", 0, 2 ) + ".x"; } - if ( ( eStringMode == SM_IP_PORT ) || - ( eStringMode == SM_IP_NO_LAST_BYTE_PORT ) ) + if ( ( eStringMode == SM_IP_PORT ) || ( eStringMode == SM_IP_NO_LAST_BYTE_PORT ) ) { // add port number after a semicolon strReturn += ":" + QString().setNum ( iPort ); @@ -797,7 +745,6 @@ class CHostAddress quint16 iPort; }; - // Instrument picture data base ------------------------------------------------ // this is a pure static class class CInstPictures @@ -824,36 +771,31 @@ class CInstPictures static EInstCategory GetCategory ( const int iInstrument ); static void UpdateTableOnLanguageChange() { GetTable ( true ); } -// clang-format off + // clang-format off // TODO make use of instrument category (not yet implemented) -// clang-format on + // clang-format on protected: class CInstPictProps { public: - CInstPictProps() : - strName ( "" ), - strResourceReference ( "" ), - eInstCategory ( IC_OTHER_INSTRUMENT ) {} - - CInstPictProps ( const QString NsName, - const QString NsResRef, - const EInstCategory NeInstCat ) : - strName ( NsName ), + CInstPictProps() : strName ( "" ), strResourceReference ( "" ), eInstCategory ( IC_OTHER_INSTRUMENT ) {} + + CInstPictProps ( const QString NsName, const QString NsResRef, const EInstCategory NeInstCat ) : + strName ( NsName ), strResourceReference ( NsResRef ), - eInstCategory ( NeInstCat ) {} + eInstCategory ( NeInstCat ) + {} QString strName; QString strResourceReference; EInstCategory eInstCategory; }; - static bool IsInstIndexInRange ( const int iIdx ); + static bool IsInstIndexInRange ( const int iIdx ); static CVector& GetTable ( const bool bReGenerateTable = false ); }; - // Locale management class ----------------------------------------------------- class CLocale { @@ -861,78 +803,72 @@ class CLocale static QString GetCountryFlagIconsResourceReference ( const QLocale::Country eCountry ); static QMap GetAvailableTranslations(); static QPair FindSysLangTransFileName ( const QMap& TranslMap ); - static void LoadTranslation ( const QString strLanguage, - QCoreApplication* pApp ); + static void LoadTranslation ( const QString strLanguage, QCoreApplication* pApp ); }; - // Info of a channel ----------------------------------------------------------- class CChannelCoreInfo { public: CChannelCoreInfo() : - strName ( "" ), - eCountry ( QLocale::AnyCountry ), - strCity ( "" ), + strName ( "" ), + eCountry ( QLocale::AnyCountry ), + strCity ( "" ), iInstrument ( CInstPictures::GetNotUsedInstrument() ), - eSkillLevel ( SL_NOT_SET ) {} + eSkillLevel ( SL_NOT_SET ) + {} CChannelCoreInfo ( const QString NsName, const QLocale::Country& NeCountry, const QString& NsCity, const int NiInstrument, const ESkillLevel NeSkillLevel ) : - strName ( NsName ), - eCountry ( NeCountry ), - strCity ( NsCity ), + strName ( NsName ), + eCountry ( NeCountry ), + strCity ( NsCity ), iInstrument ( NiInstrument ), - eSkillLevel ( NeSkillLevel ) {} + eSkillLevel ( NeSkillLevel ) + {} CChannelCoreInfo ( const CChannelCoreInfo& NCorInf ) : - strName ( NCorInf.strName ), - eCountry ( NCorInf.eCountry ), - strCity ( NCorInf.strCity ), + strName ( NCorInf.strName ), + eCountry ( NCorInf.eCountry ), + strCity ( NCorInf.strCity ), iInstrument ( NCorInf.iInstrument ), - eSkillLevel ( NCorInf.eSkillLevel ) {} + eSkillLevel ( NCorInf.eSkillLevel ) + {} // compare operator bool operator!= ( const CChannelCoreInfo& CompChanInfo ) { - return ( ( CompChanInfo.strName != strName ) || - ( CompChanInfo.eCountry != eCountry ) || - ( CompChanInfo.strCity != strCity ) || - ( CompChanInfo.iInstrument != iInstrument ) || - ( CompChanInfo.eSkillLevel != eSkillLevel ) ); + return ( ( CompChanInfo.strName != strName ) || ( CompChanInfo.eCountry != eCountry ) || ( CompChanInfo.strCity != strCity ) || + ( CompChanInfo.iInstrument != iInstrument ) || ( CompChanInfo.eSkillLevel != eSkillLevel ) ); } CChannelCoreInfo& operator= ( const CChannelCoreInfo& ) = default; // fader tag text (channel name) - QString strName; + QString strName; // country in which the client is located QLocale::Country eCountry; // city in which the client is located - QString strCity; + QString strCity; // instrument ID of the client (which instrument is he/she playing) - int iInstrument; + int iInstrument; // skill level of the musician - ESkillLevel eSkillLevel; + ESkillLevel eSkillLevel; }; class CChannelInfo : public CChannelCoreInfo { public: - CChannelInfo() : - iChanID ( 0 ) {} + CChannelInfo() : iChanID ( 0 ) {} - CChannelInfo ( const int NiID, - const CChannelCoreInfo& NCorInf ) : - CChannelCoreInfo ( NCorInf ), - iChanID ( NiID ) {} + CChannelInfo ( const int NiID, const CChannelCoreInfo& NCorInf ) : CChannelCoreInfo ( NCorInf ), iChanID ( NiID ) {} CChannelInfo ( const int NiID, const QString NsName, @@ -940,82 +876,66 @@ class CChannelInfo : public CChannelCoreInfo const QString& NsCity, const int NiInstrument, const ESkillLevel NeSkillLevel ) : - CChannelCoreInfo ( NsName, - NeCountry, - NsCity, - NiInstrument, - NeSkillLevel ), - iChanID ( NiID ) {} + CChannelCoreInfo ( NsName, NeCountry, NsCity, NiInstrument, NeSkillLevel ), + iChanID ( NiID ) + {} // ID of the channel - int iChanID; + int iChanID; }; - // Server info ----------------------------------------------------------------- class CServerCoreInfo { public: - CServerCoreInfo() : - strName ( "" ), - eCountry ( QLocale::AnyCountry ), - strCity ( "" ), - iMaxNumClients ( 0 ), - bPermanentOnline ( false ) {} - - CServerCoreInfo ( - const QString& NsName, - const QLocale::Country& NeCountry, - const QString& NsCity, - const int NiMaxNumClients, - const bool NbPermOnline) : - strName ( NsName ), - eCountry ( NeCountry ), - strCity ( NsCity ), - iMaxNumClients ( NiMaxNumClients ), - bPermanentOnline ( NbPermOnline ) {} + CServerCoreInfo() : strName ( "" ), eCountry ( QLocale::AnyCountry ), strCity ( "" ), iMaxNumClients ( 0 ), bPermanentOnline ( false ) {} + + CServerCoreInfo ( const QString& NsName, + const QLocale::Country& NeCountry, + const QString& NsCity, + const int NiMaxNumClients, + const bool NbPermOnline ) : + strName ( NsName ), + eCountry ( NeCountry ), + strCity ( NsCity ), + iMaxNumClients ( NiMaxNumClients ), + bPermanentOnline ( NbPermOnline ) + {} // name of the server - QString strName; + QString strName; // country in which the server is located QLocale::Country eCountry; // city in which the server is located - QString strCity; + QString strCity; // maximum number of clients which can connect to the server at the same // time - int iMaxNumClients; + int iMaxNumClients; // is the server permanently online or not (flag) - bool bPermanentOnline; + bool bPermanentOnline; }; class CServerInfo : public CServerCoreInfo { public: - CServerInfo() : - HostAddr ( CHostAddress() ), - LHostAddr ( CHostAddress() ) + CServerInfo() : HostAddr ( CHostAddress() ), LHostAddr ( CHostAddress() ) {} + + CServerInfo ( const CHostAddress& NHAddr, + const CHostAddress& NLAddr, + const QString& NsName, + const QLocale::Country& NeCountry, + const QString& NsCity, + const int NiMaxNumClients, + const bool NbPermOnline ) : + CServerCoreInfo ( NsName, NeCountry, NsCity, NiMaxNumClients, NbPermOnline ), + HostAddr ( NHAddr ), + LHostAddr ( NLAddr ) {} - CServerInfo ( - const CHostAddress& NHAddr, - const CHostAddress& NLAddr, - const QString& NsName, - const QLocale::Country& NeCountry, - const QString& NsCity, - const int NiMaxNumClients, - const bool NbPermOnline) : - CServerCoreInfo ( NsName, - NeCountry, - NsCity, - NiMaxNumClients, - NbPermOnline ), - HostAddr ( NHAddr ), - LHostAddr ( NLAddr ) {} - // internet address of the server CHostAddress HostAddr; @@ -1023,19 +943,19 @@ class CServerInfo : public CServerCoreInfo CHostAddress LHostAddr; }; - // Network transport properties ------------------------------------------------ class CNetworkTransportProps { public: CNetworkTransportProps() : iBaseNetworkPacketSize ( 0 ), - iBlockSizeFact ( 0 ), - iNumAudioChannels ( 0 ), - iSampleRate ( 0 ), - eAudioCodingType ( CT_NONE ), - eFlags ( NF_NONE ), - iAudioCodingArg ( 0 ) {} + iBlockSizeFact ( 0 ), + iNumAudioChannels ( 0 ), + iSampleRate ( 0 ), + eAudioCodingType ( CT_NONE ), + eFlags ( NF_NONE ), + iAudioCodingArg ( 0 ) + {} CNetworkTransportProps ( const uint32_t iNBNPS, const uint16_t iNBSF, @@ -1045,12 +965,13 @@ class CNetworkTransportProps const ENetwFlags eNFlags, const int32_t iNACA ) : iBaseNetworkPacketSize ( iNBNPS ), - iBlockSizeFact ( iNBSF ), - iNumAudioChannels ( iNNACH ), - iSampleRate ( iNSR ), - eAudioCodingType ( eNACT ), - eFlags ( eNFlags ), - iAudioCodingArg ( iNACA ) {} + iBlockSizeFact ( iNBSF ), + iNumAudioChannels ( iNNACH ), + iSampleRate ( iNSR ), + eAudioCodingType ( eNACT ), + eFlags ( eNFlags ), + iAudioCodingArg ( iNACA ) + {} uint32_t iBaseNetworkPacketSize; uint16_t iBlockSizeFact; @@ -1061,22 +982,18 @@ class CNetworkTransportProps int32_t iAudioCodingArg; }; - // Network utility functions --------------------------------------------------- class NetworkUtil { public: - static bool ParseNetworkAddress ( QString strAddress, - CHostAddress& HostAddress ); + static bool ParseNetworkAddress ( QString strAddress, CHostAddress& HostAddress ); static QString FixAddress ( const QString& strAddress ); static CHostAddress GetLocalAddress(); - static QString GetCentralServerAddress ( const ECSAddType eCentralServerAddressType, - const QString& strCentralServerAddress ); + static QString GetCentralServerAddress ( const ECSAddType eCentralServerAddressType, const QString& strCentralServerAddress ); static bool IsPrivateNetworkIP ( const QHostAddress& qhAddr ); }; - // Operating system utility functions ------------------------------------------ class COSUtil { @@ -1085,57 +1002,58 @@ class COSUtil { // used for protocol -> enum values must be fixed! OT_WINDOWS = 0, - OT_MAC_OS = 1, - OT_LINUX = 2, + OT_MAC_OS = 1, + OT_LINUX = 2, OT_ANDROID = 3, - OT_I_OS = 4, - OT_UNIX = 5 + OT_I_OS = 4, + OT_UNIX = 5 }; static QString GetOperatingSystemString ( const EOpSystemType eOSType ) { switch ( eOSType ) { - case OT_WINDOWS: return "Windows"; - case OT_MAC_OS: return "MacOS"; - case OT_LINUX: return "Linux"; - case OT_ANDROID: return "Android"; - case OT_I_OS: return "iOS"; - case OT_UNIX: return "Unix"; - default: return "Unknown"; + case OT_WINDOWS: + return "Windows"; + case OT_MAC_OS: + return "MacOS"; + case OT_LINUX: + return "Linux"; + case OT_ANDROID: + return "Android"; + case OT_I_OS: + return "iOS"; + case OT_UNIX: + return "Unix"; + default: + return "Unknown"; } } static EOpSystemType GetOperatingSystem() { #ifdef _WIN32 - return OT_WINDOWS; -#elif defined ( __APPLE__ ) || defined ( __MACOSX ) - return OT_MAC_OS; -#elif defined ( ANDROID ) - return OT_ANDROID; + return OT_WINDOWS; +#elif defined( __APPLE__ ) || defined( __MACOSX ) + return OT_MAC_OS; +#elif defined( ANDROID ) + return OT_ANDROID; #else - return OT_LINUX; + return OT_LINUX; #endif } }; - // Audio reverbration ---------------------------------------------------------- class CAudioReverb { public: CAudioReverb() {} - - void Init ( const EAudChanConf eNAudioChannelConf, - const int iNStereoBlockSizeSam, - const int iSampleRate, - const float fT60 = 1.1f ); + + void Init ( const EAudChanConf eNAudioChannelConf, const int iNStereoBlockSizeSam, const int iSampleRate, const float fT60 = 1.1f ); void Clear(); - void Process ( CVector& vecsStereoInOut, - const bool bReverbOnLeftChan, - const float fAttenuation ); + void Process ( CVector& vecsStereoInOut, const bool bReverbOnLeftChan, const float fAttenuation ); protected: void setT60 ( const float fT60, const int iSampleRate ); @@ -1166,17 +1084,15 @@ class CAudioReverb float combCoefficient[4]; }; - // CRC ------------------------------------------------------------------------- class CCRC { public: - CCRC() : iPoly ( ( 1 << 5 ) | ( 1 << 12 ) ), iBitOutMask ( 1 << 16 ) - { Reset(); } + CCRC() : iPoly ( ( 1 << 5 ) | ( 1 << 12 ) ), iBitOutMask ( 1 << 16 ) { Reset(); } - void Reset(); - void AddByte ( const uint8_t byNewInput ); - bool CheckCRC ( const uint32_t iCRC ) { return iCRC == GetCRC(); } + void Reset(); + void AddByte ( const uint8_t byNewInput ); + bool CheckCRC ( const uint32_t iCRC ) { return iCRC == GetCRC(); } uint32_t GetCRC(); protected: @@ -1185,7 +1101,6 @@ class CCRC uint32_t iStateShiftReg; }; - // Mathematics utilities ------------------------------------------------------- class MathUtils { @@ -1195,10 +1110,7 @@ class MathUtils return static_cast ( ( x - floor ( x ) ) >= 0.5 ) ? static_cast ( ceil ( x ) ) : static_cast ( floor ( x ) ); } - static void UpDownIIR1 ( double& dOldValue, - const double& dNewValue, - const double& dWeightUp, - const double& dWeightDown ) + static void UpDownIIR1 ( double& dOldValue, const double& dNewValue, const double& dWeightUp, const double& dWeightDown ) { // different IIR weights for up and down direction if ( dNewValue < dOldValue ) @@ -1211,9 +1123,7 @@ class MathUtils } } - static int DecideWithHysteresis ( const double dValue, - const int iOldValue, - const double dHysteresis ) + static int DecideWithHysteresis ( const double dValue, const int iOldValue, const double dHysteresis ) { // apply hysteresis if ( dValue > static_cast ( iOldValue ) ) @@ -1228,14 +1138,8 @@ class MathUtils // calculate pan gains: in cross fade mode the pan center is attenuated // by 6 dB, otherwise the center equals full gain for both channels - static inline float GetLeftPan ( const float fPan, const bool bXFade) - { - return bXFade ? 1 - fPan : std::min ( 0.5f, 1 - fPan ) * 2; - } - static inline float GetRightPan ( const float fPan, const bool bXFade) - { - return bXFade ? fPan : std::min ( 0.5f, fPan ) * 2; - } + static inline float GetLeftPan ( const float fPan, const bool bXFade ) { return bXFade ? 1 - fPan : std::min ( 0.5f, 1 - fPan ) * 2; } + static inline float GetRightPan ( const float fPan, const bool bXFade ) { return bXFade ? fPan : std::min ( 0.5f, fPan ) * 2; } // calculate linear gain from fader values which are in dB static float CalcFaderGain ( const float fValue ) @@ -1251,20 +1155,20 @@ class MathUtils } else { - return powf ( 10.0f, ( fInValueRange0_1 - 1.0f ) * - AUD_MIX_FADER_RANGE_DB / 20.0f ); + return powf ( 10.0f, ( fInValueRange0_1 - 1.0f ) * AUD_MIX_FADER_RANGE_DB / 20.0f ); } } }; - // Timing measurement ---------------------------------------------------------- // intended for debugging the timing jitter of the sound card or server timer class CTimingMeas { public: - CTimingMeas ( const int iNNMeas, const QString strNFName = "" ) : - iNumMeas ( iNNMeas ), vElapsedTimes ( iNNMeas ), strFileName ( strNFName ) { Reset(); } + CTimingMeas ( const int iNNMeas, const QString strNFName = "" ) : iNumMeas ( iNNMeas ), vElapsedTimes ( iNNMeas ), strFileName ( strNFName ) + { + Reset(); + } void Reset() { iCnt = INVALID_INDEX; } void Measure() @@ -1312,7 +1216,6 @@ class CTimingMeas int iCnt; }; - /******************************************************************************\ * Statistics * \******************************************************************************/ @@ -1322,8 +1225,7 @@ class CErrorRate public: CErrorRate() {} - void Init ( const int iHistoryLength, - const bool bNBlockOnDoubleErr = false ) + void Init ( const int iHistoryLength, const bool bNBlockOnDoubleErr = false ) { // initialize buffer (use "no data result" of 1.0 which stands for the // worst error rate possible) @@ -1357,7 +1259,6 @@ class CErrorRate else { ErrorsMovAvBuf.Add ( 0 ); - } // store state @@ -1365,7 +1266,7 @@ class CErrorRate } double GetAverage() { return ErrorsMovAvBuf.GetAverage(); } - double InitializationState() { return ErrorsMovAvBuf.InitializationState(); } + double InitializationState() { return ErrorsMovAvBuf.InitializationState(); } protected: CMovingAv ErrorsMovAvBuf; diff --git a/src/vstmain.cpp b/src/vstmain.cpp old mode 100755 new mode 100644 index d225658b1c..e787257f46 --- a/src/vstmain.cpp +++ b/src/vstmain.cpp @@ -24,20 +24,16 @@ #include "vstmain.h" - /* Implementation *************************************************************/ // this function is required for host to get plugin -AudioEffect* createEffectInstance ( audioMasterCallback AudioMaster ) -{ - return new CLlconVST ( AudioMaster ); -} +AudioEffect* createEffectInstance ( audioMasterCallback AudioMaster ) { return new CLlconVST ( AudioMaster ); } CLlconVST::CLlconVST ( audioMasterCallback AudioMaster ) : AudioEffectX ( AudioMaster, 1, 0 ), // 1 program with no parameters (=0) Client ( LLCON_DEFAULT_PORT_NUMBER ) { // stereo input/output - setNumInputs ( 2 ); + setNumInputs ( 2 ); setNumOutputs ( 2 ); setUniqueID ( 'Llco' ); @@ -51,16 +47,15 @@ CLlconVST::CLlconVST ( audioMasterCallback AudioMaster ) : // we want a single shot timer to shut down the connection if no // processing is done anymore (VST host has stopped the stream) TimerOnOff.setSingleShot ( true ); - TimerOnOff.setInterval ( VST_STOP_TIMER_INTERVAL ); + TimerOnOff.setInterval ( VST_STOP_TIMER_INTERVAL ); // connect timer event - connect ( &TimerOnOff, SIGNAL ( timeout() ), - this, SLOT ( OnTimerOnOff() ) ); + connect ( &TimerOnOff, SIGNAL ( timeout() ), this, SLOT ( OnTimerOnOff() ) ); -// clang-format off + // clang-format off // TODO settings Client.SetServerAddr ( DEFAULT_SERVER_ADDRESS ); -// clang-format on + // clang-format on } bool CLlconVST::GetName ( char* cName ) @@ -77,9 +72,7 @@ void CLlconVST::OnTimerOnOff() Client.Stop(); } -void CLlconVST::processReplacing ( float** pvIn, - float** pvOut, - VstInt32 iNumSamples ) +void CLlconVST::processReplacing ( float** pvIn, float** pvOut, VstInt32 iNumSamples ) { int i, j; diff --git a/src/vstmain.h b/src/vstmain.h old mode 100755 new mode 100644 index 38edc5e7a8..db79cfebbf --- a/src/vstmain.h +++ b/src/vstmain.h @@ -22,21 +22,19 @@ * \******************************************************************************/ -#if !defined ( LLCONVST_HOIHGE76G34528_3_434DFGUHF1912__INCLUDED_ ) -#define LLCONVST_HOIHGE76G34528_3_434DFGUHF1912__INCLUDED_ +#if !defined( LLCONVST_HOIHGE76G34528_3_434DFGUHF1912__INCLUDED_ ) +# define LLCONVST_HOIHGE76G34528_3_434DFGUHF1912__INCLUDED_ // copy the VST SDK in the llcon/windows directory: "llcon/windows/vstsdk2.4" to // get it work -#include "audioeffectx.h" -#include -#include "global.h" -#include "client.h" - +# include "audioeffectx.h" +# include +# include "global.h" +# include "client.h" /* Definitions ****************************************************************/ // timeout after which the llcon client is stopped -#define VST_STOP_TIMER_INTERVAL 1000 - +# define VST_STOP_TIMER_INTERVAL 1000 /* Classes ********************************************************************/ class CLlconVST : public QObject, public AudioEffectX @@ -46,15 +44,15 @@ class CLlconVST : public QObject, public AudioEffectX public: CLlconVST ( audioMasterCallback AudioMaster ); - virtual void processReplacing ( float** pvIn, float** pvOut, VstInt32 iNumSamples ); + virtual void processReplacing ( float** pvIn, float** pvOut, VstInt32 iNumSamples ); virtual void setProgramName ( char* cName ) { vst_strncpy ( strProgName, cName, kVstMaxProgNameLen ); } virtual void getProgramName ( char* cName ) { vst_strncpy ( cName, strProgName, kVstMaxProgNameLen ); } - virtual bool getEffectName ( char* cString ) { return GetName ( cString ); } - virtual bool getVendorString ( char* cString ) { return GetName ( cString ); } - virtual bool getProductString ( char* cString ) { return GetName ( cString ); } - virtual VstInt32 getVendorVersion () { return 1000; } + virtual bool getEffectName ( char* cString ) { return GetName ( cString ); } + virtual bool getVendorString ( char* cString ) { return GetName ( cString ); } + virtual bool getProductString ( char* cString ) { return GetName ( cString ); } + virtual VstInt32 getVendorVersion() { return 1000; } protected: bool GetName ( char* cName ); diff --git a/src/vstsound.h b/src/vstsound.h old mode 100755 new mode 100644 index 04ea94a675..cb2af50fde --- a/src/vstsound.h +++ b/src/vstsound.h @@ -22,33 +22,31 @@ * \******************************************************************************/ -#if !defined ( _VSTSOUND_H__9518A346345768_11D3_8C0D_EEBF182CF549__INCLUDED_ ) -#define _VSTSOUND_H__9518A346345768_11D3_8C0D_EEBF182CF549__INCLUDED_ - -#include "../src/util.h" -#include "../src/global.h" -#include "../src/soundbase.h" +#if !defined( _VSTSOUND_H__9518A346345768_11D3_8C0D_EEBF182CF549__INCLUDED_ ) +# define _VSTSOUND_H__9518A346345768_11D3_8C0D_EEBF182CF549__INCLUDED_ +# include "../src/util.h" +# include "../src/global.h" +# include "../src/soundbase.h" /* Classes ********************************************************************/ class CSound : public CSoundBase { public: - CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), void* arg ) : - CSoundBase ( true, fpNewCallback, arg ), iVSTMonoBufferSize ( 0 ) {} + CSound ( void ( *fpNewCallback ) ( CVector& psData, void* arg ), void* arg ) : + CSoundBase ( true, fpNewCallback, arg ), + iVSTMonoBufferSize ( 0 ) + {} // special VST functions void SetMonoBufferSize ( const int iNVBS ) { iVSTMonoBufferSize = iNVBS; } - void VSTProcessCallback() - { - CSoundBase::ProcessCallback ( vecsTmpAudioSndCrdStereo ); - } + void VSTProcessCallback() { CSoundBase::ProcessCallback ( vecsTmpAudioSndCrdStereo ); } virtual int Init ( const int ) { // init base class CSoundBase::Init ( iVSTMonoBufferSize ); - vecsTmpAudioSndCrdStereo.Init ( 2 * iVSTMonoBufferSize /* stereo */); + vecsTmpAudioSndCrdStereo.Init ( 2 * iVSTMonoBufferSize /* stereo */ ); return iVSTMonoBufferSize; } diff --git a/windows/nsProcess/ConvFunc.h b/windows/nsProcess/ConvFunc.h index 739737b084..513cd16f0e 100644 --- a/windows/nsProcess/ConvFunc.h +++ b/windows/nsProcess/ConvFunc.h @@ -15,27 +15,27 @@ *****************************************************************/ #ifndef _CONVFUNC_ -#define _CONVFUNC_ - -int xatoi(char *str); -int xatoiW(wchar_t *wstr); -char* xitoa(int number, char *str, int width); -wchar_t* xitoaW(int number, wchar_t *wstr, int width); -unsigned int xatoui(char *str); -unsigned int xatouiW(wchar_t *wstr); -char* xuitoa(unsigned int number, char *str, int width); -wchar_t* xuitoaW(unsigned int number, wchar_t *wstr, int width); -__int64 xatoi64(char *str); -__int64 xatoi64W(wchar_t *wstr); -char* xi64toa(__int64 number, char *str, int width); -wchar_t* xi64toaW(__int64 number, wchar_t *wstr, int width); -int hex2dec(char *hex); -int hex2decW(wchar_t *whex); -void dec2hex(unsigned int dec, char *hex, BOOL lowercase, unsigned int width); -void dec2hexW(unsigned int dec, wchar_t *whex, BOOL lowercase, unsigned int width); - -void str2hex(unsigned char *str, char *hex, BOOL lowercase, unsigned int bytes); -void hex2str(char *hex, char *str); +# define _CONVFUNC_ + +int xatoi ( char* str ); +int xatoiW ( wchar_t* wstr ); +char* xitoa ( int number, char* str, int width ); +wchar_t* xitoaW ( int number, wchar_t* wstr, int width ); +unsigned int xatoui ( char* str ); +unsigned int xatouiW ( wchar_t* wstr ); +char* xuitoa ( unsigned int number, char* str, int width ); +wchar_t* xuitoaW ( unsigned int number, wchar_t* wstr, int width ); +__int64 xatoi64 ( char* str ); +__int64 xatoi64W ( wchar_t* wstr ); +char* xi64toa ( __int64 number, char* str, int width ); +wchar_t* xi64toaW ( __int64 number, wchar_t* wstr, int width ); +int hex2dec ( char* hex ); +int hex2decW ( wchar_t* whex ); +void dec2hex ( unsigned int dec, char* hex, BOOL lowercase, unsigned int width ); +void dec2hexW ( unsigned int dec, wchar_t* whex, BOOL lowercase, unsigned int width ); + +void str2hex ( unsigned char* str, char* hex, BOOL lowercase, unsigned int bytes ); +void hex2str ( char* hex, char* str ); #endif @@ -54,27 +54,27 @@ void hex2str(char *hex, char *str); * xatoi(" -0045:value") == -45; ********************************************************************/ #if defined xatoi || defined ALLCONVFUNC -#define xatoi_INCLUDED -#undef xatoi -int xatoi(char *str) +# define xatoi_INCLUDED +# undef xatoi +int xatoi ( char* str ) { - int nNumber=0; - BOOL bMinus=FALSE; - - while (*str == ' ') - ++str; - if (*str == '+') - ++str; - else if (*str == '-') - { - bMinus=TRUE; - ++str; - } - for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str) - nNumber=(nNumber * 10) + (*str - '0'); - if (bMinus == TRUE) - nNumber=0 - nNumber; - return nNumber; + int nNumber = 0; + BOOL bMinus = FALSE; + + while ( *str == ' ' ) + ++str; + if ( *str == '+' ) + ++str; + else if ( *str == '-' ) + { + bMinus = TRUE; + ++str; + } + for ( ; *str != '\0' && *str >= '0' && *str <= '9'; ++str ) + nNumber = ( nNumber * 10 ) + ( *str - '0' ); + if ( bMinus == TRUE ) + nNumber = 0 - nNumber; + return nNumber; } #endif @@ -93,27 +93,27 @@ int xatoi(char *str) * xatoiW(L" -0045:value") == -45; ********************************************************************/ #if defined xatoiW || defined ALLCONVFUNC -#define xatoiW_INCLUDED -#undef xatoiW -int xatoiW(wchar_t *wstr) +# define xatoiW_INCLUDED +# undef xatoiW +int xatoiW ( wchar_t* wstr ) { - int nNumber=0; - BOOL bMinus=FALSE; - - while (*wstr == ' ') - ++wstr; - if (*wstr == '+') - ++wstr; - else if (*wstr == '-') - { - bMinus=TRUE; - ++wstr; - } - for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr) - nNumber=(nNumber * 10) + (*wstr - '0'); - if (bMinus == TRUE) - nNumber=0 - nNumber; - return nNumber; + int nNumber = 0; + BOOL bMinus = FALSE; + + while ( *wstr == ' ' ) + ++wstr; + if ( *wstr == '+' ) + ++wstr; + else if ( *wstr == '-' ) + { + bMinus = TRUE; + ++wstr; + } + for ( ; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr ) + nNumber = ( nNumber * 10 ) + ( *wstr - '0' ); + if ( bMinus == TRUE ) + nNumber = 0 - nNumber; + return nNumber; } #endif @@ -135,42 +135,43 @@ int xatoiW(wchar_t *wstr) * xitoa(45, szResult, 4); //szResult == "0045" ********************************************************************/ #if defined xitoa || defined ALLCONVFUNC -#define xitoa_INCLUDED -#undef xitoa -char* xitoa(int number, char *str, int width) +# define xitoa_INCLUDED +# undef xitoa +char* xitoa ( int number, char* str, int width ) { - char tmp[128]; - int a=0; - int b=0; - *tmp = 0; - - if (number == 0) - { - str[0]='0'; - --width; - b=1; - } - else if (number < 0) - { - str[0]='-'; - number=0 - number; - --width; - b=1; - } - for (tmp[a]='\0'; number != 0; ++a) - { - tmp[a]=(number % 10) + '0'; - number=number / 10; - } - if (a < width) - do - { - tmp[a]='0'; - } while (++a= 0; --a, ++b) str[b]=tmp[a]; - - str[b]='\0'; - return str; + char tmp[128]; + int a = 0; + int b = 0; + *tmp = 0; + + if ( number == 0 ) + { + str[0] = '0'; + --width; + b = 1; + } + else if ( number < 0 ) + { + str[0] = '-'; + number = 0 - number; + --width; + b = 1; + } + for ( tmp[a] = '\0'; number != 0; ++a ) + { + tmp[a] = ( number % 10 ) + '0'; + number = number / 10; + } + if ( a < width ) + do + { + tmp[a] = '0'; + } while ( ++a < width ); + for ( --a; a >= 0; --a, ++b ) + str[b] = tmp[a]; + + str[b] = '\0'; + return str; } #endif @@ -192,37 +193,39 @@ char* xitoa(int number, char *str, int width) * xitoaW(45, wszResult, 4); //wszResult == L"0045" ********************************************************************/ #if defined xitoaW || defined ALLCONVFUNC -#define xitoaW_INCLUDED -#undef xitoaW -wchar_t* xitoaW(int number, wchar_t *wstr, int width) +# define xitoaW_INCLUDED +# undef xitoaW +wchar_t* xitoaW ( int number, wchar_t* wstr, int width ) { - wchar_t wtmp[128]=L""; - int a=0; - int b=0; - - if (number == 0) - { - wstr[0]='0'; - --width; - b=1; - } - else if (number < 0) - { - wstr[0]='-'; - number=0 - number; - --width; - b=1; - } - for (wtmp[a]='\0'; number != 0; ++a) - { - wtmp[a]=(number % 10) + '0'; - number=number / 10; - } - for (; width > a; ++a) wtmp[a]='0'; - for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a]; - - wstr[b]='\0'; - return wstr; + wchar_t wtmp[128] = L""; + int a = 0; + int b = 0; + + if ( number == 0 ) + { + wstr[0] = '0'; + --width; + b = 1; + } + else if ( number < 0 ) + { + wstr[0] = '-'; + number = 0 - number; + --width; + b = 1; + } + for ( wtmp[a] = '\0'; number != 0; ++a ) + { + wtmp[a] = ( number % 10 ) + '0'; + number = number / 10; + } + for ( ; width > a; ++a ) + wtmp[a] = '0'; + for ( --a; a >= 0; --a, ++b ) + wstr[b] = wtmp[a]; + + wstr[b] = '\0'; + return wstr; } #endif @@ -241,21 +244,21 @@ wchar_t* xitoaW(int number, wchar_t *wstr, int width) * xatoui(" -0045:value") == 0; ********************************************************************/ #if defined xatoui || defined ALLCONVFUNC -#define xatoui_INCLUDED -#undef xatoui -unsigned int xatoui(char *str) +# define xatoui_INCLUDED +# undef xatoui +unsigned int xatoui ( char* str ) { - unsigned int nNumber=0; - - while (*str == ' ') - ++str; - if (*str == '+') - ++str; - else if (*str == '-') - return 0; - for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str) - nNumber=(nNumber * 10) + (*str - '0'); - return nNumber; + unsigned int nNumber = 0; + + while ( *str == ' ' ) + ++str; + if ( *str == '+' ) + ++str; + else if ( *str == '-' ) + return 0; + for ( ; *str != '\0' && *str >= '0' && *str <= '9'; ++str ) + nNumber = ( nNumber * 10 ) + ( *str - '0' ); + return nNumber; } #endif @@ -274,21 +277,21 @@ unsigned int xatoui(char *str) * xatouiW(L" -0045:value") == 0; ********************************************************************/ #if defined xatouiW || defined ALLCONVFUNC -#define xatouiW_INCLUDED -#undef xatouiW -unsigned int xatouiW(wchar_t *wstr) +# define xatouiW_INCLUDED +# undef xatouiW +unsigned int xatouiW ( wchar_t* wstr ) { - unsigned int nNumber=0; - - while (*wstr == ' ') - ++wstr; - if (*wstr == '+') - ++wstr; - else if (*wstr == '-') - return 0; - for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr) - nNumber=(nNumber * 10) + (*wstr - '0'); - return nNumber; + unsigned int nNumber = 0; + + while ( *wstr == ' ' ) + ++wstr; + if ( *wstr == '+' ) + ++wstr; + else if ( *wstr == '-' ) + return 0; + for ( ; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr ) + nNumber = ( nNumber * 10 ) + ( *wstr - '0' ); + return nNumber; } #endif @@ -309,30 +312,32 @@ unsigned int xatouiW(wchar_t *wstr) * xuitoa(45, szResult, 4); //szResult == "0045" ********************************************************************/ #if defined xuitoa || defined ALLCONVFUNC -#define xuitoa_INCLUDED -#undef xuitoa -char* xuitoa(unsigned int number, char *str, int width) +# define xuitoa_INCLUDED +# undef xuitoa +char* xuitoa ( unsigned int number, char* str, int width ) { - char tmp[128]=""; - int a=0; - int b=0; - - if (number == 0) - { - str[0]='0'; - --width; - b=1; - } - for (tmp[a]='\0'; number != 0; ++a) - { - tmp[a]=(number % 10) + '0'; - number=number / 10; - } - for (; width > a; ++a) tmp[a]='0'; - for (--a; a >= 0; --a, ++b) str[b]=tmp[a]; - - str[b]='\0'; - return str; + char tmp[128] = ""; + int a = 0; + int b = 0; + + if ( number == 0 ) + { + str[0] = '0'; + --width; + b = 1; + } + for ( tmp[a] = '\0'; number != 0; ++a ) + { + tmp[a] = ( number % 10 ) + '0'; + number = number / 10; + } + for ( ; width > a; ++a ) + tmp[a] = '0'; + for ( --a; a >= 0; --a, ++b ) + str[b] = tmp[a]; + + str[b] = '\0'; + return str; } #endif @@ -353,30 +358,32 @@ char* xuitoa(unsigned int number, char *str, int width) * xuitoaW(45, wszResult, 4); //wszResult == L"0045" ********************************************************************/ #if defined xuitoaW || defined ALLCONVFUNC -#define xuitoaW_INCLUDED -#undef xuitoaW -wchar_t* xuitoaW(unsigned int number, wchar_t *wstr, int width) +# define xuitoaW_INCLUDED +# undef xuitoaW +wchar_t* xuitoaW ( unsigned int number, wchar_t* wstr, int width ) { - wchar_t wtmp[128]=L""; - int a=0; - int b=0; - - if (number == 0) - { - wstr[0]='0'; - --width; - b=1; - } - for (wtmp[a]='\0'; number != 0; ++a) - { - wtmp[a]=(number % 10) + '0'; - number=number / 10; - } - for (; width > a; ++a) wtmp[a]='0'; - for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a]; - - wstr[b]='\0'; - return wstr; + wchar_t wtmp[128] = L""; + int a = 0; + int b = 0; + + if ( number == 0 ) + { + wstr[0] = '0'; + --width; + b = 1; + } + for ( wtmp[a] = '\0'; number != 0; ++a ) + { + wtmp[a] = ( number % 10 ) + '0'; + number = number / 10; + } + for ( ; width > a; ++a ) + wtmp[a] = '0'; + for ( --a; a >= 0; --a, ++b ) + wstr[b] = wtmp[a]; + + wstr[b] = '\0'; + return wstr; } #endif @@ -395,27 +402,27 @@ wchar_t* xuitoaW(unsigned int number, wchar_t *wstr, int width) * xatoi64(" -0045:value") == -45; ********************************************************************/ #if defined xatoi64 || defined ALLCONVFUNC -#define xatoi64_INCLUDED -#undef xatoi64 -__int64 xatoi64(char *str) +# define xatoi64_INCLUDED +# undef xatoi64 +__int64 xatoi64 ( char* str ) { - __int64 nNumber=0; - BOOL bMinus=FALSE; - - while (*str == ' ') - ++str; - if (*str == '+') - ++str; - else if (*str == '-') - { - bMinus=TRUE; - ++str; - } - for (; *str != '\0' && *str >= '0' && *str <= '9'; ++str) - nNumber=(nNumber * 10) + (*str - '0'); - if (bMinus == TRUE) - nNumber=0 - nNumber; - return nNumber; + __int64 nNumber = 0; + BOOL bMinus = FALSE; + + while ( *str == ' ' ) + ++str; + if ( *str == '+' ) + ++str; + else if ( *str == '-' ) + { + bMinus = TRUE; + ++str; + } + for ( ; *str != '\0' && *str >= '0' && *str <= '9'; ++str ) + nNumber = ( nNumber * 10 ) + ( *str - '0' ); + if ( bMinus == TRUE ) + nNumber = 0 - nNumber; + return nNumber; } #endif @@ -434,27 +441,27 @@ __int64 xatoi64(char *str) * xatoi64W(L" -0045:value") == -45; ********************************************************************/ #if defined xatoi64W || defined ALLCONVFUNC -#define xatoi64W_INCLUDED -#undef xatoi64W -__int64 xatoi64W(wchar_t *wstr) +# define xatoi64W_INCLUDED +# undef xatoi64W +__int64 xatoi64W ( wchar_t* wstr ) { - __int64 nNumber=0; - BOOL bMinus=FALSE; - - while (*wstr == ' ') - ++wstr; - if (*wstr == '+') - ++wstr; - else if (*wstr == '-') - { - bMinus=TRUE; - ++wstr; - } - for (; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr) - nNumber=(nNumber * 10) + (*wstr - '0'); - if (bMinus == TRUE) - nNumber=0 - nNumber; - return nNumber; + __int64 nNumber = 0; + BOOL bMinus = FALSE; + + while ( *wstr == ' ' ) + ++wstr; + if ( *wstr == '+' ) + ++wstr; + else if ( *wstr == '-' ) + { + bMinus = TRUE; + ++wstr; + } + for ( ; *wstr != '\0' && *wstr >= '0' && *wstr <= '9'; ++wstr ) + nNumber = ( nNumber * 10 ) + ( *wstr - '0' ); + if ( bMinus == TRUE ) + nNumber = 0 - nNumber; + return nNumber; } #endif @@ -476,37 +483,39 @@ __int64 xatoi64W(wchar_t *wstr) * xi64toa(45, szResult, 4); //szResult == "0045" ********************************************************************/ #if defined xi64toa || defined ALLCONVFUNC -#define xi64toa_INCLUDED -#undef xi64toa -char* xi64toa(__int64 number, char *str, int width) +# define xi64toa_INCLUDED +# undef xi64toa +char* xi64toa ( __int64 number, char* str, int width ) { - char tmp[128]=""; - int a=0; - int b=0; - - if (number == 0) - { - str[0]='0'; - --width; - b=1; - } - else if (number < 0) - { - str[0]='-'; - number=0 - number; - --width; - b=1; - } - for (tmp[a]='\0'; number != 0; ++a) - { - tmp[a]=(char)((number % 10) + '0'); - number=number / 10; - } - for (; width > a; ++a) tmp[a]='0'; - for (--a; a >= 0; --a, ++b) str[b]=tmp[a]; - - str[b]='\0'; - return str; + char tmp[128] = ""; + int a = 0; + int b = 0; + + if ( number == 0 ) + { + str[0] = '0'; + --width; + b = 1; + } + else if ( number < 0 ) + { + str[0] = '-'; + number = 0 - number; + --width; + b = 1; + } + for ( tmp[a] = '\0'; number != 0; ++a ) + { + tmp[a] = (char) ( ( number % 10 ) + '0' ); + number = number / 10; + } + for ( ; width > a; ++a ) + tmp[a] = '0'; + for ( --a; a >= 0; --a, ++b ) + str[b] = tmp[a]; + + str[b] = '\0'; + return str; } #endif @@ -528,37 +537,39 @@ char* xi64toa(__int64 number, char *str, int width) * xi64toaW(45, wszResult, 4); //wszResult == L"0045" ********************************************************************/ #if defined xi64toaW || defined ALLCONVFUNC -#define xi64toaW_INCLUDED -#undef xi64toaW -wchar_t* xi64toaW(__int64 number, wchar_t *wstr, int width) +# define xi64toaW_INCLUDED +# undef xi64toaW +wchar_t* xi64toaW ( __int64 number, wchar_t* wstr, int width ) { - wchar_t wtmp[128]=L""; - int a=0; - int b=0; - - if (number == 0) - { - wstr[0]='0'; - --width; - b=1; - } - else if (number < 0) - { - wstr[0]='-'; - number=0 - number; - --width; - b=1; - } - for (wtmp[a]='\0'; number != 0; ++a) - { - wtmp[a]=(char)((number % 10) + '0'); - number=number / 10; - } - for (; width > a; ++a) wtmp[a]='0'; - for (--a; a >= 0; --a, ++b) wstr[b]=wtmp[a]; - - wstr[b]='\0'; - return wstr; + wchar_t wtmp[128] = L""; + int a = 0; + int b = 0; + + if ( number == 0 ) + { + wstr[0] = '0'; + --width; + b = 1; + } + else if ( number < 0 ) + { + wstr[0] = '-'; + number = 0 - number; + --width; + b = 1; + } + for ( wtmp[a] = '\0'; number != 0; ++a ) + { + wtmp[a] = (char) ( ( number % 10 ) + '0' ); + number = number / 10; + } + for ( ; width > a; ++a ) + wtmp[a] = '0'; + for ( --a; a >= 0; --a, ++b ) + wstr[b] = wtmp[a]; + + wstr[b] = '\0'; + return wstr; } #endif @@ -577,24 +588,30 @@ wchar_t* xi64toaW(__int64 number, wchar_t *wstr, int width) * hex2dec("A1F") == 2591; ********************************************************************/ #if defined hex2dec || defined ALLCONVFUNC -#define hex2dec_INCLUDED -#undef hex2dec -int hex2dec(char *hex) +# define hex2dec_INCLUDED +# undef hex2dec +int hex2dec ( char* hex ) { - int a; - int b=0; - - while (1) - { - a=*hex++; - if (a >= '0' && a <= '9') a-='0'; - else if (a >= 'a' && a <= 'f') a-='a'-10; - else if (a >= 'A' && a <= 'F') a-='A'-10; - else return -1; - - if (*hex) b=(b + a) * 16; - else return (b + a); - } + int a; + int b = 0; + + while ( 1 ) + { + a = *hex++; + if ( a >= '0' && a <= '9' ) + a -= '0'; + else if ( a >= 'a' && a <= 'f' ) + a -= 'a' - 10; + else if ( a >= 'A' && a <= 'F' ) + a -= 'A' - 10; + else + return -1; + + if ( *hex ) + b = ( b + a ) * 16; + else + return ( b + a ); + } } #endif @@ -613,24 +630,30 @@ int hex2dec(char *hex) * hex2decW(L"A1F") == 2591; ********************************************************************/ #if defined hex2decW || defined ALLCONVFUNC -#define hex2decW_INCLUDED -#undef hex2decW -int hex2decW(wchar_t *whex) +# define hex2decW_INCLUDED +# undef hex2decW +int hex2decW ( wchar_t* whex ) { - int a; - int b=0; - - while (1) - { - a=*whex++; - if (a >= '0' && a <= '9') a-='0'; - else if (a >= 'a' && a <= 'f') a-='a'-10; - else if (a >= 'A' && a <= 'F') a-='A'-10; - else return -1; - - if (*whex) b=(b + a) * 16; - else return (b + a); - } + int a; + int b = 0; + + while ( 1 ) + { + a = *whex++; + if ( a >= '0' && a <= '9' ) + a -= '0'; + else if ( a >= 'a' && a <= 'f' ) + a -= 'a' - 10; + else if ( a >= 'A' && a <= 'F' ) + a -= 'A' - 10; + else + return -1; + + if ( *whex ) + b = ( b + a ) * 16; + else + return ( b + a ); + } } #endif @@ -651,29 +674,35 @@ int hex2decW(wchar_t *whex) * dec2hex(10, szResult, TRUE, 2); //szResult == "0a" ********************************************************************/ #if defined dec2hex || defined ALLCONVFUNC -#define dec2hex_INCLUDED -#undef dec2hex -void dec2hex(unsigned int dec, char *hex, BOOL lowercase, unsigned int width) +# define dec2hex_INCLUDED +# undef dec2hex +void dec2hex ( unsigned int dec, char* hex, BOOL lowercase, unsigned int width ) { - unsigned int a=dec; - unsigned int b=0; - unsigned int c=0; - char d='1'; - if (a == 0) d='0'; - - while (a) - { - b=a % 16; - a=a / 16; - if (b < 10) hex[c++]=b + '0'; - else if (lowercase == TRUE) hex[c++]=b + 'a' - 10; - else hex[c++]=b + 'A' - 10; - } - while (width > c) hex[c++]='0'; - hex[c]='\0'; - - if (d == '1') - for (b=0, --c; b < c; d=hex[b], hex[b++]=hex[c], hex[c--]=d); + unsigned int a = dec; + unsigned int b = 0; + unsigned int c = 0; + char d = '1'; + if ( a == 0 ) + d = '0'; + + while ( a ) + { + b = a % 16; + a = a / 16; + if ( b < 10 ) + hex[c++] = b + '0'; + else if ( lowercase == TRUE ) + hex[c++] = b + 'a' - 10; + else + hex[c++] = b + 'A' - 10; + } + while ( width > c ) + hex[c++] = '0'; + hex[c] = '\0'; + + if ( d == '1' ) + for ( b = 0, --c; b < c; d = hex[b], hex[b++] = hex[c], hex[c--] = d ) + ; } #endif @@ -694,29 +723,35 @@ void dec2hex(unsigned int dec, char *hex, BOOL lowercase, unsigned int width) * dec2hexW(10, wszResult, TRUE, 2); //wszResult == L"0a" ********************************************************************/ #if defined dec2hexW || defined ALLCONVFUNC -#define dec2hexW_INCLUDED -#undef dec2hexW -void dec2hexW(unsigned int dec, wchar_t *whex, BOOL lowercase, unsigned int width) +# define dec2hexW_INCLUDED +# undef dec2hexW +void dec2hexW ( unsigned int dec, wchar_t* whex, BOOL lowercase, unsigned int width ) { - unsigned int a=dec; - unsigned int b=0; - unsigned int c=0; - wchar_t d='1'; - if (a == 0) d='0'; - - while (a) - { - b=a % 16; - a=a / 16; - if (b < 10) whex[c++]=b + '0'; - else if (lowercase == TRUE) whex[c++]=b + 'a' - 10; - else whex[c++]=b + 'A' - 10; - } - while (width > c) whex[c++]='0'; - whex[c]='\0'; - - if (d == '1') - for (b=0, --c; b < c; d=whex[b], whex[b++]=whex[c], whex[c--]=d); + unsigned int a = dec; + unsigned int b = 0; + unsigned int c = 0; + wchar_t d = '1'; + if ( a == 0 ) + d = '0'; + + while ( a ) + { + b = a % 16; + a = a / 16; + if ( b < 10 ) + whex[c++] = b + '0'; + else if ( lowercase == TRUE ) + whex[c++] = b + 'a' - 10; + else + whex[c++] = b + 'A' - 10; + } + while ( width > c ) + whex[c++] = '0'; + whex[c] = '\0'; + + if ( d == '1' ) + for ( b = 0, --c; b < c; d = whex[b], whex[b++] = whex[c], whex[c--] = d ) + ; } #endif @@ -739,19 +774,19 @@ void dec2hexW(unsigned int dec, wchar_t *whex, BOOL lowercase, unsigned int widt * str2hex((unsigned char *)"Some Text", szResult, TRUE, lstrlen("Some Text")); //szResult == "536f6d652054657874" ********************************************************************/ #if defined str2hex || defined ALLCONVFUNCS -#define str2hex_INCLUDED -#undef str2hex -void str2hex(unsigned char *str, char *hex, BOOL lowercase, unsigned int bytes) +# define str2hex_INCLUDED +# undef str2hex +void str2hex ( unsigned char* str, char* hex, BOOL lowercase, unsigned int bytes ) { - char a[16]; - unsigned int b=0; - - for (hex[0]='\0'; b < bytes; ++b) - { - //wsprintf(a, "%02x", (unsigned int)str[b]); - dec2hex((unsigned int)str[b], a, lowercase, 2); - lstrcat(hex, a); - } + char a[16]; + unsigned int b = 0; + + for ( hex[0] = '\0'; b < bytes; ++b ) + { + // wsprintf(a, "%02x", (unsigned int)str[b]); + dec2hex ( (unsigned int) str[b], a, lowercase, 2 ); + lstrcat ( hex, a ); + } } #endif @@ -768,31 +803,33 @@ void str2hex(unsigned char *str, char *hex, BOOL lowercase, unsigned int bytes) * hex2str("536f6d652054657874", szResult); //szResult == "Some Text" ********************************************************************/ #if defined hex2str || defined ALLCONVFUNCS -#define hex2str_INCLUDED -#undef hex2str -void hex2str(char *hex, char *str) +# define hex2str_INCLUDED +# undef hex2str +void hex2str ( char* hex, char* str ) { - char a[4]; - int b; + char a[4]; + int b; - while (*hex) - { - a[0]=*hex; - a[1]=*++hex; - a[2]='\0'; - - if (*hex++) + while ( *hex ) { - if ((b=hex2dec(a)) > 0) *str++=b; - else break; - } - else break; - } - *str='\0'; + a[0] = *hex; + a[1] = *++hex; + a[2] = '\0'; + + if ( *hex++ ) + { + if ( ( b = hex2dec ( a ) ) > 0 ) + *str++ = b; + else + break; + } + else + break; + } + *str = '\0'; } #endif - /******************************************************************** * * * Example * diff --git a/windows/nsProcess/api.h b/windows/nsProcess/api.h index ed014b2df2..200881dd18 100644 --- a/windows/nsProcess/api.h +++ b/windows/nsProcess/api.h @@ -1,15 +1,15 @@ /* * apih - * + * * This file is a part of NSIS. - * + * * Copyright (C) 1999-2008 Nullsoft and Contributors - * + * * Licensed under the zlib/libpng license (the "License"); * you may not use this file except in compliance with the License. - * + * * Licence details can be found in the file COPYING. - * + * * This software is provided 'as-is', without any express or implied * warranty. */ @@ -21,61 +21,62 @@ // The format is 0xXXXXYYYY where X is the major version and Y is the minor version (MAKELONG(y,x)) // When doing version checks, always remember to use >=, ex: if (pX->exec_flags->plugin_api_version >= NSISPIAPIVER_1_0) {} -#define NSISPIAPIVER_1_0 0x00010000 +#define NSISPIAPIVER_1_0 0x00010000 #define NSISPIAPIVER_CURR NSISPIAPIVER_1_0 // NSIS Plug-In Callback Messages -enum NSPIM +enum NSPIM { - NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup - NSPIM_GUIUNLOAD, // Called after .onGUIEnd + NSPIM_UNLOAD, // This is the last message a plugin gets, do final cleanup + NSPIM_GUIUNLOAD, // Called after .onGUIEnd }; // Prototype for callbacks registered with extra_parameters->RegisterPluginCallback() // Return NULL for unknown messages // Should always be __cdecl for future expansion possibilities -typedef UINT_PTR (*NSISPLUGINCALLBACK)(enum NSPIM); +typedef UINT_PTR ( *NSISPLUGINCALLBACK ) ( enum NSPIM ); // extra_parameters data structures containing other interesting stuff // but the stack, variables and HWND passed on to plug-ins. typedef struct { - int autoclose; - int all_user_var; - int exec_error; - int abort; - int exec_reboot; // NSIS_SUPPORT_REBOOT - int reboot_called; // NSIS_SUPPORT_REBOOT - int XXX_cur_insttype; // depreacted - int plugin_api_version; // see NSISPIAPIVER_CURR - // used to be XXX_insttype_changed - int silent; // NSIS_CONFIG_SILENT_SUPPORT - int instdir_error; - int rtl; - int errlvl; - int alter_reg_view; - int status_update; + int autoclose; + int all_user_var; + int exec_error; + int abort; + int exec_reboot; // NSIS_SUPPORT_REBOOT + int reboot_called; // NSIS_SUPPORT_REBOOT + int XXX_cur_insttype; // depreacted + int plugin_api_version; // see NSISPIAPIVER_CURR + // used to be XXX_insttype_changed + int silent; // NSIS_CONFIG_SILENT_SUPPORT + int instdir_error; + int rtl; + int errlvl; + int alter_reg_view; + int status_update; } exec_flags_t; #ifndef NSISCALL -# define NSISCALL __stdcall +# define NSISCALL __stdcall #endif -typedef struct { - exec_flags_t *exec_flags; - int (NSISCALL *ExecuteCodeSegment)(int, HWND); - void (NSISCALL *validate_filename)(TCHAR *); - BOOL (NSISCALL *RegisterPluginCallback)(HMODULE, NSISPLUGINCALLBACK); +typedef struct +{ + exec_flags_t* exec_flags; + int ( NSISCALL* ExecuteCodeSegment ) ( int, HWND ); + void ( NSISCALL* validate_filename ) ( TCHAR* ); + BOOL ( NSISCALL* RegisterPluginCallback ) ( HMODULE, NSISPLUGINCALLBACK ); } extra_parameters; // Definitions for page showing plug-ins // See Ui.c to understand better how they're used // sent to the outer window to tell it to go to the next inner window -#define WM_NOTIFY_OUTER_NEXT (WM_USER+0x8) +#define WM_NOTIFY_OUTER_NEXT ( WM_USER + 0x8 ) // custom pages should send this message to let NSIS know they're ready -#define WM_NOTIFY_CUSTOM_READY (WM_USER+0xd) +#define WM_NOTIFY_CUSTOM_READY ( WM_USER + 0xd ) // sent as wParam with WM_NOTIFY_OUTER_NEXT when user cancels - heed its warning #define NOTIFY_BYE_BYE 'x' diff --git a/windows/nsProcess/nsis_tchar.h b/windows/nsProcess/nsis_tchar.h index 92025ccc5e..9ba80d5f6d 100644 --- a/windows/nsProcess/nsis_tchar.h +++ b/windows/nsProcess/nsis_tchar.h @@ -1,10 +1,10 @@ /* * nsis_tchar.h - * + * * This file is a part of NSIS. - * + * * Copyright (C) 1999-2007 Nullsoft and Contributors - * + * * This software is provided 'as-is', without any express or implied * warranty. * @@ -17,198 +17,198 @@ #ifdef _UNICODE -#ifndef _T -#define __T(x) L ## x -#define _T(x) __T(x) -#define _TEXT(x) __T(x) -#endif +# ifndef _T +# define __T( x ) L##x +# define _T( x ) __T ( x ) +# define _TEXT( x ) __T ( x ) +# endif typedef wchar_t TCHAR; typedef wchar_t _TUCHAR; // program -#define _tmain wmain -#define _tWinMain wWinMain -#define _tenviron _wenviron -#define __targv __wargv +# define _tmain wmain +# define _tWinMain wWinMain +# define _tenviron _wenviron +# define __targv __wargv // printfs -#define _ftprintf fwprintf -#define _sntprintf _snwprintf -#define _stprintf _swprintf -#define _tprintf wprintf -#define _vftprintf vfwprintf -#define _vsntprintf _vsnwprintf -#define _vstprintf _vswprintf +# define _ftprintf fwprintf +# define _sntprintf _snwprintf +# define _stprintf _swprintf +# define _tprintf wprintf +# define _vftprintf vfwprintf +# define _vsntprintf _vsnwprintf +# define _vstprintf _vswprintf // scanfs -#define _tscanf wscanf -#define _stscanf swscanf +# define _tscanf wscanf +# define _stscanf swscanf // string manipulations -#define _tcscat wcscat -#define _tcschr wcschr -#define _tcsclen wcslen -#define _tcscpy wcscpy -#define _tcsdup _wcsdup -#define _tcslen wcslen -#define _tcsnccpy wcsncpy -#define _tcsncpy wcsncpy -#define _tcsrchr wcsrchr -#define _tcsstr wcsstr -#define _tcstok wcstok +# define _tcscat wcscat +# define _tcschr wcschr +# define _tcsclen wcslen +# define _tcscpy wcscpy +# define _tcsdup _wcsdup +# define _tcslen wcslen +# define _tcsnccpy wcsncpy +# define _tcsncpy wcsncpy +# define _tcsrchr wcsrchr +# define _tcsstr wcsstr +# define _tcstok wcstok // string comparisons -#define _tcscmp wcscmp -#define _tcsicmp _wcsicmp -#define _tcsncicmp _wcsnicmp -#define _tcsncmp wcsncmp -#define _tcsnicmp _wcsnicmp +# define _tcscmp wcscmp +# define _tcsicmp _wcsicmp +# define _tcsncicmp _wcsnicmp +# define _tcsncmp wcsncmp +# define _tcsnicmp _wcsnicmp // upper / lower -#define _tcslwr _wcslwr -#define _tcsupr _wcsupr -#define _totlower towlower -#define _totupper towupper +# define _tcslwr _wcslwr +# define _tcsupr _wcsupr +# define _totlower towlower +# define _totupper towupper // conversions to numbers -#define _tcstoi64 _wcstoi64 -#define _tcstol wcstol -#define _tcstoul wcstoul -#define _tstof _wtof -#define _tstoi _wtoi -#define _tstoi64 _wtoi64 -#define _ttoi _wtoi -#define _ttoi64 _wtoi64 -#define _ttol _wtol +# define _tcstoi64 _wcstoi64 +# define _tcstol wcstol +# define _tcstoul wcstoul +# define _tstof _wtof +# define _tstoi _wtoi +# define _tstoi64 _wtoi64 +# define _ttoi _wtoi +# define _ttoi64 _wtoi64 +# define _ttol _wtol // conversion from numbers to strings -#define _itot _itow -#define _ltot _ltow -#define _i64tot _i64tow -#define _ui64tot _ui64tow +# define _itot _itow +# define _ltot _ltow +# define _i64tot _i64tow +# define _ui64tot _ui64tow // file manipulations -#define _tfopen _wfopen -#define _topen _wopen -#define _tremove _wremove -#define _tunlink _wunlink +# define _tfopen _wfopen +# define _topen _wopen +# define _tremove _wremove +# define _tunlink _wunlink // reading and writing to i/o -#define _fgettc fgetwc -#define _fgetts fgetws -#define _fputts fputws -#define _gettchar getwchar +# define _fgettc fgetwc +# define _fgetts fgetws +# define _fputts fputws +# define _gettchar getwchar // directory -#define _tchdir _wchdir +# define _tchdir _wchdir // environment -#define _tgetenv _wgetenv -#define _tsystem _wsystem +# define _tgetenv _wgetenv +# define _tsystem _wsystem // time -#define _tcsftime wcsftime +# define _tcsftime wcsftime #else // ANSI -#ifndef _T -#define _T(x) x -#define _TEXT(x) x -#endif -typedef char TCHAR; -typedef unsigned char _TUCHAR; +# ifndef _T +# define _T( x ) x +# define _TEXT( x ) x +# endif +typedef char TCHAR; +typedef unsigned char _TUCHAR; // program -#define _tmain main -#define _tWinMain WinMain -#define _tenviron environ -#define __targv __argv +# define _tmain main +# define _tWinMain WinMain +# define _tenviron environ +# define __targv __argv // printfs -#define _ftprintf fprintf -#define _sntprintf _snprintf -#define _stprintf sprintf -#define _tprintf printf -#define _vftprintf vfprintf -#define _vsntprintf _vsnprintf -#define _vstprintf vsprintf +# define _ftprintf fprintf +# define _sntprintf _snprintf +# define _stprintf sprintf +# define _tprintf printf +# define _vftprintf vfprintf +# define _vsntprintf _vsnprintf +# define _vstprintf vsprintf // scanfs -#define _tscanf scanf -#define _stscanf sscanf +# define _tscanf scanf +# define _stscanf sscanf // string manipulations -#define _tcscat strcat -#define _tcschr strchr -#define _tcsclen strlen -#define _tcscnlen strnlen -#define _tcscpy strcpy -#define _tcsdup _strdup -#define _tcslen strlen -#define _tcsnccpy strncpy -#define _tcsrchr strrchr -#define _tcsstr strstr -#define _tcstok strtok +# define _tcscat strcat +# define _tcschr strchr +# define _tcsclen strlen +# define _tcscnlen strnlen +# define _tcscpy strcpy +# define _tcsdup _strdup +# define _tcslen strlen +# define _tcsnccpy strncpy +# define _tcsrchr strrchr +# define _tcsstr strstr +# define _tcstok strtok // string comparisons -#define _tcscmp strcmp -#define _tcsicmp _stricmp -#define _tcsncmp strncmp -#define _tcsncicmp _strnicmp -#define _tcsnicmp _strnicmp +# define _tcscmp strcmp +# define _tcsicmp _stricmp +# define _tcsncmp strncmp +# define _tcsncicmp _strnicmp +# define _tcsnicmp _strnicmp // upper / lower -#define _tcslwr _strlwr -#define _tcsupr _strupr +# define _tcslwr _strlwr +# define _tcsupr _strupr -#define _totupper toupper -#define _totlower tolower +# define _totupper toupper +# define _totlower tolower // conversions to numbers -#define _tcstol strtol -#define _tcstoul strtoul -#define _tstof atof -#define _tstoi atoi -#define _tstoi64 _atoi64 -#define _tstoi64 _atoi64 -#define _ttoi atoi -#define _ttoi64 _atoi64 -#define _ttol atol +# define _tcstol strtol +# define _tcstoul strtoul +# define _tstof atof +# define _tstoi atoi +# define _tstoi64 _atoi64 +# define _tstoi64 _atoi64 +# define _ttoi atoi +# define _ttoi64 _atoi64 +# define _ttol atol // conversion from numbers to strings -#define _i64tot _i64toa -#define _itot _itoa -#define _ltot _ltoa -#define _ui64tot _ui64toa +# define _i64tot _i64toa +# define _itot _itoa +# define _ltot _ltoa +# define _ui64tot _ui64toa // file manipulations -#define _tfopen fopen -#define _topen _open -#define _tremove remove -#define _tunlink _unlink +# define _tfopen fopen +# define _topen _open +# define _tremove remove +# define _tunlink _unlink // reading and writing to i/o -#define _fgettc fgetc -#define _fgetts fgets -#define _fputts fputs -#define _gettchar getchar +# define _fgettc fgetc +# define _fgetts fgets +# define _fputts fputs +# define _gettchar getchar // directory -#define _tchdir _chdir +# define _tchdir _chdir // environment -#define _tgetenv getenv -#define _tsystem system +# define _tgetenv getenv +# define _tsystem system // time -#define _tcsftime strftime +# define _tcsftime strftime #endif // is functions (the same in Unicode / ANSI) -#define _istgraph isgraph -#define _istascii __isascii +#define _istgraph isgraph +#define _istascii __isascii -#define __TFILE__ _T(__FILE__) -#define __TDATE__ _T(__DATE__) -#define __TTIME__ _T(__TIME__) +#define __TFILE__ _T ( __FILE__ ) +#define __TDATE__ _T ( __DATE__ ) +#define __TTIME__ _T ( __TIME__ ) diff --git a/windows/nsProcess/pluginapi.h b/windows/nsProcess/pluginapi.h index b9bfee91c9..fed8c16f07 100644 --- a/windows/nsProcess/pluginapi.h +++ b/windows/nsProcess/pluginapi.h @@ -2,95 +2,99 @@ #define ___NSIS_PLUGIN__H___ #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif #include "api.h" #include "nsis_tchar.h" #ifndef NSISCALL -# define NSISCALL __stdcall +# define NSISCALL __stdcall #endif -#define EXDLL_INIT() { \ - g_stringsize=string_size; \ - g_stacktop=stacktop; \ - g_variables=variables; } - -typedef struct _stack_t { - struct _stack_t *next; - TCHAR text[1]; // this should be the length of string_size -} stack_t; - -enum -{ -INST_0, // $0 -INST_1, // $1 -INST_2, // $2 -INST_3, // $3 -INST_4, // $4 -INST_5, // $5 -INST_6, // $6 -INST_7, // $7 -INST_8, // $8 -INST_9, // $9 -INST_R0, // $R0 -INST_R1, // $R1 -INST_R2, // $R2 -INST_R3, // $R3 -INST_R4, // $R4 -INST_R5, // $R5 -INST_R6, // $R6 -INST_R7, // $R7 -INST_R8, // $R8 -INST_R9, // $R9 -INST_CMDLINE, // $CMDLINE -INST_INSTDIR, // $INSTDIR -INST_OUTDIR, // $OUTDIR -INST_EXEDIR, // $EXEDIR -INST_LANG, // $LANGUAGE -__INST_LAST -}; - -extern unsigned int g_stringsize; -extern stack_t **g_stacktop; -extern TCHAR *g_variables; - -int NSISCALL popstring(TCHAR *str); // 0 on success, 1 on empty stack -int NSISCALL popstringn(TCHAR *str, int maxlen); // with length limit, pass 0 for g_stringsize -int NSISCALL popint(); // pops an integer -int NSISCALL popint_or(); // with support for or'ing (2|4|8) -int NSISCALL myatoi(const TCHAR *s); // converts a string to an integer -unsigned NSISCALL myatou(const TCHAR *s); // converts a string to an unsigned integer, decimal only -int NSISCALL myatoi_or(const TCHAR *s); // with support for or'ing (2|4|8) -void NSISCALL pushstring(const TCHAR *str); -void NSISCALL pushint(int value); -TCHAR * NSISCALL getuservariable(const int varnum); -void NSISCALL setuservariable(const int varnum, const TCHAR *var); +#define EXDLL_INIT() \ + { \ + g_stringsize = string_size; \ + g_stacktop = stacktop; \ + g_variables = variables; \ + } + + typedef struct _stack_t + { + struct _stack_t* next; + TCHAR text[1]; // this should be the length of string_size + } stack_t; + + enum + { + INST_0, // $0 + INST_1, // $1 + INST_2, // $2 + INST_3, // $3 + INST_4, // $4 + INST_5, // $5 + INST_6, // $6 + INST_7, // $7 + INST_8, // $8 + INST_9, // $9 + INST_R0, // $R0 + INST_R1, // $R1 + INST_R2, // $R2 + INST_R3, // $R3 + INST_R4, // $R4 + INST_R5, // $R5 + INST_R6, // $R6 + INST_R7, // $R7 + INST_R8, // $R8 + INST_R9, // $R9 + INST_CMDLINE, // $CMDLINE + INST_INSTDIR, // $INSTDIR + INST_OUTDIR, // $OUTDIR + INST_EXEDIR, // $EXEDIR + INST_LANG, // $LANGUAGE + __INST_LAST + }; + + extern unsigned int g_stringsize; + extern stack_t** g_stacktop; + extern TCHAR* g_variables; + + int NSISCALL popstring ( TCHAR* str ); // 0 on success, 1 on empty stack + int NSISCALL popstringn ( TCHAR* str, int maxlen ); // with length limit, pass 0 for g_stringsize + int NSISCALL popint(); // pops an integer + int NSISCALL popint_or(); // with support for or'ing (2|4|8) + int NSISCALL myatoi ( const TCHAR* s ); // converts a string to an integer + unsigned NSISCALL myatou ( const TCHAR* s ); // converts a string to an unsigned integer, decimal only + int NSISCALL myatoi_or ( const TCHAR* s ); // with support for or'ing (2|4|8) + void NSISCALL pushstring ( const TCHAR* str ); + void NSISCALL pushint ( int value ); + TCHAR* NSISCALL getuservariable ( const int varnum ); + void NSISCALL setuservariable ( const int varnum, const TCHAR* var ); #ifdef _UNICODE -#define PopStringW(x) popstring(x) -#define PushStringW(x) pushstring(x) -#define SetUserVariableW(x,y) setuservariable(x,y) +# define PopStringW( x ) popstring ( x ) +# define PushStringW( x ) pushstring ( x ) +# define SetUserVariableW( x, y ) setuservariable ( x, y ) -int NSISCALL PopStringA(char* ansiStr); -void NSISCALL PushStringA(const char* ansiStr); -void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr); -void NSISCALL GetUserVariableA(const int varnum, char* ansiStr); -void NSISCALL SetUserVariableA(const int varnum, const char* ansiStr); + int NSISCALL PopStringA ( char* ansiStr ); + void NSISCALL PushStringA ( const char* ansiStr ); + void NSISCALL GetUserVariableW ( const int varnum, wchar_t* wideStr ); + void NSISCALL GetUserVariableA ( const int varnum, char* ansiStr ); + void NSISCALL SetUserVariableA ( const int varnum, const char* ansiStr ); #else // ANSI defs -#define PopStringA(x) popstring(x) -#define PushStringA(x) pushstring(x) -#define SetUserVariableA(x,y) setuservariable(x,y) +# define PopStringA( x ) popstring ( x ) +# define PushStringA( x ) pushstring ( x ) +# define SetUserVariableA( x, y ) setuservariable ( x, y ) -int NSISCALL PopStringW(wchar_t* wideStr); -void NSISCALL PushStringW(wchar_t* wideStr); -void NSISCALL GetUserVariableW(const int varnum, wchar_t* wideStr); -void NSISCALL GetUserVariableA(const int varnum, char* ansiStr); -void NSISCALL SetUserVariableW(const int varnum, const wchar_t* wideStr); +int NSISCALL PopStringW ( wchar_t* wideStr ); +void NSISCALL PushStringW ( wchar_t* wideStr ); +void NSISCALL GetUserVariableW ( const int varnum, wchar_t* wideStr ); +void NSISCALL GetUserVariableA ( const int varnum, char* ansiStr ); +void NSISCALL SetUserVariableW ( const int varnum, const wchar_t* wideStr ); #endif @@ -98,4 +102,4 @@ void NSISCALL SetUserVariableW(const int varnum, const wchar_t* wideStr); } #endif -#endif//!___NSIS_PLUGIN__H___ +#endif //!___NSIS_PLUGIN__H___ diff --git a/windows/sound.cpp b/windows/sound.cpp old mode 100755 new mode 100644 index c36faea001..64d01db2ae --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -27,21 +27,18 @@ #include "sound.h" - /* Implementation *************************************************************/ // external references extern AsioDrivers* asioDrivers; -bool loadAsioDriver ( char* name ); +bool loadAsioDriver ( char* name ); // pointer to our sound object CSound* pSound; - /******************************************************************************\ * Common * \******************************************************************************/ -QString CSound::LoadAndInitializeDriver ( QString strDriverName, - bool bOpenDriverSetup ) +QString CSound::LoadAndInitializeDriver ( QString strDriverName, bool bOpenDriverSetup ) { // find and load driver int iDriverIdx = INVALID_INDEX; // initialize with an invalid index @@ -62,7 +59,7 @@ QString CSound::LoadAndInitializeDriver ( QString strDriverName, // Save number of channels from last driver // Need to save these (but not the driver name) as CheckDeviceCapabilities() overwrites them - long lNumInChanPrev = lNumInChan; + long lNumInChanPrev = lNumInChan; long lNumOutChanPrev = lNumOutChan; loadAsioDriver ( cDriverNames[iDriverIdx] ); @@ -86,9 +83,7 @@ QString CSound::LoadAndInitializeDriver ( QString strDriverName, if ( strStat.isEmpty() ) { // Reset channel mapping if the sound card name has changed or the number of channels has changed - if ( ( strCurDevName.compare ( strDriverNames[iDriverIdx] ) != 0 ) || - ( lNumInChanPrev != lNumInChan ) || - ( lNumOutChanPrev != lNumOutChan ) ) + if ( ( strCurDevName.compare ( strDriverNames[iDriverIdx] ) != 0 ) || ( lNumInChanPrev != lNumInChan ) || ( lNumOutChanPrev != lNumOutChan ) ) { // In order to fix https://github.com/jamulussoftware/jamulus/issues/796 // this code runs after a change in the ASIO driver (not when changing the ASIO input selection.) @@ -106,7 +101,10 @@ QString CSound::LoadAndInitializeDriver ( QString strDriverName, if ( bOpenDriverSetup ) { OpenDriverSetup(); - QMessageBox::question ( nullptr, APP_NAME, "Are you done with your ASIO driver settings of device " + GetDeviceName ( iDriverIdx ) + "?", QMessageBox::Yes ); + QMessageBox::question ( nullptr, + APP_NAME, + "Are you done with your ASIO driver settings of device " + GetDeviceName ( iDriverIdx ) + "?", + QMessageBox::Yes ); } // driver cannot be used, clean up @@ -142,42 +140,41 @@ QString CSound::CheckDeviceCapabilities() // check the sample rate const ASIOError CanSaRateReturn = ASIOCanSampleRate ( SYSTEM_SAMPLE_RATE_HZ ); - if ( ( CanSaRateReturn == ASE_NoClock ) || - ( CanSaRateReturn == ASE_NotPresent ) ) + if ( ( CanSaRateReturn == ASE_NoClock ) || ( CanSaRateReturn == ASE_NotPresent ) ) { // return error string return tr ( "The audio device does not support the " - "required sample rate. The required sample rate is: " ) + - QString().setNum ( SYSTEM_SAMPLE_RATE_HZ ) + " Hz"; + "required sample rate. The required sample rate is: " ) + + QString().setNum ( SYSTEM_SAMPLE_RATE_HZ ) + " Hz"; } // check if sample rate can be set const ASIOError SetSaRateReturn = ASIOSetSampleRate ( SYSTEM_SAMPLE_RATE_HZ ); - if ( ( SetSaRateReturn == ASE_NoClock ) || - ( SetSaRateReturn == ASE_InvalidMode ) || - ( SetSaRateReturn == ASE_NotPresent ) ) + if ( ( SetSaRateReturn == ASE_NoClock ) || ( SetSaRateReturn == ASE_InvalidMode ) || ( SetSaRateReturn == ASE_NotPresent ) ) { // return error string return tr ( "The audio device does not support setting the required sampling " - "rate. This error can happen if you have an audio interface like the " - "Roland UA-25EX where you set the sample rate with a hardware switch " - "on the audio device. If this is the case, please change the sample rate " - "to " ) + QString().setNum ( SYSTEM_SAMPLE_RATE_HZ ) + tr ( " Hz on the " - "device and restart the " ) + APP_NAME + tr ( " software." ); + "rate. This error can happen if you have an audio interface like the " + "Roland UA-25EX where you set the sample rate with a hardware switch " + "on the audio device. If this is the case, please change the sample rate " + "to " ) + + QString().setNum ( SYSTEM_SAMPLE_RATE_HZ ) + + tr ( " Hz on the " + "device and restart the " ) + + APP_NAME + tr ( " software." ); } // check the number of available channels ASIOGetChannels ( &lNumInChan, &lNumOutChan ); - if ( ( lNumInChan < NUM_IN_OUT_CHANNELS ) || - ( lNumOutChan < NUM_IN_OUT_CHANNELS ) ) + if ( ( lNumInChan < NUM_IN_OUT_CHANNELS ) || ( lNumOutChan < NUM_IN_OUT_CHANNELS ) ) { // return error string return tr ( "The audio device does not support the " - "required number of channels. The required number of channels " - "for input and output is: " ) + - QString().setNum ( NUM_IN_OUT_CHANNELS ); + "required number of channels. The required number of channels " + "for input and output is: " ) + + QString().setNum ( NUM_IN_OUT_CHANNELS ); } // clip number of input/output channels to our maximum @@ -259,8 +256,7 @@ QString CSound::CheckDeviceCapabilities() if ( iSelAddCH >= 0 ) { // for mixed channels, show both audio channel names to be mixed - channelInputName[iCh] = - channelInputName[iSelCH] + " + " + channelInputName[iSelAddCH]; + channelInputName[iCh] = channelInputName[iSelCH] + " + " + channelInputName[iSelAddCH]; } } } @@ -274,7 +270,7 @@ QString CSound::CheckDeviceCapabilities() return ""; } -void CSound::SetLeftInputChannel ( const int iNewChan ) +void CSound::SetLeftInputChannel ( const int iNewChan ) { // apply parameter after input parameter check if ( ( iNewChan >= 0 ) && ( iNewChan < lNumInChanPlusAddChan ) ) @@ -292,7 +288,7 @@ void CSound::SetRightInputChannel ( const int iNewChan ) } } -void CSound::SetLeftOutputChannel ( const int iNewChan ) +void CSound::SetLeftOutputChannel ( const int iNewChan ) { // apply parameter after input parameter check if ( ( iNewChan >= 0 ) && ( iNewChan < lNumOutChan ) ) @@ -315,12 +311,9 @@ int CSound::GetActualBufferSize ( const int iDesiredBufferSizeMono ) int iActualBufferSizeMono; // query the usable buffer sizes - ASIOGetBufferSize ( &HWBufferInfo.lMinSize, - &HWBufferInfo.lMaxSize, - &HWBufferInfo.lPreferredSize, - &HWBufferInfo.lGranularity ); + ASIOGetBufferSize ( &HWBufferInfo.lMinSize, &HWBufferInfo.lMaxSize, &HWBufferInfo.lPreferredSize, &HWBufferInfo.lGranularity ); -// clang-format off + // clang-format off /* // TEST #include @@ -328,11 +321,11 @@ QMessageBox::information ( 0, "APP_NAME", QString("lMinSize: %1, lMaxSize: %2, l arg(HWBufferInfo.lMinSize).arg(HWBufferInfo.lMaxSize).arg(HWBufferInfo.lPreferredSize).arg(HWBufferInfo.lGranularity) ); _exit(1); */ -// clang-format on + // clang-format on -// clang-format off + // clang-format off // TODO see https://github.com/EddieRingle/portaudio/blob/master/src/hostapi/asio/pa_asio.cpp#L1654 (SelectHostBufferSizeForUnspecifiedUserFramesPerBuffer) -// clang-format on + // clang-format on // calculate "nearest" buffer size and set internal parameter accordingly // first check minimum and maximum values @@ -357,8 +350,7 @@ _exit(1); } else { - if ( ( HWBufferInfo.lGranularity < -1 ) || - ( HWBufferInfo.lGranularity == 0 ) ) + if ( ( HWBufferInfo.lGranularity < -1 ) || ( HWBufferInfo.lGranularity == 0 ) ) { // Special case (seen for EMU audio cards): granularity is // zero or less than zero (make sure to exclude the special @@ -383,8 +375,7 @@ _exit(1); { // test which buffer size fits better: the old one or the // current one - if ( ( iTrialBufSize - iDesiredBufferSizeMono ) > - ( iDesiredBufferSizeMono - iLastTrialBufSize ) ) + if ( ( iTrialBufSize - iDesiredBufferSizeMono ) > ( iDesiredBufferSizeMono - iLastTrialBufSize ) ) { iTrialBufSize = iLastTrialBufSize; } @@ -473,8 +464,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize ) bufferInfos[lNumInChan + i].buffers[1] = 0; } - ASIOCreateBuffers ( bufferInfos, lNumInChan + lNumOutChan, - iASIOBufferSizeMono, &asioCallbacks ); + ASIOCreateBuffers ( bufferInfos, lNumInChan + lNumOutChan, iASIOBufferSizeMono, &asioCallbacks ); // query the latency of the driver long lInputLatency = 0; @@ -484,9 +474,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize ) { // add the input and output latencies (returned in number of // samples) and calculate the time in ms - fInOutLatencyMs = - ( static_cast ( lInputLatency ) + lOutputLatency ) * - 1000 / SYSTEM_SAMPLE_RATE_HZ; + fInOutLatencyMs = ( static_cast ( lInputLatency ) + lOutputLatency ) * 1000 / SYSTEM_SAMPLE_RATE_HZ; } else { @@ -528,17 +516,17 @@ void CSound::Stop() } } -CSound::CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), +CSound::CSound ( void ( *fpNewCallback ) ( CVector& psData, void* arg ), void* arg, const QString& strMIDISetup, - const bool , + const bool, const QString& ) : - CSoundBase ( "ASIO", fpNewCallback, arg, strMIDISetup ), - lNumInChan ( 0 ), - lNumInChanPlusAddChan ( 0 ), - lNumOutChan ( 0 ), - fInOutLatencyMs ( 0.0f ), // "0.0" means that no latency value is available - vSelectedInputChannels ( NUM_IN_OUT_CHANNELS ), + CSoundBase ( "ASIO", fpNewCallback, arg, strMIDISetup ), + lNumInChan ( 0 ), + lNumInChanPlusAddChan ( 0 ), + lNumOutChan ( 0 ), + fInOutLatencyMs ( 0.0f ), // "0.0" means that no latency value is available + vSelectedInputChannels ( NUM_IN_OUT_CHANNELS ), vSelectedOutputChannels ( NUM_IN_OUT_CHANNELS ) { int i; @@ -565,9 +553,10 @@ CSound::CSound ( void (*fpNewCallback) ( CVector& psData, voi if ( lNumDevs == 0 ) { throw CGenErr ( "" + tr ( "No ASIO audio device driver found." ) + "

      " + - QString ( tr ( "Please install an ASIO driver before running %1. " - "If you own a device with ASIO support, install its official ASIO driver. " - "If not, you'll need to download and install a universal driver like ASIO4ALL." ) ).arg ( APP_NAME ) ); + QString ( tr ( "Please install an ASIO driver before running %1. " + "If you own a device with ASIO support, install its official ASIO driver. " + "If not, you'll need to download and install a universal driver like ASIO4ALL." ) ) + .arg ( APP_NAME ) ); } asioDrivers->removeCurrentDriver(); @@ -601,11 +590,8 @@ void CSound::ResetChannelMapping() vSelectedOutputChannels[1] = 1; } - // ASIO callbacks ------------------------------------------------------------- -ASIOTime* CSound::bufferSwitchTimeInfo ( ASIOTime*, - long index, - ASIOBool processNow ) +ASIOTime* CSound::bufferSwitchTimeInfo ( ASIOTime*, long index, ASIOBool processNow ) { bufferSwitch ( index, processNow ); return 0L; @@ -614,32 +600,17 @@ ASIOTime* CSound::bufferSwitchTimeInfo ( ASIOTime*, bool CSound::CheckSampleTypeSupported ( const ASIOSampleType SamType ) { // check for supported sample types - return ( ( SamType == ASIOSTInt16LSB ) || - ( SamType == ASIOSTInt24LSB ) || - ( SamType == ASIOSTInt32LSB ) || - ( SamType == ASIOSTFloat32LSB ) || - ( SamType == ASIOSTFloat64LSB ) || - ( SamType == ASIOSTInt32LSB16 ) || - ( SamType == ASIOSTInt32LSB18 ) || - ( SamType == ASIOSTInt32LSB20 ) || - ( SamType == ASIOSTInt32LSB24 ) || - ( SamType == ASIOSTInt16MSB ) || - ( SamType == ASIOSTInt24MSB ) || - ( SamType == ASIOSTInt32MSB ) || - ( SamType == ASIOSTFloat32MSB ) || - ( SamType == ASIOSTFloat64MSB ) || - ( SamType == ASIOSTInt32MSB16 ) || - ( SamType == ASIOSTInt32MSB18 ) || - ( SamType == ASIOSTInt32MSB20 ) || - ( SamType == ASIOSTInt32MSB24 ) ); + return ( ( SamType == ASIOSTInt16LSB ) || ( SamType == ASIOSTInt24LSB ) || ( SamType == ASIOSTInt32LSB ) || ( SamType == ASIOSTFloat32LSB ) || + ( SamType == ASIOSTFloat64LSB ) || ( SamType == ASIOSTInt32LSB16 ) || ( SamType == ASIOSTInt32LSB18 ) || + ( SamType == ASIOSTInt32LSB20 ) || ( SamType == ASIOSTInt32LSB24 ) || ( SamType == ASIOSTInt16MSB ) || ( SamType == ASIOSTInt24MSB ) || + ( SamType == ASIOSTInt32MSB ) || ( SamType == ASIOSTFloat32MSB ) || ( SamType == ASIOSTFloat64MSB ) || ( SamType == ASIOSTInt32MSB16 ) || + ( SamType == ASIOSTInt32MSB18 ) || ( SamType == ASIOSTInt32MSB20 ) || ( SamType == ASIOSTInt32MSB24 ) ); } bool CSound::CheckSampleTypeSupportedForCHMixing ( const ASIOSampleType SamType ) { // check for supported sample types for audio channel mixing (see bufferSwitch) - return ( ( SamType == ASIOSTInt16LSB ) || - ( SamType == ASIOSTInt24LSB ) || - ( SamType == ASIOSTInt32LSB ) ); + return ( ( SamType == ASIOSTInt16LSB ) || ( SamType == ASIOSTInt24LSB ) || ( SamType == ASIOSTInt32LSB ) ); } void CSound::bufferSwitch ( long index, ASIOBool ) @@ -658,8 +629,7 @@ void CSound::bufferSwitch ( long index, ASIOBool ) { int iSelCH, iSelAddCH; - GetSelCHAndAddCH ( pSound->vSelectedInputChannels[i], pSound->lNumInChan, - iSelCH, iSelAddCH ); + GetSelCHAndAddCH ( pSound->vSelectedInputChannels[i], pSound->lNumInChan, iSelCH, iSelAddCH ); // copy new captured block in thread transfer buffer (copy // mono data interleaved in stereo buffer) @@ -683,8 +653,7 @@ void CSound::bufferSwitch ( long index, ASIOBool ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { vecsMultChanAudioSndCrd[2 * iCurSample + i] = - Float2Short ( (float) vecsMultChanAudioSndCrd[2 * iCurSample + i] + - (float) pASIOBufAdd[iCurSample] ); + Float2Short ( (float) vecsMultChanAudioSndCrd[2 * iCurSample + i] + (float) pASIOBufAdd[iCurSample] ); } } break; @@ -710,8 +679,7 @@ void CSound::bufferSwitch ( long index, ASIOBool ) iCurSam >>= 8; vecsMultChanAudioSndCrd[2 * iCurSample + i] = - Float2Short ( (float) vecsMultChanAudioSndCrd[2 * iCurSample + i] + - (float) static_cast ( iCurSam ) ); + Float2Short ( (float) vecsMultChanAudioSndCrd[2 * iCurSample + i] + (float) static_cast ( iCurSam ) ); } } break; @@ -722,8 +690,7 @@ void CSound::bufferSwitch ( long index, ASIOBool ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( pASIOBuf[iCurSample] >> 16 ); + vecsMultChanAudioSndCrd[2 * iCurSample + i] = static_cast ( pASIOBuf[iCurSample] >> 16 ); } if ( iSelAddCH >= 0 ) @@ -733,103 +700,95 @@ void CSound::bufferSwitch ( long index, ASIOBool ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - vecsMultChanAudioSndCrd[2 * iCurSample + i] = - Float2Short ( (float) vecsMultChanAudioSndCrd[2 * iCurSample + i] + - (float) static_cast ( pASIOBufAdd[iCurSample] >> 16 ) ); + vecsMultChanAudioSndCrd[2 * iCurSample + i] = Float2Short ( (float) vecsMultChanAudioSndCrd[2 * iCurSample + i] + + (float) static_cast ( pASIOBufAdd[iCurSample] >> 16 ) ); } } break; } case ASIOSTFloat32LSB: // IEEE 754 32 bit float, as found on Intel x86 architecture -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] * _MAXSHORT ); + static_cast ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] * _MAXSHORT ); } break; case ASIOSTFloat64LSB: // IEEE 754 64 bit double float, as found on Intel x86 architecture -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] * _MAXSHORT ); + static_cast ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] * _MAXSHORT ); } break; - case ASIOSTInt32LSB16: // 32 bit data with 16 bit alignment -// clang-format off + case ASIOSTInt32LSB16: // 32 bit data with 16 bit alignment + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFF ); + static_cast ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFF ); } break; - case ASIOSTInt32LSB18: // 32 bit data with 18 bit alignment -// clang-format off + case ASIOSTInt32LSB18: // 32 bit data with 18 bit alignment + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0x3FFFF ) >> 2 ); + static_cast ( ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0x3FFFF ) >> 2 ); } break; - case ASIOSTInt32LSB20: // 32 bit data with 20 bit alignment -// clang-format off + case ASIOSTInt32LSB20: // 32 bit data with 20 bit alignment + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFFF ) >> 4 ); + static_cast ( ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFFF ) >> 4 ); } break; - case ASIOSTInt32LSB24: // 32 bit data with 24 bit alignment -// clang-format off + case ASIOSTInt32LSB24: // 32 bit data with 24 bit alignment + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFFFF ) >> 8 ); + static_cast ( ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFFFF ) >> 8 ); } break; case ASIOSTInt16MSB: -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on // flip bits for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { vecsMultChanAudioSndCrd[2 * iCurSample + i] = - Flip16Bits ( ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] ) )[iCurSample] ); + Flip16Bits ( ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] ) )[iCurSample] ); } break; case ASIOSTInt24MSB: -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // because the bits are flipped, we do not have to perform the @@ -837,95 +796,87 @@ void CSound::bufferSwitch ( long index, ASIOBool ) int iCurSam = 0; memcpy ( &iCurSam, ( (char*) pSound->bufferInfos[iSelCH].buffers[index] ) + iCurSample * 3, 3 ); - vecsMultChanAudioSndCrd[2 * iCurSample + i] = - Flip16Bits ( static_cast ( iCurSam ) ); + vecsMultChanAudioSndCrd[2 * iCurSample + i] = Flip16Bits ( static_cast ( iCurSam ) ); } break; case ASIOSTInt32MSB: -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // flip bits and convert to 16 bit - vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( Flip32Bits ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) >> 16 ); + vecsMultChanAudioSndCrd[2 * iCurSample + i] = static_cast ( + Flip32Bits ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) >> 16 ); } break; case ASIOSTFloat32MSB: // IEEE 754 32 bit float, as found on Intel x86 architecture -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( static_cast ( - Flip32Bits ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) ) * _MAXSHORT ); + vecsMultChanAudioSndCrd[2 * iCurSample + i] = static_cast ( + static_cast ( Flip32Bits ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) ) * + _MAXSHORT ); } break; case ASIOSTFloat64MSB: // IEEE 754 64 bit double float, as found on Intel x86 architecture -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( static_cast ( - Flip64Bits ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) ) * _MAXSHORT ); + vecsMultChanAudioSndCrd[2 * iCurSample + i] = static_cast ( + static_cast ( Flip64Bits ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) ) * + _MAXSHORT ); } break; case ASIOSTInt32MSB16: // 32 bit data with 16 bit alignment -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( Flip32Bits ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFF ); + vecsMultChanAudioSndCrd[2 * iCurSample + i] = static_cast ( + Flip32Bits ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFF ); } break; case ASIOSTInt32MSB18: // 32 bit data with 18 bit alignment -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( ( Flip32Bits ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0x3FFFF ) >> 2 ); + vecsMultChanAudioSndCrd[2 * iCurSample + i] = static_cast ( + ( Flip32Bits ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0x3FFFF ) >> 2 ); } break; case ASIOSTInt32MSB20: // 32 bit data with 20 bit alignment -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( ( Flip32Bits ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFFF ) >> 4 ); + vecsMultChanAudioSndCrd[2 * iCurSample + i] = static_cast ( + ( Flip32Bits ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFFF ) >> 4 ); } break; case ASIOSTInt32MSB24: // 32 bit data with 24 bit alignment -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - vecsMultChanAudioSndCrd[2 * iCurSample + i] = - static_cast ( ( Flip32Bits ( static_cast ( - pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFFFF ) >> 8 ); + vecsMultChanAudioSndCrd[2 * iCurSample + i] = static_cast ( + ( Flip32Bits ( static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFFFF ) >> 8 ); } break; } @@ -934,7 +885,6 @@ void CSound::bufferSwitch ( long index, ASIOBool ) // call processing callback function pSound->ProcessCallback ( vecsMultChanAudioSndCrd ); - // PLAYBACK ------------------------------------------------------------ for ( int i = 0; i < NUM_IN_OUT_CHANNELS; i++ ) { @@ -957,14 +907,13 @@ void CSound::bufferSwitch ( long index, ASIOBool ) } case ASIOSTInt24LSB: -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert current sample in 24 bit format - int32_t iCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + int32_t iCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); iCurSam <<= 8; @@ -979,8 +928,7 @@ void CSound::bufferSwitch ( long index, ASIOBool ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert to 32 bit - const int32_t iCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const int32_t iCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); pASIOBuf[iCurSample] = ( iCurSam << 16 ); } @@ -988,97 +936,85 @@ void CSound::bufferSwitch ( long index, ASIOBool ) } case ASIOSTFloat32LSB: // IEEE 754 32 bit float, as found on Intel x86 architecture -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - const float fCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const float fCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); - static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - fCurSam / _MAXSHORT; + static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = fCurSam / _MAXSHORT; } break; case ASIOSTFloat64LSB: // IEEE 754 64 bit double float, as found on Intel x86 architecture -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - const double fCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const double fCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); - static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - fCurSam / _MAXSHORT; + static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = fCurSam / _MAXSHORT; } break; - case ASIOSTInt32LSB16: // 32 bit data with 16 bit alignment -// clang-format off + case ASIOSTInt32LSB16: // 32 bit data with 16 bit alignment + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert to 32 bit - const int32_t iCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const int32_t iCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); - static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - iCurSam; + static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = iCurSam; } break; - case ASIOSTInt32LSB18: // 32 bit data with 18 bit alignment -// clang-format off + case ASIOSTInt32LSB18: // 32 bit data with 18 bit alignment + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert to 32 bit - const int32_t iCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const int32_t iCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); - static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - ( iCurSam << 2 ); + static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = ( iCurSam << 2 ); } break; - case ASIOSTInt32LSB20: // 32 bit data with 20 bit alignment -// clang-format off + case ASIOSTInt32LSB20: // 32 bit data with 20 bit alignment + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert to 32 bit - const int32_t iCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const int32_t iCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); - static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - ( iCurSam << 4 ); + static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = ( iCurSam << 4 ); } break; - case ASIOSTInt32LSB24: // 32 bit data with 24 bit alignment -// clang-format off + case ASIOSTInt32LSB24: // 32 bit data with 24 bit alignment + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert to 32 bit - const int32_t iCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const int32_t iCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); - static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - ( iCurSam << 8 ); + static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = ( iCurSam << 8 ); } break; case ASIOSTInt16MSB: -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on // flip bits for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { @@ -1088,122 +1024,107 @@ void CSound::bufferSwitch ( long index, ASIOBool ) break; case ASIOSTInt24MSB: -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // because the bits are flipped, we do not have to perform the // shift by 8 bits - int32_t iCurSam = static_cast ( Flip16Bits ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ) ); + int32_t iCurSam = static_cast ( Flip16Bits ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ) ); memcpy ( ( (char*) pSound->bufferInfos[iSelCH].buffers[index] ) + iCurSample * 3, &iCurSam, 3 ); } break; case ASIOSTInt32MSB: -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert to 32 bit and flip bits - int iCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + int iCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); - static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - Flip32Bits ( iCurSam << 16 ); + static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = Flip32Bits ( iCurSam << 16 ); } break; case ASIOSTFloat32MSB: // IEEE 754 32 bit float, as found on Intel x86 architecture -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - const float fCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const float fCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - static_cast ( Flip32Bits ( static_cast ( - fCurSam / _MAXSHORT ) ) ); + static_cast ( Flip32Bits ( static_cast ( fCurSam / _MAXSHORT ) ) ); } break; case ASIOSTFloat64MSB: // IEEE 754 64 bit double float, as found on Intel x86 architecture -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { - const double fCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const double fCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - static_cast ( Flip64Bits ( static_cast ( - fCurSam / _MAXSHORT ) ) ); + static_cast ( Flip64Bits ( static_cast ( fCurSam / _MAXSHORT ) ) ); } break; case ASIOSTInt32MSB16: // 32 bit data with 16 bit alignment -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert to 32 bit - const int32_t iCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const int32_t iCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); - static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - Flip32Bits ( iCurSam ); + static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = Flip32Bits ( iCurSam ); } break; case ASIOSTInt32MSB18: // 32 bit data with 18 bit alignment -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert to 32 bit - const int32_t iCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const int32_t iCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); - static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - Flip32Bits ( iCurSam << 2 ); + static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = Flip32Bits ( iCurSam << 2 ); } break; case ASIOSTInt32MSB20: // 32 bit data with 20 bit alignment -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert to 32 bit - const int32_t iCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const int32_t iCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); - static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - Flip32Bits ( iCurSam << 4 ); + static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = Flip32Bits ( iCurSam << 4 ); } break; case ASIOSTInt32MSB24: // 32 bit data with 24 bit alignment -// clang-format off + // clang-format off // NOT YET TESTED -// clang-format on + // clang-format on for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) { // convert to 32 bit - const int32_t iCurSam = static_cast ( - vecsMultChanAudioSndCrd[2 * iCurSample + i] ); + const int32_t iCurSam = static_cast ( vecsMultChanAudioSndCrd[2 * iCurSample + i] ); - static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = - Flip32Bits ( iCurSam << 8 ); + static_cast ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = Flip32Bits ( iCurSam << 8 ); } break; } @@ -1219,30 +1140,27 @@ void CSound::bufferSwitch ( long index, ASIOBool ) pSound->ASIOMutex.unlock(); } -long CSound::asioMessages ( long selector, - long, - void*, - double* ) +long CSound::asioMessages ( long selector, long, void*, double* ) { long ret = 0; switch ( selector ) { - case kAsioEngineVersion: - // return the supported ASIO version of the host application - ret = 2L; // Host ASIO implementation version, 2 or higher - break; - - // both messages might be send if the buffer size changes - case kAsioBufferSizeChange: - pSound->EmitReinitRequestSignal ( RS_ONLY_RESTART_AND_INIT ); - ret = 1L; // 1L if request is accepted or 0 otherwise - break; - - case kAsioResetRequest: - pSound->EmitReinitRequestSignal ( RS_RELOAD_RESTART_AND_INIT ); - ret = 1L; // 1L if request is accepted or 0 otherwise - break; + case kAsioEngineVersion: + // return the supported ASIO version of the host application + ret = 2L; // Host ASIO implementation version, 2 or higher + break; + + // both messages might be send if the buffer size changes + case kAsioBufferSizeChange: + pSound->EmitReinitRequestSignal ( RS_ONLY_RESTART_AND_INIT ); + ret = 1L; // 1L if request is accepted or 0 otherwise + break; + + case kAsioResetRequest: + pSound->EmitReinitRequestSignal ( RS_RELOAD_RESTART_AND_INIT ); + ret = 1L; // 1L if request is accepted or 0 otherwise + break; } return ret; @@ -1259,7 +1177,7 @@ int16_t CSound::Flip16Bits ( const int16_t iIn ) iOut |= ( iIn & iMask ) ? 1 : 0; // shift out value and mask by one bit - iOut <<= 1; + iOut <<= 1; iMask >>= 1; } @@ -1277,7 +1195,7 @@ int32_t CSound::Flip32Bits ( const int32_t iIn ) iOut |= ( iIn & iMask ) ? 1 : 0; // shift out value and mask by one bit - iOut <<= 1; + iOut <<= 1; iMask >>= 1; } @@ -1295,7 +1213,7 @@ int64_t CSound::Flip64Bits ( const int64_t iIn ) iOut |= ( iIn & iMask ) ? 1 : 0; // shift out value and mask by one bit - iOut <<= 1; + iOut <<= 1; iMask >>= 1; } diff --git a/windows/sound.h b/windows/sound.h old mode 100755 new mode 100644 index d79f6e8c87..433229fc25 --- a/windows/sound.h +++ b/windows/sound.h @@ -36,11 +36,9 @@ #include "asio.h" #include "asiodrivers.h" - /* Definitions ****************************************************************/ // stereo for input and output -#define NUM_IN_OUT_CHANNELS 2 - +#define NUM_IN_OUT_CHANNELS 2 /* Classes ********************************************************************/ class CSound : public CSoundBase @@ -48,11 +46,7 @@ class CSound : public CSoundBase Q_OBJECT public: - CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), - void* arg, - const QString& strMIDISetup, - const bool , - const QString& ); + CSound ( void ( *fpNewCallback ) ( CVector& psData, void* arg ), void* arg, const QString& strMIDISetup, const bool, const QString& ); virtual ~CSound() { UnloadCurrentDriver(); } @@ -65,48 +59,47 @@ class CSound : public CSoundBase // channel selection virtual int GetNumInputChannels() { return static_cast ( lNumInChanPlusAddChan ); } virtual QString GetInputChannelName ( const int iDiD ) { return channelInputName[iDiD]; } - virtual void SetLeftInputChannel ( const int iNewChan ); + virtual void SetLeftInputChannel ( const int iNewChan ); virtual void SetRightInputChannel ( const int iNewChan ); - virtual int GetLeftInputChannel() { return vSelectedInputChannels[0]; } + virtual int GetLeftInputChannel() { return vSelectedInputChannels[0]; } virtual int GetRightInputChannel() { return vSelectedInputChannels[1]; } virtual int GetNumOutputChannels() { return static_cast ( lNumOutChan ); } virtual QString GetOutputChannelName ( const int iDiD ) { return channelInfosOutput[iDiD].name; } - virtual void SetLeftOutputChannel ( const int iNewChan ); + virtual void SetLeftOutputChannel ( const int iNewChan ); virtual void SetRightOutputChannel ( const int iNewChan ); - virtual int GetLeftOutputChannel() { return vSelectedOutputChannels[0]; } + virtual int GetLeftOutputChannel() { return vSelectedOutputChannels[0]; } virtual int GetRightOutputChannel() { return vSelectedOutputChannels[1]; } - virtual float GetInOutLatencyMs() { return fInOutLatencyMs; } + virtual float GetInOutLatencyMs() { return fInOutLatencyMs; } protected: - virtual QString LoadAndInitializeDriver ( QString strDriverName, - bool bOpenDriverSetup ); - virtual void UnloadCurrentDriver(); - int GetActualBufferSize ( const int iDesiredBufferSizeMono ); - QString CheckDeviceCapabilities(); - bool CheckSampleTypeSupported ( const ASIOSampleType SamType ); - bool CheckSampleTypeSupportedForCHMixing ( const ASIOSampleType SamType ); - void ResetChannelMapping(); - - int iASIOBufferSizeMono; - int iASIOBufferSizeStereo; - - long lNumInChan; - long lNumInChanPlusAddChan; // includes additional "added" channels - long lNumOutChan; - float fInOutLatencyMs; - CVector vSelectedInputChannels; - CVector vSelectedOutputChannels; + virtual QString LoadAndInitializeDriver ( QString strDriverName, bool bOpenDriverSetup ); + virtual void UnloadCurrentDriver(); + int GetActualBufferSize ( const int iDesiredBufferSizeMono ); + QString CheckDeviceCapabilities(); + bool CheckSampleTypeSupported ( const ASIOSampleType SamType ); + bool CheckSampleTypeSupportedForCHMixing ( const ASIOSampleType SamType ); + void ResetChannelMapping(); + + int iASIOBufferSizeMono; + int iASIOBufferSizeStereo; + + long lNumInChan; + long lNumInChanPlusAddChan; // includes additional "added" channels + long lNumOutChan; + float fInOutLatencyMs; + CVector vSelectedInputChannels; + CVector vSelectedOutputChannels; CVector vecsMultChanAudioSndCrd; - QMutex ASIOMutex; + QMutex ASIOMutex; // utility functions - static int16_t Flip16Bits ( const int16_t iIn ); - static int32_t Flip32Bits ( const int32_t iIn ); - static int64_t Flip64Bits ( const int64_t iIn ); + static int16_t Flip16Bits ( const int16_t iIn ); + static int32_t Flip32Bits ( const int32_t iIn ); + static int64_t Flip64Bits ( const int64_t iIn ); // audio hardware buffer info struct sHWBufferInfo @@ -118,13 +111,13 @@ class CSound : public CSoundBase } HWBufferInfo; // ASIO stuff - ASIODriverInfo driverInfo; - ASIOBufferInfo bufferInfos[2 * MAX_NUM_IN_OUT_CHANNELS]; // for input and output buffers -> "2 *" - ASIOChannelInfo channelInfosInput[MAX_NUM_IN_OUT_CHANNELS]; - QString channelInputName[MAX_NUM_IN_OUT_CHANNELS]; - ASIOChannelInfo channelInfosOutput[MAX_NUM_IN_OUT_CHANNELS]; - bool bASIOPostOutput; - ASIOCallbacks asioCallbacks; + ASIODriverInfo driverInfo; + ASIOBufferInfo bufferInfos[2 * MAX_NUM_IN_OUT_CHANNELS]; // for input and output buffers -> "2 *" + ASIOChannelInfo channelInfosInput[MAX_NUM_IN_OUT_CHANNELS]; + QString channelInputName[MAX_NUM_IN_OUT_CHANNELS]; + ASIOChannelInfo channelInfosOutput[MAX_NUM_IN_OUT_CHANNELS]; + bool bASIOPostOutput; + ASIOCallbacks asioCallbacks; // callbacks static void bufferSwitch ( long index, ASIOBool processNow );