Skip to content

Commit

Permalink
Reformat all the things. Have fun with merge conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
delroth committed Jun 24, 2016
1 parent 2115e8a commit 3570c7f
Show file tree
Hide file tree
Showing 1,116 changed files with 202,836 additions and 195,775 deletions.
1,026 changes: 430 additions & 596 deletions Source/Android/jni/ButtonManager.cpp

Large diffs are not rendered by default.

476 changes: 238 additions & 238 deletions Source/Android/jni/ButtonManager.h

Large diffs are not rendered by default.

1,038 changes: 575 additions & 463 deletions Source/Android/jni/MainAndroid.cpp

Large diffs are not rendered by default.

96 changes: 48 additions & 48 deletions Source/Core/AudioCommon/AOSoundStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

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;
}

buf_size = format.bits/8 * format.channels * format.rate;

while (m_run_thread.load())
{
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);

{
std::lock_guard<std::mutex> lk(soundCriticalSection);
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
}

soundSyncEvent.Wait();
}
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;

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;

while (m_run_thread.load())
{
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);

{
std::lock_guard<std::mutex> lk(soundCriticalSection);
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
}

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
32 changes: 14 additions & 18 deletions Source/Core/AudioCommon/AOSoundStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,25 @@
class AOSound final : public SoundStream
{
#if defined(HAVE_AO) && HAVE_AO
std::thread thread;
std::atomic<bool> m_run_thread;
std::mutex soundCriticalSection;
Common::Event soundSyncEvent;
std::thread thread;
std::atomic<bool> m_run_thread;
std::mutex soundCriticalSection;
Common::Event soundSyncEvent;

int buf_size;
int buf_size;

ao_device *device;
ao_sample_format format;
int default_driver;
ao_device* device;
ao_sample_format format;
int default_driver;

short realtimeBuffer[1024 * 1024];
short realtimeBuffer[1024 * 1024];

public:
bool Start() override;
void SoundLoop() override;
void Stop() override;
void Update() override;

static bool isValid()
{
return true;
}
bool Start() override;
void SoundLoop() override;
void Stop() override;
void Update() override;

static bool isValid() { return true; }
#endif
};
Loading

0 comments on commit 3570c7f

Please sign in to comment.