Skip to content

Commit

Permalink
Merge pull request #1297 from RisingFog/audio-dump-during-emulation
Browse files Browse the repository at this point in the history
Start/Stop Audio Dump During Emulation
  • Loading branch information
skidau committed Oct 18, 2014
2 parents c80ba87 + f2ed533 commit 0d1f852
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
44 changes: 29 additions & 15 deletions Source/Core/AudioCommon/AudioCommon.cpp
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
}
2 changes: 2 additions & 0 deletions Source/Core/AudioCommon/AudioCommon.h
Expand Up @@ -21,4 +21,6 @@ namespace AudioCommon
void UpdateSoundStream();
void ClearAudioBuffer(bool mute);
void SendAIBuffer(short* samples, unsigned int num_samples);
void StartAudioDump();
void StopAudioDump();
}

0 comments on commit 0d1f852

Please sign in to comment.