Merge pull request #12533 from druiz17/stereo-checkbox

Adding Stereo checkbox in Audio settings
This commit is contained in:
John Conklin II 2018-03-05 12:45:01 -08:00 committed by GitHub
commit 7bc3848c36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 7 deletions

View file

@ -112,6 +112,7 @@ Rectangle {
// mute is in its own row // mute is in its own row
RowLayout { RowLayout {
spacing: (margins.sizeCheckBox - 10.5) * 3;
AudioControls.CheckBox { AudioControls.CheckBox {
id: muteMic id: muteMic
text: qsTr("Mute microphone"); text: qsTr("Mute microphone");
@ -123,6 +124,19 @@ Rectangle {
checked = Qt.binding(function() { return AudioScriptingInterface.muted; }); // restore binding checked = Qt.binding(function() { return AudioScriptingInterface.muted; }); // restore binding
} }
} }
AudioControls.CheckBox {
id: stereoMic
spacing: muteMic.spacing;
text: qsTr("use stereo for stereo devices");
checked: false;
onClicked: {
var success = Audio.setIsStereoInput(checked);
if (!success) {
checked = !checked;
}
}
}
} }
RowLayout { RowLayout {
@ -204,6 +218,8 @@ Rectangle {
text: devicename text: devicename
onPressed: { onPressed: {
if (!checked) { if (!checked) {
stereoMic.checked = false;
Audio.setIsStereoInput(false); // the next selected audio device might not support stereo
AudioScriptingInterface.setInputDevice(info, bar.currentIndex === 1); AudioScriptingInterface.setInputDevice(info, bar.currentIndex === 1);
} }
} }

View file

@ -1397,9 +1397,11 @@ void AudioClient::setNoiseReduction(bool enable) {
} }
void AudioClient::setIsStereoInput(bool isStereoInput) { bool AudioClient::setIsStereoInput(bool isStereoInput) {
if (isStereoInput != _isStereoInput) { bool stereoInputChanged = false;
if (isStereoInput != _isStereoInput && _inputDeviceInfo.supportedChannelCounts().contains(2)) {
_isStereoInput = isStereoInput; _isStereoInput = isStereoInput;
stereoInputChanged = true;
if (_isStereoInput) { if (_isStereoInput) {
_desiredInputFormat.setChannelCount(2); _desiredInputFormat.setChannelCount(2);
@ -1419,6 +1421,8 @@ void AudioClient::setIsStereoInput(bool isStereoInput) {
// restart the input device // restart the input device
switchInputToAudioDevice(_inputDeviceInfo); switchInputToAudioDevice(_inputDeviceInfo);
} }
return stereoInputChanged;
} }
bool AudioClient::outputLocalInjector(const AudioInjectorPointer& injector) { bool AudioClient::outputLocalInjector(const AudioInjectorPointer& injector) {

View file

@ -192,7 +192,7 @@ public slots:
void toggleMute(); void toggleMute();
bool isMuted() { return _muted; } bool isMuted() { return _muted; }
virtual void setIsStereoInput(bool stereo) override; virtual bool setIsStereoInput(bool stereo) override;
void setNoiseReduction(bool isNoiseGateEnabled); void setNoiseReduction(bool isNoiseGateEnabled);
bool isNoiseReductionEnabled() const { return _isNoiseGateEnabled; } bool isNoiseReductionEnabled() const { return _isNoiseGateEnabled; }

View file

@ -41,7 +41,7 @@ public:
public slots: public slots:
virtual bool shouldLoopbackInjectors() { return false; } virtual bool shouldLoopbackInjectors() { return false; }
virtual void setIsStereoInput(bool stereo) = 0; virtual bool setIsStereoInput(bool stereo) = 0;
}; };
Q_DECLARE_METATYPE(AbstractAudioInterface*) Q_DECLARE_METATYPE(AbstractAudioInterface*)

View file

@ -60,8 +60,10 @@ ScriptAudioInjector* AudioScriptingInterface::playSound(SharedSoundPointer sound
} }
} }
void AudioScriptingInterface::setStereoInput(bool stereo) { bool AudioScriptingInterface::setStereoInput(bool stereo) {
bool stereoInputChanged = false;
if (_localAudioInterface) { if (_localAudioInterface) {
_localAudioInterface->setIsStereoInput(stereo); stereoInputChanged = _localAudioInterface->setIsStereoInput(stereo);
} }
return stereoInputChanged;
} }

View file

@ -35,7 +35,7 @@ protected:
// FIXME: there is no way to play a positionless sound // FIXME: there is no way to play a positionless sound
Q_INVOKABLE ScriptAudioInjector* playSystemSound(SharedSoundPointer sound, const QVector3D& position); Q_INVOKABLE ScriptAudioInjector* playSystemSound(SharedSoundPointer sound, const QVector3D& position);
Q_INVOKABLE void setStereoInput(bool stereo); Q_INVOKABLE bool setStereoInput(bool stereo);
signals: signals:
void mutedByMixer(); /// the client has been muted by the mixer void mutedByMixer(); /// the client has been muted by the mixer