2020-01-11 03:28:40 +00:00
|
|
|
#pragma once
|
|
|
|
#include "common/audio_stream.h"
|
|
|
|
#include "cubeb/cubeb.h"
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
class CubebAudioStream final : public AudioStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CubebAudioStream();
|
|
|
|
~CubebAudioStream();
|
|
|
|
|
2020-10-11 02:04:31 +00:00
|
|
|
static std::unique_ptr<AudioStream> Create();
|
|
|
|
|
2020-01-11 03:28:40 +00:00
|
|
|
protected:
|
|
|
|
bool IsOpen() const { return m_cubeb_stream != nullptr; }
|
|
|
|
|
|
|
|
bool OpenDevice() override;
|
|
|
|
void PauseDevice(bool paused) override;
|
|
|
|
void CloseDevice() override;
|
2020-06-06 04:40:20 +00:00
|
|
|
void FramesAvailable() override;
|
2020-01-11 03:28:40 +00:00
|
|
|
|
2020-01-11 04:20:51 +00:00
|
|
|
void DestroyContext();
|
|
|
|
|
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);
|
|
|
|
static void StateCallback(cubeb_stream* stream, void* user_ptr, cubeb_state state);
|
|
|
|
|
|
|
|
cubeb* m_cubeb_context = nullptr;
|
|
|
|
cubeb_stream* m_cubeb_stream = nullptr;
|
|
|
|
bool m_paused = true;
|
2020-01-11 04:20:51 +00:00
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
bool m_com_initialized_by_us = false;
|
|
|
|
#endif
|
2020-01-11 03:28:40 +00:00
|
|
|
};
|