mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Audio: Only open mic when requested
This commit is contained in:
parent
868381fe3f
commit
bbbd450b6a
@ -113,11 +113,11 @@ void Audio::setInputVolume(float volume)
|
||||
|
||||
void Audio::suscribeInput()
|
||||
{
|
||||
if (!alInDev)
|
||||
/*if (!alInDev)
|
||||
{
|
||||
qWarning()<<"input device is closed";
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
qDebug() << "suscribing input";
|
||||
QMutexLocker lock(audioInLock);
|
||||
@ -125,6 +125,7 @@ void Audio::suscribeInput()
|
||||
{
|
||||
timer->stop();
|
||||
openOutput(Settings::getInstance().getOutDev());
|
||||
openInput(Settings::getInstance().getInDev());
|
||||
|
||||
#if (!FIX_SND_PCM_PREPARE_BUG)
|
||||
if (alInDev)
|
||||
@ -144,7 +145,9 @@ void Audio::unsuscribeInput()
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "unsuscribing input";
|
||||
assert(userCount > 0);
|
||||
|
||||
qDebug() << "unsuscribing input" << userCount;
|
||||
QMutexLocker lock(audioInLock);
|
||||
if (!--userCount)
|
||||
{
|
||||
@ -156,6 +159,7 @@ void Audio::unsuscribeInput()
|
||||
alcCaptureStop(alInDev);
|
||||
}
|
||||
#endif
|
||||
closeInput();
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +190,7 @@ void Audio::openInput(const QString& inDevDescr)
|
||||
core->resetCallSources(); // Force to regen each group call's sources
|
||||
|
||||
// Restart the capture if necessary
|
||||
if (userCount.load() != 0 && alInDev)
|
||||
if (/*userCount.load() != 0 && */alInDev)
|
||||
{
|
||||
alcCaptureStart(alInDev);
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ Core::Core(QThread *CoreThread, Profile& profile) :
|
||||
// OpenAL init
|
||||
//QString outDevDescr = Settings::getInstance().getOutDev();
|
||||
//Audio::openOutput(outDevDescr);
|
||||
QString inDevDescr = Settings::getInstance().getInDev();
|
||||
Audio::openInput(inDevDescr);
|
||||
//QString inDevDescr = Settings::getInstance().getInDev();
|
||||
//Audio::openInput(inDevDescr);
|
||||
}
|
||||
|
||||
void Core::deadifyTox()
|
||||
|
@ -22,7 +22,9 @@
|
||||
#include <QPainter>
|
||||
#include <QLinearGradient>
|
||||
|
||||
MicFeedbackWidget::MicFeedbackWidget(QWidget *parent) : QWidget(parent)
|
||||
MicFeedbackWidget::MicFeedbackWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, timerId(0)
|
||||
{
|
||||
setFixedHeight(20);
|
||||
}
|
||||
@ -83,11 +85,16 @@ void MicFeedbackWidget::timerEvent(QTimerEvent*)
|
||||
void MicFeedbackWidget::showEvent(QShowEvent*)
|
||||
{
|
||||
Audio::suscribeInput();
|
||||
int timerId = startTimer(60);
|
||||
timerId = startTimer(60);
|
||||
}
|
||||
|
||||
void MicFeedbackWidget::hideEvent(QHideEvent*)
|
||||
{
|
||||
Audio::unsuscribeInput();
|
||||
killTimer(timerId);
|
||||
|
||||
if (timerId != 0)
|
||||
{
|
||||
killTimer(timerId);
|
||||
timerId = 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user