mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 14:25:37 +00:00
CubebAudioStream: Fix crash in PulseAudio on Linux
This commit is contained in:
parent
d7f083559e
commit
86f0d32e70
|
@ -118,14 +118,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);
|
||||||
if (this_ptr->m_output_volume_changed.load())
|
|
||||||
{
|
|
||||||
this_ptr->m_output_volume_changed.store(false);
|
|
||||||
cubeb_stream_set_volume(this_ptr->m_cubeb_stream, static_cast<float>(this_ptr->m_output_volume) / 100.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
this_ptr->ReadFrames(reinterpret_cast<SampleType*>(output_buffer), static_cast<u32>(nframes), false);
|
|
||||||
return nframes;
|
return nframes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,12 +142,6 @@ void CubebAudioStream::DestroyContext()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CubebAudioStream::SetOutputVolume(u32 volume)
|
|
||||||
{
|
|
||||||
AudioStream::SetOutputVolume(volume);
|
|
||||||
m_output_volume_changed.store(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<AudioStream> AudioStream::CreateCubebAudioStream()
|
std::unique_ptr<AudioStream> AudioStream::CreateCubebAudioStream()
|
||||||
{
|
{
|
||||||
return std::make_unique<CubebAudioStream>();
|
return std::make_unique<CubebAudioStream>();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "common/audio_stream.h"
|
#include "common/audio_stream.h"
|
||||||
#include "cubeb/cubeb.h"
|
#include "cubeb/cubeb.h"
|
||||||
#include <atomic>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
class CubebAudioStream final : public AudioStream
|
class CubebAudioStream final : public AudioStream
|
||||||
|
@ -10,8 +9,6 @@ public:
|
||||||
CubebAudioStream();
|
CubebAudioStream();
|
||||||
~CubebAudioStream();
|
~CubebAudioStream();
|
||||||
|
|
||||||
void SetOutputVolume(u32 volume) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool IsOpen() const { return m_cubeb_stream != nullptr; }
|
bool IsOpen() const { return m_cubeb_stream != nullptr; }
|
||||||
|
|
||||||
|
@ -29,7 +26,6 @@ protected:
|
||||||
cubeb* m_cubeb_context = nullptr;
|
cubeb* m_cubeb_context = nullptr;
|
||||||
cubeb_stream* m_cubeb_stream = nullptr;
|
cubeb_stream* m_cubeb_stream = nullptr;
|
||||||
bool m_paused = true;
|
bool m_paused = true;
|
||||||
std::atomic_bool m_output_volume_changed{ false };
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
bool m_com_initialized_by_us = false;
|
bool m_com_initialized_by_us = false;
|
||||||
|
|
Loading…
Reference in a new issue