summaryrefslogblamecommitdiffstats
path: root/src/audio_core/sink/null_sink.h
blob: eab9c3a0cb7a58e4e1b2f08b9d51f2b60bd95b99 (plain) (tree)
1
2
3
4
5
6
7
8
9




                                                               



                      


                                        



                   
                           










                                                                        







                                                





                                                                                

     
                                             









                                                
                              


                              
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#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.
 */
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();
    }

    void CloseStream(SinkStream*) override {}
    void CloseStreams() override {}
    void PauseStreams() override {}
    void UnpauseStreams() override {}
    f32 GetDeviceVolume() const override {
        return 1.0f;
    }
    void SetDeviceVolume(f32 volume) override {}
    void SetSystemVolume(f32 volume) override {}

private:
    SinkStreamPtr null_sink{};
};

} // namespace AudioCore::Sink