configure_audio: Port to support both per-game and global modes
This commit is contained in:
@@ -23,6 +23,10 @@ ConfigureAudio::ConfigureAudio(QWidget* parent)
|
|||||||
|
|
||||||
connect(ui->volume_slider, &QSlider::valueChanged, this,
|
connect(ui->volume_slider, &QSlider::valueChanged, this,
|
||||||
&ConfigureAudio::setVolumeIndicatorText);
|
&ConfigureAudio::setVolumeIndicatorText);
|
||||||
|
connect(ui->volume_slider, &QSlider::valueChanged, this, [this]() {
|
||||||
|
if (!ui->volume_checkbox->isHidden())
|
||||||
|
ui->volume_checkbox->setChecked(true);
|
||||||
|
});
|
||||||
|
|
||||||
this->setConfiguration();
|
this->setConfiguration();
|
||||||
connect(ui->output_sink_combo_box,
|
connect(ui->output_sink_combo_box,
|
||||||
@@ -35,6 +39,31 @@ ConfigureAudio::ConfigureAudio(QWidget* parent)
|
|||||||
|
|
||||||
ConfigureAudio::~ConfigureAudio() = default;
|
ConfigureAudio::~ConfigureAudio() = default;
|
||||||
|
|
||||||
|
void ConfigureAudio::setPerGame(bool per_game) {
|
||||||
|
ui->toggle_audio_stretching->setTristate(per_game);
|
||||||
|
ui->output_sink_checkbox->setHidden(!per_game);
|
||||||
|
ui->audio_device_checkbox->setHidden(!per_game);
|
||||||
|
ui->volume_checkbox->setHidden(!per_game);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigureAudio::loadValuesChange(const PerGameValuesChange& change) {
|
||||||
|
ui->toggle_audio_stretching->setCheckState(
|
||||||
|
change.enable_audio_stretching
|
||||||
|
? (Settings::values->enable_audio_stretching ? Qt::Checked : Qt::Unchecked)
|
||||||
|
: Qt::PartiallyChecked);
|
||||||
|
ui->output_sink_checkbox->setChecked(change.sink_id);
|
||||||
|
ui->audio_device_checkbox->setChecked(change.audio_device_id);
|
||||||
|
ui->volume_checkbox->setChecked(change.volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigureAudio::mergeValuesChange(PerGameValuesChange& change) {
|
||||||
|
change.enable_audio_stretching =
|
||||||
|
ui->toggle_audio_stretching->checkState() != Qt::PartiallyChecked;
|
||||||
|
change.sink_id = ui->output_sink_checkbox->isChecked();
|
||||||
|
change.audio_device_id = ui->audio_device_checkbox->isChecked();
|
||||||
|
change.volume = ui->volume_checkbox->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigureAudio::setConfiguration() {
|
void ConfigureAudio::setConfiguration() {
|
||||||
setOutputSinkFromSinkID();
|
setOutputSinkFromSinkID();
|
||||||
|
|
||||||
@@ -43,15 +72,15 @@ void ConfigureAudio::setConfiguration() {
|
|||||||
|
|
||||||
setAudioDeviceFromDeviceID();
|
setAudioDeviceFromDeviceID();
|
||||||
|
|
||||||
ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching);
|
ui->toggle_audio_stretching->setChecked(Settings::values->enable_audio_stretching);
|
||||||
ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum());
|
ui->volume_slider->setValue(Settings::values->volume * ui->volume_slider->maximum());
|
||||||
setVolumeIndicatorText(ui->volume_slider->sliderPosition());
|
setVolumeIndicatorText(ui->volume_slider->sliderPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureAudio::setOutputSinkFromSinkID() {
|
void ConfigureAudio::setOutputSinkFromSinkID() {
|
||||||
int new_sink_index = 0;
|
int new_sink_index = 0;
|
||||||
|
|
||||||
const QString sink_id = QString::fromStdString(Settings::values.sink_id);
|
const QString sink_id = QString::fromStdString(Settings::values->sink_id);
|
||||||
for (int index = 0; index < ui->output_sink_combo_box->count(); index++) {
|
for (int index = 0; index < ui->output_sink_combo_box->count(); index++) {
|
||||||
if (ui->output_sink_combo_box->itemText(index) == sink_id) {
|
if (ui->output_sink_combo_box->itemText(index) == sink_id) {
|
||||||
new_sink_index = index;
|
new_sink_index = index;
|
||||||
@@ -65,7 +94,7 @@ void ConfigureAudio::setOutputSinkFromSinkID() {
|
|||||||
void ConfigureAudio::setAudioDeviceFromDeviceID() {
|
void ConfigureAudio::setAudioDeviceFromDeviceID() {
|
||||||
int new_device_index = -1;
|
int new_device_index = -1;
|
||||||
|
|
||||||
const QString device_id = QString::fromStdString(Settings::values.audio_device_id);
|
const QString device_id = QString::fromStdString(Settings::values->audio_device_id);
|
||||||
for (int index = 0; index < ui->audio_device_combo_box->count(); index++) {
|
for (int index = 0; index < ui->audio_device_combo_box->count(); index++) {
|
||||||
if (ui->audio_device_combo_box->itemText(index) == device_id) {
|
if (ui->audio_device_combo_box->itemText(index) == device_id) {
|
||||||
new_device_index = index;
|
new_device_index = index;
|
||||||
@@ -81,14 +110,14 @@ void ConfigureAudio::setVolumeIndicatorText(int percentage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureAudio::applyConfiguration() {
|
void ConfigureAudio::applyConfiguration() {
|
||||||
Settings::values.sink_id =
|
Settings::values->sink_id =
|
||||||
ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex())
|
ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex())
|
||||||
.toStdString();
|
.toStdString();
|
||||||
Settings::values.enable_audio_stretching = ui->toggle_audio_stretching->isChecked();
|
Settings::values->enable_audio_stretching = ui->toggle_audio_stretching->isChecked();
|
||||||
Settings::values.audio_device_id =
|
Settings::values->audio_device_id =
|
||||||
ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex())
|
ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex())
|
||||||
.toStdString();
|
.toStdString();
|
||||||
Settings::values.volume =
|
Settings::values->volume =
|
||||||
static_cast<float>(ui->volume_slider->sliderPosition()) / ui->volume_slider->maximum();
|
static_cast<float>(ui->volume_slider->sliderPosition()) / ui->volume_slider->maximum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include "yuzu/configuration/config.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ConfigureAudio;
|
class ConfigureAudio;
|
||||||
@@ -18,6 +19,10 @@ public:
|
|||||||
explicit ConfigureAudio(QWidget* parent = nullptr);
|
explicit ConfigureAudio(QWidget* parent = nullptr);
|
||||||
~ConfigureAudio();
|
~ConfigureAudio();
|
||||||
|
|
||||||
|
void setPerGame(bool per_game);
|
||||||
|
void loadValuesChange(const PerGameValuesChange& change);
|
||||||
|
void mergeValuesChange(PerGameValuesChange& change);
|
||||||
|
|
||||||
void applyConfiguration();
|
void applyConfiguration();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>188</width>
|
<width>402</width>
|
||||||
<height>246</height>
|
<height>246</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -29,18 +29,31 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="output_sink_combo_box"/>
|
<widget class="QComboBox" name="output_sink_combo_box"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="output_sink_checkbox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="toggle_audio_stretching">
|
<widget class="QCheckBox" name="toggle_audio_stretching">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>This post-processing effect adjusts audio speed to match emulation speed and helps prevent audio stutter. This however increases audio latency.</string>
|
<string>This post-processing effect adjusts audio speed to match emulation speed and helps prevent audio stutter. This however increases audio latency.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable audio stretching</string>
|
<string>Enable audio stretching</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout">
|
<layout class="QHBoxLayout">
|
||||||
<item>
|
<item>
|
||||||
@@ -53,6 +66,19 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="audio_device_combo_box"/>
|
<widget class="QComboBox" name="audio_device_combo_box"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="audio_device_checkbox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -115,6 +141,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="volume_checkbox">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -133,6 +166,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Check the box next to output engine, audio device, or volume to override the global default setting with this one for this game only.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|||||||
Reference in New Issue
Block a user