dolphin/Source/Core/AudioCommon/PulseAudioStream.h

64 lines
1.4 KiB
C
Raw Normal View History

// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#if defined(HAVE_PULSEAUDIO) && HAVE_PULSEAUDIO
#include <pulse/pulseaudio.h>
#endif
2014-02-03 14:52:34 -07:00
#include <atomic>
#include "AudioCommon/SoundStream.h"
#include "Common/CommonTypes.h"
#include "Common/Thread.h"
class PulseAudio final : public SoundStream
{
#if defined(HAVE_PULSEAUDIO) && HAVE_PULSEAUDIO
public:
PulseAudio(CMixer *mixer);
2014-03-07 17:54:44 -07:00
virtual bool Start() override;
virtual void Stop() override;
static bool isValid() { return true; }
2014-03-07 17:54:44 -07:00
virtual void Update() override;
void StateCallback(pa_context *c);
void WriteCallback(pa_stream *s, size_t length);
void UnderflowCallback(pa_stream *s);
private:
2014-03-07 17:54:44 -07:00
virtual void SoundLoop() override;
2013-01-09 16:39:19 -07:00
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;
2014-02-03 14:52:34 -07:00
std::atomic<bool> m_run_thread;
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;
#else
public:
PulseAudio(CMixer *mixer) : SoundStream(mixer) {}
#endif
};