summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/AlsaSoundStream.h
blob: 186e4871bb18716b68c9f5302d19c8940495118f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2008 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();
	virtual ~AlsaSound();

	bool Start() override;
	void SoundLoop() override;
	void Stop() override;
	void Update() override;

	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;

	snd_pcm_t *handle;
	int frames_to_deliver;
#endif
};