CubebAudioStream: Use cubeb's volume control

This commit is contained in:
Connor McLaughlin 2020-12-12 11:50:37 +10:00
parent 907e0de35a
commit eefbd8f6a6
2 changed files with 8 additions and 1 deletions

View file

@ -126,7 +126,7 @@ long CubebAudioStream::DataCallback(cubeb_stream* stm, void* user_ptr, const voi
long nframes) long nframes)
{ {
CubebAudioStream* const this_ptr = static_cast<CubebAudioStream*>(user_ptr); CubebAudioStream* const this_ptr = static_cast<CubebAudioStream*>(user_ptr);
this_ptr->ReadFrames(reinterpret_cast<SampleType*>(output_buffer), static_cast<u32>(nframes), true); this_ptr->ReadFrames(reinterpret_cast<SampleType*>(output_buffer), static_cast<u32>(nframes), false);
return nframes; return nframes;
} }
@ -139,6 +139,12 @@ void CubebAudioStream::StateCallback(cubeb_stream* stream, void* user_ptr, cubeb
void CubebAudioStream::FramesAvailable() {} void CubebAudioStream::FramesAvailable() {}
void CubebAudioStream::SetOutputVolume(u32 volume)
{
AudioStream::SetOutputVolume(volume);
cubeb_stream_set_volume(m_cubeb_stream, static_cast<float>(m_output_volume) / 100.0f);
}
void CubebAudioStream::DestroyContext() void CubebAudioStream::DestroyContext()
{ {
cubeb_destroy(m_cubeb_context); cubeb_destroy(m_cubeb_context);

View file

@ -18,6 +18,7 @@ protected:
void PauseDevice(bool paused) override; void PauseDevice(bool paused) override;
void CloseDevice() override; void CloseDevice() override;
void FramesAvailable() override; void FramesAvailable() override;
void SetOutputVolume(u32 volume) override;
void DestroyContext(); void DestroyContext();