diff options
author | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2022-07-17 00:48:45 +0200 |
---|---|---|
committer | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2022-07-22 02:11:32 +0200 |
commit | 458da8a94877677f086f06cdeecf959ec4283a33 (patch) | |
tree | 583166d77602ad90a0d552f37de8729ad80fd6c1 /src/audio_core/sink/sink.h | |
parent | Merge pull request #8598 from Link4565/recv-dontwait (diff) | |
download | yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.gz yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.bz2 yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.lz yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.xz yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.zst yuzu-458da8a94877677f086f06cdeecf959ec4283a33.zip |
Diffstat (limited to 'src/audio_core/sink/sink.h')
-rw-r--r-- | src/audio_core/sink/sink.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/src/audio_core/sink/sink.h b/src/audio_core/sink/sink.h new file mode 100644 index 000000000..91fe455e4 --- /dev/null +++ b/src/audio_core/sink/sink.h @@ -0,0 +1,106 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <memory> +#include <string> + +#include "audio_core/sink/sink_stream.h" +#include "common/common_types.h" + +namespace Common { +class Event; +} +namespace Core { +class System; +} + +namespace AudioCore::Sink { + +constexpr char auto_device_name[] = "auto"; + +/** + * This class is an interface for an audio sink, holds multiple output streams and is responsible + * for sinking samples to hardware. Used by Audio Render, Audio In and Audio Out. + */ +class Sink { +public: + virtual ~Sink() = default; + /** + * Close a given stream. + * + * @param stream - The stream to close. + */ + virtual void CloseStream(const SinkStream* stream) = 0; + + /** + * Close all streams. + */ + virtual void CloseStreams() = 0; + + /** + * Pause all streams. + */ + virtual void PauseStreams() = 0; + + /** + * Unpause all streams. + */ + virtual void UnpauseStreams() = 0; + + /** + * Create a new sink stream, kept within this sink, with a pointer returned for use. + * Do not free the returned pointer. When done with the stream, call CloseStream on the sink. + * + * @param system - Core system. + * @param system_channels - Number of channels the audio system expects. + * May differ from the device's channel count. + * @param name - Name of this stream. + * @param type - Type of this stream, render/in/out. + * @param event - Audio render only, a signal used to prevent the renderer running too + * fast. + * @return A pointer to the created SinkStream + */ + virtual SinkStream* AcquireSinkStream(Core::System& system, u32 system_channels, + const std::string& name, StreamType type) = 0; + + /** + * Get the number of channels the hardware device supports. + * Either 2 or 6. + * + * @return Number of device channels. + */ + u32 GetDeviceChannels() const { + return device_channels; + } + + /** + * Get the device volume. Set from calls to the IAudioDevice service. + * + * @return Volume of the device. + */ + virtual f32 GetDeviceVolume() const = 0; + + /** + * Set the device volume. Set from calls to the IAudioDevice service. + * + * @param volume - New volume of the device. + */ + virtual void SetDeviceVolume(f32 volume) = 0; + + /** + * Set the system volume. Comes from the audio system using this stream. + * + * @param volume - New volume of the system. + */ + virtual void SetSystemVolume(f32 volume) = 0; + +protected: + /// Number of device channels supported by the hardware + u32 device_channels{2}; +}; + +using SinkPtr = std::unique_ptr<Sink>; + +} // namespace AudioCore::Sink |