From 458da8a94877677f086f06cdeecf959ec4283a33 Mon Sep 17 00:00:00 2001 From: Kelebek1 Date: Sat, 16 Jul 2022 23:48:45 +0100 Subject: Project Andio --- src/audio_core/sink_details.cpp | 90 ----------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 src/audio_core/sink_details.cpp (limited to 'src/audio_core/sink_details.cpp') diff --git a/src/audio_core/sink_details.cpp b/src/audio_core/sink_details.cpp deleted file mode 100644 index c4cc66111..000000000 --- a/src/audio_core/sink_details.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include -#include -#include -#include -#include "audio_core/null_sink.h" -#include "audio_core/sink_details.h" -#ifdef HAVE_CUBEB -#include "audio_core/cubeb_sink.h" -#endif -#ifdef HAVE_SDL2 -#include "audio_core/sdl2_sink.h" -#endif -#include "common/logging/log.h" - -namespace AudioCore { -namespace { -struct SinkDetails { - using FactoryFn = std::unique_ptr (*)(std::string_view); - using ListDevicesFn = std::vector (*)(); - - /// Name for this sink. - const char* id; - /// A method to call to construct an instance of this type of sink. - FactoryFn factory; - /// A method to call to list available devices. - ListDevicesFn list_devices; -}; - -// sink_details is ordered in terms of desirability, with the best choice at the top. -constexpr SinkDetails sink_details[] = { -#ifdef HAVE_CUBEB - SinkDetails{"cubeb", - [](std::string_view device_id) -> std::unique_ptr { - return std::make_unique(device_id); - }, - &ListCubebSinkDevices}, -#endif -#ifdef HAVE_SDL2 - SinkDetails{"sdl2", - [](std::string_view device_id) -> std::unique_ptr { - return std::make_unique(device_id); - }, - &ListSDLSinkDevices}, -#endif - SinkDetails{"null", - [](std::string_view device_id) -> std::unique_ptr { - return std::make_unique(device_id); - }, - [] { return std::vector{"null"}; }}, -}; - -const SinkDetails& GetSinkDetails(std::string_view sink_id) { - auto iter = - std::find_if(std::begin(sink_details), std::end(sink_details), - [sink_id](const auto& sink_detail) { return sink_detail.id == sink_id; }); - - if (sink_id == "auto" || iter == std::end(sink_details)) { - if (sink_id != "auto") { - LOG_ERROR(Audio, "AudioCore::SelectSink given invalid sink_id {}", sink_id); - } - // Auto-select. - // sink_details is ordered in terms of desirability, with the best choice at the front. - iter = std::begin(sink_details); - } - - return *iter; -} -} // Anonymous namespace - -std::vector GetSinkIDs() { - std::vector sink_ids(std::size(sink_details)); - - std::transform(std::begin(sink_details), std::end(sink_details), std::begin(sink_ids), - [](const auto& sink) { return sink.id; }); - - return sink_ids; -} - -std::vector GetDeviceListForSink(std::string_view sink_id) { - return GetSinkDetails(sink_id).list_devices(); -} - -std::unique_ptr CreateSinkFromID(std::string_view sink_id, std::string_view device_id) { - return GetSinkDetails(sink_id).factory(device_id); -} - -} // namespace AudioCore -- cgit v1.2.3