Merge pull request #1297 from RisingFog/audio-dump-during-emulation

Start/Stop Audio Dump During Emulation
This commit is contained in:
skidau 2014-10-18 13:16:41 +11:00
commit 0d1f8527c7
2 changed files with 31 additions and 15 deletions

View File

@ -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;
}
}

View File

@ -21,4 +21,6 @@ namespace AudioCommon
void UpdateSoundStream();
void ClearAudioBuffer(bool mute);
void SendAIBuffer(short* samples, unsigned int num_samples);
void StartAudioDump();
void StopAudioDump();
}