mirror of https://github.com/PCSX2/pcsx2.git
SPU2-X: Improved fix for wave recoding crashes; using thread-safe mutex locks. :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2662 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
a93b0fe4a4
commit
1461281f5f
|
@ -310,7 +310,7 @@ void SndBuffer::Write( const StereoOut32& Sample )
|
||||||
// Log final output to wavefile.
|
// Log final output to wavefile.
|
||||||
WaveDump::WriteCore( 1, CoreSrc_External, Sample.DownSample() );
|
WaveDump::WriteCore( 1, CoreSrc_External, Sample.DownSample() );
|
||||||
|
|
||||||
RecordWrite( Sample.DownSample() );
|
if( WavRecordEnabled ) RecordWrite( Sample.DownSample() );
|
||||||
|
|
||||||
if(mods[OutputModule] == &NullOut) // null output doesn't need buffering or stretching! :p
|
if(mods[OutputModule] == &NullOut) // null output doesn't need buffering or stretching! :p
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -492,6 +492,8 @@ extern SndOutModule* mods[];
|
||||||
|
|
||||||
// =====================================================================================================
|
// =====================================================================================================
|
||||||
|
|
||||||
|
extern bool WavRecordEnabled;
|
||||||
|
|
||||||
extern void RecordStart();
|
extern void RecordStart();
|
||||||
extern void RecordStop();
|
extern void RecordStop();
|
||||||
extern void RecordWrite( const StereoOut16& sample );
|
extern void RecordWrite( const StereoOut16& sample );
|
||||||
|
|
|
@ -91,32 +91,43 @@ namespace WaveDump
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WavOutFile* m_wavrecord = NULL;
|
#include "Utilities/Threading.h"
|
||||||
|
|
||||||
|
using namespace Threading;
|
||||||
|
|
||||||
|
bool WavRecordEnabled = false;
|
||||||
|
|
||||||
|
static WavOutFile* m_wavrecord = NULL;
|
||||||
|
static Mutex WavRecordMutex;
|
||||||
|
|
||||||
void RecordStart()
|
void RecordStart()
|
||||||
{
|
{
|
||||||
safe_delete( m_wavrecord );
|
WavRecordEnabled = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ScopedLock lock( WavRecordMutex );
|
||||||
|
safe_delete( m_wavrecord );
|
||||||
m_wavrecord = new WavOutFile( "recording.wav", 48000, 16, 2 );
|
m_wavrecord = new WavOutFile( "recording.wav", 48000, 16, 2 );
|
||||||
|
WavRecordEnabled = true;
|
||||||
}
|
}
|
||||||
catch( std::runtime_error& )
|
catch( std::runtime_error& )
|
||||||
{
|
{
|
||||||
|
m_wavrecord = NULL; // not needed, but what the heck. :)
|
||||||
SysMessage("SPU2-X couldn't open file for recording: %s.\nRecording to wavfile disabled.", "recording.wav");
|
SysMessage("SPU2-X couldn't open file for recording: %s.\nRecording to wavfile disabled.", "recording.wav");
|
||||||
m_wavrecord = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecordStop()
|
void RecordStop()
|
||||||
{
|
{
|
||||||
WavOutFile* t = m_wavrecord;
|
WavRecordEnabled = false;
|
||||||
m_wavrecord = NULL;
|
ScopedLock lock( WavRecordMutex );
|
||||||
delete t;
|
safe_delete( m_wavrecord );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecordWrite( const StereoOut16& sample )
|
void RecordWrite( const StereoOut16& sample )
|
||||||
{
|
{
|
||||||
|
ScopedLock lock( WavRecordMutex );
|
||||||
if( m_wavrecord == NULL ) return;
|
if( m_wavrecord == NULL ) return;
|
||||||
m_wavrecord->write( (s16*)&sample, 2 );
|
m_wavrecord->write( (s16*)&sample, 2 );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue