2013-04-21 06:17:03 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-10-15 17:28:23 +00:00
|
|
|
|
|
|
|
#ifndef _PULSE_AUDIO_STREAM_H
|
|
|
|
#define _PULSE_AUDIO_STREAM_H
|
|
|
|
|
2010-06-06 04:02:16 +00:00
|
|
|
#if defined(HAVE_PULSEAUDIO) && HAVE_PULSEAUDIO
|
2014-01-31 21:00:33 +00:00
|
|
|
#include <pulse/pulseaudio.h>
|
2009-10-15 17:28:23 +00:00
|
|
|
#endif
|
|
|
|
|
2014-02-03 21:52:34 +00:00
|
|
|
#include <atomic>
|
|
|
|
|
2009-10-15 17:28:23 +00:00
|
|
|
#include "Common.h"
|
|
|
|
#include "SoundStream.h"
|
|
|
|
|
|
|
|
#include "Thread.h"
|
|
|
|
|
|
|
|
class PulseAudio : public SoundStream
|
|
|
|
{
|
2010-06-06 04:02:16 +00:00
|
|
|
#if defined(HAVE_PULSEAUDIO) && HAVE_PULSEAUDIO
|
2009-10-15 17:28:23 +00:00
|
|
|
public:
|
|
|
|
PulseAudio(CMixer *mixer);
|
|
|
|
|
|
|
|
virtual bool Start();
|
2013-10-29 05:23:17 +00:00
|
|
|
virtual void Stop();
|
2010-08-17 02:14:04 +00:00
|
|
|
|
|
|
|
static bool isValid() {return true;}
|
2009-10-15 17:28:23 +00:00
|
|
|
|
2010-08-17 02:14:04 +00:00
|
|
|
virtual bool usesMixer() const {return true;}
|
2009-10-15 17:28:23 +00:00
|
|
|
|
|
|
|
virtual void Update();
|
|
|
|
|
2014-01-31 21:00:33 +00:00
|
|
|
void StateCallback(pa_context *c);
|
|
|
|
void WriteCallback(pa_stream *s, size_t length);
|
|
|
|
void UnderflowCallback(pa_stream *s);
|
|
|
|
|
2009-10-15 17:28:23 +00:00
|
|
|
private:
|
2010-08-17 02:14:04 +00:00
|
|
|
virtual void SoundLoop();
|
2013-01-09 23:39:19 +00:00
|
|
|
|
2009-10-15 17:28:23 +00:00
|
|
|
bool PulseInit();
|
|
|
|
void PulseShutdown();
|
|
|
|
|
2014-01-31 21:00:33 +00: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);
|
|
|
|
|
|
|
|
std::thread m_thread;
|
2014-02-03 21:52:34 +00:00
|
|
|
std::atomic<bool> m_run_thread;
|
2014-01-31 21:00:33 +00: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 17:28:23 +00:00
|
|
|
#else
|
|
|
|
public:
|
|
|
|
PulseAudio(CMixer *mixer) : SoundStream(mixer) {}
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|