44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#pragma once
|
|
#include "Singleton.h"
|
|
#include "portaudio.h"
|
|
#include "pa_type.h"
|
|
|
|
class FAudioRenderThread;
|
|
DECLARE_LOG_CATEGORY_EXTERN(PortAudioAPILog, Log, All);
|
|
|
|
class FPortAudioAPI : public TSingleton<FPortAudioAPI>
|
|
{
|
|
public:
|
|
FPortAudioAPI();
|
|
virtual void Init() override;
|
|
virtual void BeginRelease() override;
|
|
virtual void Release() override;
|
|
|
|
void OpenStream(int32 InputDevice, int32 OutputDevice);
|
|
|
|
TArray<FAudioDeviceInfo> GetDevices();
|
|
TArray<FAudioHostInfo> GetHosts();
|
|
|
|
void LogAllDevices();
|
|
|
|
virtual FName GetName() override { return "PortAudioAPI"; }
|
|
|
|
float SampleRate;
|
|
int32 BlockSize;
|
|
int32 GetOutputChannelCount() const;
|
|
|
|
static bool IsInAudioThread();
|
|
|
|
// PortAudio Callback (Internally called by callback function)
|
|
int StreamCallback(SampleType** Input, SampleType** Output, unsigned long FrameCount, const PaStreamCallbackTimeInfo* TimeInfo, PaStreamCallbackFlags StatusFlags);
|
|
|
|
float GetBufferLoad();
|
|
private:
|
|
FAudioRenderThread* RenderThread;
|
|
FRunnableThread* RenderThreadHandle;
|
|
PaStream* StreamHandle;
|
|
|
|
PaStreamParameters InputParameters;
|
|
PaStreamParameters OutputParameters;
|
|
};
|