Main: disable command-line parser and signal handlers on Android

This commit is contained in:
Max Kellermann 2014-02-21 23:12:51 +01:00
parent 90114514a9
commit 3d4689756c
2 changed files with 28 additions and 4 deletions

View File

@ -87,7 +87,6 @@ libmpd_a_SOURCES = \
src/command/OtherCommands.cxx src/command/OtherCommands.hxx \ src/command/OtherCommands.cxx src/command/OtherCommands.hxx \
src/command/CommandListBuilder.cxx src/command/CommandListBuilder.hxx \ src/command/CommandListBuilder.cxx src/command/CommandListBuilder.hxx \
src/Idle.cxx src/Idle.hxx \ src/Idle.cxx src/Idle.hxx \
src/CommandLine.cxx src/CommandLine.hxx \
src/CrossFade.cxx src/CrossFade.hxx \ src/CrossFade.cxx src/CrossFade.hxx \
src/decoder/DecoderError.cxx src/decoder/DecoderError.hxx \ src/decoder/DecoderError.cxx src/decoder/DecoderError.hxx \
src/decoder/DecoderThread.cxx src/decoder/DecoderThread.hxx \ src/decoder/DecoderThread.cxx src/decoder/DecoderThread.hxx \
@ -125,9 +124,6 @@ libmpd_a_SOURCES = \
src/Instance.cxx src/Instance.hxx \ src/Instance.cxx src/Instance.hxx \
src/win32/Win32Main.cxx \ src/win32/Win32Main.cxx \
src/GlobalEvents.cxx src/GlobalEvents.hxx \ src/GlobalEvents.cxx src/GlobalEvents.hxx \
src/unix/SignalHandlers.cxx src/unix/SignalHandlers.hxx \
src/unix/Daemon.cxx src/unix/Daemon.hxx \
src/unix/PidFile.hxx \
src/MixRampInfo.hxx \ src/MixRampInfo.hxx \
src/MusicBuffer.cxx src/MusicBuffer.hxx \ src/MusicBuffer.cxx src/MusicBuffer.hxx \
src/MusicPipe.cxx src/MusicPipe.hxx \ src/MusicPipe.cxx src/MusicPipe.hxx \
@ -177,6 +173,15 @@ libmpd_a_SOURCES = \
src/SongFilter.cxx src/SongFilter.hxx \ src/SongFilter.cxx src/SongFilter.hxx \
src/PlaylistFile.cxx src/PlaylistFile.hxx src/PlaylistFile.cxx src/PlaylistFile.hxx
if ANDROID
else
libmpd_a_SOURCES += \
src/unix/SignalHandlers.cxx src/unix/SignalHandlers.hxx \
src/unix/Daemon.cxx src/unix/Daemon.hxx \
src/unix/PidFile.hxx \
src/CommandLine.cxx src/CommandLine.hxx
endif
if ENABLE_DATABASE if ENABLE_DATABASE
libmpd_a_SOURCES += \ libmpd_a_SOURCES += \
src/PlaylistUpdate.cxx \ src/PlaylistUpdate.cxx \

View File

@ -114,6 +114,8 @@ Instance *instance;
static StateFile *state_file; static StateFile *state_file;
#ifndef ANDROID
static bool static bool
glue_daemonize_init(const struct options *options, Error &error) glue_daemonize_init(const struct options *options, Error &error)
{ {
@ -131,6 +133,8 @@ glue_daemonize_init(const struct options *options, Error &error)
return true; return true;
} }
#endif
static bool static bool
glue_mapper_init(Error &error) glue_mapper_init(Error &error)
{ {
@ -375,6 +379,7 @@ int mpd_main(int argc, char *argv[])
struct options options; struct options options;
Error error; Error error;
#ifndef ANDROID
daemonize_close_stdin(); daemonize_close_stdin();
#ifdef HAVE_LOCALE_H #ifdef HAVE_LOCALE_H
@ -389,12 +394,17 @@ int mpd_main(int argc, char *argv[])
/* enable GLib's thread safety code */ /* enable GLib's thread safety code */
g_thread_init(nullptr); g_thread_init(nullptr);
#endif #endif
#endif
#endif #endif
winsock_init(); winsock_init();
io_thread_init(); io_thread_init();
config_global_init(); config_global_init();
#ifdef ANDROID
(void)argc;
(void)argv;
#else
if (!parse_cmdline(argc, argv, &options, error)) { if (!parse_cmdline(argc, argv, &options, error)) {
LogError(error); LogError(error);
return EXIT_FAILURE; return EXIT_FAILURE;
@ -404,6 +414,7 @@ int mpd_main(int argc, char *argv[])
LogError(error); LogError(error);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
#endif
stats_global_init(); stats_global_init();
TagLoadConfig(); TagLoadConfig();
@ -440,8 +451,10 @@ int mpd_main(int argc, char *argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
#ifndef ANDROID
daemonize_set_user(); daemonize_set_user();
daemonize_begin(options.daemon); daemonize_begin(options.daemon);
#endif
GlobalEvents::Initialize(*instance->event_loop); GlobalEvents::Initialize(*instance->event_loop);
GlobalEvents::Register(GlobalEvents::IDLE, idle_event_emitted); GlobalEvents::Register(GlobalEvents::IDLE, idle_event_emitted);
@ -490,11 +503,13 @@ int mpd_main(int argc, char *argv[])
playlist_list_global_init(); playlist_list_global_init();
#ifndef ANDROID
daemonize_commit(); daemonize_commit();
setup_log_output(options.log_stderr); setup_log_output(options.log_stderr);
SignalHandlersInit(*instance->event_loop); SignalHandlersInit(*instance->event_loop);
#endif
io_thread_start(); io_thread_start();
@ -616,10 +631,14 @@ int mpd_main(int argc, char *argv[])
#endif #endif
config_global_finish(); config_global_finish();
io_thread_deinit(); io_thread_deinit();
#ifndef ANDROID
SignalHandlersFinish(); SignalHandlersFinish();
#endif
delete instance->event_loop; delete instance->event_loop;
delete instance; delete instance;
#ifndef ANDROID
daemonize_finish(); daemonize_finish();
#endif
#ifdef WIN32 #ifdef WIN32
WSACleanup(); WSACleanup();
#endif #endif