dolphin/Source/Core/AudioCommon/AlsaSoundStream.h

58 lines
962 B
C
Raw Normal View History

// Copyright 2008 Dolphin Emulator Project
2015-05-17 17:08:10 -06:00
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <atomic>
#include <condition_variable>
#include <mutex>
#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();
virtual ~AlsaSound();
bool Start() override;
void SoundLoop() override;
void Stop() override;
void Update() override;
void Clear(bool) override;
2014-08-30 14:29:15 -06:00
static bool isValid()
{
return true;
}
private:
enum class ALSAThreadStatus
{
RUNNING,
STOPPING,
STOPPED,
};
bool AlsaInit();
void AlsaShutdown();
u8 *mix_buffer;
std::thread thread;
std::atomic<ALSAThreadStatus> m_thread_status;
std::condition_variable cv;
std::mutex cv_m;
snd_pcm_t *handle;
int frames_to_deliver;
#endif
};