mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Fix crash when no sound device is present #551
This commit is contained in:
parent
4b59b1f6f8
commit
20fcb52bfe
|
|
@ -206,6 +206,11 @@ void SoundEngine::init(Options *pOptions)
|
||||||
app.DebugPrintf("---SoundEngine::init\n");
|
app.DebugPrintf("---SoundEngine::init\n");
|
||||||
#ifdef __DISABLE_MILES__
|
#ifdef __DISABLE_MILES__
|
||||||
return;
|
return;
|
||||||
|
#endif
|
||||||
|
m_hDriver = 0;
|
||||||
|
#if defined(_WINDOWS64)
|
||||||
|
__try
|
||||||
|
{
|
||||||
#endif
|
#endif
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
C4JThread::PushAffinityAllCores();
|
C4JThread::PushAffinityAllCores();
|
||||||
|
|
@ -372,6 +377,14 @@ void SoundEngine::init(Options *pOptions)
|
||||||
// wait for 1 mix...
|
// wait for 1 mix...
|
||||||
AIL_release_sample_handle(Sample);
|
AIL_release_sample_handle(Sample);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(_WINDOWS64)
|
||||||
|
}
|
||||||
|
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
m_hDriver = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ORBIS__
|
#ifdef __ORBIS__
|
||||||
|
|
@ -403,6 +416,9 @@ void SoundEngine::SetStreamingSounds(int iOverworldMin, int iOverWorldMax, int i
|
||||||
// AP - moved to a separate function so it can be called from the mixer callback on Vita
|
// AP - moved to a separate function so it can be called from the mixer callback on Vita
|
||||||
void SoundEngine::updateMiles()
|
void SoundEngine::updateMiles()
|
||||||
{
|
{
|
||||||
|
#if defined(_WINDOWS64)
|
||||||
|
if (!m_hDriver) return;
|
||||||
|
#endif
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
//CD - We must check for Background Music [BGM] at any point
|
//CD - We must check for Background Music [BGM] at any point
|
||||||
//If it's playing disable our audio, otherwise enable
|
//If it's playing disable our audio, otherwise enable
|
||||||
|
|
@ -634,6 +650,9 @@ void SoundEngine::tick(shared_ptr<Mob> *players, float a)
|
||||||
#ifdef __DISABLE_MILES__
|
#ifdef __DISABLE_MILES__
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(_WINDOWS64)
|
||||||
|
if (!m_hDriver) return;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __PSVITA__
|
#ifdef __PSVITA__
|
||||||
EnterCriticalSection(&SoundEngine_MixerMutex);
|
EnterCriticalSection(&SoundEngine_MixerMutex);
|
||||||
|
|
@ -710,6 +729,8 @@ void SoundEngine::tick(shared_ptr<Mob> *players, float a)
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
SoundEngine::SoundEngine()
|
SoundEngine::SoundEngine()
|
||||||
{
|
{
|
||||||
|
m_hDriver = 0;
|
||||||
|
m_hBank = 0;
|
||||||
random = new Random();
|
random = new Random();
|
||||||
m_hStream=0;
|
m_hStream=0;
|
||||||
m_StreamState=eMusicStreamState_Idle;
|
m_StreamState=eMusicStreamState_Idle;
|
||||||
|
|
@ -760,6 +781,9 @@ void SoundEngine::GetSoundName(char *szSoundName,int iSound)
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
void SoundEngine::play(int iSound, float x, float y, float z, float volume, float pitch)
|
void SoundEngine::play(int iSound, float x, float y, float z, float volume, float pitch)
|
||||||
{
|
{
|
||||||
|
#if defined(_WINDOWS64)
|
||||||
|
if (!m_hDriver) return;
|
||||||
|
#endif
|
||||||
U8 szSoundName[256];
|
U8 szSoundName[256];
|
||||||
|
|
||||||
if(iSound==-1)
|
if(iSound==-1)
|
||||||
|
|
@ -819,6 +843,9 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume, floa
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
void SoundEngine::playUI(int iSound, float volume, float pitch)
|
void SoundEngine::playUI(int iSound, float volume, float pitch)
|
||||||
{
|
{
|
||||||
|
#if defined(_WINDOWS64)
|
||||||
|
if (!m_hDriver) return;
|
||||||
|
#endif
|
||||||
U8 szSoundName[256];
|
U8 szSoundName[256];
|
||||||
wstring name;
|
wstring name;
|
||||||
// we have some game sounds played as UI sounds...
|
// we have some game sounds played as UI sounds...
|
||||||
|
|
@ -1135,6 +1162,9 @@ int SoundEngine::OpenStreamThreadProc( void* lpParameter )
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
SoundEngine *soundEngine = (SoundEngine *)lpParameter;
|
SoundEngine *soundEngine = (SoundEngine *)lpParameter;
|
||||||
|
#if defined(_WINDOWS64)
|
||||||
|
if (!soundEngine->m_hDriver) return 0;
|
||||||
|
#endif
|
||||||
soundEngine->m_hStream = AIL_open_stream(soundEngine->m_hDriver,soundEngine->m_szStreamName,0);
|
soundEngine->m_hStream = AIL_open_stream(soundEngine->m_hDriver,soundEngine->m_szStreamName,0);
|
||||||
|
|
||||||
if(soundEngine->m_hStream==0)
|
if(soundEngine->m_hStream==0)
|
||||||
|
|
@ -1160,6 +1190,9 @@ void SoundEngine::playMusicTick()
|
||||||
// AP - moved to a separate function so it can be called from the mixer callback on Vita
|
// AP - moved to a separate function so it can be called from the mixer callback on Vita
|
||||||
void SoundEngine::playMusicUpdate()
|
void SoundEngine::playMusicUpdate()
|
||||||
{
|
{
|
||||||
|
#if defined(_WINDOWS64)
|
||||||
|
if (!m_hDriver) return;
|
||||||
|
#endif
|
||||||
//return;
|
//return;
|
||||||
static bool firstCall = true;
|
static bool firstCall = true;
|
||||||
static float fMusicVol = 0.0f;
|
static float fMusicVol = 0.0f;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue