Commit Graph

3387 Commits

Author SHA1 Message Date
Max Kellermann 272ee5f7d2 event_pipe: replaced PIPE_EVENT_SIGNAL with main_notify
There is only one location using PIPE_EVENT_SIGNAL: to synchronize
player_command() with player_command_finished().  Use the "notify"
library instead of the event_pipe here.
2009-01-02 11:20:41 +01:00
Max Kellermann daf7c3db5a mapper: allocate the result of map_directory_child_fs(), map_song_fs()
Don't use fixed stack buffers.
2009-01-02 10:48:55 +01:00
Max Kellermann 72255d580e mapper: allocate the result of map_uri_fs(), map_directory_fs()
Don't use fixed stack buffers.
2009-01-02 10:48:11 +01:00
Max Kellermann b2e3b64483 update: use g_file_test() instead of stat()
If we want to check whether a file is a directory, use GLib's
g_file_test() instead of stat().
2009-01-02 10:47:31 +01:00
Max Kellermann 38e3220fd4 oggflac: don't use gcc.h
Use G_GNUC_UNUSED instead of mpd_unused (which has already been
removed).
2009-01-02 09:50:12 +01:00
Max Kellermann 0c422838a8 playlist: use g_file_test() instead of stat()
To find out whether a file exists, use g_file_test() instead of
stat(), because it is more portable and easier to use.
2009-01-01 19:22:07 +01:00
Max Kellermann 80fa9183e4 mapper: allocate playlist path from heap
Don't pass a static buffer to map_spl_utf8_to_fs().
2009-01-01 19:17:44 +01:00
Max Kellermann 886ed1b225 mapper: fall back to XDG music directory
If no music_directory is configured, fall back to the XDG music
directory, determined by
g_get_user_special_dir(G_USER_DIRECTORY_MUSIC).
2009-01-01 19:07:38 +01:00
Max Kellermann 46aedbae09 removed the signal_check libraries
Nobody is using the signal_check library anymore.

This patch also removes the SIGUSR1 handler.
2009-01-01 18:51:38 +01:00
Max Kellermann 2f71b647f4 sig_handlers: use event_pipe for delivering SIGHUP
The signal_check library went out of order when we started using the
GLib main loop.  Convert the SIGHUP handler to use event_pipe instead.
2009-01-01 18:51:17 +01:00
Max Kellermann e93136ef0f event_pipe: added event_pipe_emit_fast()
event_pipe_emit_fast() is aimed for use in signal handlers: it doesn't
lock the mutex, and doesn't log on error.  That makes it potentially
lossy, but for its intended use, that does not matter.
2009-01-01 18:47:25 +01:00
Max Kellermann ecb20c5f7e mixer: renamed mix_* options to mixer_*
There is no reason to use the shortcut "mix" instead of "mixer".
2009-01-01 18:36:47 +01:00
Max Kellermann 65f037eb32 cmdline: exit after --version
Don't start the daemon when MPD is called with "--version".
2009-01-01 18:26:59 +01:00
Max Kellermann b3e2635ac1 event_pipe: added pipe_event enum and callbacks
Make the event_pipe (formerly main_notify) send/receive a set of
events, with a callback for each one.

The default event PIPE_EVENT_SIGNAL does not have a callback.  It
is still there for waking up the main thread, when it is waiting for
the player thread.
2009-01-01 18:22:11 +01:00
Max Kellermann 22bb5a5856 event_pipe: renamed functions from main_notify_* to event_pipe_*
Continuing the previous patch.
2009-01-01 18:12:14 +01:00
Max Kellermann 9f5934d95b main_notify: renamed source to event_pipe.c
We are going to migrate away from the concept of notifying the main
thread.  There should be events sent to it instead.  This patch starts
a series to implement that.
2009-01-01 18:12:00 +01:00
Max Kellermann 99f8dc0168 gcc.h: removed all duplicate macros
Removed all macros which are already provided by GLib.
2009-01-01 18:09:28 +01:00
Max Kellermann 17bdcc8bae decoder plugins: don't include gcc.h
Use GLib's G_GNUC_UNUSED instead of gcc.h's mpd_unused.
2009-01-01 18:09:24 +01:00
Max Kellermann 7dfe301b54 output plugins: don't include gcc.h
Use GLib's G_GNUC_UNUSED instead of gcc.h's mpd_unused.
2009-01-01 18:08:29 +01:00
Max Kellermann 0734acf392 null: don't include gcc.h
Use GLib's G_GNUC_UNUSED instead of macros from gcc.h.
2009-01-01 18:00:46 +01:00
Viliam Mateicka 9a70c4d06d Moving mixers to audio outputs 2008-12-31 16:46:41 +01:00
Viliam Mateicka dd9af72a74 exporting functions 2008-12-31 15:10:53 +01:00
Max Kellermann 3cd0b90ff6 client: run client_manager_expire() in an idle event
With the GLib main loop, the client manager can install its own event
in case a client is expired.  No need for main.c to call
client_manager_expire() manually.
2008-12-31 14:30:03 +01:00
Laszlo Ashin a12b57e1e9 ls.c: include config.h to have HAVE_CURL here 2008-12-31 13:00:33 +01:00
Max Kellermann dd0f8e42f3 main_notify: removed lock()/unlock()
These functions are not used anymore since we use the GLib main loop.
2008-12-31 00:32:56 +01:00
Max Kellermann 2cdfd93830 client: remember GLib source id
Remove the event source from the GMainLoop object in
client_set_expired().
2008-12-31 00:29:27 +01:00
Max Kellermann d196ffdf3a sig_handlers: call g_main_loop_quit() in SIGTERM handler
We don't need to use asynchronous events to quit MPD, we can just call
g_main_loop_quit() inside the handler.
2008-12-30 19:50:38 +01:00
Max Kellermann d40cf1652d main: export the main_loop variable
Other libraries may need to access the main_loop reference, to add or
remove events, or to call g_main_loop_quit().
2008-12-30 19:50:22 +01:00
Max Kellermann a3b0506cfd sig_handlers: removed SIGCHLD
We have no child processes anymore.  Remove the SIGCHLD handler.
2008-12-30 19:35:01 +01:00
Max Kellermann f38aaa2bb7 sig_handlers: don't reload database on SIGHUP
The SIGHUP handler was used by the update process to make the main
process re-read the database.  We don't need this anymore, since the
update takes place in a thread now.
2008-12-30 19:34:05 +01:00
Max Kellermann a1434914a7 sig_handlers: removed unused functions
Most of these functions were obsoleted when we switched to threaded
MPD.
2008-12-30 19:32:12 +01:00
Max Kellermann 71e7ce5d8e main: use the GLib main loop
This is a rather huge patch, which unfortunately cannot be splitted.

Instead of using our custom ioops.h library, convert everything to use
the GLib main loop.
2008-12-30 19:24:39 +01:00
Max Kellermann 03e650aa9e main_notify: make the read side of the pipe blocking
Currently, both sides of the pipe are blocking, although we do not
need blocking read().  Convert it back to blocking.  Eliminate the
select() from wait_main_task().
2008-12-30 19:20:36 +01:00
Max Kellermann 10b5966bf6 main_notify: removed notify object, use only pipe
To wake up the main thread, don't attempt to use a GCond/GMutex
(struct notify).  This kind of mixed wakeup method has known race
conditions.

The idea behind this patch is: for wakeups which happen while the main
thread is sleeping, use only a pipe.  For wakeups which happen while
the main thread is waiting for the player thread, we can later change
to GCond.  For now, accept the overhead of using a pipe for the
latter.

In the long run, the main thread will never wait for the player
thread, but will do everything asynchronously.
2008-12-30 19:20:20 +01:00
Max Kellermann 1f0804bdca listen: don't make the server socket non-blocking
There is no point in making the server socket non-blocking.  We call
accept() only after select() has notified us about a new connection.
2008-12-30 19:18:59 +01:00
Max Kellermann 6890183c50 utils: port set_nonblocking() to WIN32
The new WIN32 version of set_nonblocking() can only deal with sockets,
i.e. it will fail on main_notify.c.  On WIN32, we have to reimplement
main_notify.c anyway, so this is not a big deal.
2008-12-30 19:17:20 +01:00
Max Kellermann bb55ec6b4e command: don't allow adding local files on WIN32
There are no unix sockets on WIN32, and therefore no authentication.
WIN32 might have similar capabilities, but until we implement them,
disable that MPD feature.
2008-12-30 19:14:13 +01:00
Max Kellermann 7330002960 utils: implement my_usleep() with Sleep() on WIN32
Sleep() has only millisecond granularity, but good enough for now.
2008-12-30 19:10:08 +01:00
Max Kellermann 2eaeb65666 listen: include winsock headers on WIN32
On Windows, socket declarations reside in winsock.h and ws2tcpip.h.
The POSIX headers are not available.
2008-12-30 19:07:10 +01:00
Max Kellermann e888af98a2 bonjour: fixed "unused parameter" warnings
Add G_GNUC_UNUSED attributes.
2008-12-30 16:45:49 +01:00
Max Kellermann 13867a1e7c zeroconf: eliminated strlen() usage from initZeroconf()
To test if a string is empty, we can just see if the first byte is 0.
No need to include string.h for strlen() here.
2008-12-30 16:45:43 +01:00
Max Kellermann 49fa9708d5 zeroconf: moved code to zeroconf-avahi.c and zeroconf-bonjour.c
Moved implementation specific code to their own sources, internal
declarations in zeroconf-internal.h.
2008-12-30 16:43:58 +01:00
Max Kellermann bbed35822e zeroconf: fail if avahi service name is invalid
If the configured avahi service name is invalid, abort MPD.  Don't
fall back to the default service name.
2008-12-30 16:43:58 +01:00
Max Kellermann e9a3c4ce32 playlist: use GLib's random number generator
srandom() and random() are not portable.  Use GLib's implementation.
2008-12-30 16:34:32 +01:00
Max Kellermann cdf1eaeb2c daemon: simplified daemonize_close_stdin()
Don't bother to call fstat() or isatty() on STDIN_FILENO.
2008-12-30 16:28:18 +01:00
Max Kellermann 6c0f5fc612 listen: moved redirect_stdin() to daemon.c
redirect_stdin() is a daemonization function, and disconnecting from
the standard input is always a good idea for MPD.
2008-12-30 16:28:13 +01:00
Max Kellermann 671480814c main: moved daemonize() to daemon.c 2008-12-30 16:28:07 +01:00
Max Kellermann d99595c214 listen: eliminated freeAllListenSockets()
Merged freeAllListenSockets() into closeAllListenSockets(), because
this is its only caller.
2008-12-30 16:28:00 +01:00
Viliam Mateicka 4cc0caf1af print supported decoders in --version 2008-12-30 14:17:15 +01:00
Max Kellermann d38a7967ab main: disable non-portable code on WIN32
Disable changeToUser(), daemonize(), killFromPidFile().
2008-12-29 17:43:00 +01:00