From 7d74f37c26dc2cb124af35637f4fb758affd332a Mon Sep 17 00:00:00 2001 From: Thorvald Natvig Date: Wed, 10 Feb 2010 23:06:07 +0100 Subject: [PATCH] Fix new audio compile problems in 11x --- src/mumble/main.cpp | 2 -- src/mumble11x/Audio.cpp | 63 +++++++++++++++++++++++++++++++++++++++++ src/mumble11x/Audio.h | 11 +++++++ 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/src/mumble/main.cpp b/src/mumble/main.cpp index 34102eda5..8529b16a6 100644 --- a/src/mumble/main.cpp +++ b/src/mumble/main.cpp @@ -408,8 +408,6 @@ int main(int argc, char **argv) { if (! g.bQuit) res=a.exec(); - qWarning() << "OUTLOOP"; - g.s.save(); if (g.sh && g.sh->isRunning()) Database::setShortcuts(g.sh->qbaDigest, g.s.qlShortcuts); diff --git a/src/mumble11x/Audio.cpp b/src/mumble11x/Audio.cpp index 9dc212a78..7d8f40dd3 100644 --- a/src/mumble11x/Audio.cpp +++ b/src/mumble11x/Audio.cpp @@ -31,6 +31,7 @@ #include #include "Audio.h" +#include "AudioInput.h" #include "AudioOutput.h" #include "Global.h" @@ -103,3 +104,65 @@ void LoopPlayer::fetchFrames() { qtLastFetch.restart(); } + +void Audio::startOutput(const QString &output) { + g.ao = AudioOutputRegistrar::newFromChoice(output); + if (g.ao) + g.ao->start(QThread::HighPriority); +} + +void Audio::stopOutput() { + AudioOutputPtr ao = g.ao; + + g.ao.reset(); + + while (ao.get() && ! ao.unique()) { +#if QT_VERSION >= 0x040500 + QThread::yieldCurrentThread(); +#endif + } + + ao.reset(); +} + +void Audio::startInput(const QString &input) { + g.ai = AudioInputRegistrar::newFromChoice(input); + if (g.ai) + g.ai->start(QThread::HighestPriority); +} + +void Audio::stopInput() { + AudioInputPtr ai = g.ai; + + g.ai.reset(); + + while (ai.get() && ! ai.unique()) { +#if QT_VERSION >= 0x040500 + QThread::yieldCurrentThread(); +#endif + } + + ai.reset(); +} + +void Audio::start(const QString &input, const QString &output) { + startInput(input); + startOutput(output); +} + +void Audio::stop() { + AudioInputPtr ai = g.ai; + AudioOutputPtr ao = g.ao; + + g.ao.reset(); + g.ai.reset(); + + while ((ai.get() && ! ai.unique()) || (ao.get() && ! ao.unique())) { +#if QT_VERSION >= 0x040500 + QThread::yieldCurrentThread(); +#endif + } + + ai.reset(); + ao.reset(); +} diff --git a/src/mumble11x/Audio.h b/src/mumble11x/Audio.h index 98cbe237e..57931c5b7 100644 --- a/src/mumble11x/Audio.h +++ b/src/mumble11x/Audio.h @@ -54,4 +54,15 @@ class LoopPlayer : public ClientPlayer { void fetchFrames(); }; +namespace Audio { + void startInput(const QString &input = QString()); + void stopInput(); + + void startOutput(const QString &output = QString()); + void stopOutput(); + + void start(const QString &input = QString(), const QString &output = QString()); + void stop(); +} + #endif