| 
									
										
										
										
											2015-05-24 06:55:12 +02:00
										 |  |  | // Copyright 2008 Dolphin Emulator Project
 | 
					
						
							| 
									
										
										
										
											2015-05-18 01:08:10 +02:00
										 |  |  | // Licensed under GPLv2+
 | 
					
						
							| 
									
										
										
										
											2013-04-21 02:17:03 -04:00
										 |  |  | // Refer to the license.txt file included.
 | 
					
						
							| 
									
										
										
										
											2009-09-09 21:26:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-10 13:54:46 -05:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2009-09-09 21:26:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-10 00:20:27 -04:00
										 |  |  | #include <atomic>
 | 
					
						
							|  |  |  | #include <thread>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "AudioCommon/SoundStream.h"
 | 
					
						
							| 
									
										
										
										
											2014-09-07 20:06:58 -05:00
										 |  |  | #include "Common/CommonTypes.h"
 | 
					
						
							| 
									
										
										
										
											2009-09-09 21:26:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-18 10:37:45 -04:00
										 |  |  | class AlsaSound final : public SoundStream | 
					
						
							| 
									
										
										
										
											2009-09-09 21:26:33 +00:00
										 |  |  | { | 
					
						
							|  |  |  | #if defined(HAVE_ALSA) && HAVE_ALSA
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2015-05-24 04:13:02 -04:00
										 |  |  | 	AlsaSound(); | 
					
						
							| 
									
										
										
										
											2009-09-09 21:26:33 +00:00
										 |  |  | 	virtual ~AlsaSound(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-24 06:02:30 -04:00
										 |  |  | 	bool Start() override; | 
					
						
							|  |  |  | 	void SoundLoop() override; | 
					
						
							|  |  |  | 	void Stop() override; | 
					
						
							|  |  |  | 	void Update() override; | 
					
						
							| 
									
										
										
										
											2009-09-09 21:26:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-30 16:29:15 -04:00
										 |  |  | 	static bool isValid() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-09-09 21:26:33 +00:00
										 |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2015-05-10 02:30:24 -04:00
										 |  |  | 	enum class ALSAThreadStatus | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		RUNNING, | 
					
						
							|  |  |  | 		STOPPING, | 
					
						
							|  |  |  | 		STOPPED, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-09 21:26:33 +00:00
										 |  |  | 	bool AlsaInit(); | 
					
						
							|  |  |  | 	void AlsaShutdown(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	u8 *mix_buffer; | 
					
						
							| 
									
										
										
										
											2011-01-27 21:34:37 +00:00
										 |  |  | 	std::thread thread; | 
					
						
							| 
									
										
										
										
											2015-05-10 02:30:24 -04:00
										 |  |  | 	std::atomic<ALSAThreadStatus> m_thread_status; | 
					
						
							| 
									
										
										
										
											2009-09-09 21:26:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	snd_pcm_t *handle; | 
					
						
							| 
									
										
										
										
											2010-05-21 22:48:57 +00:00
										 |  |  | 	int frames_to_deliver; | 
					
						
							| 
									
										
										
										
											2009-09-09 21:26:33 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | }; |