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
1 changed files with 10 additions and 3 deletions

View File

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