Fix new audio compile problems in 11x

This commit is contained in:
Thorvald Natvig 2010-02-10 23:06:07 +01:00
parent 1ef46ba055
commit 7d74f37c26
3 changed files with 74 additions and 2 deletions

View File

@ -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);

View File

@ -31,6 +31,7 @@
#include <math.h>
#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();
}

View File

@ -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