mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(audio): actually disable the audio in/out device in settings, when selected
As esecially the "Disabled" text is translated, the audio device will change from "disabled" to "default", just by changing the language. In contrast to video devices, an audio device is either always available, or sound will be disabled. So "Disabled" is the correct term to use here.
This commit is contained in:
parent
81df534c9a
commit
9694d6b6d4
|
@ -320,7 +320,7 @@ bool Audio::autoInitOutput()
|
||||||
|
|
||||||
bool Audio::initInput(const QString& deviceName)
|
bool Audio::initInput(const QString& deviceName)
|
||||||
{
|
{
|
||||||
if (deviceName.toLower() == QStringLiteral("none"))
|
if (!Settings::getInstance().getAudioInDevEnabled())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
qDebug() << "Opening audio input" << deviceName;
|
qDebug() << "Opening audio input" << deviceName;
|
||||||
|
@ -363,7 +363,7 @@ bool Audio::initOutput(const QString& deviceName)
|
||||||
outSources.clear();
|
outSources.clear();
|
||||||
|
|
||||||
outputInitialized = false;
|
outputInitialized = false;
|
||||||
if (deviceName.toLower() == QStringLiteral("none"))
|
if (!Settings::getInstance().getAudioOutDevEnabled())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
qDebug() << "Opening audio output" << deviceName;
|
qDebug() << "Opening audio output" << deviceName;
|
||||||
|
|
|
@ -242,7 +242,9 @@ void Settings::loadGlobal()
|
||||||
|
|
||||||
s.beginGroup("Audio");
|
s.beginGroup("Audio");
|
||||||
inDev = s.value("inDev", "").toString();
|
inDev = s.value("inDev", "").toString();
|
||||||
|
audioInDevEnabled = s.value("audioInDevEnabled", true).toBool();
|
||||||
outDev = s.value("outDev", "").toString();
|
outDev = s.value("outDev", "").toString();
|
||||||
|
audioOutDevEnabled = s.value("audioOutDevEnabled", true).toBool();
|
||||||
audioInGainDecibel = s.value("inGain", 0).toReal();
|
audioInGainDecibel = s.value("inGain", 0).toReal();
|
||||||
outVolume = s.value("outVolume", 100).toInt();
|
outVolume = s.value("outVolume", 100).toInt();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
@ -478,7 +480,9 @@ void Settings::saveGlobal()
|
||||||
|
|
||||||
s.beginGroup("Audio");
|
s.beginGroup("Audio");
|
||||||
s.setValue("inDev", inDev);
|
s.setValue("inDev", inDev);
|
||||||
|
s.setValue("audioInDevEnabled", audioInDevEnabled);
|
||||||
s.setValue("outDev", outDev);
|
s.setValue("outDev", outDev);
|
||||||
|
s.setValue("audioOutDevEnabled", audioOutDevEnabled);
|
||||||
s.setValue("inGain", audioInGainDecibel);
|
s.setValue("inGain", audioInGainDecibel);
|
||||||
s.setValue("outVolume", outVolume);
|
s.setValue("outVolume", outVolume);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
@ -1389,6 +1393,18 @@ void Settings::setInDev(const QString& deviceSpecifier)
|
||||||
inDev = deviceSpecifier;
|
inDev = deviceSpecifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::getAudioInDevEnabled() const
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&bigLock);
|
||||||
|
return audioInDevEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setAudioInDevEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&bigLock);
|
||||||
|
audioInDevEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
qreal Settings::getAudioInGain() const
|
qreal Settings::getAudioInGain() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&bigLock};
|
QMutexLocker locker{&bigLock};
|
||||||
|
@ -1425,6 +1441,18 @@ void Settings::setOutDev(const QString& deviceSpecifier)
|
||||||
outDev = deviceSpecifier;
|
outDev = deviceSpecifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::getAudioOutDevEnabled() const
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&bigLock);
|
||||||
|
return audioOutDevEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setAudioOutDevEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&bigLock);
|
||||||
|
audioOutDevEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
int Settings::getOutVolume() const
|
int Settings::getOutVolume() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&bigLock};
|
QMutexLocker locker{&bigLock};
|
||||||
|
|
|
@ -179,9 +179,15 @@ public:
|
||||||
QString getInDev() const;
|
QString getInDev() const;
|
||||||
void setInDev(const QString& deviceSpecifier);
|
void setInDev(const QString& deviceSpecifier);
|
||||||
|
|
||||||
|
bool getAudioInDevEnabled() const;
|
||||||
|
void setAudioInDevEnabled(bool enabled);
|
||||||
|
|
||||||
QString getOutDev() const;
|
QString getOutDev() const;
|
||||||
void setOutDev(const QString& deviceSpecifier);
|
void setOutDev(const QString& deviceSpecifier);
|
||||||
|
|
||||||
|
bool getAudioOutDevEnabled() const;
|
||||||
|
void setAudioOutDevEnabled(bool enabled);
|
||||||
|
|
||||||
qreal getAudioInGain() const;
|
qreal getAudioInGain() const;
|
||||||
void setAudioInGain(qreal dB);
|
void setAudioInGain(qreal dB);
|
||||||
|
|
||||||
|
@ -433,8 +439,10 @@ private:
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
QString inDev;
|
QString inDev;
|
||||||
QString outDev;
|
bool audioInDevEnabled;
|
||||||
qreal audioInGainDecibel;
|
qreal audioInGainDecibel;
|
||||||
|
QString outDev;
|
||||||
|
bool audioOutDevEnabled;
|
||||||
int outVolume;
|
int outVolume;
|
||||||
|
|
||||||
// Video
|
// Video
|
||||||
|
|
|
@ -345,36 +345,42 @@ void AVForm::getVideoDevices()
|
||||||
void AVForm::getAudioInDevices()
|
void AVForm::getAudioInDevices()
|
||||||
{
|
{
|
||||||
QStringList deviceNames;
|
QStringList deviceNames;
|
||||||
deviceNames << tr("None") << Audio::inDeviceNames();
|
deviceNames << tr("Disabled") << Audio::inDeviceNames();
|
||||||
|
|
||||||
bodyUI->inDevCombobox->blockSignals(true);
|
bodyUI->inDevCombobox->blockSignals(true);
|
||||||
bodyUI->inDevCombobox->clear();
|
bodyUI->inDevCombobox->clear();
|
||||||
bodyUI->inDevCombobox->addItems(deviceNames);
|
bodyUI->inDevCombobox->addItems(deviceNames);
|
||||||
bodyUI->inDevCombobox->blockSignals(false);
|
bodyUI->inDevCombobox->blockSignals(false);
|
||||||
|
|
||||||
int idx = deviceNames.indexOf(Settings::getInstance().getInDev());
|
int idx = Settings::getInstance().getAudioInDevEnabled()
|
||||||
bodyUI->inDevCombobox->setCurrentIndex(idx > 0 ? idx : 0);
|
? deviceNames.indexOf(Settings::getInstance().getInDev())
|
||||||
|
: 0;
|
||||||
|
bodyUI->inDevCombobox->setCurrentIndex(idx < 0 ? 1 : idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVForm::getAudioOutDevices()
|
void AVForm::getAudioOutDevices()
|
||||||
{
|
{
|
||||||
QStringList deviceNames;
|
QStringList deviceNames;
|
||||||
deviceNames << tr("None") << Audio::outDeviceNames();
|
deviceNames << tr("Disabled") << Audio::outDeviceNames();
|
||||||
|
|
||||||
bodyUI->outDevCombobox->blockSignals(true);
|
bodyUI->outDevCombobox->blockSignals(true);
|
||||||
bodyUI->outDevCombobox->clear();
|
bodyUI->outDevCombobox->clear();
|
||||||
bodyUI->outDevCombobox->addItems(deviceNames);
|
bodyUI->outDevCombobox->addItems(deviceNames);
|
||||||
bodyUI->outDevCombobox->blockSignals(false);
|
bodyUI->outDevCombobox->blockSignals(false);
|
||||||
|
|
||||||
int idx = deviceNames.indexOf(Settings::getInstance().getOutDev());
|
int idx = Settings::getInstance().getAudioOutDevEnabled()
|
||||||
bodyUI->outDevCombobox->setCurrentIndex(idx > 0 ? idx : 0);
|
? deviceNames.indexOf(Settings::getInstance().getOutDev())
|
||||||
|
: 0;
|
||||||
|
bodyUI->outDevCombobox->setCurrentIndex(idx < 0 ? 1 : idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVForm::onAudioInDevChanged(int deviceIndex)
|
void AVForm::onAudioInDevChanged(int deviceIndex)
|
||||||
{
|
{
|
||||||
QString deviceName = deviceIndex > 0
|
Settings::getInstance().setAudioInDevEnabled(deviceIndex != 0);
|
||||||
? bodyUI->inDevCombobox->itemText(deviceIndex)
|
|
||||||
: QStringLiteral("none");
|
QString deviceName;
|
||||||
|
if (deviceIndex > 0)
|
||||||
|
deviceName = bodyUI->inDevCombobox->itemText(deviceIndex);
|
||||||
|
|
||||||
Settings::getInstance().setInDev(deviceName);
|
Settings::getInstance().setInDev(deviceName);
|
||||||
|
|
||||||
|
@ -386,9 +392,11 @@ void AVForm::onAudioInDevChanged(int deviceIndex)
|
||||||
|
|
||||||
void AVForm::onAudioOutDevChanged(int deviceIndex)
|
void AVForm::onAudioOutDevChanged(int deviceIndex)
|
||||||
{
|
{
|
||||||
QString deviceName = deviceIndex > 0
|
Settings::getInstance().setAudioOutDevEnabled(deviceIndex != 0);
|
||||||
? bodyUI->outDevCombobox->itemText(deviceIndex)
|
|
||||||
: QStringLiteral("none");
|
QString deviceName;
|
||||||
|
if (deviceIndex > 0)
|
||||||
|
deviceName = bodyUI->outDevCombobox->itemText(deviceIndex);
|
||||||
|
|
||||||
Settings::getInstance().setOutDev(deviceName);
|
Settings::getInstance().setOutDev(deviceName);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user