Commit 6fd2c826 authored by Philipp Schafft's avatar Philipp Schafft 🦁

added win32 support. Thanks to stephan48. Patch slightly modified. close #2095

svn path=/icecast/trunk/ices/; revision=19366
parent 69d1cfd1
......@@ -24,6 +24,11 @@
#include <thread/thread.h>
#ifdef _WIN32
/* for FreeConsole() */
#include <windows.h>
#endif
#include "cfgparse.h"
#include "stream.h"
#include "signals.h"
......@@ -56,8 +61,10 @@ int main(int argc, char **argv)
fprintf(stderr, "Failed to read config file \"%s\"\n", argv[1]);
goto fail;
}
if (ices_config->background)
{
#ifndef _WIN32
int ret = 0;
/* Start up new session, to lose old session and process group */
switch (fork())
......@@ -80,13 +87,18 @@ int main(int argc, char **argv)
default:
exit (ret);
}
#else
FreeConsole();
#endif
}
log_initialize();
thread_initialize();
shout_init();
encode_init();
#ifndef _WIN32
signals_setup();
#endif
snprintf(logpath, FILENAME_MAX, "%s/%s", ices_config->logpath,
ices_config->logfile);
......
......@@ -55,7 +55,7 @@
#include "im_alsa.h"
#endif
#ifdef _WIN32
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__))
typedef __int64 int64_t
typedef unsigned __int64 uint64_t
#endif
......
......@@ -32,6 +32,10 @@
#define MODULE "metadata/"
#include "logging.h"
#ifdef _WIN32
#include <windows.h>
#endif
volatile int metadata_update_signalled = 0;
void *metadata_thread_stdin(void *arg)
......
......@@ -37,10 +37,12 @@ void signal_usr1_handler(int signum)
LOG_INFO0("Metadata update requested");
metadata_update_signalled = 1;
thread_cond_broadcast(&ices_config->event_pending_cond);
#ifndef _WIN32
signal(SIGUSR1, signal_usr1_handler);
#endif
}
#ifndef _WIN32
void signal_hup_handler(int signum)
{
LOG_INFO0("Flushing logs");
......@@ -51,6 +53,7 @@ void signal_hup_handler(int signum)
signal(SIGHUP, signal_hup_handler);
}
#endif
void signal_int_handler(int signum)
{
......@@ -67,12 +70,14 @@ void signal_int_handler(int signum)
}
#ifndef _WIN32
void signals_setup(void)
{
signal(SIGHUP, signal_hup_handler);
signal(SIGINT, signal_int_handler);
signal(SIGHUP, signal_hup_handler);
signal(SIGUSR1, signal_usr1_handler);
signal(SIGPIPE, SIG_IGN);
}
#endif
......@@ -69,7 +69,9 @@ void *ices_instance_stream(void *arg)
shout_set_format(sdsc->shout, SHOUT_FORMAT_VORBIS);
shout_set_protocol(sdsc->shout, SHOUT_PROTOCOL_HTTP);
#ifndef _WIN32
signal(SIGPIPE, signal_hup_handler);
#endif
if (!(shout_set_host(sdsc->shout, stream->hostname)) == SHOUTERR_SUCCESS) {
LOG_ERROR1("libshout error: %s\n", shout_get_error(sdsc->shout));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment