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