1
// Copyright 2013 Dolphin Emulator Project
2
// Licensed under GPLv2
3
// Refer to the license.txt file included.
8
#include "AOSoundStream.h"
11
#if defined(HAVE_AO) && HAVE_AO
13
void AOSound::SoundLoop()
15
Common::SetCurrentThreadName("Audio thread - ao");
17
uint_32 numBytesToRender = 256;
19
default_driver = ao_default_driver_id();
22
format.rate = m_mixer->GetSampleRate();
23
format.byte_format = AO_FMT_LITTLE;
25
device = ao_open_live(default_driver, &format, NULL /* no options */);
28
PanicAlertT("AudioCommon: Error opening AO device.\n");
34
buf_size = format.bits/8 * format.channels * format.rate;
38
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
41
std::lock_guard<std::mutex> lk(soundCriticalSection);
42
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
45
soundSyncEvent.Wait();
51
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
53
thread = std::thread(std::mem_fun(&AOSound::SoundLoop), this);
57
void AOSound::Update()
68
std::lock_guard<std::mutex> lk(soundCriticalSection);