diff options
| author | 2017-01-26 04:33:26 +0100 | |
|---|---|---|
| committer | 2017-01-25 22:33:26 -0500 | |
| commit | f8523699864b6000572affaa0e36d9a4d89ffce6 (patch) | |
| tree | 952a96e11d4efe860272ea7a47ebbee896fb5d61 /src/citra_qt/configure_audio.cpp | |
| parent | Merge pull request #2434 from mailwl/nfc-amiibo (diff) | |
| download | yuzu-f8523699864b6000572affaa0e36d9a4d89ffce6.tar.gz yuzu-f8523699864b6000572affaa0e36d9a4d89ffce6.tar.xz yuzu-f8523699864b6000572affaa0e36d9a4d89ffce6.zip | |
SDL: Select audio device (#2403)
* Initial Commit
Added Device logic to Sinks
Started on UI for selecting devices
Removed redundant import
* Audio Core: Complete Device Switching
Complete the device switching implementation by allowing the output
device to be loaded, changed and saved through the configurations menu.
Worked with the Sink abstraction and tuned the "Device Selection"
configuration so that the Device List is automatically populated when
the Sink is changed.
This hopefully addresses the concerns and recommendations mentioned in
the comments of the PR.
* Clean original implementation.
* Refactor GetSinkDetails
Diffstat (limited to 'src/citra_qt/configure_audio.cpp')
| -rw-r--r-- | src/citra_qt/configure_audio.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/citra_qt/configure_audio.cpp b/src/citra_qt/configure_audio.cpp index 3cdd4c780..3ddcf9232 100644 --- a/src/citra_qt/configure_audio.cpp +++ b/src/citra_qt/configure_audio.cpp | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <memory> | ||
| 6 | #include "audio_core/audio_core.h" | ||
| 7 | #include "audio_core/sink.h" | ||
| 5 | #include "audio_core/sink_details.h" | 8 | #include "audio_core/sink_details.h" |
| 6 | #include "citra_qt/configure_audio.h" | 9 | #include "citra_qt/configure_audio.h" |
| 7 | #include "core/settings.h" | 10 | #include "core/settings.h" |
| @@ -18,6 +21,8 @@ ConfigureAudio::ConfigureAudio(QWidget* parent) | |||
| 18 | } | 21 | } |
| 19 | 22 | ||
| 20 | this->setConfiguration(); | 23 | this->setConfiguration(); |
| 24 | connect(ui->output_sink_combo_box, SIGNAL(currentIndexChanged(int)), this, | ||
| 25 | SLOT(updateAudioDevices(int))); | ||
| 21 | } | 26 | } |
| 22 | 27 | ||
| 23 | ConfigureAudio::~ConfigureAudio() {} | 28 | ConfigureAudio::~ConfigureAudio() {} |
| @@ -33,6 +38,19 @@ void ConfigureAudio::setConfiguration() { | |||
| 33 | ui->output_sink_combo_box->setCurrentIndex(new_sink_index); | 38 | ui->output_sink_combo_box->setCurrentIndex(new_sink_index); |
| 34 | 39 | ||
| 35 | ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching); | 40 | ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching); |
| 41 | |||
| 42 | // The device list cannot be pre-populated (nor listed) until the output sink is known. | ||
| 43 | updateAudioDevices(new_sink_index); | ||
| 44 | |||
| 45 | int new_device_index = -1; | ||
| 46 | for (int index = 0; index < ui->audio_device_combo_box->count(); index++) { | ||
| 47 | if (ui->audio_device_combo_box->itemText(index).toStdString() == | ||
| 48 | Settings::values.audio_device_id) { | ||
| 49 | new_device_index = index; | ||
| 50 | break; | ||
| 51 | } | ||
| 52 | } | ||
| 53 | ui->audio_device_combo_box->setCurrentIndex(new_device_index); | ||
| 36 | } | 54 | } |
| 37 | 55 | ||
| 38 | void ConfigureAudio::applyConfiguration() { | 56 | void ConfigureAudio::applyConfiguration() { |
| @@ -40,5 +58,20 @@ void ConfigureAudio::applyConfiguration() { | |||
| 40 | ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex()) | 58 | ui->output_sink_combo_box->itemText(ui->output_sink_combo_box->currentIndex()) |
| 41 | .toStdString(); | 59 | .toStdString(); |
| 42 | Settings::values.enable_audio_stretching = ui->toggle_audio_stretching->isChecked(); | 60 | Settings::values.enable_audio_stretching = ui->toggle_audio_stretching->isChecked(); |
| 61 | Settings::values.audio_device_id = | ||
| 62 | ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex()) | ||
| 63 | .toStdString(); | ||
| 43 | Settings::Apply(); | 64 | Settings::Apply(); |
| 44 | } | 65 | } |
| 66 | |||
| 67 | void ConfigureAudio::updateAudioDevices(int sink_index) { | ||
| 68 | ui->audio_device_combo_box->clear(); | ||
| 69 | ui->audio_device_combo_box->addItem("auto"); | ||
| 70 | |||
| 71 | std::string sink_id = ui->output_sink_combo_box->itemText(sink_index).toStdString(); | ||
| 72 | std::vector<std::string> device_list = | ||
| 73 | AudioCore::GetSinkDetails(sink_id).factory()->GetDeviceList(); | ||
| 74 | for (const auto& device : device_list) { | ||
| 75 | ui->audio_device_combo_box->addItem(device.c_str()); | ||
| 76 | } | ||
| 77 | } | ||