2013-04-21 08:17:03 +02:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-09-09 23:26:33 +02:00
|
|
|
|
2014-02-10 19:54:46 +01:00
|
|
|
#pragma once
|
2009-09-09 23:26:33 +02:00
|
|
|
|
2015-05-10 06:20:27 +02:00
|
|
|
#include <atomic>
|
|
|
|
#include <thread>
|
|
|
|
|
2009-09-10 00:56:23 +02:00
|
|
|
#if defined(HAVE_ALSA) && HAVE_ALSA
|
2009-09-09 23:26:33 +02:00
|
|
|
#include <alsa/asoundlib.h>
|
2009-09-10 00:56:23 +02:00
|
|
|
#endif
|
2009-09-09 23:26:33 +02:00
|
|
|
|
2014-02-17 11:18:15 +01:00
|
|
|
#include "AudioCommon/SoundStream.h"
|
2014-09-08 03:06:58 +02:00
|
|
|
#include "Common/CommonTypes.h"
|
2009-09-09 23:26:33 +02:00
|
|
|
|
2014-03-18 15:37:45 +01:00
|
|
|
class AlsaSound final : public SoundStream
|
2009-09-09 23:26:33 +02:00
|
|
|
{
|
|
|
|
#if defined(HAVE_ALSA) && HAVE_ALSA
|
|
|
|
public:
|
|
|
|
AlsaSound(CMixer *mixer);
|
|
|
|
virtual ~AlsaSound();
|
|
|
|
|
2014-03-08 01:54:44 +01:00
|
|
|
virtual bool Start() override;
|
|
|
|
virtual void SoundLoop() override;
|
|
|
|
virtual void Stop() override;
|
2009-09-09 23:26:33 +02:00
|
|
|
|
2014-08-30 22:29:15 +02:00
|
|
|
static bool isValid()
|
|
|
|
{
|
2009-09-09 23:26:33 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-08 01:54:44 +01:00
|
|
|
virtual void Update() override;
|
2009-09-09 23:26:33 +02:00
|
|
|
|
|
|
|
private:
|
2015-05-10 08:30:24 +02:00
|
|
|
enum class ALSAThreadStatus
|
|
|
|
{
|
|
|
|
RUNNING,
|
|
|
|
STOPPING,
|
|
|
|
STOPPED,
|
|
|
|
};
|
|
|
|
|
2009-09-09 23:26:33 +02:00
|
|
|
bool AlsaInit();
|
|
|
|
void AlsaShutdown();
|
|
|
|
|
|
|
|
u8 *mix_buffer;
|
2011-01-27 22:34:37 +01:00
|
|
|
std::thread thread;
|
2015-05-10 08:30:24 +02:00
|
|
|
std::atomic<ALSAThreadStatus> m_thread_status;
|
2009-09-09 23:26:33 +02:00
|
|
|
|
|
|
|
snd_pcm_t *handle;
|
2010-05-22 00:48:57 +02:00
|
|
|
int frames_to_deliver;
|
2009-09-09 23:26:33 +02:00
|
|
|
#else
|
|
|
|
public:
|
|
|
|
AlsaSound(CMixer *mixer) : SoundStream(mixer) {}
|
|
|
|
#endif
|
|
|
|
};
|