12 changed files with 330 additions and 21 deletions
-
5src/audio_core/audio_out.cpp
-
35src/audio_core/stream.cpp
-
5src/core/settings.h
-
3src/yuzu/CMakeLists.txt
-
13src/yuzu/configuration/config.cpp
-
21src/yuzu/configuration/configure.ui
-
90src/yuzu/configuration/configure_audio.cpp
-
31src/yuzu/configuration/configure_audio.h
-
130src/yuzu/configuration/configure_audio.ui
-
1src/yuzu/configuration/configure_dialog.cpp
-
5src/yuzu_cmd/config.cpp
-
12src/yuzu_cmd/default_ini.h
@ -0,0 +1,90 @@ |
|||
// Copyright 2018 yuzu Emulator Project
|
|||
// Licensed under GPLv2 or any later version
|
|||
// Refer to the license.txt file included.
|
|||
|
|||
#include <memory>
|
|||
|
|||
#include "audio_core/sink.h"
|
|||
#include "audio_core/sink_details.h"
|
|||
#include "core/core.h"
|
|||
#include "core/settings.h"
|
|||
#include "ui_configure_audio.h"
|
|||
#include "yuzu/configuration/configure_audio.h"
|
|||
|
|||
ConfigureAudio::ConfigureAudio(QWidget* parent) |
|||
: QWidget(parent), ui(std::make_unique<Ui::ConfigureAudio>()) { |
|||
ui->setupUi(this); |
|||
|
|||
ui->output_sink_combo_box->clear(); |
|||
ui->output_sink_combo_box->addItem("auto"); |
|||
for (const auto& sink_detail : AudioCore::g_sink_details) { |
|||
ui->output_sink_combo_box->addItem(sink_detail.id); |
|||
} |
|||
|
|||
connect(ui->volume_slider, &QSlider::valueChanged, [this] { |
|||
ui->volume_indicator->setText(tr("%1 %").arg(ui->volume_slider->sliderPosition())); |
|||
}); |
|||
|
|||
this->setConfiguration(); |
|||
connect(ui->output_sink_combo_box, |
|||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, |
|||
&ConfigureAudio::updateAudioDevices); |
|||
|
|||
ui->output_sink_combo_box->setEnabled(!Core::System::GetInstance().IsPoweredOn()); |
|||
ui->audio_device_combo_box->setEnabled(!Core::System::GetInstance().IsPoweredOn()); |
|||
} |
|||
|
|||
ConfigureAudio::~ConfigureAudio() = default; |
|||
|
|||
void ConfigureAudio::setConfiguration() { |
|||
int new_sink_index = 0; |
|||
for (int index = 0; index < ui->output_sink_combo_box->count(); index++) { |
|||
if (ui->output_sink_combo_box->itemText(index).toStdString() == Settings::values.sink_id) { |
|||
new_sink_index = index; |
|||
break; |
|||
} |
|||
} |
|||
ui->output_sink_combo_box->setCurrentIndex(new_sink_index); |
|||
|
|||
// The device list cannot be pre-populated (nor listed) until the output sink is known.
|
|||
updateAudioDevices(new_sink_index); |
|||
|
|||
int new_device_index = -1; |
|||
for (int index = 0; index < ui->audio_device_combo_box->count(); index++) { |
|||
if (ui->audio_device_combo_box->itemText(index).toStdString() == |
|||
Settings::values.audio_device_id) { |
|||
new_device_index = index; |
|||
break; |
|||
} |
|||
} |
|||
ui->audio_device_combo_box->setCurrentIndex(new_device_index); |
|||
|
|||
ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum()); |
|||
ui->volume_indicator->setText(tr("%1 %").arg(ui->volume_slider->sliderPosition())); |
|||
} |
|||
|
|||
void ConfigureAudio::applyConfiguration() { |
|||
Settings::values.sink_id = |
|||
ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex()) |
|||
.toStdString(); |
|||
Settings::values.audio_device_id = |
|||
ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex()) |
|||
.toStdString(); |
|||
Settings::values.volume = |
|||
static_cast<float>(ui->volume_slider->sliderPosition()) / ui->volume_slider->maximum(); |
|||
} |
|||
|
|||
void ConfigureAudio::updateAudioDevices(int sink_index) { |
|||
ui->audio_device_combo_box->clear(); |
|||
ui->audio_device_combo_box->addItem(AudioCore::auto_device_name); |
|||
|
|||
std::string sink_id = ui->output_sink_combo_box->itemText(sink_index).toStdString(); |
|||
std::vector<std::string> device_list = AudioCore::GetSinkDetails(sink_id).list_devices(); |
|||
for (const auto& device : device_list) { |
|||
ui->audio_device_combo_box->addItem(device.c_str()); |
|||
} |
|||
} |
|||
|
|||
void ConfigureAudio::retranslateUi() { |
|||
ui->retranslateUi(this); |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
// Copyright 2018 yuzu Emulator Project |
|||
// Licensed under GPLv2 or any later version |
|||
// Refer to the license.txt file included. |
|||
|
|||
#pragma once |
|||
|
|||
#include <memory> |
|||
#include <QWidget> |
|||
|
|||
namespace Ui { |
|||
class ConfigureAudio; |
|||
} |
|||
|
|||
class ConfigureAudio : public QWidget { |
|||
Q_OBJECT |
|||
|
|||
public: |
|||
explicit ConfigureAudio(QWidget* parent = nullptr); |
|||
~ConfigureAudio(); |
|||
|
|||
void applyConfiguration(); |
|||
void retranslateUi(); |
|||
|
|||
public slots: |
|||
void updateAudioDevices(int sink_index); |
|||
|
|||
private: |
|||
void setConfiguration(); |
|||
|
|||
std::unique_ptr<Ui::ConfigureAudio> ui; |
|||
}; |
|||
@ -0,0 +1,130 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ui version="4.0"> |
|||
<class>ConfigureAudio</class> |
|||
<widget class="QWidget" name="ConfigureAudio"> |
|||
<property name="geometry"> |
|||
<rect> |
|||
<x>0</x> |
|||
<y>0</y> |
|||
<width>188</width> |
|||
<height>246</height> |
|||
</rect> |
|||
</property> |
|||
<layout class="QVBoxLayout"> |
|||
<item> |
|||
<widget class="QGroupBox" name="groupBox"> |
|||
<property name="title"> |
|||
<string>Audio</string> |
|||
</property> |
|||
<layout class="QVBoxLayout"> |
|||
<item> |
|||
<layout class="QHBoxLayout"> |
|||
<item> |
|||
<widget class="QLabel" name="label"> |
|||
<property name="text"> |
|||
<string>Output Engine:</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QComboBox" name="output_sink_combo_box"/> |
|||
</item> |
|||
</layout> |
|||
</item> |
|||
<item> |
|||
<layout class="QHBoxLayout"> |
|||
<item> |
|||
<widget class="QLabel" name="label"> |
|||
<property name="text"> |
|||
<string>Audio Device:</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QComboBox" name="audio_device_combo_box"/> |
|||
</item> |
|||
</layout> |
|||
</item> |
|||
<item> |
|||
<layout class="QHBoxLayout" name="horizontalLayout_2"> |
|||
<property name="topMargin"> |
|||
<number>0</number> |
|||
</property> |
|||
<item> |
|||
<widget class="QLabel" name="label"> |
|||
<property name="text"> |
|||
<string>Volume:</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<spacer name="horizontalSpacer"> |
|||
<property name="orientation"> |
|||
<enum>Qt::Horizontal</enum> |
|||
</property> |
|||
<property name="sizeHint" stdset="0"> |
|||
<size> |
|||
<width>40</width> |
|||
<height>20</height> |
|||
</size> |
|||
</property> |
|||
</spacer> |
|||
</item> |
|||
<item> |
|||
<widget class="QSlider" name="volume_slider"> |
|||
<property name="sizePolicy"> |
|||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> |
|||
<horstretch>0</horstretch> |
|||
<verstretch>0</verstretch> |
|||
</sizepolicy> |
|||
</property> |
|||
<property name="maximum"> |
|||
<number>100</number> |
|||
</property> |
|||
<property name="pageStep"> |
|||
<number>10</number> |
|||
</property> |
|||
<property name="orientation"> |
|||
<enum>Qt::Horizontal</enum> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<widget class="QLabel" name="volume_indicator"> |
|||
<property name="minimumSize"> |
|||
<size> |
|||
<width>32</width> |
|||
<height>0</height> |
|||
</size> |
|||
</property> |
|||
<property name="text"> |
|||
<string>0 %</string> |
|||
</property> |
|||
<property name="alignment"> |
|||
<set>Qt::AlignCenter</set> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
</layout> |
|||
</item> |
|||
</layout> |
|||
</widget> |
|||
</item> |
|||
<item> |
|||
<spacer> |
|||
<property name="orientation"> |
|||
<enum>Qt::Vertical</enum> |
|||
</property> |
|||
<property name="sizeHint" stdset="0"> |
|||
<size> |
|||
<width>167</width> |
|||
<height>55</height> |
|||
</size> |
|||
</property> |
|||
</spacer> |
|||
</item> |
|||
</layout> |
|||
</widget> |
|||
<resources/> |
|||
<connections/> |
|||
</ui> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue