dolphin/Source/Core/AudioCommon/AlsaSoundStream.h

57 lines
949 B
C
Raw Normal View History

// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#include <atomic>
#include <thread>
#if defined(HAVE_ALSA) && HAVE_ALSA
#include <alsa/asoundlib.h>
#endif
#include "AudioCommon/SoundStream.h"
#include "Common/CommonTypes.h"
class AlsaSound final : public SoundStream
{
#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;
2014-08-30 22:29:15 +02:00
static bool isValid()
{
return true;
}
2014-03-08 01:54:44 +01:00
virtual void Update() override;
private:
enum class ALSAThreadStatus
{
RUNNING,
STOPPING,
STOPPED,
};
bool AlsaInit();
void AlsaShutdown();
u8 *mix_buffer;
std::thread thread;
std::atomic<ALSAThreadStatus> m_thread_status;
snd_pcm_t *handle;
int frames_to_deliver;
#else
public:
AlsaSound(CMixer *mixer) : SoundStream(mixer) {}
#endif
};