2017-03-22 23:09:59 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-03-22 23:09:59 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstddef>
|
2022-06-18 03:31:14 +00:00
|
|
|
#include <functional>
|
2017-03-22 23:09:59 +00:00
|
|
|
#include <memory>
|
2017-05-28 03:50:39 +00:00
|
|
|
#include <vector>
|
2017-03-22 23:09:59 +00:00
|
|
|
|
|
|
|
#include "AudioCommon/SoundStream.h"
|
2022-06-18 03:31:14 +00:00
|
|
|
#include "Common/WorkQueueThread.h"
|
2017-03-22 23:09:59 +00:00
|
|
|
|
|
|
|
#include <cubeb/cubeb.h>
|
|
|
|
|
|
|
|
class CubebStream final : public SoundStream
|
|
|
|
{
|
|
|
|
public:
|
2022-06-18 03:31:14 +00:00
|
|
|
CubebStream();
|
|
|
|
CubebStream(const CubebStream& other) = delete;
|
|
|
|
CubebStream(CubebStream&& other) = delete;
|
|
|
|
CubebStream& operator=(const CubebStream& other) = delete;
|
|
|
|
CubebStream& operator=(CubebStream&& other) = delete;
|
2017-10-21 23:23:40 +00:00
|
|
|
~CubebStream() override;
|
|
|
|
bool Init() override;
|
|
|
|
bool SetRunning(bool running) override;
|
2017-03-22 23:09:59 +00:00
|
|
|
void SetVolume(int) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_stereo = false;
|
2017-04-24 06:55:37 +00:00
|
|
|
std::shared_ptr<cubeb> m_ctx;
|
2017-03-22 23:09:59 +00:00
|
|
|
cubeb_stream* m_stream = nullptr;
|
|
|
|
|
|
|
|
std::vector<short> m_short_buffer;
|
|
|
|
std::vector<float> m_floatstereo_buffer;
|
|
|
|
|
2022-06-18 03:31:14 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
Common::WorkQueueThread<std::function<void()>> m_work_queue;
|
|
|
|
bool m_coinit_success = false;
|
2022-11-27 02:58:16 +00:00
|
|
|
bool m_should_couninit = false;
|
2022-06-18 03:31:14 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-22 23:09:59 +00:00
|
|
|
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);
|
|
|
|
};
|