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 08:17:03 +02:00
|
|
|
// Refer to the license.txt file included.
|
2009-10-15 19:28:23 +02:00
|
|
|
|
2014-02-10 19:54:46 +01:00
|
|
|
#pragma once
|
2009-10-15 19:28:23 +02:00
|
|
|
|
2010-06-06 06:02:16 +02:00
|
|
|
#if defined(HAVE_PULSEAUDIO) && HAVE_PULSEAUDIO
|
2014-01-31 22:00:33 +01:00
|
|
|
#include <pulse/pulseaudio.h>
|
2009-10-15 19:28:23 +02:00
|
|
|
#endif
|
|
|
|
|
2014-02-17 11:18:15 +01:00
|
|
|
#include "AudioCommon/SoundStream.h"
|
2014-09-08 03:06:58 +02:00
|
|
|
#include "Common/CommonTypes.h"
|
2016-08-05 16:04:39 +02:00
|
|
|
#include "Common/Flag.h"
|
2014-02-17 11:18:15 +01:00
|
|
|
#include "Common/Thread.h"
|
2009-10-15 19:28:23 +02:00
|
|
|
|
2014-03-18 15:37:45 +01:00
|
|
|
class PulseAudio final : public SoundStream
|
2009-10-15 19:28:23 +02:00
|
|
|
{
|
2010-06-06 06:02:16 +02:00
|
|
|
#if defined(HAVE_PULSEAUDIO) && HAVE_PULSEAUDIO
|
2009-10-15 19:28:23 +02:00
|
|
|
public:
|
2015-05-24 10:13:02 +02:00
|
|
|
PulseAudio();
|
2017-10-22 01:23:40 +02:00
|
|
|
~PulseAudio() override;
|
2009-10-15 19:28:23 +02:00
|
|
|
|
2017-10-22 01:23:40 +02:00
|
|
|
bool Init() override;
|
|
|
|
bool SetRunning(bool running) override { return running; }
|
2015-02-15 20:43:31 +01:00
|
|
|
static bool isValid() { return true; }
|
2014-01-31 22:00:33 +01:00
|
|
|
void StateCallback(pa_context* c);
|
|
|
|
void WriteCallback(pa_stream* s, size_t length);
|
|
|
|
void UnderflowCallback(pa_stream* s);
|
|
|
|
|
2009-10-15 19:28:23 +02:00
|
|
|
private:
|
2015-07-30 12:47:02 +02:00
|
|
|
void SoundLoop() override;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2009-10-15 19:28:23 +02:00
|
|
|
bool PulseInit();
|
|
|
|
void PulseShutdown();
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2014-01-31 22:00:33 +01:00
|
|
|
// wrapper callback functions, last parameter _must_ be PulseAudio*
|
|
|
|
static void StateCallback(pa_context* c, void* userdata);
|
|
|
|
static void WriteCallback(pa_stream* s, size_t length, void* userdata);
|
|
|
|
static void UnderflowCallback(pa_stream* s, void* userdata);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2014-01-31 22:00:33 +01:00
|
|
|
std::thread m_thread;
|
2016-08-05 16:04:39 +02:00
|
|
|
Common::Flag m_run_thread;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-01-07 11:57:20 +01:00
|
|
|
bool m_stereo; // stereo, else surround
|
|
|
|
int m_bytespersample;
|
|
|
|
int m_channels;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2014-01-31 22:00:33 +01:00
|
|
|
int m_pa_error;
|
|
|
|
int m_pa_connected;
|
|
|
|
pa_mainloop* m_pa_ml;
|
|
|
|
pa_mainloop_api* m_pa_mlapi;
|
|
|
|
pa_context* m_pa_ctx;
|
|
|
|
pa_stream* m_pa_s;
|
|
|
|
pa_buffer_attr m_pa_ba;
|
2009-10-15 19:28:23 +02:00
|
|
|
#endif
|
|
|
|
};
|