2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:09:55 -06:00
|
|
|
// Refer to the license.txt file included.
|
2008-08-16 15:58:07 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2008-08-16 15:58:07 -06:00
|
|
|
|
2015-05-09 21:48:22 -06:00
|
|
|
#include <atomic>
|
2014-08-13 23:14:35 -06:00
|
|
|
#include <mutex>
|
|
|
|
#include <thread>
|
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "AudioCommon/SoundStream.h"
|
2014-04-13 17:15:23 -06:00
|
|
|
#include "Common/Event.h"
|
2014-09-18 22:17:41 -06:00
|
|
|
#include "Common/Thread.h"
|
2009-01-28 17:57:55 -07:00
|
|
|
|
|
|
|
#if defined(HAVE_AO) && HAVE_AO
|
|
|
|
#include <ao/ao.h>
|
|
|
|
#endif
|
|
|
|
|
2014-03-18 08:37:45 -06:00
|
|
|
class AOSound final : public SoundStream
|
2008-08-16 15:58:07 -06:00
|
|
|
{
|
2009-01-28 17:57:55 -07:00
|
|
|
#if defined(HAVE_AO) && HAVE_AO
|
2011-01-27 13:47:58 -07:00
|
|
|
std::thread thread;
|
2015-05-09 21:48:22 -06:00
|
|
|
std::atomic<bool> m_run_thread;
|
2011-03-04 23:11:26 -07:00
|
|
|
std::mutex soundCriticalSection;
|
2009-03-26 03:29:14 -06:00
|
|
|
Common::Event soundSyncEvent;
|
2009-02-20 15:04:52 -07:00
|
|
|
|
|
|
|
int buf_size;
|
|
|
|
|
|
|
|
ao_device *device;
|
|
|
|
ao_sample_format format;
|
|
|
|
int default_driver;
|
|
|
|
|
|
|
|
short realtimeBuffer[1024 * 1024];
|
2009-01-28 17:57:55 -07:00
|
|
|
|
|
|
|
public:
|
2015-05-24 04:02:30 -06:00
|
|
|
bool Start() override;
|
|
|
|
void SoundLoop() override;
|
|
|
|
void Stop() override;
|
|
|
|
void Update() override;
|
2013-03-19 19:51:12 -06:00
|
|
|
|
2014-08-30 14:29:15 -06:00
|
|
|
static bool isValid()
|
|
|
|
{
|
2009-02-20 15:04:52 -07:00
|
|
|
return true;
|
|
|
|
}
|
2013-03-19 19:51:12 -06:00
|
|
|
|
2009-01-28 17:57:55 -07:00
|
|
|
#endif
|
|
|
|
};
|