2022-12-04 11:03:45 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
|
|
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
|
|
|
2020-01-11 03:28:40 +00:00
|
|
|
#pragma once
|
2023-08-13 06:28:28 +00:00
|
|
|
|
|
|
|
#include "audio_stream.h"
|
|
|
|
|
2020-01-11 03:28:40 +00:00
|
|
|
#include <cstdint>
|
|
|
|
|
2022-07-27 14:42:41 +00:00
|
|
|
struct cubeb;
|
|
|
|
struct cubeb_stream;
|
|
|
|
|
|
|
|
class CubebAudioStream : public AudioStream
|
2020-01-11 03:28:40 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-07-27 14:42:41 +00:00
|
|
|
CubebAudioStream(u32 sample_rate, u32 channels, u32 buffer_ms, AudioStretchMode stretch);
|
2020-01-11 03:28:40 +00:00
|
|
|
~CubebAudioStream();
|
|
|
|
|
2022-07-27 14:42:41 +00:00
|
|
|
void SetPaused(bool paused) override;
|
2020-12-12 01:50:37 +00:00
|
|
|
void SetOutputVolume(u32 volume) override;
|
2020-01-11 03:28:40 +00:00
|
|
|
|
2022-07-27 14:42:41 +00:00
|
|
|
bool Initialize(u32 latency_ms);
|
2020-01-11 04:20:51 +00:00
|
|
|
|
2022-07-27 14:42:41 +00:00
|
|
|
private:
|
|
|
|
static void LogCallback(const char* fmt, ...);
|
2020-01-11 03:28:40 +00:00
|
|
|
static long DataCallback(cubeb_stream* stm, void* user_ptr, const void* input_buffer, void* output_buffer,
|
|
|
|
long nframes);
|
|
|
|
|
2022-07-27 14:42:41 +00:00
|
|
|
void DestroyContextAndStream();
|
|
|
|
|
|
|
|
cubeb* m_context = nullptr;
|
|
|
|
cubeb_stream* stream = nullptr;
|
2020-01-11 04:20:51 +00:00
|
|
|
|
2021-06-28 10:16:48 +00:00
|
|
|
#ifdef _WIN32
|
2020-01-11 04:20:51 +00:00
|
|
|
bool m_com_initialized_by_us = false;
|
|
|
|
#endif
|
2020-01-11 03:28:40 +00:00
|
|
|
};
|