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)
|
, audioInLock(QMutex::Recursive)
|
||||||
, audioOutLock(QMutex::Recursive)
|
, audioOutLock(QMutex::Recursive)
|
||||||
, inputSubscriptions(0)
|
, inputSubscriptions(0)
|
||||||
|
, outputSubscriptions(0)
|
||||||
, alOutDev(nullptr)
|
, alOutDev(nullptr)
|
||||||
, alInDev(nullptr)
|
, alInDev(nullptr)
|
||||||
, outputVolume(1.0)
|
, outputVolume(1.0)
|
||||||
@ -161,6 +162,29 @@ void Audio::unsubscribeInput()
|
|||||||
cleanupInput();
|
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
|
Open an input device, use before suscribing
|
||||||
*/
|
*/
|
||||||
|
@ -62,6 +62,8 @@ public:
|
|||||||
|
|
||||||
void subscribeInput();
|
void subscribeInput();
|
||||||
void unsubscribeInput();
|
void unsubscribeInput();
|
||||||
|
void subscribeOutput();
|
||||||
|
void unsubscribeOutput();
|
||||||
void openInput(const QString& inDevDescr);
|
void openInput(const QString& inDevDescr);
|
||||||
bool openOutput(const QString& outDevDescr);
|
bool openOutput(const QString& outDevDescr);
|
||||||
|
|
||||||
@ -114,6 +116,7 @@ private:
|
|||||||
QMutex audioInLock;
|
QMutex audioInLock;
|
||||||
QMutex audioOutLock;
|
QMutex audioOutLock;
|
||||||
std::atomic<int> inputSubscriptions;
|
std::atomic<int> inputSubscriptions;
|
||||||
|
std::atomic<int> outputSubscriptions;
|
||||||
ALCdevice* alOutDev;
|
ALCdevice* alOutDev;
|
||||||
ALCdevice* alInDev;
|
ALCdevice* alInDev;
|
||||||
qreal outputVolume;
|
qreal outputVolume;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user