gsdx-linux-recorder: upgrade code to use n threads

Unfortunately it requires too much memory (easily 6GB)
This commit is contained in:
Gregory Hainaut 2015-05-18 15:55:08 +02:00
parent cff168e002
commit e7665ee7dd
2 changed files with 11 additions and 10 deletions

View File

@ -381,17 +381,13 @@ static IPin* GetFirstPin(IBaseFilter* pBF, PIN_DIRECTION dir)
GSCapture::GSCapture()
: m_capturing(false), m_frame(0)
, m_out_dir("/tmp/GSdx_Capture") // FIXME Later add an option
, m_threads(4) // option too
{
#ifdef __linux__
m_worker = NULL;
#endif
}
GSCapture::~GSCapture()
{
EndCapture();
delete m_worker;
}
bool GSCapture::BeginCapture(float fps)
@ -495,7 +491,11 @@ bool GSCapture::BeginCapture(float fps)
m_size.x = 1280;
m_size.y = 1024;
m_worker = new GSPng::Worker();
#ifdef __linux__
for(int i = 0; i < m_threads; i++) {
m_workers.push_back(new GSPng::Worker());
}
#endif
#endif
@ -532,7 +532,7 @@ bool GSCapture::DeliverFrame(const void* bits, int pitch, bool rgba)
std::string out_file = m_out_dir + format("/frame.%010d.png", m_frame);
//GSPng::Save(GSPng::RGB_PNG, out_file, (char*)bits, m_size.x, m_size.y, pitch);
m_worker->Push(shared_ptr<GSPng::Transaction>(new GSPng::Transaction(GSPng::RGB_PNG, out_file, (char*)bits, m_size.x, m_size.y, pitch)));
m_workers[m_frame%m_threads]->Push(shared_ptr<GSPng::Transaction>(new GSPng::Transaction(GSPng::RGB_PNG, out_file, (char*)bits, m_size.x, m_size.y, pitch)));
m_frame++;
@ -566,8 +566,8 @@ bool GSCapture::EndCapture()
}
#elif __linux__
if (m_worker) {
m_worker->Wait();
for(size_t i = 0; i < m_workers.size(); i++) {
m_workers[i]->Wait();
}
m_frame = 0;

View File

@ -42,6 +42,7 @@ class GSCapture
GSVector2i m_size;
uint64 m_frame;
std::string m_out_dir;
int m_threads;
#ifdef _WINDOWS
@ -50,7 +51,7 @@ class GSCapture
#elif __linux__
GSPng::Worker* m_worker;
vector<GSPng::Worker*> m_workers;
#endif