yuzu/src/audio_core/sink/null_sink.h

58 lines
1.5 KiB
C++
Raw Normal View History

2022-07-17 00:48:45 +02:00
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <string>
#include <string_view>
#include <vector>
2022-07-17 00:48:45 +02:00
#include "audio_core/sink/sink.h"
#include "audio_core/sink/sink_stream.h"
namespace Core {
class System;
} // namespace Core
2022-07-17 00:48:45 +02:00
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::span<s16>) override {}
std::vector<s16> ReleaseBuffer(u64) override {
return {};
}
};
2022-07-17 00:48:45 +02:00
/**
* A no-op sink for when no audio out is wanted.
*/
class NullSink final : public Sink {
public:
explicit NullSink(std::string_view) {}
~NullSink() override = default;
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();
2022-07-17 00:48:45 +02:00
}
void CloseStream(SinkStream*) override {}
2022-07-17 00:48:45 +02:00
void CloseStreams() override {}
f32 GetDeviceVolume() const override {
return 1.0f;
}
void SetDeviceVolume(f32 volume) override {}
void SetSystemVolume(f32 volume) override {}
private:
SinkStreamPtr null_sink{};
2022-07-17 00:48:45 +02:00
};
} // namespace AudioCore::Sink