NullAudioStream: Provide factory function
This commit is contained in:
parent
e66214d93e
commit
6176fc4486
|
@ -18,3 +18,8 @@ void NullAudioStream::BufferAvailable()
|
||||||
// drop any buffer as soon as they're available
|
// drop any buffer as soon as they're available
|
||||||
DropBuffer();
|
DropBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<AudioStream> NullAudioStream::Create()
|
||||||
|
{
|
||||||
|
return std::unique_ptr<AudioStream>(new NullAudioStream());
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
class NullAudioStream final : public AudioStream
|
class NullAudioStream final : public AudioStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NullAudioStream();
|
|
||||||
~NullAudioStream();
|
~NullAudioStream();
|
||||||
|
|
||||||
static std::unique_ptr<AudioStream> Create();
|
static std::unique_ptr<AudioStream> Create();
|
||||||
|
@ -14,4 +13,7 @@ protected:
|
||||||
void PauseDevice(bool paused) override;
|
void PauseDevice(bool paused) override;
|
||||||
void CloseDevice() override;
|
void CloseDevice() override;
|
||||||
void BufferAvailable() override;
|
void BufferAvailable() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
NullAudioStream();
|
||||||
};
|
};
|
||||||
|
|
|
@ -130,7 +130,7 @@ void SDLHostInterface::CreateAudioStream()
|
||||||
switch (m_settings.audio_backend)
|
switch (m_settings.audio_backend)
|
||||||
{
|
{
|
||||||
case AudioBackend::Null:
|
case AudioBackend::Null:
|
||||||
m_audio_stream = std::make_unique<NullAudioStream>();
|
m_audio_stream = NullAudioStream::Create();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AudioBackend::Default:
|
case AudioBackend::Default:
|
||||||
|
@ -143,7 +143,7 @@ void SDLHostInterface::CreateAudioStream()
|
||||||
{
|
{
|
||||||
ReportError("Failed to recreate audio stream, falling back to null");
|
ReportError("Failed to recreate audio stream, falling back to null");
|
||||||
m_audio_stream.reset();
|
m_audio_stream.reset();
|
||||||
m_audio_stream = std::make_unique<NullAudioStream>();
|
m_audio_stream = NullAudioStream::Create();
|
||||||
if (!m_audio_stream->Reconfigure(44100, 2))
|
if (!m_audio_stream->Reconfigure(44100, 2))
|
||||||
Panic("Failed to reconfigure null audio stream");
|
Panic("Failed to reconfigure null audio stream");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue