mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 13:57:57 -07:00
dca22e08eb
Replaces old and simple usages of std::atomic<bool> with Common::Flag (which was introduced after the initial usage), so it's clear that the variable is a flag and because Common::Flag is well tested. This also replaces the ready logic in WiimoteReal with Common::Event since it was basically just unnecessarily reimplementing Common::Event.
58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
// Copyright 2008 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
|
|
|
|
#include "AudioCommon/SoundStream.h"
|
|
#include "Common/CommonTypes.h"
|
|
#include "Common/Flag.h"
|
|
#include "Common/Thread.h"
|
|
|
|
class PulseAudio final : public SoundStream
|
|
{
|
|
#if defined(HAVE_PULSEAUDIO) && HAVE_PULSEAUDIO
|
|
public:
|
|
PulseAudio();
|
|
|
|
bool Start() override;
|
|
void Stop() override;
|
|
void Update() override;
|
|
|
|
static bool isValid() { return true; }
|
|
void StateCallback(pa_context* c);
|
|
void WriteCallback(pa_stream* s, size_t length);
|
|
void UnderflowCallback(pa_stream* s);
|
|
|
|
private:
|
|
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;
|
|
Common::Flag 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;
|
|
#endif
|
|
};
|