summaryrefslogtreecommitdiffstats
path: root/src/audio_core
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-08-02 20:25:52 +0200
committerGitHub <noreply@github.com>2023-08-02 20:25:52 +0200
commitfca7d975fdbeb1c63677b80efc03920affee4b12 (patch)
treebbded6cf80886c6def87bae92cf6784340165de9 /src/audio_core
parentMerge pull request #11204 from liamwhite/eds3-blend-amd (diff)
parentconfig(qt): Fix name of network category (diff)
downloadyuzu-fca7d975fdbeb1c63677b80efc03920affee4b12.tar
yuzu-fca7d975fdbeb1c63677b80efc03920affee4b12.tar.gz
yuzu-fca7d975fdbeb1c63677b80efc03920affee4b12.tar.bz2
yuzu-fca7d975fdbeb1c63677b80efc03920affee4b12.tar.lz
yuzu-fca7d975fdbeb1c63677b80efc03920affee4b12.tar.xz
yuzu-fca7d975fdbeb1c63677b80efc03920affee4b12.tar.zst
yuzu-fca7d975fdbeb1c63677b80efc03920affee4b12.zip
Diffstat (limited to '')
-rw-r--r--src/audio_core/sink/sink_details.cpp34
-rw-r--r--src/audio_core/sink/sink_details.h8
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..027bfa517 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,47 @@ 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::CanonicalizeEnum(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::CanonicalizeEnum(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 +104,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..c8498842b 100644
--- a/src/audio_core/sink/sink_details.h
+++ b/src/audio_core/sink/sink_details.h
@@ -3,9 +3,11 @@
#pragma once
+#include <memory>
#include <string>
#include <string_view>
#include <vector>
+#include "common/settings_enums.h"
namespace AudioCore {
class AudioManager;
@@ -19,7 +21,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 +30,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 +39,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