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