clean up OpenALStream::Start()
This commit is contained in:
parent
56961f5561
commit
32470ef284
|
@ -24,48 +24,41 @@
|
||||||
//
|
//
|
||||||
bool OpenALStream::Start()
|
bool OpenALStream::Start()
|
||||||
{
|
{
|
||||||
m_run_thread.Set();
|
|
||||||
bool bReturn = false;
|
|
||||||
|
|
||||||
ALDeviceList pDeviceList;
|
ALDeviceList pDeviceList;
|
||||||
if (pDeviceList.GetNumDevices())
|
if (!pDeviceList.GetNumDevices())
|
||||||
{
|
{
|
||||||
|
PanicAlertT("OpenAL: can't find sound devices");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
char* defDevName = pDeviceList.GetDeviceName(pDeviceList.GetDefaultDevice());
|
char* defDevName = pDeviceList.GetDeviceName(pDeviceList.GetDefaultDevice());
|
||||||
|
|
||||||
INFO_LOG(AUDIO, "Found OpenAL device %s", defDevName);
|
INFO_LOG(AUDIO, "Found OpenAL device %s", defDevName);
|
||||||
|
|
||||||
ALCdevice* pDevice = alcOpenDevice(defDevName);
|
ALCdevice* pDevice = alcOpenDevice(defDevName);
|
||||||
if (pDevice)
|
if (!pDevice)
|
||||||
{
|
{
|
||||||
|
PanicAlertT("OpenAL: can't open device %s", defDevName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ALCcontext* pContext = alcCreateContext(pDevice, nullptr);
|
ALCcontext* pContext = alcCreateContext(pDevice, nullptr);
|
||||||
if (pContext)
|
if (!pContext)
|
||||||
{
|
{
|
||||||
|
alcCloseDevice(pDevice);
|
||||||
|
PanicAlertT("OpenAL: can't create context for device %s", defDevName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Used to determine an appropriate period size (2x period = total buffer size)
|
// Used to determine an appropriate period size (2x period = total buffer size)
|
||||||
// ALCint refresh;
|
// ALCint refresh;
|
||||||
// alcGetIntegerv(pDevice, ALC_REFRESH, 1, &refresh);
|
// alcGetIntegerv(pDevice, ALC_REFRESH, 1, &refresh);
|
||||||
// period_size_in_millisec = 1000 / refresh;
|
// period_size_in_millisec = 1000 / refresh;
|
||||||
|
|
||||||
alcMakeContextCurrent(pContext);
|
alcMakeContextCurrent(pContext);
|
||||||
|
m_run_thread.Set();
|
||||||
thread = std::thread(&OpenALStream::SoundLoop, this);
|
thread = std::thread(&OpenALStream::SoundLoop, this);
|
||||||
bReturn = true;
|
return true;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
alcCloseDevice(pDevice);
|
|
||||||
PanicAlertT("OpenAL: can't create context for device %s", defDevName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PanicAlertT("OpenAL: can't open device %s", defDevName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PanicAlertT("OpenAL: can't find sound devices");
|
|
||||||
}
|
|
||||||
|
|
||||||
return bReturn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenALStream::Stop()
|
void OpenALStream::Stop()
|
||||||
|
|
Loading…
Reference in New Issue