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:
parent
e8a4f6511d
commit
c540faf271
@ -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
|
||||
*/
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user