mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
Merge pull request #10741 from Pokechu22/audio-dma-one-block-at-a-time
DSP: Copy audio dma samples one block at a time
This commit is contained in:
commit
4787b25a7f
@ -119,10 +119,16 @@ void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count,
|
|||||||
u32 sample_rate_divisor, int l_volume, int r_volume)
|
u32 sample_rate_divisor, int l_volume, int r_volume)
|
||||||
{
|
{
|
||||||
if (!file)
|
if (!file)
|
||||||
|
{
|
||||||
ERROR_LOG_FMT(AUDIO, "WaveFileWriter - file not open.");
|
ERROR_LOG_FMT(AUDIO, "WaveFileWriter - file not open.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (count > BUFFER_SIZE * 2)
|
if (count * 2 > BUFFER_SIZE)
|
||||||
|
{
|
||||||
ERROR_LOG_FMT(AUDIO, "WaveFileWriter - buffer too small (count = {}).", count);
|
ERROR_LOG_FMT(AUDIO, "WaveFileWriter - buffer too small (count = {}).", count);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (skip_silence)
|
if (skip_silence)
|
||||||
{
|
{
|
||||||
|
@ -418,7 +418,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
|||||||
bool already_enabled = state.audio_dma.AudioDMAControl.Enable;
|
bool already_enabled = state.audio_dma.AudioDMAControl.Enable;
|
||||||
state.audio_dma.AudioDMAControl.Hex = val;
|
state.audio_dma.AudioDMAControl.Hex = val;
|
||||||
|
|
||||||
// Only load new values if were not already doing a DMA transfer,
|
// Only load new values if we're not already doing a DMA transfer,
|
||||||
// otherwise just let the new values be autoloaded in when the
|
// otherwise just let the new values be autoloaded in when the
|
||||||
// current transfer ends.
|
// current transfer ends.
|
||||||
if (!already_enabled && state.audio_dma.AudioDMAControl.Enable)
|
if (!already_enabled && state.audio_dma.AudioDMAControl.Enable)
|
||||||
@ -429,10 +429,6 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
|||||||
INFO_LOG_FMT(AUDIO_INTERFACE, "Audio DMA configured: {} blocks from {:#010x}",
|
INFO_LOG_FMT(AUDIO_INTERFACE, "Audio DMA configured: {} blocks from {:#010x}",
|
||||||
state.audio_dma.AudioDMAControl.NumBlocks, state.audio_dma.SourceAddress);
|
state.audio_dma.AudioDMAControl.NumBlocks, state.audio_dma.SourceAddress);
|
||||||
|
|
||||||
// We make the samples ready as soon as possible
|
|
||||||
void* address = Memory::GetPointer(state.audio_dma.SourceAddress);
|
|
||||||
AudioCommon::SendAIBuffer((short*)address, state.audio_dma.AudioDMAControl.NumBlocks * 8);
|
|
||||||
|
|
||||||
// TODO: need hardware tests for the timing of this interrupt.
|
// TODO: need hardware tests for the timing of this interrupt.
|
||||||
// Sky Crawlers crashes at boot if this is scheduled less than 87 cycles in the future.
|
// Sky Crawlers crashes at boot if this is scheduled less than 87 cycles in the future.
|
||||||
// Other Namco games crash too, see issue 9509. For now we will just push it to 200 cycles
|
// Other Namco games crash too, see issue 9509. For now we will just push it to 200 cycles
|
||||||
@ -524,6 +520,8 @@ void UpdateAudioDMA()
|
|||||||
// Read audio at g_audioDMA.current_source_address in RAM and push onto an
|
// Read audio at g_audioDMA.current_source_address in RAM and push onto an
|
||||||
// external audio fifo in the emulator, to be mixed with the disc
|
// external audio fifo in the emulator, to be mixed with the disc
|
||||||
// streaming output.
|
// streaming output.
|
||||||
|
void* address = Memory::GetPointer(state.audio_dma.current_source_address);
|
||||||
|
AudioCommon::SendAIBuffer(reinterpret_cast<short*>(address), 8);
|
||||||
|
|
||||||
if (state.audio_dma.remaining_blocks_count != 0)
|
if (state.audio_dma.remaining_blocks_count != 0)
|
||||||
{
|
{
|
||||||
@ -536,12 +534,6 @@ void UpdateAudioDMA()
|
|||||||
state.audio_dma.current_source_address = state.audio_dma.SourceAddress;
|
state.audio_dma.current_source_address = state.audio_dma.SourceAddress;
|
||||||
state.audio_dma.remaining_blocks_count = state.audio_dma.AudioDMAControl.NumBlocks;
|
state.audio_dma.remaining_blocks_count = state.audio_dma.AudioDMAControl.NumBlocks;
|
||||||
|
|
||||||
if (state.audio_dma.remaining_blocks_count != 0)
|
|
||||||
{
|
|
||||||
// We make the samples ready as soon as possible
|
|
||||||
void* address = Memory::GetPointer(state.audio_dma.SourceAddress);
|
|
||||||
AudioCommon::SendAIBuffer((short*)address, state.audio_dma.AudioDMAControl.NumBlocks * 8);
|
|
||||||
}
|
|
||||||
GenerateDSPInterrupt(DSP::INT_AID);
|
GenerateDSPInterrupt(DSP::INT_AID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user