Winsock2 is needed on MinGW (or other pure Win32 toolchains) for
networking, select(), ntohl(), etc.
This commit is contained in:
parent
b91517e761
commit
9c63ffa546
36
src/main.c
36
src/main.c
@ -75,6 +75,11 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
DEFAULT_BUFFER_SIZE = 2048,
|
DEFAULT_BUFFER_SIZE = 2048,
|
||||||
DEFAULT_BUFFER_BEFORE_PLAY = 10,
|
DEFAULT_BUFFER_BEFORE_PLAY = 10,
|
||||||
@ -135,6 +140,31 @@ openDB(const Options *options)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Windows-only initialization of the Winsock2 library.
|
||||||
|
*/
|
||||||
|
#ifdef WIN32
|
||||||
|
static void winsock_init(void)
|
||||||
|
{
|
||||||
|
WSADATA sockinfo;
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
retval = WSAStartup(MAKEWORD(2, 2), &sockinfo);
|
||||||
|
if(retval != 0)
|
||||||
|
{
|
||||||
|
g_error("Attempt to open Winsock2 failed; error code %d\n",
|
||||||
|
retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LOBYTE(sockinfo.wVersion) != 2)
|
||||||
|
{
|
||||||
|
g_error("We use Winsock2 but your version is either too new or "
|
||||||
|
"old; please install Winsock 2.x\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the decoder and player core, including the music pipe.
|
* Initialize the decoder and player core, including the music pipe.
|
||||||
*/
|
*/
|
||||||
@ -212,6 +242,9 @@ int main(int argc, char *argv[])
|
|||||||
/* enable GLib's thread safety code */
|
/* enable GLib's thread safety code */
|
||||||
g_thread_init(NULL);
|
g_thread_init(NULL);
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
winsock_init();
|
||||||
|
#endif
|
||||||
idle_init();
|
idle_init();
|
||||||
dirvec_init();
|
dirvec_init();
|
||||||
songvec_init();
|
songvec_init();
|
||||||
@ -339,6 +372,9 @@ int main(int argc, char *argv[])
|
|||||||
idle_deinit();
|
idle_deinit();
|
||||||
stats_global_finish();
|
stats_global_finish();
|
||||||
daemonize_finish();
|
daemonize_finish();
|
||||||
|
#ifdef WIN32
|
||||||
|
WSACleanup();
|
||||||
|
#endif
|
||||||
|
|
||||||
close_log_files();
|
close_log_files();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user