From cb12ad94e4a4f01eb2b76b045dfdfa38db311883 Mon Sep 17 00:00:00 2001 From: Maksym Veremeyenko Date: Tue, 10 Jul 2012 01:10:58 +0300 Subject: [PATCH] add winsock support --- configure.in | 9 +++++++++ src/Makefile.am | 2 +- src/instance.c | 11 +++++++++++ src/player.c | 15 ++++++++++++--- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index da70122..e1a0dad 100644 --- a/configure.in +++ b/configure.in @@ -12,6 +12,15 @@ AM_PROG_CC_C_O AC_HEADER_STDC AC_PROG_CXX +LIBDEP="-lpthread" +case "${host}" in + *-*-mingw32*) + LIBDEP="$LIBDEP -lws2_32 -lwsock32" + ;; +esac +AC_SUBST(LIBDEP) + + PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 1.3.13]) AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) diff --git a/src/Makefile.am b/src/Makefile.am index 7633b2e..42dc663 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,4 +30,4 @@ melted_gui_SOURCES = \ $(MVCP_FILES): ln -s $(MELTED_PATH)/src/mvcp/$@ $@ -melted_gui_LDADD = @GTHREAD_LIBS@ @GTK_LIBS@ @CURL_LIBS@ -lpthread +melted_gui_LDADD = @GTHREAD_LIBS@ @GTK_LIBS@ @CURL_LIBS@ @LIBDEP@ diff --git a/src/instance.c b/src/instance.c index 54a4bf6..df64987 100644 --- a/src/instance.c +++ b/src/instance.c @@ -32,6 +32,10 @@ #include #include +#if defined(__MINGW32__) +#include +#endif + #include "instance.h" #include "ui.h" #include "opts.h" @@ -321,6 +325,13 @@ void instance_init(instance_t* app) int i; pthread_mutexattr_t attr; +#if defined(__MINGW32__) + WORD wVersionRequested; + WSADATA wsaData; + wVersionRequested = MAKEWORD(2, 2); + WSAStartup(wVersionRequested, &wsaData); +#endif + gtk_signal_connect( GTK_OBJECT( app->window ), "delete-event", GTK_SIGNAL_FUNC(on_main_window_delete_event), app); diff --git a/src/player.c b/src/player.c index 206191b..018661f 100644 --- a/src/player.c +++ b/src/player.c @@ -35,6 +35,10 @@ #include #include +#if defined(__MINGW32__) +#include +#endif + #include "player.h" #include "ui.h" #include "timecode.h" @@ -145,12 +149,17 @@ static void* player_thread_proc(void* data) /* endless reconnect loop */ for(; !player->app->f_exit;) { + r = mvcp_connect(handle->command); /* connect */ - if(mvcp_connect(handle->command) != mvcp_ok) + if(mvcp_ok != r) { - g_warning("player_thread_proc: failed to connect to server %s:%d (player=%d, unit=%d)\n", - player->app->players.host, player->app->players.port, player->idx, player->unit); + g_warning("player_thread_proc: failed to connect to server %s:%d (player=%d, unit=%d), r=%d\n", + player->app->players.host, player->app->players.port, player->idx, player->unit, r); +#if defined(__MINGW32__) + Sleep(1000); +#else sleep(1); +#endif continue; }; -- 1.7.4.4