rpcsx/rpcs3/Emu/Audio/AudioDumper.cpp

33 lines
567 B
C++
Raw Normal View History

2018-12-20 22:35:49 +00:00
#include "stdafx.h"
#include "AudioDumper.h"
2017-01-25 02:22:19 +03:00
2016-02-02 00:51:35 +03:00
AudioDumper::AudioDumper(u16 ch)
: m_header(ch)
{
2016-02-02 00:51:35 +03:00
if (GetCh())
2015-01-16 17:36:53 +03:00
{
m_output.open(fs::get_cache_dir() + "audio.wav", fs::rewrite);
2016-02-02 00:51:35 +03:00
m_output.write(m_header); // write initial file header
2015-01-16 17:36:53 +03:00
}
}
2016-02-02 00:51:35 +03:00
AudioDumper::~AudioDumper()
{
2016-02-02 00:51:35 +03:00
if (GetCh())
2015-01-16 17:36:53 +03:00
{
2016-02-02 00:51:35 +03:00
m_output.seek(0);
m_output.write(m_header); // rewrite file header
2015-01-16 17:36:53 +03:00
}
}
2016-02-02 00:51:35 +03:00
void AudioDumper::WriteData(const void* buffer, u32 size)
{
2016-02-02 00:51:35 +03:00
if (GetCh())
2014-03-19 04:32:23 +04:00
{
2016-08-15 03:11:49 +03:00
verify(HERE), size, m_output.write(buffer, size) == size;
2016-02-02 00:51:35 +03:00
m_header.Size += size;
m_header.RIFF.Size += size;
2014-03-19 04:32:23 +04:00
}
}