From eefbd8f6a68963e10a4a77a53ea80f2cb4a7e980 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 12 Dec 2020 11:50:37 +1000 Subject: [PATCH] CubebAudioStream: Use cubeb's volume control --- src/frontend-common/cubeb_audio_stream.cpp | 8 +++++++- src/frontend-common/cubeb_audio_stream.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/frontend-common/cubeb_audio_stream.cpp b/src/frontend-common/cubeb_audio_stream.cpp index 19eaef062..d0e61748f 100644 --- a/src/frontend-common/cubeb_audio_stream.cpp +++ b/src/frontend-common/cubeb_audio_stream.cpp @@ -126,7 +126,7 @@ long CubebAudioStream::DataCallback(cubeb_stream* stm, void* user_ptr, const voi long nframes) { CubebAudioStream* const this_ptr = static_cast(user_ptr); - this_ptr->ReadFrames(reinterpret_cast(output_buffer), static_cast(nframes), true); + this_ptr->ReadFrames(reinterpret_cast(output_buffer), static_cast(nframes), false); return nframes; } @@ -139,6 +139,12 @@ void CubebAudioStream::StateCallback(cubeb_stream* stream, void* user_ptr, cubeb void CubebAudioStream::FramesAvailable() {} +void CubebAudioStream::SetOutputVolume(u32 volume) +{ + AudioStream::SetOutputVolume(volume); + cubeb_stream_set_volume(m_cubeb_stream, static_cast(m_output_volume) / 100.0f); +} + void CubebAudioStream::DestroyContext() { cubeb_destroy(m_cubeb_context); diff --git a/src/frontend-common/cubeb_audio_stream.h b/src/frontend-common/cubeb_audio_stream.h index a58f1431c..830e044a7 100644 --- a/src/frontend-common/cubeb_audio_stream.h +++ b/src/frontend-common/cubeb_audio_stream.h @@ -18,6 +18,7 @@ protected: void PauseDevice(bool paused) override; void CloseDevice() override; void FramesAvailable() override; + void SetOutputVolume(u32 volume) override; void DestroyContext();