summaryrefslogtreecommitdiffstats
path: root/src/audio_core/sink
diff options
context:
space:
mode:
authorlat9nq <22451773+lat9nq@users.noreply.github.com>2023-05-18 23:54:22 +0200
committerlat9nq <22451773+lat9nq@users.noreply.github.com>2023-07-21 16:56:07 +0200
commit432f68ad29df7a368ba375d75d667c954e9c80b9 (patch)
treec09b7f5ae90f30e074ff6823a6e361329b71af2e /src/audio_core/sink
parentsettings: Split enums to new file (diff)
downloadyuzu-432f68ad29df7a368ba375d75d667c954e9c80b9.tar
yuzu-432f68ad29df7a368ba375d75d667c954e9c80b9.tar.gz
yuzu-432f68ad29df7a368ba375d75d667c954e9c80b9.tar.bz2
yuzu-432f68ad29df7a368ba375d75d667c954e9c80b9.tar.lz
yuzu-432f68ad29df7a368ba375d75d667c954e9c80b9.tar.xz
yuzu-432f68ad29df7a368ba375d75d667c954e9c80b9.tar.zst
yuzu-432f68ad29df7a368ba375d75d667c954e9c80b9.zip
Diffstat (limited to 'src/audio_core/sink')
-rw-r--r--src/audio_core/sink/sink_details.cpp33
-rw-r--r--src/audio_core/sink/sink_details.h9
2 files changed, 23 insertions, 19 deletions
diff --git a/src/audio_core/sink/sink_details.cpp b/src/audio_core/sink/sink_details.cpp
index 39ea6d91b..751e97bfc 100644
--- a/src/audio_core/sink/sink_details.cpp
+++ b/src/audio_core/sink/sink_details.cpp
@@ -15,6 +15,7 @@
#endif
#include "audio_core/sink/null_sink.h"
#include "common/logging/log.h"
+#include "common/settings_enums.h"
namespace AudioCore::Sink {
namespace {
@@ -24,7 +25,7 @@ struct SinkDetails {
using LatencyFn = u32 (*)();
/// Name for this sink.
- std::string_view id;
+ Settings::AudioEngine id;
/// A method to call to construct an instance of this type of sink.
FactoryFn factory;
/// A method to call to list available devices.
@@ -37,7 +38,7 @@ struct SinkDetails {
constexpr SinkDetails sink_details[] = {
#ifdef HAVE_CUBEB
SinkDetails{
- "cubeb",
+ Settings::AudioEngine::Cubeb,
[](std::string_view device_id) -> std::unique_ptr<Sink> {
return std::make_unique<CubebSink>(device_id);
},
@@ -47,7 +48,7 @@ constexpr SinkDetails sink_details[] = {
#endif
#ifdef HAVE_SDL2
SinkDetails{
- "sdl2",
+ Settings::AudioEngine::Sdl2,
[](std::string_view device_id) -> std::unique_ptr<Sink> {
return std::make_unique<SDLSink>(device_id);
},
@@ -55,46 +56,46 @@ constexpr SinkDetails sink_details[] = {
&GetSDLLatency,
},
#endif
- SinkDetails{"null",
+ SinkDetails{Settings::AudioEngine::Null,
[](std::string_view device_id) -> std::unique_ptr<Sink> {
return std::make_unique<NullSink>(device_id);
},
[](bool capture) { return std::vector<std::string>{"null"}; }, []() { return 0u; }},
};
-const SinkDetails& GetOutputSinkDetails(std::string_view sink_id) {
- const auto find_backend{[](std::string_view id) {
+const SinkDetails& GetOutputSinkDetails(Settings::AudioEngine sink_id) {
+ const auto find_backend{[](Settings::AudioEngine id) {
return std::find_if(std::begin(sink_details), std::end(sink_details),
[&id](const auto& sink_detail) { return sink_detail.id == id; });
}};
auto iter = find_backend(sink_id);
- if (sink_id == "auto") {
+ if (sink_id == Settings::AudioEngine::Auto) {
// Auto-select a backend. Prefer CubeB, but it may report a large minimum latency which
// causes audio issues, in that case go with SDL.
#if defined(HAVE_CUBEB) && defined(HAVE_SDL2)
- iter = find_backend("cubeb");
+ iter = find_backend(Settings::AudioEngine::Cubeb);
if (iter->latency() > TargetSampleCount * 3) {
- iter = find_backend("sdl2");
+ iter = find_backend(Settings::AudioEngine::Sdl2);
}
#else
iter = std::begin(sink_details);
#endif
- LOG_INFO(Service_Audio, "Auto-selecting the {} backend", iter->id);
+ LOG_INFO(Service_Audio, "Auto-selecting the {} backend", Settings::TranslateEnum(iter->id));
}
if (iter == std::end(sink_details)) {
- LOG_ERROR(Audio, "Invalid sink_id {}", sink_id);
- iter = find_backend("null");
+ LOG_ERROR(Audio, "Invalid sink_id {}", Settings::TranslateEnum(sink_id));
+ iter = find_backend(Settings::AudioEngine::Null);
}
return *iter;
}
} // Anonymous namespace
-std::vector<std::string_view> GetSinkIDs() {
- std::vector<std::string_view> sink_ids(std::size(sink_details));
+std::vector<Settings::AudioEngine> GetSinkIDs() {
+ std::vector<Settings::AudioEngine> 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; });
@@ -102,11 +103,11 @@ std::vector<std::string_view> GetSinkIDs() {
return sink_ids;
}
-std::vector<std::string> GetDeviceListForSink(std::string_view sink_id, bool capture) {
+std::vector<std::string> GetDeviceListForSink(Settings::AudioEngine sink_id, bool capture) {
return GetOutputSinkDetails(sink_id).list_devices(capture);
}
-std::unique_ptr<Sink> CreateSinkFromID(std::string_view sink_id, std::string_view device_id) {
+std::unique_ptr<Sink> CreateSinkFromID(Settings::AudioEngine sink_id, std::string_view device_id) {
return GetOutputSinkDetails(sink_id).factory(device_id);
}
diff --git a/src/audio_core/sink/sink_details.h b/src/audio_core/sink/sink_details.h
index e75932898..44403db71 100644
--- a/src/audio_core/sink/sink_details.h
+++ b/src/audio_core/sink/sink_details.h
@@ -7,6 +7,9 @@
#include <string_view>
#include <vector>
+namespace Settings {
+enum class AudioEngine : u32;
+}
namespace AudioCore {
class AudioManager;
@@ -19,7 +22,7 @@ class Sink;
*
* @return Vector of available sink names.
*/
-std::vector<std::string_view> GetSinkIDs();
+std::vector<Settings::AudioEngine> GetSinkIDs();
/**
* Gets the list of devices for a particular sink identified by the given ID.
@@ -28,7 +31,7 @@ std::vector<std::string_view> GetSinkIDs();
* @param capture - Get capture (input) devices, or output devices?
* @return Vector of device names.
*/
-std::vector<std::string> GetDeviceListForSink(std::string_view sink_id, bool capture);
+std::vector<std::string> GetDeviceListForSink(Settings::AudioEngine sink_id, bool capture);
/**
* Creates an audio sink identified by the given device ID.
@@ -37,7 +40,7 @@ std::vector<std::string> GetDeviceListForSink(std::string_view sink_id, bool cap
* @param device_id - Name of the device to create.
* @return Pointer to the created sink.
*/
-std::unique_ptr<Sink> CreateSinkFromID(std::string_view sink_id, std::string_view device_id);
+std::unique_ptr<Sink> CreateSinkFromID(Settings::AudioEngine sink_id, std::string_view device_id);
} // namespace Sink
} // namespace AudioCore