2019-02-16 11:23:01 -05:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "SoundMixer.h"
|
|
|
|
|
|
|
|
SoundMixer::SoundMixer()
|
|
|
|
{
|
|
|
|
_audioDevice = nullptr;
|
|
|
|
_sampleRate = 32000;
|
|
|
|
}
|
|
|
|
|
|
|
|
SoundMixer::~SoundMixer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoundMixer::RegisterAudioDevice(IAudioDevice *audioDevice)
|
|
|
|
{
|
|
|
|
_audioDevice = audioDevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoundMixer::StopAudio(bool clearBuffer)
|
|
|
|
{
|
|
|
|
if(_audioDevice) {
|
|
|
|
if(clearBuffer) {
|
|
|
|
_audioDevice->Stop();
|
|
|
|
} else {
|
|
|
|
_audioDevice->Pause();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoundMixer::PlayAudioBuffer(int16_t* samples, uint32_t sampleCount)
|
|
|
|
{
|
|
|
|
if(_audioDevice) {
|
|
|
|
_audioDevice->PlayBuffer(samples, sampleCount, _sampleRate, true);
|
2019-02-21 16:49:19 -05:00
|
|
|
_audioDevice->ProcessEndOfFrame();
|
2019-02-16 11:23:01 -05:00
|
|
|
}
|
|
|
|
}
|