mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-22 22:45:39 +00:00
Fix crash if audio init fails (especially if there are no output devices)
This commit is contained in:
@@ -134,7 +134,7 @@ void ToggleMusicWhilePlaying (void)
|
||||
|
||||
void SetMusicalMode (short newMode)
|
||||
{
|
||||
if (dontLoadMusic)
|
||||
if (dontLoadMusic || failedMusic)
|
||||
return;
|
||||
|
||||
musicMutex->Lock();
|
||||
@@ -302,6 +302,12 @@ void InitMusic (void)
|
||||
return;
|
||||
}
|
||||
theErr = OpenMusicChannel();
|
||||
if (theErr != PLErrors::kNone)
|
||||
{
|
||||
YellowAlert(kYellowNoMusic, theErr);
|
||||
failedMusic = true;
|
||||
return;
|
||||
}
|
||||
|
||||
musicScore[0] = 0;
|
||||
musicScore[1] = 1;
|
||||
|
@@ -353,12 +353,15 @@ namespace PortabilityLayer
|
||||
|
||||
AudioChannel *SoundSystemImpl::CreateChannel()
|
||||
{
|
||||
IGpAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance();
|
||||
if (!audioDriver)
|
||||
return nullptr;
|
||||
|
||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||
void *storage = mm->Alloc(sizeof(PortabilityLayer::AudioChannelImpl));
|
||||
if (!storage)
|
||||
return nullptr;
|
||||
|
||||
IGpAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance();
|
||||
IGpAudioChannel *audioChannel = audioDriver->CreateChannel();
|
||||
if (!audioChannel)
|
||||
{
|
||||
@@ -388,7 +391,12 @@ namespace PortabilityLayer
|
||||
|
||||
void SoundSystemImpl::SetVolume(uint8_t vol)
|
||||
{
|
||||
PortabilityLayer::HostAudioDriver::GetInstance()->SetMasterVolume(vol, 255);
|
||||
IGpAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance();
|
||||
|
||||
if (!audioDriver)
|
||||
return;
|
||||
|
||||
audioDriver->SetMasterVolume(vol, 255);
|
||||
m_volume = vol;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user