Suppost boost threads for MT dumping
This commit is contained in:
parent
291024486a
commit
354d0edd75
5 changed files with 53 additions and 66 deletions
9
Makefile
9
Makefile
|
@ -43,12 +43,17 @@ endif
|
|||
#Threads
|
||||
ifdef THREADS
|
||||
ifeq ($(THREADS), YES)
|
||||
CFLAGS += -DUSE_THREADS
|
||||
CFLAGS += -DSTD_THREADS
|
||||
else
|
||||
ifeq ($(THREADS), BOOST)
|
||||
CFLAGS += -DBOOST_THREADS
|
||||
LDFLAGS += -lboost_thread-mt
|
||||
else
|
||||
ifeq ($(THREADS), NO)
|
||||
CFLAGS += -DNO_THREADS
|
||||
else
|
||||
$(error "Bad value for THREADS (expected YES or NO)")
|
||||
$(error "Bad value for THREADS (expected YES, BOOST or NO)")
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -798,7 +798,7 @@ void avi_cscd_dumper::video(const void* framedata) throw(std::bad_alloc, std::ru
|
|||
frame_cond.notify_all();
|
||||
//std::cerr << "Requesting processing of frame" << std::endl;
|
||||
frame_mutex.unlock();
|
||||
#ifndef REALLY_USE_THREADS
|
||||
#ifndef ACTUALLY_USE_THREADS
|
||||
_video(framedata);
|
||||
#endif
|
||||
}
|
||||
|
@ -1068,7 +1068,7 @@ void avi_cscd_dumper::request_flush_buffers(bool forced)
|
|||
frame_cond.notify_all();
|
||||
//std::cerr << "Requesting buffer flush (" << flush_requested_forced << ")" << std::endl;
|
||||
frame_mutex.unlock();
|
||||
#ifndef REALLY_USE_THREADS
|
||||
#ifndef ACTUALLY_USE_THREADS
|
||||
flush_buffers(forced);
|
||||
#endif
|
||||
}
|
||||
|
|
68
avi/cscd.hpp
68
avi/cscd.hpp
|
@ -1,88 +1,56 @@
|
|||
#ifndef _output_cscd__hpp__included__
|
||||
#define _output_cscd__hpp__included__
|
||||
|
||||
#ifdef USE_THREADS
|
||||
#define REALLY_USE_THREADS 1
|
||||
#endif
|
||||
#ifndef NO_THREADS
|
||||
#ifdef __linux__
|
||||
#define REALLY_USE_THREADS 1
|
||||
#endif
|
||||
#if defined(__linux__) && !defined(BOOST_THREADS) && !defined(NO_THREADS)
|
||||
#define STD_THREADS 1
|
||||
#endif
|
||||
|
||||
#ifdef REALLY_USE_THREADS
|
||||
|
||||
|
||||
#ifdef BOOST_THREADS
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
|
||||
#define ACTUALLY_USE_THREADS
|
||||
typedef boost::thread thread_class;
|
||||
typedef boost::condition_variable cv_class;
|
||||
typedef boost::mutex mutex_class;
|
||||
typedef boost::unique_lock<boost::mutex> umutex_class;
|
||||
|
||||
#else
|
||||
#ifdef STD_THREADS
|
||||
#include <thread>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
|
||||
/**
|
||||
* Class of thread.
|
||||
*/
|
||||
#define ACTUALLY_USE_THREADS
|
||||
typedef std::thread thread_class;
|
||||
|
||||
/**
|
||||
* Class of condition variables.
|
||||
*/
|
||||
typedef std::condition_variable cv_class;
|
||||
|
||||
/**
|
||||
* Class of mutexes.
|
||||
*/
|
||||
typedef std::mutex mutex_class;
|
||||
|
||||
/**
|
||||
* Class of unique mutexes (for condition variable waiting).
|
||||
*/
|
||||
typedef std::unique_lock<std::mutex> umutex_class;
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Class of thread.
|
||||
*/
|
||||
struct thread_class
|
||||
{
|
||||
/**
|
||||
* Does nothing.
|
||||
*/
|
||||
template<typename T, typename args>
|
||||
thread_class(T obj, args a) {}
|
||||
/**
|
||||
* Does nothing.
|
||||
*/
|
||||
void join() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Class of mutexes.
|
||||
*/
|
||||
typedef struct mutex_class
|
||||
{
|
||||
/**
|
||||
* Does nothing.
|
||||
*/
|
||||
void lock() {}
|
||||
/**
|
||||
* Does nothing.
|
||||
*/
|
||||
void unlock() {}
|
||||
} umutex_class;
|
||||
|
||||
/**
|
||||
* Class of condition variables.
|
||||
*/
|
||||
struct cv_class
|
||||
{
|
||||
/**
|
||||
* Does nothing.
|
||||
*/
|
||||
void wait(umutex_class& m) {}
|
||||
/**
|
||||
* Does nothing.
|
||||
*/
|
||||
void notify_all() {}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
|
15
manual.lyx
15
manual.lyx
|
@ -101,6 +101,10 @@ boost_iostreams
|
|||
boost_filesystem
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
boost_thread
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
libsdl (SDL only)
|
||||
\end_layout
|
||||
|
@ -122,7 +126,8 @@ Portaudio (portaudio sound only)
|
|||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
std::thread and co (for threaded dumper only)
|
||||
std::thread and co (for threaded dumper only, not needed if std::thread
|
||||
is available)
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
|
@ -316,7 +321,7 @@ Default is not to build Lua support.
|
|||
|
||||
\end_deeper
|
||||
\begin_layout Itemize
|
||||
THREADS=<bool>
|
||||
THREADS=<value>
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
|
@ -329,7 +334,11 @@ Threading is default on Linux.
|
|||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
'YES' tries to use threading.
|
||||
'YES' tries to use threading (std::thread).
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
'BOOST' tries to use threading (boost::thread).
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
|
|
23
manual.txt
23
manual.txt
|
@ -18,19 +18,22 @@ lsnes is SNES rerecording emulator based on bsnes core.
|
|||
|
||||
4. boost_filesystem
|
||||
|
||||
5. libsdl (SDL only)
|
||||
5. boost_thread
|
||||
|
||||
6. sdlmain (SDL only, part of SDL)
|
||||
6. libsdl (SDL only)
|
||||
|
||||
7. boost_conversion (this is header-only library)
|
||||
7. sdlmain (SDL only, part of SDL)
|
||||
|
||||
8. libswscale (wxwidgets graphics only)
|
||||
8. boost_conversion (this is header-only library)
|
||||
|
||||
9. Portaudio (portaudio sound only)
|
||||
9. libswscale (wxwidgets graphics only)
|
||||
|
||||
10. std::thread and co (for threaded dumper only)
|
||||
10. Portaudio (portaudio sound only)
|
||||
|
||||
11. Lua (if Lua support is needed).
|
||||
11. std::thread and co (for threaded dumper only, not needed if
|
||||
std::thread is available)
|
||||
|
||||
12. Lua (if Lua support is needed).
|
||||
|
||||
• Version 5.1.X or 5.2X.
|
||||
|
||||
|
@ -119,13 +122,15 @@ Building is via makefile, the following options are available:
|
|||
|
||||
– Default is not to build Lua support.
|
||||
|
||||
• THREADS=<bool>
|
||||
• THREADS=<value>
|
||||
|
||||
– Override platform default for dumper threading support.
|
||||
|
||||
– Threading is default on Linux.
|
||||
|
||||
– 'YES' tries to use threading.
|
||||
– 'YES' tries to use threading (std::thread).
|
||||
|
||||
– 'BOOST' tries to use threading (boost::thread).
|
||||
|
||||
– 'NO' disables threading.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue