2013-04-21 00:17:03 -06:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-09-09 15:26:33 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2009-09-09 15:26:33 -06:00
|
|
|
|
2009-09-09 16:56:23 -06:00
|
|
|
#if defined(HAVE_ALSA) && HAVE_ALSA
|
2009-09-09 15:26:33 -06:00
|
|
|
#include <alsa/asoundlib.h>
|
2009-09-09 16:56:23 -06:00
|
|
|
#endif
|
2009-09-09 15:26:33 -06:00
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "AudioCommon/SoundStream.h"
|
|
|
|
#include "Common/Common.h"
|
|
|
|
#include "Common/Thread.h"
|
2009-09-09 15:26:33 -06:00
|
|
|
|
2014-03-18 08:37:45 -06:00
|
|
|
class AlsaSound final : public SoundStream
|
2009-09-09 15:26:33 -06:00
|
|
|
{
|
|
|
|
#if defined(HAVE_ALSA) && HAVE_ALSA
|
|
|
|
public:
|
|
|
|
AlsaSound(CMixer *mixer);
|
|
|
|
virtual ~AlsaSound();
|
|
|
|
|
2014-03-07 17:54:44 -07:00
|
|
|
virtual bool Start() override;
|
|
|
|
virtual void SoundLoop() override;
|
|
|
|
virtual void Stop() override;
|
2009-09-09 15:26:33 -06:00
|
|
|
|
|
|
|
static bool isValid() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-07 17:54:44 -07:00
|
|
|
virtual void Update() override;
|
2009-09-09 15:26:33 -06:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool AlsaInit();
|
|
|
|
void AlsaShutdown();
|
|
|
|
|
|
|
|
u8 *mix_buffer;
|
2011-01-27 14:34:37 -07:00
|
|
|
std::thread thread;
|
2009-09-09 15:26:33 -06:00
|
|
|
// 0 = continue
|
|
|
|
// 1 = shutdown
|
|
|
|
// 2 = done shutting down.
|
|
|
|
volatile int thread_data;
|
|
|
|
|
|
|
|
snd_pcm_t *handle;
|
2010-05-21 16:48:57 -06:00
|
|
|
int frames_to_deliver;
|
2009-09-09 15:26:33 -06:00
|
|
|
#else
|
|
|
|
public:
|
|
|
|
AlsaSound(CMixer *mixer) : SoundStream(mixer) {}
|
|
|
|
#endif
|
|
|
|
};
|