Implemented proper timing in the "No audio output" back-end.

This commit is contained in:
skidau 2012-07-01 17:07:58 +10:00
parent b4ec836aca
commit c57640dfbd

View file

@ -17,6 +17,8 @@
#include "AudioCommon.h"
#include "NullSoundStream.h"
#include "../../Core/Src/HW/SystemTimers.h"
#include "../../Core/Src/HW/AudioInterface.h"
void NullSound::SoundLoop()
{
@ -33,9 +35,14 @@ void NullSound::SetVolume(int volume)
void NullSound::Update()
{
// This should equal AUDIO_DMA_PERIOD. TODO: Fix after DSP merge
int numBytesToRender = 32000 * 4 / 32;
m_mixer->Mix(realtimeBuffer, numBytesToRender / 4);
// num_samples_to_render in this update - depends on SystemTimers::AUDIO_DMA_PERIOD.
const u32 stereo_16_bit_size = 4;
const u32 dma_length = 32;
const u64 audio_dma_period = SystemTimers::GetTicksPerSecond() / (AudioInterface::GetAIDSampleRate() * stereo_16_bit_size / dma_length);
const u64 ais_samples_per_second = 48000 * stereo_16_bit_size;
const u64 num_samples_to_render = (audio_dma_period * ais_samples_per_second) / SystemTimers::GetTicksPerSecond();
m_mixer->Mix(realtimeBuffer, (unsigned int)num_samples_to_render);
}
void NullSound::Clear(bool mute)