Changeset View
Changeset View
Standalone View
Standalone View
source/soundmanager/SoundManager.cpp
Show First 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | private: | ||||
bool m_Shutdown; | bool m_Shutdown; | ||||
CSoundManagerWorker(ISoundManager* UNUSED(other)){}; | CSoundManagerWorker(ISoundManager* UNUSED(other)){}; | ||||
}; | }; | ||||
void ISoundManager::CreateSoundManager() | void ISoundManager::CreateSoundManager() | ||||
{ | { | ||||
if (!g_SoundManager) | if (!g_SoundManager) | ||||
elexis: (early return if this function is modified and contains more than 4 lines) | |||||
{ | { | ||||
try | |||||
{ | |||||
g_SoundManager = new CSoundManager(); | g_SoundManager = new CSoundManager(); | ||||
g_SoundManager->StartWorker(); | g_SoundManager->StartWorker(); | ||||
} | } | ||||
catch (Status a) | |||||
vladislavbelovUnsubmitted Done Inline ActionsWhat do you catch here? vladislavbelov: What do you catch here? | |||||
StanAuthorUnsubmitted Done Inline ActionsThe exception he added just below. Stan: The exception he added just below. | |||||
vladislavbelovUnsubmitted Done Inline ActionsYes, but the Status name is not acceptable here as the exception name (that was the original question). Because you can't understand, what's the status? And it's not the CSoundManager status, it's internal and unknown to the ISoundManager. vladislavbelov: Yes, but the `Status` name is not acceptable here as the exception name (that was the original… | |||||
vladislavbelovUnsubmitted Done Inline ActionsAlso I'd prefer to not return values through exceptions at all, but use a named exception. vladislavbelov: Also I'd prefer to not return values through exceptions at all, but use a named exception. | |||||
ImarokUnsubmitted Done Inline ActionsI agree the type of exception I've chosen is not the best. Imarok: I agree the type of exception I've chosen is not the best.
Any idea, what I should use? | |||||
StanAuthorUnsubmitted Done Inline ActionsCan we create a named exception for this ? Stan: Can we create a named exception for this ? | |||||
ImarokUnsubmitted Done Inline ActionsSure, I just ran out of names. Imarok: Sure, I just ran out of names. | |||||
{ | |||||
SAFE_DELETE(g_SoundManager); | |||||
} | |||||
} | |||||
} | } | ||||
void ISoundManager::SetEnabled(bool doEnable) | void ISoundManager::SetEnabled(bool doEnable) | ||||
{ | { | ||||
if (g_SoundManager && !doEnable) | if (g_SoundManager && !doEnable) | ||||
SAFE_DELETE(g_SoundManager); | SAFE_DELETE(g_SoundManager); | ||||
else if (!g_SoundManager && doEnable) | else if (!g_SoundManager && doEnable) | ||||
ISoundManager::CreateSoundManager(); | ISoundManager::CreateSoundManager(); | ||||
Show All 39 Lines | CSoundManager::CSoundManager() | ||||
m_PlaylistGap(0), m_DistressErrCount(0), m_DistressTime(0) | m_PlaylistGap(0), m_DistressErrCount(0), m_DistressTime(0) | ||||
{ | { | ||||
CFG_GET_VAL("sound.mastergain", m_Gain); | CFG_GET_VAL("sound.mastergain", m_Gain); | ||||
CFG_GET_VAL("sound.musicgain", m_MusicGain); | CFG_GET_VAL("sound.musicgain", m_MusicGain); | ||||
CFG_GET_VAL("sound.ambientgain", m_AmbientGain); | CFG_GET_VAL("sound.ambientgain", m_AmbientGain); | ||||
CFG_GET_VAL("sound.actiongain", m_ActionGain); | CFG_GET_VAL("sound.actiongain", m_ActionGain); | ||||
CFG_GET_VAL("sound.uigain", m_UIGain); | CFG_GET_VAL("sound.uigain", m_UIGain); | ||||
AlcInit(); | Status alcInitInfo = AlcInit(); | ||||
if (alcInitInfo != INFO::OK) | |||||
throw alcInitInfo; | |||||
if (m_Enabled) | if (m_Enabled) | ||||
{ | { | ||||
SetMasterGain(m_Gain); | SetMasterGain(m_Gain); | ||||
InitListener(); | InitListener(); | ||||
m_PlayListItems = new PlayList; | m_PlayListItems = new PlayList; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | if (m_Context) | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
LOGERROR("error in gensource = %d", err); | LOGERROR("error in gensource = %d", err); | ||||
} | } | ||||
delete[] sourceList; | delete[] sourceList; | ||||
} | } | ||||
} | } | ||||
elexisUnsubmitted Done Inline ActionsCheck also this below elexis: Check also this below | |||||
// check if init succeeded. | // check if init succeeded. | ||||
// some OpenAL implementations don't indicate failure here correctly; | // some OpenAL implementations don't indicate failure here correctly; | ||||
// we need to check if the device and context pointers are actually valid. | // we need to check if the device and context pointers are actually valid. | ||||
ALCenum err = alcGetError(m_Device); | ALCenum err = alcGetError(m_Device); | ||||
const char* dev_name = (const char*)alcGetString(m_Device, ALC_DEVICE_SPECIFIER); | const char* dev_name = (const char*)alcGetString(m_Device, ALC_DEVICE_SPECIFIER); | ||||
if (err == ALC_NO_ERROR && m_Device && m_Context) | if (err == ALC_NO_ERROR && m_Device && m_Context) | ||||
debug_printf("Sound: AlcInit success, using %s\n", dev_name); | debug_printf("Sound: AlcInit success, using %s\n", dev_name); | ||||
▲ Show 20 Lines • Show All 474 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
(early return if this function is modified and contains more than 4 lines)