2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-21 00:17:03 -06:00
|
|
|
// Refer to the license.txt file included.
|
2009-10-15 11:28:23 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2009-10-15 11:28:23 -06:00
|
|
|
|
2010-06-05 22:02:16 -06:00
|
|
|
#if defined(HAVE_PULSEAUDIO) && HAVE_PULSEAUDIO
|
2014-01-31 14:00:33 -07:00
|
|
|
#include <pulse/pulseaudio.h>
|
2009-10-15 11:28:23 -06:00
|
|
|
#endif
|
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "AudioCommon/SoundStream.h"
|
2014-09-07 19:06:58 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2016-08-05 08:04:39 -06:00
|
|
|
#include "Common/Flag.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/Thread.h"
|
2009-10-15 11:28:23 -06:00
|
|
|
|
2014-03-18 08:37:45 -06:00
|
|
|
class PulseAudio final : public SoundStream
|
2009-10-15 11:28:23 -06:00
|
|
|
{
|
2010-06-05 22:02:16 -06:00
|
|
|
#if defined(HAVE_PULSEAUDIO) && HAVE_PULSEAUDIO
|
2009-10-15 11:28:23 -06:00
|
|
|
public:
|
2016-06-24 02:43:46 -06:00
|
|
|
PulseAudio();
|
2009-10-15 11:28:23 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
bool Start() override;
|
|
|
|
void Stop() override;
|
|
|
|
void Update() override;
|
2010-08-16 20:14:04 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
static bool isValid() { return true; }
|
|
|
|
void StateCallback(pa_context* c);
|
|
|
|
void WriteCallback(pa_stream* s, size_t length);
|
|
|
|
void UnderflowCallback(pa_stream* s);
|
2014-01-31 14:00:33 -07:00
|
|
|
|
2009-10-15 11:28:23 -06:00
|
|
|
private:
|
2016-06-24 02:43:46 -06:00
|
|
|
void SoundLoop() override;
|
|
|
|
|
|
|
|
bool PulseInit();
|
|
|
|
void PulseShutdown();
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
std::thread m_thread;
|
2016-08-05 08:04:39 -06:00
|
|
|
Common::Flag m_run_thread;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
bool m_stereo; // stereo, else surround
|
|
|
|
int m_bytespersample;
|
|
|
|
int m_channels;
|
|
|
|
|
|
|
|
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 11:28:23 -06:00
|
|
|
#endif
|
|
|
|
};
|