Skip to content
Permalink
Browse files

AudioOutput: make playSample() time out after 1 second if no AudioOut…

…put is present.
  • Loading branch information...
mkrautz committed Apr 28, 2016
1 parent a50a120 commit a1a969e7d3566ae4bb2ca8d7ce811712672e4aca
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/mumble/AudioOutput.cpp
@@ -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
@@ -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;

0 comments on commit a1a969e

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