summaryrefslogtreecommitdiff
path: root/src/audio_core/sink_details.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core/sink_details.cpp')
-rw-r--r--src/audio_core/sink_details.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/audio_core/sink_details.cpp b/src/audio_core/sink_details.cpp
index 95ccc9e9d..6972395af 100644
--- a/src/audio_core/sink_details.cpp
+++ b/src/audio_core/sink_details.cpp
@@ -2,6 +2,7 @@
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 <algorithm>
5#include <memory> 6#include <memory>
6#include <vector> 7#include <vector>
7#include "audio_core/null_sink.h" 8#include "audio_core/null_sink.h"
@@ -9,6 +10,7 @@
9#ifdef HAVE_SDL2 10#ifdef HAVE_SDL2
10#include "audio_core/sdl2_sink.h" 11#include "audio_core/sdl2_sink.h"
11#endif 12#endif
13#include "common/logging/log.h"
12 14
13namespace AudioCore { 15namespace AudioCore {
14 16
@@ -20,4 +22,21 @@ const std::vector<SinkDetails> g_sink_details = {
20 {"null", []() { return std::make_unique<NullSink>(); }}, 22 {"null", []() { return std::make_unique<NullSink>(); }},
21}; 23};
22 24
25const SinkDetails& GetSinkDetails(std::string sink_id) {
26 auto iter =
27 std::find_if(g_sink_details.begin(), g_sink_details.end(),
28 [sink_id](const auto& sink_detail) { return sink_detail.id == sink_id; });
29
30 if (sink_id == "auto" || iter == g_sink_details.end()) {
31 if (sink_id != "auto") {
32 LOG_ERROR(Audio, "AudioCore::SelectSink given invalid sink_id %s", sink_id.c_str());
33 }
34 // Auto-select.
35 // g_sink_details is ordered in terms of desirability, with the best choice at the front.
36 iter = g_sink_details.begin();
37 }
38
39 return *iter;
40}
41
23} // namespace AudioCore 42} // namespace AudioCore