cellAudio: recover Cubeb on failed initialization

This commit is contained in:
Megamouse 2021-12-02 00:58:28 +01:00
parent 68466f05b6
commit 3f3b4bc363
3 changed files with 9 additions and 11 deletions

View File

@ -97,6 +97,12 @@ void CubebBackend::Open(AudioFreq freq, AudioSampleSize sample_size, AudioChanne
{
m_stream = nullptr;
Cubeb.error("cubeb_stream_init() failed: 0x%08x", err);
}
if (m_stream == nullptr)
{
Cubeb.error("Failed to open audio backend. Make sure that no other application is running that might block audio access (e.g. Netflix).");
CloseUnlocked();
return;
}
@ -130,8 +136,6 @@ void CubebBackend::Close()
void CubebBackend::Play()
{
ensure(m_stream != nullptr);
if (m_playing) return;
if (int err = cubeb_stream_start(m_stream))
@ -145,8 +149,6 @@ void CubebBackend::Play()
void CubebBackend::Pause()
{
ensure(m_stream != nullptr);
if (int err = cubeb_stream_stop(m_stream))
{
Cubeb.error("cubeb_stream_stop() failed: 0x%08x", err);
@ -158,8 +160,6 @@ void CubebBackend::Pause()
bool CubebBackend::IsPlaying()
{
ensure(m_stream != nullptr);
return m_playing;
}
@ -171,8 +171,6 @@ void CubebBackend::SetWriteCallback(std::function<u32(u32, void *)> cb)
f64 CubebBackend::GetCallbackFrameLen()
{
ensure(m_stream != nullptr);
cubeb_stream_params stream_param{};
stream_param.format = get_convert_to_s16() ? CUBEB_SAMPLE_S16NE : CUBEB_SAMPLE_FLOAT32NE;
stream_param.rate = get_sampling_rate();

View File

@ -117,7 +117,7 @@ EmuCallbacks main_application::CreateCallbacks()
if (!result->Initialized())
{
// Fall back to a null backend if something went wrong
sys_log.error("Audio renderer %s could not be initialized, using a Null renderer instead", result->GetName());
sys_log.error("Audio renderer %s could not be initialized, using a Null renderer instead. Make sure that no other application is running that might block audio access (e.g. Netflix).", result->GetName());
result = std::make_shared<NullAudioBackend>();
}
return result;