Skip to content
Permalink
Browse files

Merge PR #3464: Fix crash when Opus is not available and add critical…

… error message
  • Loading branch information...
davidebeatrici committed Dec 20, 2018
2 parents 16c1145 + d63337d commit 5f370a8c7e9c9d5b597c5973a8bd1336f32eeccf
Showing with 74 additions and 53 deletions.
  1. +9 −3 src/mumble/AudioInput.cpp
  2. +13 −9 src/mumble/AudioOutputSpeech.cpp
  3. +10 −4 src/mumble/Messages.cpp
  4. +42 −37 src/mumble/mumble_en.ts
@@ -82,6 +82,8 @@ AudioInput::AudioInput() : opusBuffer(g.s.iFramesPerPacket * (SAMPLE_RATE / 100)
umtType = MessageHandler::UDPVoiceCELTAlpha;

activityState = ActivityStateActive;
oCodec = NULL;
opusState = NULL;
cCodec = NULL;
ceEncoder = NULL;

@@ -743,8 +745,12 @@ bool AudioInput::selectCodec() {
}

int AudioInput::encodeOpusFrame(short *source, int size, EncodingOutputBuffer& buffer) {
int len = 0;
int len;
#ifdef USE_OPUS
if (!oCodec) {
return 0;
}

if (bResetEncoder) {
oCodec->opus_encoder_ctl(opusState, OPUS_RESET_STATE, NULL);
bResetEncoder = false;
@@ -760,9 +766,9 @@ int AudioInput::encodeOpusFrame(short *source, int size, EncodingOutputBuffer& b
}

int AudioInput::encodeCELTFrame(short *psSource, EncodingOutputBuffer& buffer) {
int len = 0;
int len;
if (!cCodec)
return len;
return 0;

if (bResetEncoder) {
cCodec->celt_encoder_ctl(ceEncoder, CELT_RESET_STATE);
@@ -291,14 +291,16 @@ bool AudioOutputSpeech::needSamples(unsigned int snum) {
memset(pOut, 0, sizeof(float) * iFrameSize);
} else if (umtType == MessageHandler::UDPVoiceOpus) {
#ifdef USE_OPUS
decodedSamples = oCodec->opus_decode_float(opusState,
qba.isEmpty() ?
NULL :
reinterpret_cast<const unsigned char *>(qba.constData()),
qba.size(),
pOut,
iAudioBufferSize,
0);
if (oCodec) {
decodedSamples = oCodec->opus_decode_float(opusState,
qba.isEmpty() ?
NULL :
reinterpret_cast<const unsigned char *>(qba.constData()),
qba.size(),
pOut,
iAudioBufferSize,
0);
}

if (decodedSamples < 0) {
decodedSamples = iFrameSize;
@@ -354,7 +356,9 @@ bool AudioOutputSpeech::needSamples(unsigned int snum) {
memset(pOut, 0, sizeof(float) * iFrameSize);
} else if (umtType == MessageHandler::UDPVoiceOpus) {
#ifdef USE_OPUS
decodedSamples = oCodec->opus_decode_float(opusState, NULL, 0, pOut, iFrameSize, 0);
if (oCodec) {
decodedSamples = oCodec->opus_decode_float(opusState, NULL, 0, pOut, iFrameSize, 0);
}

if (decodedSamples < 0) {
decodedSamples = iFrameSize;
@@ -865,7 +865,13 @@ void MainWindow::msgCodecVersion(const MumbleProto::CodecVersion &msg) {
bool pref = msg.prefer_alpha();

#ifdef USE_OPUS
static bool warnedOpus = false;
g.bOpus = msg.opus();

if (!g.oCodec && !warnedOpus) {
g.l->log(Log::CriticalError, tr("Failed to load Opus, it will not be available for audio encoding/decoding."));
warnedOpus = true;
}
#endif

// Workaround for broken 1.2.2 servers
@@ -890,15 +896,15 @@ void MainWindow::msgCodecVersion(const MumbleProto::CodecVersion &msg) {

int willuse = pref ? g.iCodecAlpha : g.iCodecBeta;

static bool warned = false;
static bool warnedCELT = false;

if (! g.qmCodecs.contains(willuse)) {
if (! warned) {
if (! warnedCELT) {
g.l->log(Log::CriticalError, tr("Unable to find matching CELT codecs with other clients. You will not be able to talk to all users."));
warned = true;
warnedCELT = true;
}
} else {
warned = false;
warnedCELT = false;
}
}

@@ -1093,7 +1093,7 @@ This value allows you to set the maximum number of users allowed in the channel.
<translation type="unfinished"></translation>
</message>
<message>
<location filename="AudioInput.cpp" line="+597"/>
<location filename="AudioInput.cpp" line="+599"/>
<source>Server maximum network bandwidth is only %1 kbit/s. Audio quality auto-adjusted to %2 kbit/s (%3 ms)</source>
<translation type="unfinished"></translation>
</message>
@@ -4126,7 +4126,7 @@ This field describes the size of an LCD device. The size is given either in pixe
<translation type="unfinished"></translation>
</message>
<message>
<location line="+74"/>
<location line="+77"/>
<source>link to %1</source>
<translation type="unfinished"></translation>
</message>
@@ -4154,7 +4154,7 @@ This field describes the size of an LCD device. The size is given either in pixe
<context>
<name>LogConfig</name>
<message>
<location line="-499"/>
<location line="-502"/>
<source>Toggle console for %1 events</source>
<translation type="unfinished"></translation>
</message>
@@ -4675,12 +4675,12 @@ This field describes the size of an LCD device. The size is given either in pixe
<name>MainWindow</name>
<message>
<location filename="MainWindow.cpp" line="+107"/>
<location line="+2701"/>
<location line="+2702"/>
<source>Root</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-2644"/>
<location line="-2645"/>
<source>Push-to-Talk</source>
<comment>Global Shortcut</comment>
<translation type="unfinished"></translation>
@@ -4759,12 +4759,12 @@ This field describes the size of an LCD device. The size is given either in pixe
<message>
<location filename="MainWindow.cpp" line="+4"/>
<location line="+159"/>
<location line="+2638"/>
<location line="+2639"/>
<source>Mumble -- %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-2766"/>
<location line="-2767"/>
<source>&amp;Window</source>
<translation type="unfinished"></translation>
</message>
@@ -4833,13 +4833,13 @@ This field describes the size of an LCD device. The size is given either in pixe
</message>
<message>
<location line="+79"/>
<location line="+2797"/>
<location line="+2798"/>
<source>&lt;center&gt;Not connected&lt;/center&gt;</source>
<oldsource>Not connected</oldsource>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-2349"/>
<location line="-2350"/>
<source>Clear</source>
<translation type="unfinished"></translation>
</message>
@@ -4896,7 +4896,7 @@ This field describes the size of an LCD device. The size is given either in pixe
</message>
<message>
<location line="+76"/>
<location line="+1497"/>
<location line="+1498"/>
<source>Transmit Mode set to Continuous</source>
<translation type="unfinished"></translation>
</message>
@@ -4911,14 +4911,14 @@ This field describes the size of an LCD device. The size is given either in pixe
<translation type="unfinished"></translation>
</message>
<message>
<location line="-179"/>
<location line="+448"/>
<location line="-180"/>
<location line="+449"/>
<source>Register yourself as %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-448"/>
<location line="+448"/>
<location line="-449"/>
<location line="+449"/>
<source>&lt;p&gt;You are about to register yourself on this server. This action cannot be undone, and your username cannot be changed once this is done. You will forever be known as &apos;%1&apos; on this server.&lt;/p&gt;&lt;p&gt;Are you sure you want to register yourself?&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
@@ -5065,7 +5065,7 @@ This field describes the size of an LCD device. The size is given either in pixe
<translation type="unfinished"></translation>
</message>
<message>
<location line="-3103"/>
<location line="-3104"/>
<source>&amp;User</source>
<translation type="unfinished"></translation>
</message>
@@ -5164,13 +5164,13 @@ This field describes the size of an LCD device. The size is given either in pixe
</message>
<message>
<location line="+41"/>
<location line="+1484"/>
<location line="+1485"/>
<source>Transmit Mode set to Voice Activity</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-1479"/>
<location line="+1483"/>
<location line="-1480"/>
<location line="+1484"/>
<source>Transmit Mode set to Push-to-Talk</source>
<translation type="unfinished"></translation>
</message>
@@ -5410,8 +5410,8 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-2238"/>
<location line="+2450"/>
<location line="-2239"/>
<location line="+2451"/>
<source>Images (*.png *.jpg *.jpeg)</source>
<translation type="unfinished"></translation>
</message>
@@ -5908,7 +5908,7 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="Messages.cpp" line="+408"/>
<location filename="Messages.cpp" line="+416"/>
<source>You muted and deafened %1.</source>
<translation type="unfinished"></translation>
</message>
@@ -5948,7 +5948,7 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-218"/>
<location line="-214"/>
<source>%1 moved to %2.</source>
<translation type="unfinished"></translation>
</message>
@@ -5963,12 +5963,12 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+52"/>
<location line="+48"/>
<source>%1 is now muted and deafened.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-296"/>
<location line="-304"/>
<source>Your account information can not be verified currently. Please try again later</source>
<translation type="unfinished"></translation>
</message>
@@ -6054,7 +6054,7 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+32"/>
<location line="+42"/>
<source>%1 connected and entered channel.</source>
<translation type="unfinished"></translation>
</message>
@@ -6064,7 +6064,7 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+93"/>
<location line="+91"/>
<source>%1 is now muted.</source>
<translation type="unfinished"></translation>
</message>
@@ -6175,7 +6175,7 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-173"/>
<location line="-169"/>
<source>You joined %1.</source>
<translation type="unfinished"></translation>
</message>
@@ -6196,7 +6196,7 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+240"/>
<location line="+236"/>
<source>%1 disconnected.</source>
<translation type="unfinished"></translation>
</message>
@@ -6228,7 +6228,12 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+201"/>
<location line="+149"/>
<source>Failed to load Opus, it will not be available for audio encoding/decoding.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+58"/>
<source>The server requests minimum client version %1</source>
<translation type="unfinished"></translation>
</message>
@@ -6253,7 +6258,7 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-464"/>
<location line="-470"/>
<source>You were unmuted by %1.</source>
<translation type="unfinished"></translation>
</message>
@@ -6288,12 +6293,12 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+367"/>
<location line="+373"/>
<source>Unable to find matching CELT codecs with other clients. You will not be able to talk to all users.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-433"/>
<location line="-439"/>
<source>You were muted and deafened by %1.</source>
<oldsource>You were deafened by %1.</oldsource>
<translation type="unfinished"></translation>
@@ -6319,7 +6324,7 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-270"/>
<location line="-266"/>
<source>You were moved to %1 by %2.</source>
<translation type="unfinished"></translation>
</message>
@@ -6329,7 +6334,7 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-225"/>
<location line="-237"/>
<source>Server connection rejected: %1.</source>
<translation type="unfinished"></translation>
</message>
@@ -6339,12 +6344,12 @@ Otherwise abort and check your certificate and username.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+98"/>
<location line="+110"/>
<source>%1 renamed to %2.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+235"/>
<location line="+231"/>
<source>%1 left channel and disconnected.</source>
<translation type="unfinished"></translation>
</message>
@@ -6627,7 +6632,7 @@ the channel&apos;s context menu.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="MainWindow.cpp" line="-3067"/>
<location filename="MainWindow.cpp" line="-3068"/>
<source>&amp;Developer</source>
<translation type="unfinished"></translation>
</message>

0 comments on commit 5f370a8

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