mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +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)
|
void SetMusicalMode (short newMode)
|
||||||
{
|
{
|
||||||
if (dontLoadMusic)
|
if (dontLoadMusic || failedMusic)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
musicMutex->Lock();
|
musicMutex->Lock();
|
||||||
@@ -302,6 +302,12 @@ void InitMusic (void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
theErr = OpenMusicChannel();
|
theErr = OpenMusicChannel();
|
||||||
|
if (theErr != PLErrors::kNone)
|
||||||
|
{
|
||||||
|
YellowAlert(kYellowNoMusic, theErr);
|
||||||
|
failedMusic = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
musicScore[0] = 0;
|
musicScore[0] = 0;
|
||||||
musicScore[1] = 1;
|
musicScore[1] = 1;
|
||||||
|
@@ -353,12 +353,15 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
AudioChannel *SoundSystemImpl::CreateChannel()
|
AudioChannel *SoundSystemImpl::CreateChannel()
|
||||||
{
|
{
|
||||||
|
IGpAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance();
|
||||||
|
if (!audioDriver)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
PortabilityLayer::MemoryManager *mm = PortabilityLayer::MemoryManager::GetInstance();
|
||||||
void *storage = mm->Alloc(sizeof(PortabilityLayer::AudioChannelImpl));
|
void *storage = mm->Alloc(sizeof(PortabilityLayer::AudioChannelImpl));
|
||||||
if (!storage)
|
if (!storage)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
IGpAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance();
|
|
||||||
IGpAudioChannel *audioChannel = audioDriver->CreateChannel();
|
IGpAudioChannel *audioChannel = audioDriver->CreateChannel();
|
||||||
if (!audioChannel)
|
if (!audioChannel)
|
||||||
{
|
{
|
||||||
@@ -388,7 +391,12 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
void SoundSystemImpl::SetVolume(uint8_t vol)
|
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;
|
m_volume = vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user