summaryrefslogtreecommitdiffstats
path: root/src/audio_core/sink/null_sink.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core/sink/null_sink.h')
-rw-r--r--src/audio_core/sink/null_sink.h49
1 files changed, 27 insertions, 22 deletions
diff --git a/src/audio_core/sink/null_sink.h b/src/audio_core/sink/null_sink.h
index 47a342171..1215d3cd2 100644
--- a/src/audio_core/sink/null_sink.h
+++ b/src/audio_core/sink/null_sink.h
@@ -3,10 +3,29 @@
#pragma once
+#include <string>
+#include <string_view>
+#include <vector>
+
#include "audio_core/sink/sink.h"
#include "audio_core/sink/sink_stream.h"
+namespace Core {
+class System;
+} // namespace Core
+
namespace AudioCore::Sink {
+class NullSinkStreamImpl final : public SinkStream {
+public:
+ explicit NullSinkStreamImpl(Core::System& system_, StreamType type_)
+ : SinkStream{system_, type_} {}
+ ~NullSinkStreamImpl() override {}
+ void AppendBuffer(SinkBuffer&, std::vector<s16>&) override {}
+ std::vector<s16> ReleaseBuffer(u64) override {
+ return {};
+ }
+};
+
/**
* A no-op sink for when no audio out is wanted.
*/
@@ -15,17 +34,16 @@ public:
explicit NullSink(std::string_view) {}
~NullSink() override = default;
- SinkStream* AcquireSinkStream([[maybe_unused]] Core::System& system,
- [[maybe_unused]] u32 system_channels,
- [[maybe_unused]] const std::string& name,
- [[maybe_unused]] StreamType type) override {
- return &null_sink_stream;
+ SinkStream* AcquireSinkStream(Core::System& system, u32, const std::string&,
+ StreamType type) override {
+ if (null_sink == nullptr) {
+ null_sink = std::make_unique<NullSinkStreamImpl>(system, type);
+ }
+ return null_sink.get();
}
- void CloseStream([[maybe_unused]] const SinkStream* stream) override {}
+ void CloseStream(SinkStream*) override {}
void CloseStreams() override {}
- void PauseStreams() override {}
- void UnpauseStreams() override {}
f32 GetDeviceVolume() const override {
return 1.0f;
}
@@ -33,20 +51,7 @@ public:
void SetSystemVolume(f32 volume) override {}
private:
- struct NullSinkStreamImpl final : SinkStream {
- void Finalize() override {}
- void Start(bool resume = false) override {}
- void Stop() override {}
- void AppendBuffer([[maybe_unused]] ::AudioCore::Sink::SinkBuffer& buffer,
- [[maybe_unused]] std::vector<s16>& samples) override {}
- std::vector<s16> ReleaseBuffer([[maybe_unused]] u64 num_samples) override {
- return {};
- }
- bool IsBufferConsumed([[maybe_unused]] const u64 tag) {
- return true;
- }
- void ClearQueue() override {}
- } null_sink_stream;
+ SinkStreamPtr null_sink{};
};
} // namespace AudioCore::Sink