dolphin/Source/Core/AudioCommon/CubebStream.h
Weston Heard 1301cec538 WiimoteAudio: Add individual Wiimote audio mixer
Added Platform checks, Incremented state ID

Removed semicolon from PR version comment

Riveting change

Changed Remote Names and References

Updated Wii remote Audio routing to only show
enabled when not using passthrough adapter,
enabling speaker data, and  Cubeb audio backend,
and show enable/disable per Remote when supported
2026-03-20 17:09:01 -04:00

65 lines
1.8 KiB
C++

// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <array>
#include <memory>
#include <vector>
#include "AudioCommon/SoundStream.h"
#ifdef _WIN32
#include "Common/WorkQueueThread.h"
#endif
#ifdef HAVE_CUBEB
#include <cubeb/cubeb.h>
#endif
class CubebStream final : public SoundStream
{
#ifdef HAVE_CUBEB
public:
CubebStream();
CubebStream(const CubebStream& other) = delete;
CubebStream(CubebStream&& other) = delete;
CubebStream& operator=(const CubebStream& other) = delete;
CubebStream& operator=(CubebStream&& other) = delete;
~CubebStream() override;
bool Init() override;
bool SetRunning(bool running) override;
void SetVolume(int) override;
static bool IsValid() { return true; }
private:
struct WiimoteStreamData
{
CubebStream* self;
std::size_t wiimote_index;
};
bool m_stereo = false;
std::shared_ptr<cubeb> m_ctx;
cubeb_stream* m_stream = nullptr;
std::array<WiimoteStreamData, 4> m_wiimote_stream_data{};
std::array<cubeb_stream*, 4> m_wiimote_streams{};
std::vector<short> m_short_buffer;
std::vector<float> m_floatstereo_buffer;
#ifdef _WIN32
Common::AsyncWorkThread m_work_queue;
bool m_coinit_success = false;
bool m_should_couninit = false;
#endif
static long DataCallback(cubeb_stream* stream, void* user_data, const void* /*input_buffer*/,
void* output_buffer, long num_frames);
static void StateCallback(cubeb_stream* stream, void* user_data, cubeb_state state);
static long WiimoteDataCallback(cubeb_stream* stream, void* user_data,
const void* /*input_buffer*/, void* output_buffer,
long num_frames);
static void WiimoteStateCallback(cubeb_stream* stream, void* user_data, cubeb_state state);
#endif
};