diff options
| author | 2018-07-28 13:40:50 -0400 | |
|---|---|---|
| committer | 2018-07-30 21:45:24 -0400 | |
| commit | 9ef227e09d6e374008d9536935d01c11a6ca06bd (patch) | |
| tree | 55a0169ab36ff521770a94a59b857063caf65f8b /src/audio_core/sink_details.cpp | |
| parent | audio_core: Misc. improvements to stream/buffer/audio_out. (diff) | |
| download | yuzu-9ef227e09d6e374008d9536935d01c11a6ca06bd.tar.gz yuzu-9ef227e09d6e374008d9536935d01c11a6ca06bd.tar.xz yuzu-9ef227e09d6e374008d9536935d01c11a6ca06bd.zip | |
audio_core: Add interfaces for Sink and SinkStream.
Diffstat (limited to 'src/audio_core/sink_details.cpp')
| -rw-r--r-- | src/audio_core/sink_details.cpp | 38 |
1 files changed, 38 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..6396d8065 --- /dev/null +++ b/src/audio_core/sink_details.cpp | |||
| @@ -0,0 +1,38 @@ | |||
| 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 | #include "common/logging/log.h" | ||
| 12 | |||
| 13 | namespace AudioCore { | ||
| 14 | |||
| 15 | // g_sink_details is ordered in terms of desirability, with the best choice at the top. | ||
| 16 | const std::vector<SinkDetails> g_sink_details = { | ||
| 17 | SinkDetails{"null", &std::make_unique<NullSink, std::string>, | ||
| 18 | [] { return std::vector<std::string>{"null"}; }}, | ||
| 19 | }; | ||
| 20 | |||
| 21 | const SinkDetails& GetSinkDetails(std::string sink_id) { | ||
| 22 | auto iter = | ||
| 23 | std::find_if(g_sink_details.begin(), g_sink_details.end(), | ||
| 24 | [sink_id](const auto& sink_detail) { return sink_detail.id == sink_id; }); | ||
| 25 | |||
| 26 | if (sink_id == "auto" || iter == g_sink_details.end()) { | ||
| 27 | if (sink_id != "auto") { | ||
| 28 | LOG_ERROR(Audio, "AudioCore::SelectSink given invalid sink_id {}", sink_id); | ||
| 29 | } | ||
| 30 | // Auto-select. | ||
| 31 | // g_sink_details is ordered in terms of desirability, with the best choice at the front. | ||
| 32 | iter = g_sink_details.begin(); | ||
| 33 | } | ||
| 34 | |||
| 35 | return *iter; | ||
| 36 | } | ||
| 37 | |||
| 38 | } // namespace AudioCore | ||