diff options
23 files changed, 195 insertions, 195 deletions
diff --git a/src/MumbleProtocol.cpp b/src/MumbleProtocol.cpp index bc0a18ada..34aa88e72 100644 --- a/src/MumbleProtocol.cpp +++ b/src/MumbleProtocol.cpp @@ -334,12 +334,12 @@ namespace Protocol { template< Role role > void UDPAudioEncoder< role >::preparePreEncodedSnippets() { m_audioMessage.Clear(); - static_assert(AudioContext::begin == 0, "AudioContext::begin is not zero (breaks assumption)"); - static_assert(AudioContext::end >= 0, "AudioContext::end is negative (breaks assumption)"); - m_preEncodedContext.resize(AudioContext::end); + static_assert(AudioContext::BEGIN == 0, "AudioContext::BEGIN is not zero (breaks assumption)"); + static_assert(AudioContext::END >= 0, "AudioContext::END is negative (breaks assumption)"); + m_preEncodedContext.resize(AudioContext::END); // Pre-encode the expected voice audio contexts. - for (audio_context_t current = AudioContext::begin; current < AudioContext::end; ++current) { + for (audio_context_t current = AudioContext::BEGIN; current < AudioContext::END; ++current) { m_audioMessage.set_context(current); // The max size of the properly encoded package is the size of the used field type (uint32) plus 1 byte @@ -389,7 +389,7 @@ namespace Protocol { UDPAudioEncoder< role >::getPreEncodedVolumeAdjustment(const VolumeAdjustment &adjustment) const { int index = (adjustment.dbAdjustment - preEncodedDBAdjustmentBegin); - if (adjustment.dbAdjustment == VolumeAdjustment::InvalidDBAdjustment || index < 0 + if (adjustment.dbAdjustment == VolumeAdjustment::INVALID_DB_ADJUSTMENT || index < 0 || static_cast< std::size_t >(index) >= m_preEncodedVolumeAdjustment.size()) { // No pre-encoded snippet for the given adjustment return {}; @@ -461,13 +461,13 @@ namespace Protocol { actualSize = packetSize; } else { // 8 bytes for a uint64 timestamp + 1byte for the varint encoding of that stamp + 1byte header - constexpr std::size_t maxSize = 8 + 1 + 1; - m_byteBuffer.resize(maxSize); + constexpr std::size_t MAX_SIZE = 8 + 1 + 1; + m_byteBuffer.resize(MAX_SIZE); // Write header byte (type bits are zero, so they don't have to be set explicitly) m_byteBuffer[0] = static_cast< byte >(LegacyUDPMessageType::Ping) << 5; - PacketDataStream stream(m_byteBuffer.data() + 1, maxSize - 1); + PacketDataStream stream(m_byteBuffer.data() + 1, MAX_SIZE - 1); stream << static_cast< quint64 >(data.timestamp); diff --git a/src/MumbleProtocol.h b/src/MumbleProtocol.h index 7c0bd7d6e..d15e6857e 100644 --- a/src/MumbleProtocol.h +++ b/src/MumbleProtocol.h @@ -89,20 +89,20 @@ namespace Protocol { }; namespace ReservedTargetIDs { - constexpr const unsigned int RegularSpeech = 0; - constexpr const unsigned int ServerLoopback = 31; + constexpr unsigned int REGULAR_SPEECH = 0; + constexpr unsigned int SERVER_LOOPBACK = 31; }; // namespace ReservedTargetIDs using audio_context_t = byte; namespace AudioContext { - constexpr audio_context_t Invalid = 0xFF; // This is the equivalent of -1 as a signed 8bit number - constexpr audio_context_t Normal = 0; - constexpr audio_context_t Shout = 1; - constexpr audio_context_t Whisper = 2; - constexpr audio_context_t Listen = 3; - - constexpr audio_context_t begin = Normal; - constexpr audio_context_t end = Listen + 1; + constexpr audio_context_t INVALID = 0xFF; // This is the equivalent of -1 as a signed 8bit number + constexpr audio_context_t NORMAL = 0; + constexpr audio_context_t SHOUT = 1; + constexpr audio_context_t WHISPER = 2; + constexpr audio_context_t LISTEN = 3; + + constexpr audio_context_t BEGIN = NORMAL; + constexpr audio_context_t END = LISTEN + 1; }; // namespace AudioContext enum class Role { Server, Client }; @@ -127,7 +127,7 @@ namespace Protocol { }; struct AudioData { - std::uint32_t targetOrContext = ReservedTargetIDs::RegularSpeech; + std::uint32_t targetOrContext = ReservedTargetIDs::REGULAR_SPEECH; AudioCodec usedCodec = AudioCodec::Opus; std::uint32_t senderSession = 0; std::uint64_t frameNumber = 0; diff --git a/src/VolumeAdjustment.cpp b/src/VolumeAdjustment.cpp index 261b53bbe..de3bf6546 100644 --- a/src/VolumeAdjustment.cpp +++ b/src/VolumeAdjustment.cpp @@ -8,33 +8,33 @@ #include <cassert> #include <cmath> -constexpr float dbThreshold = 0.1; +constexpr float DB_THRESHOLD = 0.1; VolumeAdjustment::VolumeAdjustment(float factor, int dbAdjustment) : factor(factor), dbAdjustment(dbAdjustment) { - assert(dbAdjustment == InvalidDBAdjustment + assert(dbAdjustment == INVALID_DB_ADJUSTMENT // Verify that the used dbAdjustment is a reasonable representation of the given factor. Particularly, we // want to make sure that the deviation of the true dB representation of the factor (usually a floating point // value) doesn't deviate more than dbThreshold from the passed integer dB value. For all cases, where this - // would be the case, we expect InvalidDBAdjustment to be passed instead. + // would be the case, we expect INVALID_DB_ADJUSTMENT to be passed instead. // // If dB is the dB-representation of a loudness change factor f, we have // dB = log2(f) * 6 <=> f = 2^{dB/6} // (+6dB equals a doubling in loudness) - || dbThreshold >= std::abs(dbAdjustment - std::log2(factor) * 6)); + || DB_THRESHOLD >= std::abs(dbAdjustment - std::log2(factor) * 6)); } VolumeAdjustment VolumeAdjustment::fromFactor(float factor) { if (factor > 0) { float dB = std::log2(factor) * 6; - if (std::abs(dB - static_cast< int >(dB)) < dbThreshold) { + if (std::abs(dB - static_cast< int >(dB)) < DB_THRESHOLD) { // Close-enough return VolumeAdjustment(factor, std::round(dB)); } else { - return VolumeAdjustment(factor, InvalidDBAdjustment); + return VolumeAdjustment(factor, INVALID_DB_ADJUSTMENT); } } else { - return VolumeAdjustment(factor, InvalidDBAdjustment); + return VolumeAdjustment(factor, INVALID_DB_ADJUSTMENT); } } diff --git a/src/VolumeAdjustment.h b/src/VolumeAdjustment.h index 6c13be9e1..a2e6a416c 100644 --- a/src/VolumeAdjustment.h +++ b/src/VolumeAdjustment.h @@ -10,9 +10,9 @@ class VolumeAdjustment { public: - static constexpr const int InvalidDBAdjustment = std::numeric_limits< int >::max(); + static constexpr const int INVALID_DB_ADJUSTMENT = std::numeric_limits< int >::max(); - explicit VolumeAdjustment(float factor = 1.0f, int dbAdjustment = InvalidDBAdjustment); + explicit VolumeAdjustment(float factor = 1.0f, int dbAdjustment = INVALID_DB_ADJUSTMENT); float factor; int dbAdjustment; diff --git a/src/benchmarks/AudioReceiverBuffer/AudioReceiverBuffer_benchmark.cpp b/src/benchmarks/AudioReceiverBuffer/AudioReceiverBuffer_benchmark.cpp index 1362b9208..3d3cdb0ba 100644 --- a/src/benchmarks/AudioReceiverBuffer/AudioReceiverBuffer_benchmark.cpp +++ b/src/benchmarks/AudioReceiverBuffer/AudioReceiverBuffer_benchmark.cpp @@ -18,12 +18,12 @@ std::vector< Mumble::Protocol::audio_context_t > contexts; std::vector< VolumeAdjustment > volumeAdjustments; std::vector< ServerUser > users; -constexpr const std::size_t ReceiverCountRange = 0; -constexpr const std::size_t DuplicateRange = 1; +constexpr const std::size_t RECEIVER_COUNT_RANGE = 0; +constexpr const std::size_t DUPLICATE_RANGE = 1; -constexpr int Multiplier = 2; -constexpr int ReceiverCountBegin = 1; -constexpr int ReceiverCountEnd = 512; +constexpr int MULTIPLIER = 2; +constexpr int RECEIVER_COUNT_BEGIN = 1; +constexpr int RECEIVER_COUNT_END = 512; struct ReceiverData { ServerUser *receiver; @@ -35,14 +35,14 @@ struct ReceiverData { std::vector< ReceiverData > selectedData; void globalInit() { - for (int i = 0; i <= ReceiverCountEnd; ++i) { + for (int i = 0; i <= RECEIVER_COUNT_END; ++i) { contexts.push_back(random_context(rng)); volumeAdjustments.push_back(VolumeAdjustment::fromDBAdjustment(random_volume_adjustment(rng))); users.push_back(ServerUser(i, random_version(rng))); } // add one additional user acting as the sender - users.push_back(ServerUser(ReceiverCountEnd + 1, random_version(rng))); + users.push_back(ServerUser(RECEIVER_COUNT_END + 1, random_version(rng))); } class Fixture : public ::benchmark::Fixture { @@ -50,8 +50,8 @@ public: void SetUp(const ::benchmark::State &state) { selectedData.clear(); - std::size_t totalReceivers = state.range(ReceiverCountRange); - std::size_t duplicateReceivers = totalReceivers * (state.range(DuplicateRange) / 100.0f); + std::size_t totalReceivers = state.range(RECEIVER_COUNT_RANGE); + std::size_t duplicateReceivers = totalReceivers * (state.range(DUPLICATE_RANGE) / 100.0f); for (std::size_t i = 0; i < totalReceivers - duplicateReceivers; ++i) { selectedData.push_back({ &users[i], contexts[i], false, volumeAdjustments[i] }); @@ -100,7 +100,7 @@ BENCHMARK_DEFINE_F(Fixture, BM_addReceiver)(::benchmark::State &state) { } BENCHMARK_REGISTER_F(Fixture, BM_addReceiver) - ->ArgsProduct({ benchmark::CreateRange(ReceiverCountBegin, ReceiverCountEnd, /*multi=*/Multiplier), + ->ArgsProduct({ benchmark::CreateRange(RECEIVER_COUNT_BEGIN, RECEIVER_COUNT_END, /*multi=*/MULTIPLIER), { 0, 10, 40, 80 } }); @@ -143,7 +143,7 @@ BENCHMARK_DEFINE_F(Fixture, BM_full)(::benchmark::State &state) { } BENCHMARK_REGISTER_F(Fixture, BM_full) - ->ArgsProduct({ benchmark::CreateRange(ReceiverCountBegin, ReceiverCountEnd, /*multi=*/Multiplier), + ->ArgsProduct({ benchmark::CreateRange(RECEIVER_COUNT_BEGIN, RECEIVER_COUNT_END, /*multi=*/MULTIPLIER), { 0, 10, 40, 80 } }); diff --git a/src/benchmarks/protocol/protocol_benchmark.cpp b/src/benchmarks/protocol/protocol_benchmark.cpp index 4ff078757..bb3e6ebb3 100644 --- a/src/benchmarks/protocol/protocol_benchmark.cpp +++ b/src/benchmarks/protocol/protocol_benchmark.cpp @@ -14,9 +14,9 @@ std::uniform_int_distribution< unsigned int > random_byte(0, std::numeric_limits constexpr int PAYLOAD_SIZE_RANGE = 0; -constexpr int fromPayloadSize = 0; -constexpr int toPayloadSize = 900; -constexpr int payloadSizeMultiplier = 2; +constexpr int FROM_PAYLOAD_SIZE = 0; +constexpr int TO_PAYLOAD_SIZE = 900; +constexpr int PAYLOAD_SIZE_MULTIPLIER = 2; std::vector< Mumble::Protocol::byte > audioPayload; Mumble::Protocol::AudioData audioData; @@ -67,8 +67,8 @@ BENCHMARK_DEFINE_F(Fixture, BM_encodeLegacyDirect)(::benchmark::State &state) { } BENCHMARK_REGISTER_F(Fixture, BM_encodeLegacyDirect) - ->RangeMultiplier(payloadSizeMultiplier) - ->Range(fromPayloadSize, toPayloadSize); + ->RangeMultiplier(PAYLOAD_SIZE_MULTIPLIER) + ->Range(FROM_PAYLOAD_SIZE, TO_PAYLOAD_SIZE); BENCHMARK_DEFINE_F(Fixture, BM_encodeLegacy)(::benchmark::State &state) { encoder.setProtocolVersion(Version::toRaw(1, 3, 0)); @@ -79,8 +79,8 @@ BENCHMARK_DEFINE_F(Fixture, BM_encodeLegacy)(::benchmark::State &state) { } BENCHMARK_REGISTER_F(Fixture, BM_encodeLegacy) - ->RangeMultiplier(payloadSizeMultiplier) - ->Range(fromPayloadSize, toPayloadSize); + ->RangeMultiplier(PAYLOAD_SIZE_MULTIPLIER) + ->Range(FROM_PAYLOAD_SIZE, TO_PAYLOAD_SIZE); BENCHMARK_DEFINE_F(Fixture, BM_encodeLegacy_UpdateOnly)(::benchmark::State &state) { encoder.setProtocolVersion(Version::toRaw(1, 3, 0)); @@ -93,8 +93,8 @@ BENCHMARK_DEFINE_F(Fixture, BM_encodeLegacy_UpdateOnly)(::benchmark::State &stat } BENCHMARK_REGISTER_F(Fixture, BM_encodeLegacy_UpdateOnly) - ->RangeMultiplier(payloadSizeMultiplier) - ->Range(fromPayloadSize, toPayloadSize); + ->RangeMultiplier(PAYLOAD_SIZE_MULTIPLIER) + ->Range(FROM_PAYLOAD_SIZE, TO_PAYLOAD_SIZE); BENCHMARK_DEFINE_F(Fixture, BM_encodeNew)(::benchmark::State &state) { encoder.setProtocolVersion(Mumble::Protocol::PROTOBUF_INTRODUCTION_VERSION); @@ -105,8 +105,8 @@ BENCHMARK_DEFINE_F(Fixture, BM_encodeNew)(::benchmark::State &state) { } BENCHMARK_REGISTER_F(Fixture, BM_encodeNew) - ->RangeMultiplier(payloadSizeMultiplier) - ->Range(fromPayloadSize, toPayloadSize); + ->RangeMultiplier(PAYLOAD_SIZE_MULTIPLIER) + ->Range(FROM_PAYLOAD_SIZE, TO_PAYLOAD_SIZE); BENCHMARK_DEFINE_F(Fixture, BM_encodeNew_UpdateOnly)(::benchmark::State &state) { encoder.setProtocolVersion(Mumble::Protocol::PROTOBUF_INTRODUCTION_VERSION); @@ -119,8 +119,8 @@ BENCHMARK_DEFINE_F(Fixture, BM_encodeNew_UpdateOnly)(::benchmark::State &state) } BENCHMARK_REGISTER_F(Fixture, BM_encodeNew_UpdateOnly) - ->RangeMultiplier(payloadSizeMultiplier) - ->Range(fromPayloadSize, toPayloadSize); + ->RangeMultiplier(PAYLOAD_SIZE_MULTIPLIER) + ->Range(FROM_PAYLOAD_SIZE, TO_PAYLOAD_SIZE); BENCHMARK_MAIN(); diff --git a/src/mumble/AudioInput.cpp b/src/mumble/AudioInput.cpp index 1249e52ab..a6aadbc83 100644 --- a/src/mumble/AudioInput.cpp +++ b/src/mumble/AudioInput.cpp @@ -1119,7 +1119,7 @@ void AudioInput::encodeAudioFrame(AudioChunk chunk) { if (Global::get().s.bTxMuteCue && !Global::get().bPushToMute && !Global::get().s.bDeaf && bTalkingWhenMuted) { - if (!qetLastMuteCue.isValid() || qetLastMuteCue.elapsed() > iMuteCueDelay) { + if (!qetLastMuteCue.isValid() || qetLastMuteCue.elapsed() > MUTE_CUE_DELAY) { qetLastMuteCue.start(); ao->playSample(Global::get().s.qsTxMuteCue); } @@ -1256,7 +1256,7 @@ void AudioInput::flushCheck(const QByteArray &frame, bool terminator, int voiceT Global::get().iPrevTarget = 0; } if (Global::get().s.lmLoopMode == Settings::Server) { - audioData.targetOrContext = Mumble::Protocol::ReservedTargetIDs::ServerLoopback; + audioData.targetOrContext = Mumble::Protocol::ReservedTargetIDs::SERVER_LOOPBACK; } audioData.usedCodec = m_codec; diff --git a/src/mumble/AudioInput.h b/src/mumble/AudioInput.h index 9fa755e53..13cbe5577 100644 --- a/src/mumble/AudioInput.h +++ b/src/mumble/AudioInput.h @@ -240,7 +240,7 @@ protected: int iAudioFrames; /// The minimum time in ms that has to pass between the playback of two consecutive mute cues. - static constexpr unsigned int iMuteCueDelay = 5000; + static constexpr unsigned int MUTE_CUE_DELAY = 5000; float *pfMicInput; float *pfEchoInput; diff --git a/src/mumble/AudioOutput.cpp b/src/mumble/AudioOutput.cpp index a873a47c6..2f6494ee9 100644 --- a/src/mumble/AudioOutput.cpp +++ b/src/mumble/AudioOutput.cpp @@ -502,7 +502,7 @@ bool AudioOutput::mix(void *outbuff, unsigned int frameCount) { if (user->cChannel && Global::get().channelListenerManager->isListening(Global::get().uiSession, user->cChannel->iId) - && (speech->m_audioContext == Mumble::Protocol::AudioContext::Listen)) { + && (speech->m_audioContext == Mumble::Protocol::AudioContext::LISTEN)) { // We are receiving this audio packet only because we are listening to the channel // the speaking user is in. Thus we receive the audio via our "listener proxy". // Thus we'll apply the volume adjustment for our listener proxy as well diff --git a/src/mumble/AudioOutputCache.h b/src/mumble/AudioOutputCache.h index ae81b564b..d75b47e86 100644 --- a/src/mumble/AudioOutputCache.h +++ b/src/mumble/AudioOutputCache.h @@ -41,7 +41,7 @@ public: private: std::vector< Mumble::Protocol::byte > m_audioData; bool m_isLastFrame = false; - Mumble::Protocol::audio_context_t m_audioContext = Mumble::Protocol::AudioContext::Invalid; + Mumble::Protocol::audio_context_t m_audioContext = Mumble::Protocol::AudioContext::INVALID; float m_volumeAdjustment = 1.0f; bool m_containsPosition = false; std::array< float, 3 > m_position; diff --git a/src/mumble/AudioOutputSpeech.cpp b/src/mumble/AudioOutputSpeech.cpp index 4552b391d..52da02a0f 100644 --- a/src/mumble/AudioOutputSpeech.cpp +++ b/src/mumble/AudioOutputSpeech.cpp @@ -144,7 +144,7 @@ AudioOutputSpeech::AudioOutputSpeech(ClientUser *user, unsigned int freq, Mumble iMissCount = 0; iMissedFrames = 0; - m_audioContext = Mumble::Protocol::AudioContext::Invalid; + m_audioContext = Mumble::Protocol::AudioContext::INVALID; jbJitter = jitter_buffer_init(iFrameSize); int margin = Global::get().s.iJitterBufferSize * iFrameSize; @@ -590,22 +590,22 @@ bool AudioOutputSpeech::prepareSampleBuffer(unsigned int frameCount) { if (p) { Settings::TalkState ts; if (!nextalive) { - m_audioContext = Mumble::Protocol::AudioContext::Invalid; + m_audioContext = Mumble::Protocol::AudioContext::INVALID; } switch (m_audioContext) { - case Mumble::Protocol::AudioContext::Listen: + case Mumble::Protocol::AudioContext::LISTEN: // Fallthrough - case Mumble::Protocol::AudioContext::Normal: + case Mumble::Protocol::AudioContext::NORMAL: ts = Settings::Talking; break; - case Mumble::Protocol::AudioContext::Shout: + case Mumble::Protocol::AudioContext::SHOUT: ts = Settings::Shouting; break; - case Mumble::Protocol::AudioContext::Invalid: + case Mumble::Protocol::AudioContext::INVALID: ts = Settings::Passive; break; - case Mumble::Protocol::AudioContext::Whisper: + case Mumble::Protocol::AudioContext::WHISPER: ts = Settings::Whispering; break; default: diff --git a/src/mumble/GlobalShortcut_win.cpp b/src/mumble/GlobalShortcut_win.cpp index c1edc03ec..170098b0a 100644 --- a/src/mumble/GlobalShortcut_win.cpp +++ b/src/mumble/GlobalShortcut_win.cpp @@ -209,11 +209,11 @@ void GlobalShortcutWin::registerMetaTypes() { } QList< Shortcut > GlobalShortcutWin::migrateSettings(const QList< Shortcut > &oldShortcuts) { - constexpr QUuid keyboardUuid(0x6F1D2B61, 0xD5A0, 0x11CF, 0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00); - constexpr QUuid mouseUuid(0x6F1D2B60, 0xD5A0, 0x11CF, 0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00); - constexpr QUuid xinputUuid(0xCA3937E3, 0x640C, 0x4D9E, 0x9E, 0xF3, 0x90, 0x3F, 0x8B, 0x4F, 0xBC, 0xAB); - constexpr QUuid gkeyKeyboardUuid(0x153E64E6, 0x98C8, 0x4E, 0x03, 0x80EF, 0x5F, 0xFD, 0x33, 0xD2, 0x5B, 0x8A); - constexpr QUuid gkeyMouseUuid(0xC41E60AF, 0x9022, 0x46CF, 0xBC, 0x39, 0x37, 0x98, 0x10, 0x82, 0xD7, 0x16); + constexpr QUuid KEYBOARD_UUID(0x6F1D2B61, 0xD5A0, 0x11CF, 0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00); + constexpr QUuid MOUSE_UUID(0x6F1D2B60, 0xD5A0, 0x11CF, 0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00); + constexpr QUuid XINPUT_UUID(0xCA3937E3, 0x640C, 0x4D9E, 0x9E, 0xF3, 0x90, 0x3F, 0x8B, 0x4F, 0xBC, 0xAB); + constexpr QUuid GKEY_KEYBOARD_UUID(0x153E64E6, 0x98C8, 0x4E, 0x03, 0x80EF, 0x5F, 0xFD, 0x33, 0xD2, 0x5B, 0x8A); + constexpr QUuid GKEY_MOUSE_UUID(0xC41E60AF, 0x9022, 0x46CF, 0xBC, 0x39, 0x37, 0x98, 0x10, 0x82, 0xD7, 0x16); QList< Shortcut > newShortcuts; @@ -253,7 +253,7 @@ QList< Shortcut > GlobalShortcutWin::migrateSettings(const QList< Shortcut > &ol } const auto uuid = entries.at(1).toUuid(); - if (uuid == keyboardUuid) { + if (uuid == KEYBOARD_UUID) { InputKeyboard input; input.code = (value & ~0x8000U) >> 8; input.e0 = value & 0x8000U; @@ -267,7 +267,7 @@ QList< Shortcut > GlobalShortcutWin::migrateSettings(const QList< Shortcut > &ol } button = QVariant::fromValue(input); - } else if (uuid == mouseUuid) { + } else if (uuid == MOUSE_UUID) { value >>= 8; if (value < 3 || value > 7) { ok = false; @@ -276,7 +276,7 @@ QList< Shortcut > GlobalShortcutWin::migrateSettings(const QList< Shortcut > &ol button = QVariant::fromValue(static_cast< InputMouse >(value - 2)); #ifdef USE_XBOXINPUT - } else if (uuid == xinputUuid) { + } else if (uuid == XINPUT_UUID) { InputXinput input; input.device = (value >> 24) & 0xFF; input.code = value & 0x00FFFFFF; @@ -284,14 +284,14 @@ QList< Shortcut > GlobalShortcutWin::migrateSettings(const QList< Shortcut > &ol button = QVariant::fromValue(input); #endif #ifdef USE_GKEY - } else if (uuid == gkeyKeyboardUuid) { + } else if (uuid == GKEY_KEYBOARD_UUID) { InputGkey input = {}; input.keyboard = true; input.mode = value >> 16; input.button = value & 0xFFFF; button = QVariant::fromValue(input); - } else if (uuid == gkeyMouseUuid) { + } else if (uuid == GKEY_MOUSE_UUID) { InputGkey input = {}; input.button = value; @@ -363,8 +363,8 @@ void GlobalShortcutWin::run() { yieldCurrentThread(); } - constexpr uint8_t nRid = 5; - RAWINPUTDEVICE rid[nRid] = {}; + constexpr uint8_t NRID = 5; + RAWINPUTDEVICE rid[NRID] = {}; rid[0].usUsagePage = HID_USAGE_PAGE_GENERIC; rid[0].usUsage = HID_USAGE_GENERIC_MOUSE; @@ -391,7 +391,7 @@ void GlobalShortcutWin::run() { rid[4].dwFlags = RIDEV_INPUTSINK | RIDEV_DEVNOTIFY; rid[4].hwndTarget = mumble_mw_hwnd; - if (!RegisterRawInputDevices(rid, nRid, sizeof(RAWINPUTDEVICE))) { + if (!RegisterRawInputDevices(rid, NRID, sizeof(RAWINPUTDEVICE))) { qWarning("GlobalShortcutWindows: RegisterRawInputDevices() failed with error %u!", GetLastError()); } diff --git a/src/mumble/Log.cpp b/src/mumble/Log.cpp index f948df543..389cfd18d 100644 --- a/src/mumble/Log.cpp +++ b/src/mumble/Log.cpp @@ -551,11 +551,11 @@ QString Log::imageToImg(const QByteArray &format, const QByteArray &image) { } QString Log::imageToImg(QImage img, int maxSize) { - constexpr int maxWidth = 600; - constexpr int maxHeight = 400; + constexpr int MAX_WIDTH = 600; + constexpr int MAX_HEIGHT = 400; - if ((img.width() > maxWidth) || (img.height() > maxHeight)) { - img = img.scaled(maxWidth, maxHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation); + if ((img.width() > MAX_WIDTH) || (img.height() > MAX_HEIGHT)) { + img = img.scaled(MAX_WIDTH, MAX_HEIGHT, Qt::KeepAspectRatio, Qt::SmoothTransformation); } int quality = 100; diff --git a/src/mumble/PipeWire.cpp b/src/mumble/PipeWire.cpp index ed03cd031..6540f42ca 100644 --- a/src/mumble/PipeWire.cpp +++ b/src/mumble/PipeWire.cpp @@ -315,12 +315,12 @@ PipeWireInput::PipeWireInput() { iMicChannels = Global::get().s.pipeWireInput; - constexpr uint32_t channels[]{ + constexpr uint32_t CHANNELS[]{ SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT, }; - if (!m_engine->connect(PW_DIRECTION_INPUT, channels, iMicChannels)) { + if (!m_engine->connect(PW_DIRECTION_INPUT, CHANNELS, iMicChannels)) { return; } @@ -374,16 +374,16 @@ PipeWireOutput::PipeWireOutput() { // - 7.1 surround // // Ideally this should be configurable by the user. - constexpr uint32_t channels[]{ SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT, SPEAKER_LOW_FREQUENCY, SPEAKER_FRONT_CENTER, + constexpr uint32_t CHANNELS[]{ SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT, SPEAKER_LOW_FREQUENCY, SPEAKER_FRONT_CENTER, SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT, SPEAKER_SIDE_LEFT, SPEAKER_SIDE_RIGHT }; - if (!m_engine->connect(PW_DIRECTION_OUTPUT, channels, iChannels)) { + if (!m_engine->connect(PW_DIRECTION_OUTPUT, CHANNELS, iChannels)) { return; } eSampleFormat = SampleFloat; iMixerFreq = SAMPLE_RATE; - initializeMixer(channels); + initializeMixer(CHANNELS); m_engine->start(); } diff --git a/src/mumble/PluginConfig.cpp b/src/mumble/PluginConfig.cpp index 689fbd8b5..c4e0b2d04 100644 --- a/src/mumble/PluginConfig.cpp +++ b/src/mumble/PluginConfig.cpp @@ -90,15 +90,15 @@ void PluginConfig::save() const { Global::get().pluginManager->unlinkPositionalData(); } - constexpr int enableCol = 1; - constexpr int positionalDataCol = 2; - constexpr int keyboardMonitorCol = 3; + constexpr int ENABLE_COL = 1; + constexpr int POSITIONAL_DATA_COL = 2; + constexpr int KEYBOARD_MONITOR_COL = 3; QList< QTreeWidgetItem * > list = qtwPlugins->findItems(QString(), Qt::MatchContains); for (QTreeWidgetItem *i : list) { - bool enable = (i->checkState(enableCol) == Qt::Checked); - bool positionalDataEnabled = (i->checkState(positionalDataCol) == Qt::Checked); - bool keyboardMonitoringEnabled = (i->checkState(keyboardMonitorCol) == Qt::Checked); + bool enable = (i->checkState(ENABLE_COL) == Qt::Checked); + bool positionalDataEnabled = (i->checkState(POSITIONAL_DATA_COL) == Qt::Checked); + bool keyboardMonitoringEnabled = (i->checkState(KEYBOARD_MONITOR_COL) == Qt::Checked); const_plugin_ptr_t plugin = pluginForItem(i); if (plugin) { diff --git a/src/mumble/SearchDialog.cpp b/src/mumble/SearchDialog.cpp index 5f7e9d48e..dfc228b2c 100644 --- a/src/mumble/SearchDialog.cpp +++ b/src/mumble/SearchDialog.cpp @@ -58,12 +58,12 @@ public: SearchResultItem(const SearchResult &result, unsigned int id, parent_t parent, QTreeWidgetItem *precedingItem = nullptr) : QTreeWidgetItem(parent, precedingItem), m_result(result), m_id(id) { - constexpr int typeColumn = 0; - constexpr int matchColumn = 1; + constexpr int TYPE_COLUMN = 0; + constexpr int MATCH_COLUMN = 1; if (m_result.type == SearchType::User) { QIcon userIcon = QIcon(QLatin1String("skin:talking_off.svg")); - setIcon(typeColumn, userIcon); + setIcon(TYPE_COLUMN, userIcon); } setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator); @@ -72,10 +72,10 @@ public: m_result.fullText.replace(m_result.begin, m_result.length, "<b>" + m_result.fullText.midRef(m_result.begin, m_result.length) + "</b>"); - setData(matchColumn, Qt::DisplayRole, std::move(matchText)); - setData(matchColumn, SearchDialogItemDelegate::CHANNEL_TREE_ROLE, m_result.channelHierarchy); + setData(MATCH_COLUMN, Qt::DisplayRole, std::move(matchText)); + setData(MATCH_COLUMN, SearchDialogItemDelegate::CHANNEL_TREE_ROLE, m_result.channelHierarchy); - setTextAlignment(matchColumn, Qt::AlignLeft | Qt::AlignVCenter); + setTextAlignment(MATCH_COLUMN, Qt::AlignLeft | Qt::AlignVCenter); } unsigned int getID() const { return m_id; } @@ -94,11 +94,11 @@ public: template< typename parent_t > ChannelItem(const Channel *chan, parent_t parent = nullptr, QTreeWidgetItem *precedingItem = nullptr) : QTreeWidgetItem(parent, precedingItem), m_chanID(chan->iId) { - constexpr int nameColumn = 0; + constexpr int NAME_COLUMN = 0; - setText(nameColumn, chan->qsName); + setText(NAME_COLUMN, chan->qsName); - setTextAlignment(nameColumn, Qt::AlignLeft | Qt::AlignVCenter); + setTextAlignment(NAME_COLUMN, Qt::AlignLeft | Qt::AlignVCenter); } int getChannelID() const { return m_chanID; } @@ -254,8 +254,8 @@ void SearchDialog::clearSearchResults() { } SearchResult regularSearch(const QString &source, const QString &searchTerm, SearchType type, bool caseSensitive) { - constexpr int from = 0; - int startIndex = source.indexOf(searchTerm, from, caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); + constexpr int FROM = 0; + int startIndex = source.indexOf(searchTerm, FROM, caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); if (startIndex >= 0) { int length = searchTerm.size(); diff --git a/src/mumble/ServerHandler.cpp b/src/mumble/ServerHandler.cpp index 5d1a21c02..cb3f17c81 100644 --- a/src/mumble/ServerHandler.cpp +++ b/src/mumble/ServerHandler.cpp @@ -277,7 +277,7 @@ void ServerHandler::handleVoicePacket(const Mumble::Protocol::AudioData &audioDa AudioOutputPtr ao = Global::get().ao; if (ao && sender - && !((audioData.targetOrContext == Mumble::Protocol::AudioContext::Whisper) && Global::get().s.bWhisperFriends + && !((audioData.targetOrContext == Mumble::Protocol::AudioContext::WHISPER) && Global::get().s.bWhisperFriends && sender->qsFriendName.isEmpty())) { ao->addFrameToBuffer(sender, audioData); } diff --git a/src/mumble/ServerInformation.cpp b/src/mumble/ServerInformation.cpp index 2f9d332f4..b47924f9c 100644 --- a/src/mumble/ServerInformation.cpp +++ b/src/mumble/ServerInformation.cpp @@ -156,12 +156,12 @@ void ServerInformation::updateConnectionDetails() { void ServerInformation::populateUDPStatistics(const Connection &connection) { // statistics - constexpr int toServerCol = 0; - constexpr int fromServerCol = 1; - constexpr int goodRow = 0; - constexpr int lateRow = 1; - constexpr int lostRow = 2; - constexpr int resyncRow = 3; + constexpr int TO_SERVER_COL = 0; + constexpr int FROM_SERVER_COL = 1; + constexpr int GOOD_ROW = 0; + constexpr int LATE_ROW = 1; + constexpr int LOST_ROW = 2; + constexpr int RESYNC_ROW = 3; QTableWidgetItem *toGoodItem = new QTableWidgetItem(QString::number(connection.csCrypt->uiRemoteGood)); QTableWidgetItem *fromGoodItem = new QTableWidgetItem(QString::number(connection.csCrypt->uiGood)); @@ -172,14 +172,14 @@ void ServerInformation::populateUDPStatistics(const Connection &connection) { QTableWidgetItem *toResyncItem = new QTableWidgetItem(QString::number(connection.csCrypt->uiRemoteResync)); QTableWidgetItem *fromResyncItem = new QTableWidgetItem(QString::number(connection.csCrypt->uiResync)); - connection_udp_statisticsTable->setItem(goodRow, toServerCol, toGoodItem); - connection_udp_statisticsTable->setItem(goodRow, fromServerCol, fromGoodItem); - connection_udp_statisticsTable->setItem(lateRow, toServerCol, toLateItem); - connection_udp_statisticsTable->setItem(lateRow, fromServerCol, fromLateItem); - connection_udp_statisticsTable->setItem(lostRow, toServerCol, toLostItem); - connection_udp_statisticsTable->setItem(lostRow, fromServerCol, fromLostItem); - connection_udp_statisticsTable->setItem(resyncRow, toServerCol, toResyncItem); - connection_udp_statisticsTable->setItem(resyncRow, fromServerCol, fromResyncItem); + connection_udp_statisticsTable->setItem(GOOD_ROW, TO_SERVER_COL, toGoodItem); + connection_udp_statisticsTable->setItem(GOOD_ROW, FROM_SERVER_COL, fromGoodItem); + connection_udp_statisticsTable->setItem(LATE_ROW, TO_SERVER_COL, toLateItem); + connection_udp_statisticsTable->setItem(LATE_ROW, FROM_SERVER_COL, fromLateItem); + connection_udp_statisticsTable->setItem(LOST_ROW, TO_SERVER_COL, toLostItem); + connection_udp_statisticsTable->setItem(LOST_ROW, FROM_SERVER_COL, fromLostItem); + connection_udp_statisticsTable->setItem(RESYNC_ROW, TO_SERVER_COL, toResyncItem); + connection_udp_statisticsTable->setItem(RESYNC_ROW, FROM_SERVER_COL, fromResyncItem); connection_udp_statisticsTable->adjustSize(); } diff --git a/src/murmur/AudioReceiverBuffer.h b/src/murmur/AudioReceiverBuffer.h index 7a8741da3..9d2aeefc8 100644 --- a/src/murmur/AudioReceiverBuffer.h +++ b/src/murmur/AudioReceiverBuffer.h @@ -34,7 +34,7 @@ public: protected: std::reference_wrapper< ServerUser > m_receiver; - Mumble::Protocol::audio_context_t m_context = Mumble::Protocol::AudioContext::Invalid; + Mumble::Protocol::audio_context_t m_context = Mumble::Protocol::AudioContext::INVALID; VolumeAdjustment m_volumeAdjustment = VolumeAdjustment::fromFactor(1.0f); }; diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index fce3efac6..cb9462e76 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -802,7 +802,7 @@ void Server::run() { ++nfds; while (bRunning) { - FrameMarkNamed(TracyConstants::udp_frame); + FrameMarkNamed(TracyConstants::UDP_FRAME); #ifdef Q_OS_UNIX int pret = poll(fds, nfds, -1); @@ -877,7 +877,7 @@ void Server::run() { #endif // Capture only the processing without the polling - ZoneScopedN(TracyConstants::udp_packet_processing_zone); + ZoneScopedN(TracyConstants::UDP_PACKET_PROCESSING_ZONE); if (len == 0) { break; @@ -911,7 +911,7 @@ void Server::run() { // This may be a general ping requesting server details, unencrypted. if (bAllowPing && m_udpDecoder.decodePing(gsl::span< Mumble::Protocol::byte >(encrypt, len)) && m_udpDecoder.getMessageType() == Mumble::Protocol::UDPMessageType::Ping) { - ZoneScopedN(TracyConstants::ping_processing_zone); + ZoneScopedN(TracyConstants::PING_PROCESSING_ZONE); gsl::span< const Mumble::Protocol::byte > encodedPing = handlePing(m_udpDecoder, m_udpPingEncoder, true); @@ -937,7 +937,7 @@ void Server::run() { continue; } } else { - ZoneScopedN(TracyConstants::decrypt_unknown_peer_zone); + ZoneScopedN(TracyConstants::DECRYPT_UNKNOWN_PEER_ZONE); // Unknown peer foreach (ServerUser *usr, qhHostUsers.value(ha)) { @@ -990,7 +990,7 @@ void Server::run() { break; } case Mumble::Protocol::UDPMessageType::Ping: { - ZoneScopedN(TracyConstants::udp_ping_processing_zone); + ZoneScopedN(TracyConstants::UDP_PING_PROCESSING_ZONE); Mumble::Protocol::PingData pingData = m_udpDecoder.getPingData(); if (!pingData.requestAdditionalInformation && !pingData.containsAdditionalInformation) { @@ -1156,16 +1156,16 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au buffer.clear(); - if (audioData.targetOrContext == Mumble::Protocol::ReservedTargetIDs::ServerLoopback) { - buffer.forceAddReceiver(*u, Mumble::Protocol::AudioContext::Normal, audioData.containsPositionalData); - } else if (audioData.targetOrContext == Mumble::Protocol::ReservedTargetIDs::RegularSpeech) { + if (audioData.targetOrContext == Mumble::Protocol::ReservedTargetIDs::SERVER_LOOPBACK) { + buffer.forceAddReceiver(*u, Mumble::Protocol::AudioContext::NORMAL, audioData.containsPositionalData); + } else if (audioData.targetOrContext == Mumble::Protocol::ReservedTargetIDs::REGULAR_SPEECH) { Channel *c = u->cChannel; // Send audio to all users that are listening to the channel foreach (unsigned int currentSession, m_channelListenerManager.getListenersForChannel(c->iId)) { ServerUser *pDst = static_cast< ServerUser * >(qhUsers.value(currentSession)); if (pDst) { - buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::Listen, audioData.containsPositionalData); + buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::LISTEN, audioData.containsPositionalData); } } @@ -1173,7 +1173,7 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au for (User *p : c->qlUsers) { ServerUser *pDst = static_cast< ServerUser * >(p); - buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::Normal, audioData.containsPositionalData); + buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::NORMAL, audioData.containsPositionalData); } // Send audio to all linked channels the user has speak-permission @@ -1189,7 +1189,7 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au for (unsigned int currentSession : m_channelListenerManager.getListenersForChannel(l->iId)) { ServerUser *pDst = static_cast< ServerUser * >(qhUsers.value(currentSession)); if (pDst) { - buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::Listen, + buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::LISTEN, audioData.containsPositionalData); } } @@ -1198,7 +1198,7 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au for (User *p : l->qlUsers) { ServerUser *pDst = static_cast< ServerUser * >(p); - buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::Normal, + buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::NORMAL, audioData.containsPositionalData); } } @@ -1210,14 +1210,14 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au QSet< ServerUser * > listener; if (u->qmTargetCache.contains(audioData.targetOrContext)) { - ZoneScopedN(TracyConstants::audio_whisper_cache_restore); + ZoneScopedN(TracyConstants::AUDIO_WHISPER_CACHE_STORE); const WhisperTargetCache &cache = u->qmTargetCache.value(audioData.targetOrContext); channel = cache.channelTargets; direct = cache.directTargets; listener = cache.listeningTargets; } else { - ZoneScopedN(TracyConstants::audio_whisper_cache_create); + ZoneScopedN(TracyConstants::AUDIO_WHISPER_CACHE_CREATE); const WhisperTarget &wt = u->qmTargets.value(audioData.targetOrContext); if (!wt.qlChannels.isEmpty()) { @@ -1308,19 +1308,19 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au } // These users receive the audio because someone is shouting to their channel for (ServerUser *pDst : channel) { - buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::Shout, audioData.containsPositionalData); + buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::SHOUT, audioData.containsPositionalData); } // These users receive audio because someone is whispering to them for (ServerUser *pDst : direct) { - buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::Whisper, audioData.containsPositionalData); + buffer.addReceiver(*u, *pDst, Mumble::Protocol::AudioContext::WHISPER, audioData.containsPositionalData); } // These users receive audio because someone is sending audio to one of their listeners for (ServerUser *current : listener) { - buffer.addReceiver(*u, *current, Mumble::Protocol::AudioContext::Listen, audioData.containsPositionalData); + buffer.addReceiver(*u, *current, Mumble::Protocol::AudioContext::LISTEN, audioData.containsPositionalData); } } - ZoneNamedN(__tracy_scoped_zone2, TracyConstants::audio_send_out_zone, true); + ZoneNamedN(__tracy_scoped_zone2, TracyConstants::AUDIO_SENDOUT_ZONE, true); buffer.preprocessBuffer(); @@ -1345,7 +1345,7 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au if (isFirstIteration || !Mumble::Protocol::protocolVersionsAreCompatible(encoder.getProtocolVersion(), currentRange.begin->getReceiver().uiVersion)) { - ZoneScopedN(TracyConstants::audio_encode); + ZoneScopedN(TracyConstants::AUDIO_ENCODE); encoder.setProtocolVersion(currentRange.begin->getReceiver().uiVersion); @@ -1362,7 +1362,7 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au audioData.targetOrContext = currentRange.begin->getContext(); // Update data - TracyCZoneN(__tracy_zone, TracyConstants::audio_update, true); + TracyCZoneN(__tracy_zone, TracyConstants::AUDIO_UPDATE, true); gsl::span< const Mumble::Protocol::byte > encodedPacket = encoder.updateAudioPacket(audioData); TracyCZoneEnd(__tracy_zone); @@ -1735,7 +1735,7 @@ void Server::connectionClosed(QAbstractSocket::SocketError err, const QString &r } void Server::message(Mumble::Protocol::TCPMessageType type, const QByteArray &qbaMsg, ServerUser *u) { - ZoneScopedN(TracyConstants::tcp_packet_processing_zone); + ZoneScopedN(TracyConstants::TCP_PACKET_PROCESSING_ZONE); if (!u) { u = static_cast< ServerUser * >(sender()); diff --git a/src/murmur/TracyConstants.h b/src/murmur/TracyConstants.h index 355eafd40..6c2f0db7c 100644 --- a/src/murmur/TracyConstants.h +++ b/src/murmur/TracyConstants.h @@ -7,19 +7,19 @@ #define MUMBLE_MURMUR_TRACYCONSTANTS_H_ namespace TracyConstants { -static constexpr const char *udp_packet_processing_zone = "udp_packet_processing"; -static constexpr const char *tcp_packet_processing_zone = "tcp_packet_processing"; -static constexpr const char *ping_processing_zone = "tcp_ping"; -static constexpr const char *udp_ping_processing_zone = "udp_ping"; -static constexpr const char *decrypt_unknown_peer_zone = "decrypt_unknown_peer"; +static constexpr const char *UDP_PACKET_PROCESSING_ZONE = "udp_packet_processing"; +static constexpr const char *TCP_PACKET_PROCESSING_ZONE = "tcp_packet_processing"; +static constexpr const char *PING_PROCESSING_ZONE = "tcp_ping"; +static constexpr const char *UDP_PING_PROCESSING_ZONE = "udp_ping"; +static constexpr const char *DECRYPT_UNKNOWN_PEER_ZONE = "decrypt_unknown_peer"; -static constexpr const char *udp_frame = "udp_frame"; +static constexpr const char *UDP_FRAME = "udp_frame"; -static constexpr const char *audio_send_out_zone = "audio_send_out"; -static constexpr const char *audio_encode = "audio_encode"; -static constexpr const char *audio_update = "audio_update"; -static constexpr const char *audio_whisper_cache_restore = "audio_whisper_cache_restore"; -static constexpr const char *audio_whisper_cache_create = "audio_whisper_cache_create"; +static constexpr const char *AUDIO_SENDOUT_ZONE = "audio_send_out"; +static constexpr const char *AUDIO_ENCODE = "audio_encode"; +static constexpr const char *AUDIO_UPDATE = "audio_update"; +static constexpr const char *AUDIO_WHISPER_CACHE_STORE = "audio_whisper_cache_restore"; +static constexpr const char *AUDIO_WHISPER_CACHE_CREATE = "audio_whisper_cache_create"; }; // namespace TracyConstants #endif // MUMBLE_MURMUR_TRACYCONSTANTS_H_ diff --git a/src/tests/TestAudioReceiverBuffer/TestAudioReceiverBuffer.cpp b/src/tests/TestAudioReceiverBuffer/TestAudioReceiverBuffer.cpp index 46cf8f5b5..3d37c3099 100644 --- a/src/tests/TestAudioReceiverBuffer/TestAudioReceiverBuffer.cpp +++ b/src/tests/TestAudioReceiverBuffer/TestAudioReceiverBuffer.cpp @@ -85,7 +85,7 @@ public: protected: std::size_t m_encodings = 0; Version::mumble_raw_version_t m_protocolVersion = Version::UNKNOWN; - Mumble::Protocol::audio_context_t m_context = Mumble::Protocol::AudioContext::Invalid; + Mumble::Protocol::audio_context_t m_context = Mumble::Protocol::AudioContext::INVALID; float m_volumeAdjustment = 0.0f; }; @@ -112,9 +112,9 @@ private slots: usedIDs.insert(current.uiSession); } - QVERIFY(Mumble::Protocol::AudioContext::Normal < Mumble::Protocol::AudioContext::Whisper); - QVERIFY(Mumble::Protocol::AudioContext::Normal < Mumble::Protocol::AudioContext::Shout); - QVERIFY(Mumble::Protocol::AudioContext::Normal < Mumble::Protocol::AudioContext::Listen); + QVERIFY(Mumble::Protocol::AudioContext::NORMAL < Mumble::Protocol::AudioContext::WHISPER); + QVERIFY(Mumble::Protocol::AudioContext::NORMAL < Mumble::Protocol::AudioContext::SHOUT); + QVERIFY(Mumble::Protocol::AudioContext::NORMAL < Mumble::Protocol::AudioContext::LISTEN); QVERIFY(contextUser1.ssContext == contextUser3.ssContext); QVERIFY(contextUser1.ssContext != contextUser2.ssContext); @@ -125,12 +125,12 @@ private slots: ServerUser &sender = users[0]; - buffer.addReceiver(sender, sender, Mumble::Protocol::AudioContext::Listen, false); - buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::Whisper, false); - buffer.addReceiver(sender, users[2], Mumble::Protocol::AudioContext::Shout, false); - buffer.addReceiver(sender, contextUser1, Mumble::Protocol::AudioContext::Shout, false); - buffer.addReceiver(sender, selfDeafUser, Mumble::Protocol::AudioContext::Shout, false); - buffer.addReceiver(sender, deafUser, Mumble::Protocol::AudioContext::Shout, false); + buffer.addReceiver(sender, sender, Mumble::Protocol::AudioContext::LISTEN, false); + buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::WHISPER, false); + buffer.addReceiver(sender, users[2], Mumble::Protocol::AudioContext::SHOUT, false); + buffer.addReceiver(sender, contextUser1, Mumble::Protocol::AudioContext::SHOUT, false); + buffer.addReceiver(sender, selfDeafUser, Mumble::Protocol::AudioContext::SHOUT, false); + buffer.addReceiver(sender, deafUser, Mumble::Protocol::AudioContext::SHOUT, false); QCOMPARE(buffer.getReceivers(false).size(), static_cast< std::size_t >(3)); QVERIFY(buffer.getReceivers(true).empty()); @@ -141,10 +141,10 @@ private slots: ServerUser &sender = contextUser1; - buffer.addReceiver(sender, users[0], Mumble::Protocol::AudioContext::Normal, true); - buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::Normal, true); - buffer.addReceiver(sender, contextUser2, Mumble::Protocol::AudioContext::Normal, true); - buffer.addReceiver(sender, contextUser3, Mumble::Protocol::AudioContext::Normal, true); + buffer.addReceiver(sender, users[0], Mumble::Protocol::AudioContext::NORMAL, true); + buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::NORMAL, true); + buffer.addReceiver(sender, contextUser2, Mumble::Protocol::AudioContext::NORMAL, true); + buffer.addReceiver(sender, contextUser3, Mumble::Protocol::AudioContext::NORMAL, true); // There is only one receiver whose context matches that of the sender QCOMPARE(buffer.getReceivers(true).size(), static_cast< std::size_t >(1)); @@ -157,7 +157,7 @@ private slots: ServerUser &sender = users[0]; - buffer.forceAddReceiver(sender, Mumble::Protocol::AudioContext::Normal, false); + buffer.forceAddReceiver(sender, Mumble::Protocol::AudioContext::NORMAL, false); QCOMPARE(buffer.getReceivers(false).size(), static_cast< std::size_t >(1)); QVERIFY(buffer.getReceivers(true).empty()); @@ -168,16 +168,16 @@ private slots: ServerUser &sender = users[0]; - buffer.addReceiver(sender, users[3], Mumble::Protocol::AudioContext::Listen, false, + buffer.addReceiver(sender, users[3], Mumble::Protocol::AudioContext::LISTEN, false, VolumeAdjustment::fromFactor(1.2f)); - buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::Whisper, false); - buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::Normal, false); - buffer.addReceiver(sender, users[2], Mumble::Protocol::AudioContext::Shout, false); - buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::Listen, false); - buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::Shout, false); - buffer.addReceiver(sender, users[3], Mumble::Protocol::AudioContext::Listen, false, + buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::WHISPER, false); + buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::NORMAL, false); + buffer.addReceiver(sender, users[2], Mumble::Protocol::AudioContext::SHOUT, false); + buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::LISTEN, false); + buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::SHOUT, false); + buffer.addReceiver(sender, users[3], Mumble::Protocol::AudioContext::LISTEN, false, VolumeAdjustment::fromFactor(1.4f)); - buffer.addReceiver(sender, contextUser1, Mumble::Protocol::AudioContext::Shout, false); + buffer.addReceiver(sender, contextUser1, Mumble::Protocol::AudioContext::SHOUT, false); buffer.preprocessBuffer(); @@ -199,7 +199,7 @@ private slots: QVERIFY(volumeReceiver != nullptr); // Verify that the "Normal" speech receiver has survived (instead of one of the other contexts) - QCOMPARE(duplicateReceiver->getContext(), Mumble::Protocol::AudioContext::Normal); + QCOMPARE(duplicateReceiver->getContext(), Mumble::Protocol::AudioContext::NORMAL); // Verify that the highest volume adjustment has survived QCOMPARE(volumeReceiver->getVolumeAdjustment().factor, 1.4f); } @@ -209,16 +209,16 @@ private slots: ServerUser &sender = contextUser2; - buffer.addReceiver(sender, users[3], Mumble::Protocol::AudioContext::Shout, false); - buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::Listen, false); - buffer.addReceiver(sender, users[4], Mumble::Protocol::AudioContext::Shout, false); - buffer.addReceiver(sender, users[2], Mumble::Protocol::AudioContext::Normal, false); - buffer.addReceiver(sender, users[0], Mumble::Protocol::AudioContext::Normal, false); - buffer.addReceiver(sender, contextUser1, Mumble::Protocol::AudioContext::Shout, false, + buffer.addReceiver(sender, users[3], Mumble::Protocol::AudioContext::SHOUT, false); + buffer.addReceiver(sender, users[1], Mumble::Protocol::AudioContext::LISTEN, false); + buffer.addReceiver(sender, users[4], Mumble::Protocol::AudioContext::SHOUT, false); + buffer.addReceiver(sender, users[2], Mumble::Protocol::AudioContext::NORMAL, false); + buffer.addReceiver(sender, users[0], Mumble::Protocol::AudioContext::NORMAL, false); + buffer.addReceiver(sender, contextUser1, Mumble::Protocol::AudioContext::SHOUT, false, VolumeAdjustment::fromFactor(1.4f)); - buffer.addReceiver(sender, contextUser2, Mumble::Protocol::AudioContext::Shout, false, + buffer.addReceiver(sender, contextUser2, Mumble::Protocol::AudioContext::SHOUT, false, VolumeAdjustment::fromFactor(1.2f)); - buffer.addReceiver(sender, contextUser3, Mumble::Protocol::AudioContext::Shout, false, + buffer.addReceiver(sender, contextUser3, Mumble::Protocol::AudioContext::SHOUT, false, VolumeAdjustment::fromFactor(1.2f)); buffer.preprocessBuffer(); diff --git a/src/tests/TestMumbleProtocol/TestMumbleProtocol.cpp b/src/tests/TestMumbleProtocol/TestMumbleProtocol.cpp index 85e0b502a..d284655c1 100644 --- a/src/tests/TestMumbleProtocol/TestMumbleProtocol.cpp +++ b/src/tests/TestMumbleProtocol/TestMumbleProtocol.cpp @@ -174,12 +174,12 @@ template< Mumble::Protocol::Role encoderRole, Mumble::Protocol::Role decoderRole if (decoderRole == Mumble::Protocol::Role::Client) { QVERIFY(encoder.getRole() == Mumble::Protocol::Role::Server); - data.targetOrContext = Mumble::Protocol::AudioContext::Shout; + data.targetOrContext = Mumble::Protocol::AudioContext::SHOUT; data.senderSession = 42; } else { QVERIFY(encoder.getRole() == Mumble::Protocol::Role::Client); - data.targetOrContext = Mumble::Protocol::ReservedTargetIDs::ServerLoopback; + data.targetOrContext = Mumble::Protocol::ReservedTargetIDs::SERVER_LOOPBACK; } auto encodedData = encoder.encodeAudioPacket(data); @@ -193,7 +193,7 @@ template< Mumble::Protocol::Role encoderRole, Mumble::Protocol::Role decoderRole qWarning() << "Partial re-encoding"; // Re-encode fields from the "variable" part - data.targetOrContext = Mumble::Protocol::AudioContext::Listen; + data.targetOrContext = Mumble::Protocol::AudioContext::LISTEN; if (version >= Mumble::Protocol::PROTOBUF_INTRODUCTION_VERSION && decoderRole == Mumble::Protocol::Role::Client) { data.volumeAdjustment = VolumeAdjustment::fromFactor(0.9f); @@ -210,7 +210,7 @@ template< Mumble::Protocol::Role encoderRole, Mumble::Protocol::Role decoderRole qWarning() << "Removing positional data"; // Update the audio packet to no longer contain positional data. data.containsPositionalData = false; - data.targetOrContext = Mumble::Protocol::AudioContext::Normal; + data.targetOrContext = Mumble::Protocol::AudioContext::NORMAL; encoder.dropPositionalData(); @@ -249,8 +249,8 @@ private slots: MumbleUDP::Audio msg; std::vector< Mumble::Protocol::byte > buffer; - for (Mumble::Protocol::audio_context_t currentContext = Mumble::Protocol::AudioContext::begin; - currentContext < Mumble::Protocol::AudioContext::end; currentContext++) { + for (Mumble::Protocol::audio_context_t currentContext = Mumble::Protocol::AudioContext::BEGIN; + currentContext < Mumble::Protocol::AudioContext::END; currentContext++) { gsl::span< const Mumble::Protocol::byte > snippet = encoder.getPreEncodedContext(currentContext); QVERIFY2(!snippet.empty(), "Unable to find pre-encoded snippet for audio context"); @@ -270,7 +270,7 @@ private slots: } // Ensure that an unknown context yields an empty span - QVERIFY(encoder.getPreEncodedContext(Mumble::Protocol::AudioContext::end).empty()); + QVERIFY(encoder.getPreEncodedContext(Mumble::Protocol::AudioContext::END).empty()); } void test_preEncode_volume_adjustments() { @@ -278,10 +278,10 @@ private slots: MumbleUDP::Audio msg; - constexpr int min = -60; - constexpr int max = 30; + constexpr int MIN = -60; + constexpr int MAX = 30; - for (int currentAdjustment = min; currentAdjustment <= max; ++currentAdjustment) { + for (int currentAdjustment = MIN; currentAdjustment <= MAX; ++currentAdjustment) { msg.Clear(); gsl::span< const Mumble::Protocol::byte > snippet = @@ -296,9 +296,9 @@ private slots: } // Ensure that an unknown/unexpected volume adjustment yields an empty span - QVERIFY(encoder.getPreEncodedVolumeAdjustment(VolumeAdjustment::fromDBAdjustment(min - 1)).empty()); + QVERIFY(encoder.getPreEncodedVolumeAdjustment(VolumeAdjustment::fromDBAdjustment(MIN - 1)).empty()); // We only expect pre-encoded values for integer dB adjustments - QVERIFY(encoder.getPreEncodedVolumeAdjustment(VolumeAdjustment(std::pow(2.0f, (min + 0.5) / 6.0f))).empty()); + QVERIFY(encoder.getPreEncodedVolumeAdjustment(VolumeAdjustment(std::pow(2.0f, (MAX + 0.5) / 6.0f))).empty()); } }; |