2018-09-22 06:30:47 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <portaudio.h>
|
|
|
|
|
|
|
|
#include "renderer.h"
|
|
|
|
|
2018-09-23 04:00:44 +00:00
|
|
|
#define CIRCULAR_BUFFER_SIZE 16
|
2018-09-22 06:30:47 +00:00
|
|
|
#define MAX_CHANNEL_COUNT 6
|
|
|
|
|
|
|
|
#define CIRCULAR_BUFFER_STRIDE (MAX_CHANNEL_COUNT * SAMPLES_PER_FRAME)
|
|
|
|
|
|
|
|
class PortAudioRenderer : public IAudioRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PortAudioRenderer();
|
|
|
|
|
|
|
|
virtual ~PortAudioRenderer();
|
|
|
|
|
|
|
|
virtual bool prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* opusConfig);
|
|
|
|
|
|
|
|
virtual void submitAudio(short* audioBuffer, int audioSize);
|
|
|
|
|
2018-09-30 05:19:41 +00:00
|
|
|
virtual bool testAudio(int audioConfiguration) const;
|
2018-09-22 06:30:47 +00:00
|
|
|
|
2018-09-30 05:19:41 +00:00
|
|
|
virtual int detectAudioConfiguration() const;
|
2018-09-22 06:30:47 +00:00
|
|
|
|
|
|
|
static int paStreamCallback(const void *input,
|
|
|
|
void *output,
|
|
|
|
unsigned long frameCount,
|
|
|
|
const PaStreamCallbackTimeInfo *timeInfo,
|
|
|
|
PaStreamCallbackFlags statusFlags,
|
|
|
|
void *userData);
|
|
|
|
|
|
|
|
private:
|
|
|
|
PaStream* m_Stream;
|
|
|
|
int m_ChannelCount;
|
|
|
|
int m_WriteIndex;
|
|
|
|
int m_ReadIndex;
|
2018-09-29 23:52:40 +00:00
|
|
|
bool m_Started;
|
2018-09-22 06:30:47 +00:00
|
|
|
short m_AudioBuffer[CIRCULAR_BUFFER_SIZE * CIRCULAR_BUFFER_STRIDE];
|
|
|
|
};
|
|
|
|
|