From f2ed5338415d0890df9f45aa2b59829cf0290a68 Mon Sep 17 00:00:00 2001 From: Fog Date: Wed, 15 Oct 2014 20:03:31 -0400 Subject: [PATCH] Start/Stop Audio Dump During Emulation --- Source/Core/AudioCommon/AudioCommon.cpp | 44 ++++++++++++++++--------- Source/Core/AudioCommon/AudioCommon.h | 2 ++ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp index 8afbc1478e8a..cfd2b9e278e7 100644 --- a/Source/Core/AudioCommon/AudioCommon.cpp +++ b/Source/Core/AudioCommon/AudioCommon.cpp @@ -23,6 +23,8 @@ // This shouldn't be a global, at least not here. SoundStream* g_sound_stream = nullptr; +static bool s_audio_dump_start = false; + namespace AudioCommon { SoundStream* InitSoundStream() @@ -66,15 +68,8 @@ namespace AudioCommon UpdateSoundStream(); if (g_sound_stream->Start()) { - if (SConfig::GetInstance().m_DumpAudio) - { - std::string audio_file_name_dtk = File::GetUserPath(D_DUMPAUDIO_IDX) + "dtkdump.wav"; - std::string audio_file_name_dsp = File::GetUserPath(D_DUMPAUDIO_IDX) + "dspdump.wav"; - File::CreateFullPath(audio_file_name_dtk); - File::CreateFullPath(audio_file_name_dsp); - mixer->StartLogDTKAudio(audio_file_name_dtk); - mixer->StartLogDSPAudio(audio_file_name_dsp); - } + if (SConfig::GetInstance().m_DumpAudio && !s_audio_dump_start) + StartAudioDump(); return g_sound_stream; } @@ -95,12 +90,8 @@ namespace AudioCommon if (g_sound_stream) { g_sound_stream->Stop(); - if (SConfig::GetInstance().m_DumpAudio) - { - g_sound_stream->GetMixer()->StopLogDTKAudio(); - g_sound_stream->GetMixer()->StopLogDSPAudio(); - //g_sound_stream->StopLogAudio(); - } + if (SConfig::GetInstance().m_DumpAudio && s_audio_dump_start) + StopAudioDump(); delete g_sound_stream; g_sound_stream = nullptr; } @@ -168,6 +159,11 @@ namespace AudioCommon if (!g_sound_stream) return; + if (SConfig::GetInstance().m_DumpAudio && !s_audio_dump_start) + StartAudioDump(); + else if (!SConfig::GetInstance().m_DumpAudio && s_audio_dump_start) + StopAudioDump(); + CMixer* pMixer = g_sound_stream->GetMixer(); if (pMixer && samples) @@ -177,4 +173,22 @@ namespace AudioCommon g_sound_stream->Update(); } + + void StartAudioDump() + { + std::string audio_file_name_dtk = File::GetUserPath(D_DUMPAUDIO_IDX) + "dtkdump.wav"; + std::string audio_file_name_dsp = File::GetUserPath(D_DUMPAUDIO_IDX) + "dspdump.wav"; + File::CreateFullPath(audio_file_name_dtk); + File::CreateFullPath(audio_file_name_dsp); + g_sound_stream->GetMixer()->StartLogDTKAudio(audio_file_name_dtk); + g_sound_stream->GetMixer()->StartLogDSPAudio(audio_file_name_dsp); + s_audio_dump_start = true; + } + + void StopAudioDump() + { + g_sound_stream->GetMixer()->StopLogDTKAudio(); + g_sound_stream->GetMixer()->StopLogDSPAudio(); + s_audio_dump_start = false; + } } diff --git a/Source/Core/AudioCommon/AudioCommon.h b/Source/Core/AudioCommon/AudioCommon.h index 721dc28700a2..6042562790b1 100644 --- a/Source/Core/AudioCommon/AudioCommon.h +++ b/Source/Core/AudioCommon/AudioCommon.h @@ -21,4 +21,6 @@ namespace AudioCommon void UpdateSoundStream(); void ClearAudioBuffer(bool mute); void SendAIBuffer(short* samples, unsigned int num_samples); + void StartAudioDump(); + void StopAudioDump(); }