Reformat all the things. Have fun with merge conflicts.

This commit is contained in:
Pierre Bourdon
2016-06-24 10:43:46 +02:00
parent 2115e8a4a6
commit 3570c7f03a
1116 changed files with 187405 additions and 180344 deletions

View File

@ -6,77 +6,77 @@
#include "AudioCommon/AOSoundStream.h"
#include "AudioCommon/Mixer.h"
#include "Common/MsgHandler.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#if defined(HAVE_AO) && HAVE_AO
void AOSound::SoundLoop()
{
Common::SetCurrentThreadName("Audio thread - ao");
Common::SetCurrentThreadName("Audio thread - ao");
uint_32 numBytesToRender = 256;
ao_initialize();
default_driver = ao_default_driver_id();
format.bits = 16;
format.channels = 2;
format.rate = m_mixer->GetSampleRate();
format.byte_format = AO_FMT_LITTLE;
uint_32 numBytesToRender = 256;
ao_initialize();
default_driver = ao_default_driver_id();
format.bits = 16;
format.channels = 2;
format.rate = m_mixer->GetSampleRate();
format.byte_format = AO_FMT_LITTLE;
device = ao_open_live(default_driver, &format, nullptr /* no options */);
if (!device)
{
PanicAlertT("AudioCommon: Error opening AO device.\n");
ao_shutdown();
Stop();
return;
}
device = ao_open_live(default_driver, &format, nullptr /* no options */);
if (!device)
{
PanicAlertT("AudioCommon: Error opening AO device.\n");
ao_shutdown();
Stop();
return;
}
buf_size = format.bits/8 * format.channels * format.rate;
buf_size = format.bits / 8 * format.channels * format.rate;
while (m_run_thread.load())
{
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
while (m_run_thread.load())
{
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
{
std::lock_guard<std::mutex> lk(soundCriticalSection);
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
}
{
std::lock_guard<std::mutex> lk(soundCriticalSection);
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
}
soundSyncEvent.Wait();
}
soundSyncEvent.Wait();
}
}
bool AOSound::Start()
{
m_run_thread.store(true);
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
m_run_thread.store(true);
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
thread = std::thread(&AOSound::SoundLoop, this);
return true;
thread = std::thread(&AOSound::SoundLoop, this);
return true;
}
void AOSound::Update()
{
soundSyncEvent.Set();
soundSyncEvent.Set();
}
void AOSound::Stop()
{
m_run_thread.store(false);
soundSyncEvent.Set();
m_run_thread.store(false);
soundSyncEvent.Set();
{
std::lock_guard<std::mutex> lk(soundCriticalSection);
thread.join();
{
std::lock_guard<std::mutex> lk(soundCriticalSection);
thread.join();
if (device)
ao_close(device);
if (device)
ao_close(device);
ao_shutdown();
ao_shutdown();
device = nullptr;
}
device = nullptr;
}
}
#endif