bool SoundStream::Start() { if (m_enablesoundloop) { DPL2Reset(); thread.reset(new std::thread(std::mem_fn(&SoundStream::SoundLoop), this)); #ifdef _WIN32 SetThreadPriority(thread.get()->native_handle(), THREAD_PRIORITY_TIME_CRITICAL); #endif } return true; }
// // AyuanX: Spec says OpenAL1.1 is thread safe already // bool OpenALStream::Start() { m_run_thread.Set(); bool bReturn = false; ALDeviceList pDeviceList; if (pDeviceList.GetNumDevices()) { char* defDevName = pDeviceList.GetDeviceName(pDeviceList.GetDefaultDevice()); INFO_LOG(AUDIO, "Found OpenAL device %s", defDevName); ALCdevice* pDevice = alcOpenDevice(defDevName); if (pDevice) { ALCcontext* pContext = alcCreateContext(pDevice, nullptr); if (pContext) { // Used to determine an appropriate period size (2x period = total buffer size) // ALCint refresh; // alcGetIntegerv(pDevice, ALC_REFRESH, 1, &refresh); // period_size_in_millisec = 1000 / refresh; alcMakeContextCurrent(pContext); thread = std::thread(&OpenALStream::SoundLoop, this); bReturn = 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"); } // Initialize DPL2 parameters DPL2Reset(); soundTouch.clear(); return bReturn; }