diff options
| author | 2018-07-30 20:29:17 -0700 | |
|---|---|---|
| committer | 2018-07-30 20:29:17 -0700 | |
| commit | bf9c62bc76a2296c1a81cfc1b83aaf4028578901 (patch) | |
| tree | dad8906c597af3f579d4f72f4c9f493503c40665 /src/audio_core/sink_details.cpp | |
| parent | Port #3758 from Citra (#852): Add missing std::string import in text_formatter (diff) | |
| parent | audio_core: Implement Sink and SinkStream interfaces with cubeb. (diff) | |
| download | yuzu-bf9c62bc76a2296c1a81cfc1b83aaf4028578901.tar.gz yuzu-bf9c62bc76a2296c1a81cfc1b83aaf4028578901.tar.xz yuzu-bf9c62bc76a2296c1a81cfc1b83aaf4028578901.zip | |
Merge pull request #855 from bunnei/cubeb
Audio output backend based on cubeb
Diffstat (limited to 'src/audio_core/sink_details.cpp')
| -rw-r--r-- | src/audio_core/sink_details.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/audio_core/sink_details.cpp b/src/audio_core/sink_details.cpp new file mode 100644 index 000000000..955ba20fb --- /dev/null +++ b/src/audio_core/sink_details.cpp | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | // Copyright 2018 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | #include <memory> | ||
| 7 | #include <string> | ||
| 8 | #include <vector> | ||
| 9 | #include "audio_core/null_sink.h" | ||
| 10 | #include "audio_core/sink_details.h" | ||
| 11 | #ifdef HAVE_CUBEB | ||
| 12 | #include "audio_core/cubeb_sink.h" | ||
| 13 | #endif | ||
| 14 | #include "common/logging/log.h" | ||
| 15 | |||
| 16 | namespace AudioCore { | ||
| 17 | |||
| 18 | // g_sink_details is ordered in terms of desirability, with the best choice at the top. | ||
| 19 | const std::vector<SinkDetails> g_sink_details = { | ||
| 20 | #ifdef HAVE_CUBEB | ||
| 21 | SinkDetails{"cubeb", &std::make_unique<CubebSink, std::string>, &ListCubebSinkDevices}, | ||
| 22 | #endif | ||
| 23 | SinkDetails{"null", &std::make_unique<NullSink, std::string>, | ||
| 24 | [] { return std::vector<std::string>{"null"}; }}, | ||
| 25 | }; | ||
| 26 | |||
| 27 | const SinkDetails& GetSinkDetails(std::string sink_id) { | ||
| 28 | auto iter = | ||
| 29 | std::find_if(g_sink_details.begin(), g_sink_details.end(), | ||
| 30 | [sink_id](const auto& sink_detail) { return sink_detail.id == sink_id; }); | ||
| 31 | |||
| 32 | if (sink_id == "auto" || iter == g_sink_details.end()) { | ||
| 33 | if (sink_id != "auto") { | ||
| 34 | LOG_ERROR(Audio, "AudioCore::SelectSink given invalid sink_id {}", sink_id); | ||
| 35 | } | ||
| 36 | // Auto-select. | ||
| 37 | // g_sink_details is ordered in terms of desirability, with the best choice at the front. | ||
| 38 | iter = g_sink_details.begin(); | ||
| 39 | } | ||
| 40 | |||
| 41 | return *iter; | ||
| 42 | } | ||
| 43 | |||
| 44 | } // namespace AudioCore | ||