aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Replace strdup and {c,re,m}alloc with x* variants to check for OOM errorsEric Wong2006-08-261-1/+1
| | | | | | | | | | | | | | | | | | | I'm checking for zero-size allocations and assert()-ing them, so we can more easily get backtraces and debug problems, but we'll also allow -DNDEBUG people to live on the edge if they wish. We do not rely on errno when checking for OOM errors because some implementations of malloc do not set it, and malloc is commonly overridden by userspace wrappers. I've spent some time looking through the source and didn't find any obvious places where we would explicitly allocate 0 bytes, so we shouldn't trip any of those assertions. We also avoid allocating zero bytes because C libraries don't handle this consistently (some return NULL, some not); and it's dangerous either way. git-svn-id: https://svn.musicpd.org/mpd/trunk@4690 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Several bugfixes during exit found by valgrindEric Wong2006-08-141-2/+2
| | | | | | | | | | | | | | | | | First, make sure we call finishPlaylist() before closeMp3Directory() since the latter will free non-SONG_TYPE_URL songs in playlist, which causes an invalid read when we try to look for SONG_TYPE_URL songs to free in finishPlaylist. Secondly, make sure our children have all exited before freeing the playerData. If we do not, slowly-delivered signals can trigger a race condition in the signal handlers of the decode and player processes which rely on getPlayerData. To avoid waitpid-ing too long (or at all), move the freePlayerData() call farther down in main() (this won't affect anything else) to give the OS a better chance to deliver signals and finish running sig handlers for terminated children. git-svn-id: https://svn.musicpd.org/mpd/trunk@4640 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* sparse / gcc-2.95 / -pedantic fixesEric Wong2006-08-071-1/+2
| | | | | Not everybody has access to the latest and greatest compilers. git-svn-id: https://svn.musicpd.org/mpd/trunk@4595 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* merge changes from mpd-tree:Warren Dukes2006-08-061-70/+19
| | | | | | -use tree for tagTracker -eliminate the master process git-svn-id: https://svn.musicpd.org/mpd/trunk@4571 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* main.c: initialize the verbose flag correctlyEric Wong2006-08-031-0/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4533 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* logging cleanupsEric Wong2006-08-011-75/+7
| | | | | | | | | | | | | | * Moved all logging-related stuff into log.c (and not myfprintf.c) * ISO C90-compliant strftime usage: %e and %R replaced with %d and %H:%M respectively * Got rid of variadic macros since some old-school compilers don't like them * compiling with -DNDEBUG disables the DEBUG() macro git-svn-id: https://svn.musicpd.org/mpd/trunk@4512 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Standardize state_file handling routines.Eric Wong2006-07-301-4/+3
| | | | | This way it's easier to manage and extend. git-svn-id: https://svn.musicpd.org/mpd/trunk@4494 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* remove deprecated myfprintf wrapperEric Wong2006-07-301-4/+4
| | | | | | | This shaves another 5-6k because we've removed the paranoid fflush() calls after every fprintf. Now we only fflush() when we need to git-svn-id: https://svn.musicpd.org/mpd/trunk@4493 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Use AudioCompress for volume normalizationJ. Alexander Treuman2006-07-271-0/+3
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4474 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Open the db file before daemonizing/creating the master process, so we can ↵J. Alexander Treuman2006-07-241-2/+1
| | | | | handle failures gracefully git-svn-id: https://svn.musicpd.org/mpd/trunk@4454 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Initialize more stuff before daemonizing so we exit properly on fatal errorsJ. Alexander Treuman2006-07-211-4/+5
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4421 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Rolling back change to when we redirect to logs. Turns out it silenced ↵J. Alexander Treuman2006-07-201-5/+1
| | | | | fatal audio_output errors. git-svn-id: https://svn.musicpd.org/mpd/trunk@4415 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Add mpd-indent.shAvuton Olrich2006-07-201-1/+1
| | | | | | Add a few new options for indent to try to make things a bit cleaner git-svn-id: https://svn.musicpd.org/mpd/trunk@4411 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Redirect to log files earlier to prevent some debug spam on consoleJ. Alexander Treuman2006-07-191-1/+5
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4406 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Fix whitespace->tabs in main.c, it was afuAvuton Olrich2006-07-191-383/+362
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4405 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Don't bother freeing a bunch of stuff at exit, since it takes far too long ↵J. Alexander Treuman2006-07-181-3/+6
| | | | | and accomplishes nothing. git-svn-id: https://svn.musicpd.org/mpd/trunk@4396 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Committing qball's patch to list supported audio outputs in --versionJ. Alexander Treuman2006-07-161-0/+6
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4357 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* main: static-fication, ANSI fixesEric Wong2006-07-151-13/+13
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4354 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Avoid spewing messages to the consoleEric Wong2006-07-151-2/+1
| | | | | | | | Just setupLogOutput and redirect things to the logs before spawning the main process. We've already daemonized at this point, so we've already proven that we can fork, but we haven't done it yet. git-svn-id: https://svn.musicpd.org/mpd/trunk@4353 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Update copyright in --versionJ. Alexander Treuman2006-07-141-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4334 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Change shank's email addressJ. Alexander Treuman2006-07-141-2/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Huge header update, update the copyright and addAvuton Olrich2006-07-131-1/+1
| | | | | the GPL header where necessary git-svn-id: https://svn.musicpd.org/mpd/trunk@4317 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Declare functions not used outside dbUtils.c static.Avuton Olrich2006-07-131-2/+0
| | | | | Remove a disabled function from dbUtils.c out of main.c git-svn-id: https://svn.musicpd.org/mpd/trunk@4314 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* main.c: fix gcc-2.95 compilation problemEric Wong2006-06-051-1/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4251 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Made pid_file an optional config parameter.J. Alexander Treuman2006-06-051-17/+28
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4250 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* correctly check for setenv() functionEric Wong2006-06-041-2/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4245 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Jat/Q patch for checking permission on database before creating itQball Cow2006-05-081-0/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4140 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Commit Jat's patch for bug 1281Qball Cow2006-05-081-0/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4136 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* update help textQball Cow2006-04-301-4/+4
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4128 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Fix for the macro, use gitsetenv, thanks to normalperson, eleusis, jatAvuton Olrich2006-04-221-8/+34
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4098 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Solaris is reported to not have a setenv() thusAvuton Olrich2006-04-221-0/+12
| | | | | | breaking compilation. This fixes that problem with a macro that emulates setenv() with putenv(). git-svn-id: https://svn.musicpd.org/mpd/trunk@4097 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* rewrite statefile code for audio devicesEric Wong2006-03-181-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the words of the original author, it was 'crappy'. I tend to agree :) The code has also been broken for at least the past few months, and nobody bothered fixing it The previous format it was overly complex: 5 lines to describe each device. The new format is one-line per-device: audio_device_state:%d:%s %d - 0 for disabled, any integer for enabled %s - name of the device as specified in the config file, whitespace and all Incompatibilities: * Output names are now _required_ to be unique. This is required because the new format relies solely on the name of the audio device. Relying on the device IDs internal to MPD was a bad idea anyways since the user usually has none or very little idea how they're generated, and adding a new device or removing one from a config would throw things off completely. This is also just a Good Idea(TM) because it makes things less confusing to users when they see it in their clients. * Output states are not preserved from the previous format. Not a big deal, since the previous code was never officially released. Also, it's been broken for months now, so I doubt anybody would notice :) git-svn-id: https://svn.musicpd.org/mpd/trunk@3928 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Hopefully the last of the spelling fixes :>Eric Wong2006-03-161-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3923 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* r1067@BL4ST: normalperson | 2005-12-30 19:21:28 -0800Eric Wong2005-12-311-0/+1
| | | | | Fix a couple of warnings (sbh, from oggflac branch) git-svn-id: https://svn.musicpd.org/mpd/trunk@3752 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Configure fix, so when no glib found it gives a error, and another race ↵Qball Cow2005-12-141-1/+1
| | | | | condition fix in the master proces patch. git-svn-id: https://svn.musicpd.org/mpd/trunk@3730 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* DJWLindenaar's fix race condition and some memory leaks patchQball Cow2005-11-181-7/+17
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3681 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* DJWLindenaar balanced tree and master process patchQball Cow2005-11-161-14/+60
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3669 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Saving state of output-device in state-file. (This is a temporary solution, ↵Qball Cow2005-08-231-0/+7
| | | | | rewrite of state-file is planned for 0.13) git-svn-id: https://svn.musicpd.org/mpd/trunk@3449 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* *) slight code cleanupWarren Dukes2005-03-121-5/+5
| | | | | *) now --kill will not check for /proc/<pid>/exe (this is linux specific) git-svn-id: https://svn.musicpd.org/mpd/trunk@3063 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* if no audioOutput specified, we no attempt to detect if there exists a ↵Warren Dukes2005-03-121-1/+1
| | | | | usable oss or alsa device git-svn-id: https://svn.musicpd.org/mpd/trunk@3057 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix segfault in error messageWarren Dukes2005-03-091-3/+3
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3046 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* add ability to forcefully kill pid listed in pid file with '-kill -kill'Warren Dukes2005-03-091-16/+27
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3045 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* don't print out config line in error message about pid file missingWarren Dukes2005-03-091-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3044 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix an error messageWarren Dukes2005-03-091-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3043 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* *) add support for pid filesWarren Dukes2005-03-091-3/+85
| | | | | | | *) we now require pid_file to specified in the config *) new prefered method for killing mpd: mpd --kill *) cleaned up some nastiness with decode_pid handling git-svn-id: https://svn.musicpd.org/mpd/trunk@3042 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* update usage and mpd man page to indicate that we now require a config fileWarren Dukes2005-03-061-1/+0
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3028 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* config file change! now 'port' is optional and 'db_file' is required!Warren Dukes2005-03-061-82/+39
| | | | | | also, should have better error reporting when failing to open playlist or music directory's, or writing the db, etc git-svn-id: https://svn.musicpd.org/mpd/trunk@3027 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* remove --update-db optionWarren Dukes2004-11-201-3/+3
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2719 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* a few DEBUG statementsWarren Dukes2004-11-131-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2642 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* better saved memmory displayWarren Dukes2004-11-111-0/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2607 09075e82-0dd4-0310-85a5-a0d7c8717e4f