mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
initialize gain/volume after initialization of audio in/out device
The gain/volume values are now applied to the settings once, when releasing the slider instead of continuously.
This commit is contained in:
parent
719def932b
commit
6f7df25f4a
|
@ -64,13 +64,19 @@ AVForm::AVForm() :
|
||||||
getAudioOutDevices();
|
getAudioOutDevices();
|
||||||
getVideoDevices();
|
getVideoDevices();
|
||||||
});
|
});
|
||||||
bodyUI->playbackSlider->setValue(Settings::getInstance().getOutVolume());
|
|
||||||
bodyUI->microphoneSlider->setValue(Settings::getInstance().getInVolume());
|
|
||||||
connect(bodyUI->playbackSlider, &QSlider::valueChanged, this, &AVForm::onPlaybackValueChanged);
|
|
||||||
connect(bodyUI->microphoneSlider, &QSlider::valueChanged, this, &AVForm::onMicrophoneValueChanged);
|
|
||||||
|
|
||||||
|
bodyUI->playbackSlider->setTracking(false);
|
||||||
bodyUI->playbackSlider->installEventFilter(this);
|
bodyUI->playbackSlider->installEventFilter(this);
|
||||||
|
connect(bodyUI->playbackSlider, &QSlider::sliderMoved,
|
||||||
|
this, &AVForm::onPlaybackSliderMoved);
|
||||||
|
connect(bodyUI->playbackSlider, &QSlider::valueChanged,
|
||||||
|
this, &AVForm::onPlaybackValueChanged);
|
||||||
|
bodyUI->microphoneSlider->setTracking(false);
|
||||||
bodyUI->microphoneSlider->installEventFilter(this);
|
bodyUI->microphoneSlider->installEventFilter(this);
|
||||||
|
connect(bodyUI->microphoneSlider, &QSlider::sliderMoved,
|
||||||
|
this, &AVForm::onMicrophoneSliderMoved);
|
||||||
|
connect(bodyUI->microphoneSlider, &QSlider::valueChanged,
|
||||||
|
this, &AVForm::onMicrophoneValueChanged);
|
||||||
|
|
||||||
for (QComboBox* cb : findChildren<QComboBox*>())
|
for (QComboBox* cb : findChildren<QComboBox*>())
|
||||||
{
|
{
|
||||||
|
@ -328,7 +334,9 @@ void AVForm::onInDevChanged(QString deviceDescriptor)
|
||||||
deviceDescriptor = "none";
|
deviceDescriptor = "none";
|
||||||
|
|
||||||
Settings::getInstance().setInDev(deviceDescriptor);
|
Settings::getInstance().setInDev(deviceDescriptor);
|
||||||
Audio::getInstance().reinitInput(deviceDescriptor);
|
Audio& audio = Audio::getInstance();
|
||||||
|
audio.reinitInput(deviceDescriptor);
|
||||||
|
bodyUI->microphoneSlider->setSliderPosition(audio.inputVolume() * 100.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVForm::onOutDevChanged(QString deviceDescriptor)
|
void AVForm::onOutDevChanged(QString deviceDescriptor)
|
||||||
|
@ -337,7 +345,9 @@ void AVForm::onOutDevChanged(QString deviceDescriptor)
|
||||||
deviceDescriptor = "none";
|
deviceDescriptor = "none";
|
||||||
|
|
||||||
Settings::getInstance().setOutDev(deviceDescriptor);
|
Settings::getInstance().setOutDev(deviceDescriptor);
|
||||||
Audio::getInstance().reinitOutput(deviceDescriptor);
|
Audio& audio = Audio::getInstance();
|
||||||
|
audio.reinitOutput(deviceDescriptor);
|
||||||
|
bodyUI->playbackSlider->setSliderPosition(audio.outputVolume() * 100.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVForm::onFilterAudioToggled(bool filterAudio)
|
void AVForm::onFilterAudioToggled(bool filterAudio)
|
||||||
|
@ -345,16 +355,29 @@ void AVForm::onFilterAudioToggled(bool filterAudio)
|
||||||
Settings::getInstance().setFilterAudio(filterAudio);
|
Settings::getInstance().setFilterAudio(filterAudio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AVForm::onPlaybackSliderMoved(int value)
|
||||||
|
{
|
||||||
|
Audio& audio = Audio::getInstance();
|
||||||
|
if (audio.isOutputReady()) {
|
||||||
|
const qreal percentage = value / 100.0;
|
||||||
|
audio.setOutputVolume(percentage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AVForm::onPlaybackValueChanged(int value)
|
void AVForm::onPlaybackValueChanged(int value)
|
||||||
{
|
{
|
||||||
Audio::getInstance().setOutputVolume(value / 100.0);
|
Settings::getInstance().setOutVolume(value);
|
||||||
Settings::getInstance().setOutVolume(bodyUI->playbackSlider->value());
|
}
|
||||||
|
|
||||||
|
void AVForm::onMicrophoneSliderMoved(int value)
|
||||||
|
{
|
||||||
|
const qreal percentage = value / 100.0;
|
||||||
|
Audio::getInstance().setInputVolume(percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVForm::onMicrophoneValueChanged(int value)
|
void AVForm::onMicrophoneValueChanged(int value)
|
||||||
{
|
{
|
||||||
Audio::getInstance().setInputVolume(value / 100.0);
|
Settings::getInstance().setInVolume(value);
|
||||||
Settings::getInstance().setInVolume(bodyUI->microphoneSlider->value());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVForm::createVideoSurface()
|
void AVForm::createVideoSurface()
|
||||||
|
|
|
@ -57,7 +57,9 @@ private slots:
|
||||||
void onInDevChanged(QString deviceDescriptor);
|
void onInDevChanged(QString deviceDescriptor);
|
||||||
void onOutDevChanged(QString deviceDescriptor);
|
void onOutDevChanged(QString deviceDescriptor);
|
||||||
void onFilterAudioToggled(bool filterAudio);
|
void onFilterAudioToggled(bool filterAudio);
|
||||||
|
void onPlaybackSliderMoved(int value);
|
||||||
void onPlaybackValueChanged(int value);
|
void onPlaybackValueChanged(int value);
|
||||||
|
void onMicrophoneSliderMoved(int value);
|
||||||
void onMicrophoneValueChanged(int value);
|
void onMicrophoneValueChanged(int value);
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
|
|
Loading…
Reference in New Issue
Block a user