#pragma once #include #include #include "WallpaperEngine/Application/ApplicationContext.h" #include "WallpaperEngine/Audio/Drivers/Recorders/PulseAudioPlaybackRecorder.h" namespace WallpaperEngine { namespace Application { class ApplicationContext; } namespace Audio { namespace Drivers { class AudioDriver; namespace Recorders { class PulseAudioPlaybackRecorder; } } // namespace Drivers class AudioStream; class AudioContext { public: explicit AudioContext (Drivers::AudioDriver& driver); /** * Registers the given stream in the driver for playing * * @param stream */ int addStream (AudioStream* stream, int volume = -1, float left = 1.0f, float right = 1.0f) const; /** * @param streamId The stream to stop playing */ void removeStream (int streamId) const; /** * Overrides the volume used to mix a single stream, instead of the driver's global volume * * @param streamId The stream to change * @param volume 0-128, or a negative value to go back to using the global volume */ void setStreamVolume (int streamId, int volume) const; /** * Scales the left and right channel of a stream on top of its volume */ void setStreamGains (int streamId, float left, float right) const; /** * Pauses or resumes a stream where it is */ void setStreamPaused (int streamId, bool paused) const; /** * TODO: MAYBE THIS SHOULD BE OUR OWN DEFINITIONS INSTEAD OF LIBRARY SPECIFIC ONES? * * @return The audio format the driver supports */ [[nodiscard]] AVSampleFormat getFormat () const; /** * @return The sample rate the driver supports */ [[nodiscard]] int getSampleRate () const; /** * @return The channels the driver supports */ [[nodiscard]] int getChannels () const; /** * @return The application context under which the audio driver is initialized */ Application::ApplicationContext& getApplicationContext () const; /** * @return The audio recorder to use to capture stereo mix data */ [[nodiscard]] Drivers::Recorders::PlaybackRecorder& getRecorder () const; /** * @return The audio driver used to playback and record audio */ [[nodiscard]] Drivers::AudioDriver& getDriver () const; private: /** The audio driver in use */ Drivers::AudioDriver& m_driver; }; } // namespace Audio } // namespace WallpaperEngine