Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
AudioOutput: make playSample() time out after 1 second if no AudioOut…
…put is present.
  • Loading branch information
mkrautz committed May 1, 2016
1 parent a50a120 commit a1a969e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/mumble/AudioOutput.cpp
Expand Up @@ -42,6 +42,7 @@
#include "Plugins.h"
#include "PacketDataStream.h"
#include "ServerHandler.h"
#include "Timer.h"
#include "VoiceRecorder.h"

// Remember that we cannot use static member classes that are not pointers, as the constructor
Expand Down Expand Up @@ -229,10 +230,19 @@ AudioOutputSample *AudioOutput::playSample(const QString &filename, bool loop) {
if (handle == NULL)
return NULL;

while ((iMixerFreq == 0) && isAlive()) {
Timer t;
const quint64 oneSecond = 1000000;

while (!t.isElapsed(oneSecond) && (iMixerFreq == 0) && isAlive()) {
QThread::yieldCurrentThread();
}

// If we've waited for more than one second, we declare timeout.
if (t.isElapsed(oneSecond)) {
qWarning("AudioOutput: playSample() timed out after 1 second: device not ready");
return NULL;
}

if (! iMixerFreq)
return NULL;

Expand Down

0 comments on commit a1a969e

Please sign in to comment.