1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

add method to un-/subscribe to audio output as well

This commit is contained in:
Nils Fenner 2015-11-08 21:05:34 +01:00
parent e8a4f6511d
commit c540faf271
No known key found for this signature in database
GPG Key ID: 9591A163FF9BE04C
2 changed files with 27 additions and 0 deletions

View File

@ -59,6 +59,7 @@ Audio::Audio()
, audioInLock(QMutex::Recursive)
, audioOutLock(QMutex::Recursive)
, inputSubscriptions(0)
, outputSubscriptions(0)
, alOutDev(nullptr)
, alInDev(nullptr)
, outputVolume(1.0)
@ -161,6 +162,29 @@ void Audio::unsubscribeInput()
cleanupInput();
}
void Audio::subscribeOutput()
{
QMutexLocker locker(&audioOutLock);
if (!alOutDev)
initOutput(Settings::getInstance().getOutDev());
outputSubscriptions++;
qDebug() << "Subscribed to audio output device [" << outputSubscriptions << " subscriptions ]";
}
void Audio::unsubscribeOutput()
{
if (outputSubscriptions > 0)
{
outputSubscriptions--;
qDebug() << "Unsubscribed from audio output device [" << outputSubscriptions << " subscriptions]";
}
if (!outputSubscriptions)
cleanupOutput();
}
/**
Open an input device, use before suscribing
*/

View File

@ -62,6 +62,8 @@ public:
void subscribeInput();
void unsubscribeInput();
void subscribeOutput();
void unsubscribeOutput();
void openInput(const QString& inDevDescr);
bool openOutput(const QString& outDevDescr);
@ -114,6 +116,7 @@ private:
QMutex audioInLock;
QMutex audioOutLock;
std::atomic<int> inputSubscriptions;
std::atomic<int> outputSubscriptions;
ALCdevice* alOutDev;
ALCdevice* alInDev;
qreal outputVolume;