mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
cleanup close audio device
This commit is contained in:
parent
efda47a226
commit
7b98f2a4a0
@ -154,11 +154,13 @@ If the input device has no more subscriptions, it will be closed.
|
|||||||
*/
|
*/
|
||||||
void Audio::unsubscribeInput()
|
void Audio::unsubscribeInput()
|
||||||
{
|
{
|
||||||
qDebug() << "unsubscribing input" << inputSubscriptions;
|
|
||||||
QMutexLocker locker(&audioInLock);
|
QMutexLocker locker(&audioInLock);
|
||||||
|
|
||||||
if (inputSubscriptions > 0)
|
if (inputSubscriptions > 0)
|
||||||
|
{
|
||||||
inputSubscriptions--;
|
inputSubscriptions--;
|
||||||
|
qDebug() << "Unsubscribed from audio input device [" << inputSubscriptions << " subscriptions]";
|
||||||
|
}
|
||||||
|
|
||||||
if (!inputSubscriptions)
|
if (!inputSubscriptions)
|
||||||
cleanupInput();
|
cleanupInput();
|
||||||
@ -333,7 +335,6 @@ Close an input device, please don't use unless everyone's unsuscribed
|
|||||||
*/
|
*/
|
||||||
void Audio::closeInput()
|
void Audio::closeInput()
|
||||||
{
|
{
|
||||||
qDebug() << "Closing input";
|
|
||||||
QMutexLocker locker(&audioInLock);
|
QMutexLocker locker(&audioInLock);
|
||||||
cleanupInput();
|
cleanupInput();
|
||||||
}
|
}
|
||||||
@ -343,7 +344,6 @@ Close an output device
|
|||||||
*/
|
*/
|
||||||
void Audio::closeOutput()
|
void Audio::closeOutput()
|
||||||
{
|
{
|
||||||
qDebug() << "Closing output";
|
|
||||||
QMutexLocker locker(&audioOutLock);
|
QMutexLocker locker(&audioOutLock);
|
||||||
cleanupOutput();
|
cleanupOutput();
|
||||||
}
|
}
|
||||||
@ -484,28 +484,22 @@ void Audio::cleanupInput()
|
|||||||
if (alInDev)
|
if (alInDev)
|
||||||
{
|
{
|
||||||
#if (!FIX_SND_PCM_PREPARE_BUG)
|
#if (!FIX_SND_PCM_PREPARE_BUG)
|
||||||
qDebug() << "stopping capture";
|
qDebug() << "stopping audio capture";
|
||||||
alcCaptureStop(alInDev);
|
alcCaptureStop(alInDev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (alcCaptureCloseDevice(alInDev))
|
qDebug() << "Closing audio input";
|
||||||
{
|
if (alcCaptureCloseDevice(alInDev) == ALC_TRUE)
|
||||||
alInDev = nullptr;
|
alInDev = nullptr;
|
||||||
inputSubscriptions = 0;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
qWarning() << "Failed to close input";
|
qWarning() << "Failed to close input";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Audio::cleanupOutput()
|
void Audio::cleanupOutput()
|
||||||
{
|
{
|
||||||
if (inputSubscriptions)
|
|
||||||
cleanupInput();
|
|
||||||
|
|
||||||
if (alOutDev) {
|
if (alOutDev) {
|
||||||
|
qDebug() << "Closing audio output";
|
||||||
alSourcei(alMainSource, AL_LOOPING, AL_FALSE);
|
alSourcei(alMainSource, AL_LOOPING, AL_FALSE);
|
||||||
alSourceStop(alMainSource);
|
alSourceStop(alMainSource);
|
||||||
alDeleteSources(1, &alMainSource);
|
alDeleteSources(1, &alMainSource);
|
||||||
@ -517,7 +511,9 @@ void Audio::cleanupOutput()
|
|||||||
alcDestroyContext(alContext);
|
alcDestroyContext(alContext);
|
||||||
alContext = nullptr;
|
alContext = nullptr;
|
||||||
|
|
||||||
if (!alcCloseDevice(device))
|
if (alcCloseDevice(device))
|
||||||
|
alOutDev = nullptr;
|
||||||
|
else
|
||||||
qWarning("Failed to close output.");
|
qWarning("Failed to close output.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -528,7 +524,7 @@ Returns true if the input device is open and suscribed to
|
|||||||
bool Audio::isInputReady()
|
bool Audio::isInputReady()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&audioInLock);
|
QMutexLocker locker(&audioInLock);
|
||||||
return alInDev && inputSubscriptions;
|
return alInDev;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Audio::isInputSubscribed()
|
bool Audio::isInputSubscribed()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user