1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Enable/disable threading support.

This commit is contained in:
Themaister 2011-11-30 17:46:58 +01:00
parent b87f50dc9d
commit a221e3e4cd
7 changed files with 57 additions and 20 deletions

View File

@ -2,11 +2,11 @@ include config.mk
TARGET = ssnes tools/ssnes-joyconfig
OBJ = ssnes.o file.o driver.o settings.o dynamic.o message.o rewind.o movie.o autosave.o gfx/gfx_common.o ups.o bps.o strl.o getopt.o screenshot.o thread.o audio/hermite.o
OBJ = ssnes.o file.o driver.o settings.o dynamic.o message.o rewind.o movie.o gfx/gfx_common.o ups.o bps.o strl.o getopt.o screenshot.o thread.o audio/hermite.o
JOYCONFIG_OBJ = tools/ssnes-joyconfig.o conf/config_file.o strl.o
HEADERS = $(wildcard */*.h) $(wildcard *.h)
LIBS = -lm -lpthread
LIBS = -lm
DEFINES = -DHAVE_CONFIG_H
ifneq ($(findstring Darwin,$(OS)),)
@ -27,6 +27,11 @@ ifneq ($(findstring Linux,$(OS)),)
LIBS += -lrt
endif
ifeq ($(HAVE_THREADS), 1)
OBJ += autosave.o
LIBS += -lpthread
endif
ifeq ($(HAVE_CONFIGFILE), 1)
OBJ += conf/config_file.o
endif

View File

@ -1,6 +1,6 @@
TARGET = ssnes.exe
JTARGET = ssnes-joyconfig.exe
OBJ = ssnes.o file.o driver.o conf/config_file.o settings.o dynamic.o message.o rewind.o movie.o autosave.o gfx/gfx_common.o bps.o ups.o strl.o screenshot.o audio/hermite.o thread.o getopt.o
OBJ = ssnes.o file.o driver.o conf/config_file.o settings.o dynamic.o message.o rewind.o movie.o gfx/gfx_common.o bps.o ups.o strl.o screenshot.o audio/hermite.o thread.o getopt.o
JOBJ = conf/config_file.o tools/main-stub.o tools/ssnes-joyconfig.o strl.o
CC = gcc
@ -13,6 +13,7 @@ HAVE_SDL = 1
HAVE_OPENGL = 1
HAVE_DYLIB = 1
HAVE_NETPLAY = 1
HAVE_THREADS = 1
DYNAMIC = 1
ifeq ($(SLIM),)
@ -39,6 +40,11 @@ ifeq ($(HAVE_SDL), 1)
DEFINES += -ISDL -DHAVE_SDL
endif
ifeq ($(HAVE_THREADS), 1)
OBJ += autosave.o
DEFINES += -DHAVE_THREADS
endif
ifeq ($(HAVE_OPENGL), 1)
DEFINES += -DHAVE_OPENGL
LIBS += -lopengl32

View File

@ -14,6 +14,12 @@ static const bool _sdl_supp = true;
static const bool _sdl_supp = false;
#endif
#ifdef HAVE_THREADS
static const bool _thread_supp = true;
#else
static const bool _thread_supp = false;
#endif
#ifdef HAVE_OPENGL
static const bool _opengl_supp = true;
#else

View File

@ -735,9 +735,13 @@ void netplay_post_frame(netplay_t *handle)
while (first || (handle->tmp_ptr != handle->self_ptr))
{
psnes_serialize(handle->buffer[handle->tmp_ptr].state, handle->state_size);
#ifdef HAVE_THREADS
lock_autosave();
#endif
psnes_run();
#ifdef HAVE_THREADS
unlock_autosave();
#endif
handle->tmp_ptr = NEXT_PTR(handle->tmp_ptr);
first = false;
}

View File

@ -31,6 +31,7 @@ if [ $HAVE_DYNAMIC != yes ]; then
add_define_make libsnes $LIBSNES
fi
check_lib THREADS -lpthread pthread_create
check_lib DYLIB $DYLIB dlopen
check_lib NETPLAY -lc socket
check_lib GETOPT_LONG -lc getopt_long
@ -78,25 +79,30 @@ fi
check_pkgconf XML libxml-2.0
check_pkgconf SDL_IMAGE SDL_image
if [ $HAVE_FFMPEG != no ]; then
check_pkgconf AVCODEC libavcodec
check_pkgconf AVFORMAT libavformat
check_pkgconf AVUTIL libavutil
check_pkgconf SWSCALE libswscale
if [ $HAVE_THREADS != no ]; then
if [ $HAVE_FFMPEG != no ]; then
check_pkgconf AVCODEC libavcodec
check_pkgconf AVFORMAT libavformat
check_pkgconf AVUTIL libavutil
check_pkgconf SWSCALE libswscale
( [ $HAVE_FFMPEG = auto ] && ( [ $HAVE_AVCODEC = no ] || [ $HAVE_AVFORMAT = no ] || [ $HAVE_AVUTIL = no ] || [ $HAVE_SWSCALE = no ] ) && HAVE_FFMPEG=no ) || HAVE_FFMPEG=yes
fi
( [ $HAVE_FFMPEG = auto ] && ( [ $HAVE_AVCODEC = no ] || [ $HAVE_AVFORMAT = no ] || [ $HAVE_AVUTIL = no ] || [ $HAVE_SWSCALE = no ] ) && HAVE_FFMPEG=no ) || HAVE_FFMPEG=yes
fi
if [ $HAVE_FFMPEG = yes ]; then
check_lib FFMPEG_ALLOC_CONTEXT3 "$AVCODEC_LIBS" avcodec_alloc_context3
check_lib FFMPEG_AVCODEC_OPEN2 "$AVCODEC_LIBS" avcodec_open2
check_lib FFMPEG_AVIO_OPEN "$AVFORMAT_LIBS" avio_open
check_lib FFMPEG_AVFORMAT_WRITE_HEADER "$AVFORMAT_LIBS" avformat_write_header
check_lib FFMPEG_AVFORMAT_NEW_STREAM "$AVFORMAT_LIBS" avformat_new_stream
fi
if [ $HAVE_FFMPEG = yes ]; then
check_lib FFMPEG_ALLOC_CONTEXT3 "$AVCODEC_LIBS" avcodec_alloc_context3
check_lib FFMPEG_AVCODEC_OPEN2 "$AVCODEC_LIBS" avcodec_open2
check_lib FFMPEG_AVIO_OPEN "$AVFORMAT_LIBS" avio_open
check_lib FFMPEG_AVFORMAT_WRITE_HEADER "$AVFORMAT_LIBS" avformat_write_header
check_lib FFMPEG_AVFORMAT_NEW_STREAM "$AVFORMAT_LIBS" avformat_new_stream
fi
if [ $HAVE_FFMPEG = no ] && [ $HAVE_X264RGB = yes ]; then
echo "x264 RGB recording is enabled, but FFmpeg is not. --enable-x264rgb will not have any effect."
if [ $HAVE_FFMPEG = no ] && [ $HAVE_X264RGB = yes ]; then
echo "x264 RGB recording is enabled, but FFmpeg is not. --enable-x264rgb will not have any effect."
fi
else
echo "Not building with threading support. Will skip FFmpeg."
HAVE_FFMPEG=no
fi
check_lib DYNAMIC $DYLIB dlopen
@ -118,7 +124,7 @@ check_pkgconf PYTHON python3
add_define_make OS $OS
# Creates config.mk and config.h.
VARS="ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL OPENGL DYLIB GETOPT_LONG CG XML SDL_IMAGE DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE CONFIGFILE FREETYPE XVIDEO X11 XEXT NETPLAY FBO STRL PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM X264RGB"
VARS="ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL OPENGL DYLIB GETOPT_LONG THREADS CG XML SDL_IMAGE DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE CONFIGFILE FREETYPE XVIDEO X11 XEXT NETPLAY FBO STRL PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM X264RGB"
create_config_make config.mk $VARS
create_config_header config.h $VARS

View File

@ -9,6 +9,7 @@ PACKAGE_VERSION=0.9.2
# $3: Default arg. auto implies that HAVE_ALSA will be set according to library checks later on.
add_command_line_enable DYNAMIC "Disable dynamic loading of libsnes library" yes
add_command_line_string LIBSNES "libsnes library used" ""
add_command_line_enable THREADS "Threading support" auto
add_command_line_enable FFMPEG "Enable FFmpeg recording support" auto
add_command_line_enable X264RGB "Enable lossless X264 RGB recording" no
add_command_line_enable DYLIB "Enable dynamic loading support" auto

View File

@ -406,6 +406,7 @@ static void print_features(void)
puts("");
puts("Features:");
_PSUPP(sdl, "SDL", "SDL drivers");
_PSUPP(thread, "Threads", "Threading support");
_PSUPP(opengl, "OpenGL", "OpenGL driver");
_PSUPP(xvideo, "XVideo", "XVideo output");
_PSUPP(alsa, "ALSA", "audio driver");
@ -1212,6 +1213,7 @@ static void deinit_netplay(void)
static void init_autosave(void)
{
#ifdef HAVE_THREADS
int ram_types[2] = {-1, -1};
const char *ram_paths[2] = {NULL, NULL};
@ -1261,15 +1263,18 @@ static void init_autosave(void)
}
}
}
#endif
}
static void deinit_autosave(void)
{
#ifdef HAVE_THREADS
for (unsigned i = 0; i < sizeof(g_extern.autosave)/sizeof(g_extern.autosave[0]); i++)
{
if (g_extern.autosave[i])
autosave_free(g_extern.autosave[i]);
}
#endif
}
static void set_savestate_auto_index(void)
@ -2032,7 +2037,9 @@ int main(int argc, char *argv[])
// Run libsnes for one frame.
if (!g_extern.is_paused || g_extern.is_oneshot)
{
#ifdef HAVE_THREADS
lock_autosave();
#endif
#ifdef HAVE_NETPLAY
if (g_extern.netplay)
@ -2050,7 +2057,9 @@ int main(int argc, char *argv[])
netplay_post_frame(g_extern.netplay);
#endif
#ifdef HAVE_THREADS
unlock_autosave();
#endif
}
else
{