Skip to content
Permalink
Browse files

Merge PR #2864: Fix crash when using the VoiceRecorder with voice tar…

…get shortcuts
  • Loading branch information...
mkrautz committed Feb 26, 2017
2 parents e32f971 + f4dfc4a commit 329dd4ee19b0bdf3e25710e9e18f3a5d7cddfc5a
Showing with 29 additions and 3 deletions.
  1. +15 −0 src/Message.h
  2. +6 −2 src/mumble/AudioInput.cpp
  3. +5 −0 src/mumble/AudioOutput.cpp
  4. +3 −1 src/mumble/AudioOutputSpeech.cpp
@@ -54,6 +54,21 @@ class MessageHandler {
#undef MUMBLE_MH_MSG
};

/// UDPMessageTypeIsValidVoicePacket checks whether the given
/// UDPMessageType is a valid voice packet.
inline bool UDPMessageTypeIsValidVoicePacket(MessageHandler::UDPMessageType umt) {
switch (umt) {
case MessageHandler::UDPVoiceCELTAlpha:
case MessageHandler::UDPVoiceSpeex:
case MessageHandler::UDPVoiceCELTBeta:
case MessageHandler::UDPVoiceOpus:
return true;
case MessageHandler::UDPPing:
return false;
}
return false;
}

inline QString u8(const ::std::string &str) {
return QString::fromUtf8(str.data(), static_cast<int>(str.length()));
}
@@ -914,9 +914,13 @@ void AudioInput::flushCheck(const QByteArray &frame, bool terminator) {
if (! terminator && iBufferedFrames < iAudioFrames)
return;

int flags = g.iTarget;
if (terminator)
int flags = 0;
if (g.iTarget > 0) {
flags = g.iTarget;
}
if (terminator && g.iPrevTarget > 0) {
flags = g.iPrevTarget;
}

if (g.s.lmLoopMode == Settings::Server)
flags = 0x1f; // Server loopback
@@ -160,6 +160,11 @@ void AudioOutput::addFrameToBuffer(ClientUser *user, const QByteArray &qbaPacket
qrwlOutputs.lockForRead();
AudioOutputSpeech *aop = qobject_cast<AudioOutputSpeech *>(qmOutputs.value(user));

if (!UDPMessageTypeIsValidVoicePacket(type)) {
qWarning("AudioOutput: ignored frame with invalid message type 0x%x in addFrameToBuffer().", static_cast<unsigned char>(type));
return;
}

if (! aop || (aop->umtType != type)) {
qrwlOutputs.unlock();

@@ -301,7 +301,7 @@ bool AudioOutputSpeech::needSamples(unsigned int snum) {
memset(pOut, 0, iFrameSize * sizeof(float));
}
#endif
} else {
} else if (umtType == MessageHandler::UDPVoiceSpeex) {
if (qba.isEmpty()) {
speex_decode(dsSpeex, NULL, pOut);
} else {
@@ -310,6 +310,8 @@ bool AudioOutputSpeech::needSamples(unsigned int snum) {
}
for (unsigned int i=0;i<iFrameSize;++i)
pOut[i] *= (1.0f / 32767.f);
} else {
qWarning("AudioOutputSpeech: encountered unknown message type %li in needSamples().", static_cast<long>(umtType));
}

bool update = true;

0 comments on commit 329dd4e

Please sign in to comment.
You can’t perform that action at this time.