2013-04-21 06:17:03 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-09-09 21:26:33 +00:00
|
|
|
|
|
|
|
#ifndef _ALSA_SOUND_STREAM_H
|
|
|
|
#define _ALSA_SOUND_STREAM_H
|
|
|
|
|
2009-09-09 22:56:23 +00:00
|
|
|
#if defined(HAVE_ALSA) && HAVE_ALSA
|
2009-09-09 21:26:33 +00:00
|
|
|
#include <alsa/asoundlib.h>
|
2009-09-09 22:56:23 +00:00
|
|
|
#endif
|
2009-09-09 21:26:33 +00:00
|
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
#include "SoundStream.h"
|
|
|
|
|
|
|
|
#include "Thread.h"
|
|
|
|
|
|
|
|
class AlsaSound : public SoundStream
|
|
|
|
{
|
|
|
|
#if defined(HAVE_ALSA) && HAVE_ALSA
|
|
|
|
public:
|
|
|
|
AlsaSound(CMixer *mixer);
|
|
|
|
virtual ~AlsaSound();
|
|
|
|
|
|
|
|
virtual bool Start();
|
|
|
|
virtual void SoundLoop();
|
2009-12-13 11:51:29 +00:00
|
|
|
virtual void Stop();
|
2009-09-09 21:26:33 +00:00
|
|
|
|
|
|
|
static bool isValid() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
virtual bool usesMixer() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Update();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool AlsaInit();
|
|
|
|
void AlsaShutdown();
|
|
|
|
|
|
|
|
u8 *mix_buffer;
|
2011-01-27 21:34:37 +00:00
|
|
|
std::thread thread;
|
2009-09-09 21:26:33 +00:00
|
|
|
// 0 = continue
|
|
|
|
// 1 = shutdown
|
|
|
|
// 2 = done shutting down.
|
|
|
|
volatile int thread_data;
|
|
|
|
|
|
|
|
snd_pcm_t *handle;
|
2010-05-21 22:48:57 +00:00
|
|
|
int frames_to_deliver;
|
2009-09-09 21:26:33 +00:00
|
|
|
#else
|
|
|
|
public:
|
|
|
|
AlsaSound(CMixer *mixer) : SoundStream(mixer) {}
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|