mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Pulseaudio: rewrite the pa backend with the async api
The default async api allow us to set some latency options. The old one (simple API) was the lazy way to go for usual audio where latency doesn't matter. This also streams audio, so it should be a bit faster then the old one.
This commit is contained in:
@ -6,8 +6,7 @@
|
||||
#define _PULSE_AUDIO_STREAM_H
|
||||
|
||||
#if defined(HAVE_PULSEAUDIO) && HAVE_PULSEAUDIO
|
||||
#include <pulse/simple.h>
|
||||
#include <pulse/error.h>
|
||||
#include <pulse/pulseaudio.h>
|
||||
#endif
|
||||
|
||||
#include "Common.h"
|
||||
@ -15,8 +14,6 @@
|
||||
|
||||
#include "Thread.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class PulseAudio : public SoundStream
|
||||
{
|
||||
#if defined(HAVE_PULSEAUDIO) && HAVE_PULSEAUDIO
|
||||
@ -32,18 +29,31 @@ public:
|
||||
|
||||
virtual void Update();
|
||||
|
||||
void StateCallback(pa_context *c);
|
||||
void WriteCallback(pa_stream *s, size_t length);
|
||||
void UnderflowCallback(pa_stream *s);
|
||||
|
||||
private:
|
||||
virtual void SoundLoop();
|
||||
|
||||
bool PulseInit();
|
||||
void PulseShutdown();
|
||||
void Write(const void *data, size_t bytes);
|
||||
|
||||
std::vector<s16> mix_buffer;
|
||||
std::thread thread;
|
||||
volatile bool run_thread;
|
||||
// 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);
|
||||
|
||||
pa_simple* pa;
|
||||
std::thread m_thread;
|
||||
bool m_run_thread;
|
||||
|
||||
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) {}
|
||||
|
Reference in New Issue
Block a user