Merge pull request #4523 from RisingFog/overwrite_audio_warning

Display warning when dumping audio if file exists
This commit is contained in:
Anthony 2017-01-01 17:20:39 -08:00 committed by GitHub
commit a7f7ccc9d2
2 changed files with 38 additions and 8 deletions

View File

@ -214,10 +214,18 @@ void CMixer::StartLogDTKAudio(const std::string& filename)
{
if (!m_log_dtk_audio)
{
m_log_dtk_audio = true;
m_wave_writer_dtk.Start(filename, m_streaming_mixer.GetInputSampleRate());
m_wave_writer_dtk.SetSkipSilence(false);
NOTICE_LOG(AUDIO, "Starting DTK Audio logging");
bool success = m_wave_writer_dtk.Start(filename, m_streaming_mixer.GetInputSampleRate());
if (success)
{
m_log_dtk_audio = true;
m_wave_writer_dtk.SetSkipSilence(false);
NOTICE_LOG(AUDIO, "Starting DTK Audio logging");
}
else
{
m_wave_writer_dtk.Stop();
NOTICE_LOG(AUDIO, "Unable to start DTK Audio logging");
}
}
else
{
@ -243,10 +251,18 @@ void CMixer::StartLogDSPAudio(const std::string& filename)
{
if (!m_log_dsp_audio)
{
m_log_dsp_audio = true;
m_wave_writer_dsp.Start(filename, m_dma_mixer.GetInputSampleRate());
m_wave_writer_dsp.SetSkipSilence(false);
NOTICE_LOG(AUDIO, "Starting DSP Audio logging");
bool success = m_wave_writer_dsp.Start(filename, m_dma_mixer.GetInputSampleRate());
if (success)
{
m_log_dsp_audio = true;
m_wave_writer_dsp.SetSkipSilence(false);
NOTICE_LOG(AUDIO, "Starting DSP Audio logging");
}
else
{
m_wave_writer_dsp.Stop();
NOTICE_LOG(AUDIO, "Unable to start DSP Audio logging");
}
}
else
{

View File

@ -24,6 +24,20 @@ WaveFileWriter::~WaveFileWriter()
bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRate)
{
// Ask to delete file
if (File::Exists(filename))
{
if (AskYesNoT("Delete the existing file '%s'?", filename.c_str()))
{
File::Delete(filename);
}
else
{
// Stop and cancel dumping the audio
return false;
}
}
// Check if the file is already open
if (file)
{