aboutsummaryrefslogtreecommitdiffstats
path: root/src/directory.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Replace SongList with struct songvecEric Wong2008-09-231-47/+47
| | | | | | | Our linked-list implementation is wasteful and the SongList isn't modified enough to benefit from being a linked list. So use a more compact array of song pointers which saves ~200K on a library with ~9K songs (on x86-32).
* directory: remove unused updateMp3Directory() functionEric Wong2008-09-231-18/+0
| | | | | | | | | | | | It hasn't been used in many years commit 3a89afdd80f228139554372a83a9d74486acf691 Author: Warren Dukes <warren.dukes@gmail.com> Date: Sat Nov 20 20:28:32 2004 +0000 remove --update-db option (SVN r2719)
* start using prefixcmp()Eric Wong2008-09-231-15/+8
| | | | | LOC reduction and less noise makes things easier for tired old folks to follow.
* Directory: don't allocate stat information dynamicallyEric Wong2008-09-231-44/+19
| | | | | | | This should save a few thousand ops. Not worth it to malloc for such a small (3-words on 32-bit ARM and x86) structures. Signed-off-by: Eric Wong <normalperson@yhbt.net>
* pass "struct client" to dbUtils.c, song.c, tag_print.cMax Kellermann2008-09-071-7/+6
| | | | | | Don't pass the raw file descriptor around. This migration patch is rather large, because all of the sources have inter dependencies - we have to change all of them at the same time.
* directory: don't pass "fd" to updateInit()Max Kellermann2008-09-071-11/+4
| | | | Again, move error handling to command.c.
* directory: printDirectoryInfo() does not call commandError()Max Kellermann2008-09-071-3/+1
| | | | Move another ocurrence of error handling over to command.c.
* directory: don't pass fd to traverseAllIn()Max Kellermann2008-09-071-7/+5
| | | | | | | | This patch continues the work of the previous patch: don't pass a file descriptor at all to traverseAllIn(). Since this fd was only used to report "directory not found" errors, we can easily move that check to the caller. This is a great relief, since it removes the dependency on a client connection from a lot of enumeration functions.
* directory: don't pass fd to traverseAllIn() callbacksMax Kellermann2008-09-071-12/+11
| | | | | | | | | | Database traversal should be generic, and not bound to a client connection. This is the first step: no file descriptor for the callback functions forEachSong() and forEachDir(). If a callback needs the file descriptor, it has to be passed in the void*data pointer somehow; some callbacks might need a new struct for passing more than one parameter. This might look a bit cumbersome right now, but our goal is to have a clean API.
* song: moved code to song_print.c, song_save.cMax Kellermann2008-09-071-0/+2
| | | | | | | Move everything which dumps song information (via tag_print.c) to a separate source file. song_print.c gets code which writes song data to the client; song_save.c is responsible for serializing songs from the tag cache.
* dbUtils, playlist, directory: pass constant pointersMax Kellermann2008-09-061-2/+2
| | | | The usual bunch of const pointer conversions.
* tag: static directory nameMax Kellermann2008-08-291-5/+3
| | | | | | While parsing the tag cache, don't allocate the directory name from the heap, but copy it into a buffer on the stack. This reduces heap fragmentation by 1%.
* client: renamed all public functionsMax Kellermann2008-08-281-1/+1
| | | | | | Functions which operate on the whole client list are prefixed with "client_manager_", and functions which handle just one client just get "client_".
* renamed interface.c to client.cMax Kellermann2008-08-281-1/+1
| | | | | | | I don't believe "interface" is a good name for something like "connection by a client to MPD", let's call it "client". This is the first patch in the series which changes the name, beginning with the file name.
* include cleanupMax Kellermann2008-08-281-0/+1
| | | | Only include headers which are really needed.
* clean up CPP includesMax Kellermann2008-04-121-6/+2
| | | | | | | | | Try to only include headers which are really needed. We should particularly check all "headers including other headers". The long-term goal is to have a manageable, small API for plugins (decoders, output) without so many mpd internals cluttering the namespace. git-svn-id: https://svn.musicpd.org/mpd/trunk@7319 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Initial cut of fork() => pthreads() for decoder and playerEric Wong2008-04-121-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I initially started to do a heavy rewrite that changed the way processes communicated, but that was too much to do at once. So this change only focuses on replacing the player and decode processes with threads and using condition variables instead of polling in loops; so the changeset itself is quiet small. * The shared output buffer variables will still need locking to guard against race conditions. So in this effect, we're probably just as buggy as before. The reduced context-switching overhead of using threads instead of processes may even make bugs show up more or less often... * Basic functionality appears to be working for playing local (and NFS) audio, including: play, pause, stop, seek, previous, next, and main playlist editing * I haven't tested HTTP streams yet, they should work. * I've only tested ALSA and Icecast. ALSA works fine, Icecast metadata seems to get screwy at times and breaks song advancement in the playlist at times. * state file loading works, too (after some last-minute hacks with non-blocking wakeup functions) * The non-blocking (*_nb) variants of the task management functions are probably overused. They're more lenient and easier to use because much of our code is still based on our previous polling-based system. * It currently segfaults on exit. I haven't paid much attention to the exit/signal-handling routines other than ensuring it compiles. At least the state file seems to work. We don't do any cleanups of the threads on exit, yet. * Update is still done in a child process and not in a thread. To do this in a thread, we'll need to ensure it does proper locking and communication with the main thread; but should require less memory in the end because we'll be updating the database "in-place" rather than updating a copy and then bulk-loading when done. * We're more sensitive to bugs in 3rd party libraries now. My plan is to eventually use a master process which forks() and restarts the child when it dies: locking and communication with the main thread; but should require less memory in the end because we'll be updating the database "in-place" rather than updating a copy and then bulk-loading when done. * We're more sensitive to bugs in 3rd party libraries now. My plan is to eventually use a master process which forks() and restarts the child when it dies: master - just does waitpid() + fork() in a loop \- main thread \- decoder thread \- player thread At the beginning of every song, the main thread will set a dirty flag and update the state file. This way, if we encounter a song that triggers a segfault killing the main thread, the master will start the replacement main on the next song. * The main thread still wakes up every second on select() to check for signals; which affects power management. [merged r7138 from branches/ew] git-svn-id: https://svn.musicpd.org/mpd/trunk@7240 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix -Wconst warningsMax Kellermann2008-02-051-30/+38
| | | | | | [ew: cleaned up the dirty union hack a bit] Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7180 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fixed -Wshadow warningsMax Kellermann2008-01-261-14/+14
| | | | | Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7143 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fixed invalid C prototypesMax Kellermann2008-01-261-1/+1
| | | | | Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7142 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* directory: allow db_file to reside on / once againEric Wong2008-01-031-0/+2
| | | | | | Oops!, I went back and documented the change going to parent_path(), but forgot to change the code that was affected by it. git-svn-id: https://svn.musicpd.org/mpd/trunk@7131 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Cleanup #includes of standard system headers and put them in one placeEric Wong2008-01-031-5/+0
| | | | | | | | | | | | | This will make refactoring features easier, especially now that pthreads support and larger refactorings are on the horizon. Hopefully, this will make porting to other platforms (even non-UNIX-like ones for masochists) easier, too. os_compat.h will house all the #includes for system headers considered to be the "core" of MPD. Headers for optional features will be left to individual source files. git-svn-id: https://svn.musicpd.org/mpd/trunk@7130 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* directory.c: get rid of the horrid dirname(3) and libgen.h dependencyEric Wong2008-01-031-13/+3
| | | | | | | | | Ok, so basename(3) is even more brain-damaged, inconsistent and/or broken than dirname(3) on most systems, but there are broken implementations of it out there. Just use our already existing internal parent_path() function instead and get rid of the only place where we look for libgen.h. git-svn-id: https://svn.musicpd.org/mpd/trunk@7129 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Merge branches/ew r7104Eric Wong2007-12-281-139/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | thread-safety work in preparation for rewrite to use pthreads Expect no regressions against trunk (r7078), possibly minor performance improvements in update (due to fewer heap allocations), but increased stack usage. Applied the following patches: * maxpath_str for reentrancy (temporary fix, reverted) * path: start working on thread-safe variants of these methods * Re-entrancy work on path/character-set conversions * directory.c: exploreDirectory() use reentrant functions here * directory/update: more use of reentrant functions + cleanups * string_toupper: a strdup-less version of strDupToUpper * get_song_url: a static-variable-free version of getSongUrl() * Use reentrant/thread-safe get_song_url everywhere * replace rmp2amp with the reentrant version, rmp2amp_r * Get rid of the non-reentrant/non-thread-safe rpp2app, too. * buffer2array: assert strdup() returns a usable value in unit tests * replace utf8ToFsCharset and fsCharsetToUtf8 with thread-safe variants * fix storing playlists w/o absolute paths * parent_path(), a reentrant version of parentPath() * parentPath => parent_path for reentrancy and thread-safety * allow "make test" to automatically run embedded unit tests * remove convStrDup() and maxpath_str() * use MPD_PATH_MAX everywhere instead of MAXPATHLEN * path: get rid of appendSlash, pfx_path and just use pfx_dir * get_song_url: fix the ability to play songs in the top-level music_directory git-svn-id: https://svn.musicpd.org/mpd/trunk@7106 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* removing debug messages from signal handlersJ. Alexander Treuman2007-08-271-6/+8
| | | | | | | | | As unfortunate as it is to remove such useful debugging messages, it's necessary to fix a potential deadlock with signal handling. A bunch of functions the debug functions call aren't safe to call from a signal handler. There are some alternate solutions, but they're neither pretty nor simple. So just remove them entirely for now. git-svn-id: https://svn.musicpd.org/mpd/trunk@6828 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Extra debug outputQball Cow2007-07-161-3/+16
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6689 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* "unable open" -> "unable to open"J. Alexander Treuman2007-05-261-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6278 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Changing all calls to ERROR() followed by exit(EXIT_FAILURE) with a singleJ. Alexander Treuman2007-05-261-33/+15
| | | | | call to FATAL(). git-svn-id: https://svn.musicpd.org/mpd/trunk@6276 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Don't list playlists in lsinfo if the path isn't the root directory (theyJ. Alexander Treuman2007-05-241-1/+9
| | | | | can't be loaded anyway). git-svn-id: https://svn.musicpd.org/mpd/trunk@6244 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Fixing some code that was rendered unreadable by indent.J. Alexander Treuman2007-04-261-6/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5955 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Set directory_dbModTime when writing the db, so that it will be set afterJ. Alexander Treuman2007-04-251-2/+6
| | | | | initial db creation. git-svn-id: https://svn.musicpd.org/mpd/trunk@5948 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fials -> failsJ. Alexander Treuman2007-04-251-2/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5947 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Remove the now unused struct stat from initMp3Directory().J. Alexander Treuman2007-04-251-2/+0
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5946 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* initMp3Directory() is only called when (re)creating the db, but before theJ. Alexander Treuman2007-04-251-3/+0
| | | | | | db file is written. So don't try to set directory_dbModTime to the mtime of the db file, since it will be incorrect. git-svn-id: https://svn.musicpd.org/mpd/trunk@5945 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* The massive copyright updateAvuton Olrich2007-04-051-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5834 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Don't initialize globals to zero (or NULL)Eric Wong2007-01-141-5/+5
| | | | | | | | Some compilers and linkers aren't smart enough to optimize this, as global variables are implictly initialized to zero. As a result, binaries are a bit smaller as more goes in the .bss and less in the text section. git-svn-id: https://svn.musicpd.org/mpd/trunk@5254 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Replace strdup and {c,re,m}alloc with x* variants to check for OOM errorsEric Wong2006-08-261-18/+18
| | | | | | | | | | | | | | | | | | | 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
* Fix warnings for -Wmissing-prototypesAvuton Olrich2006-08-201-5/+5
| | | | | | Add -Wmissing-prototypes if compiling with gcc Static where possible git-svn-id: https://svn.musicpd.org/mpd/trunk@4657 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* more sparse cleanupsEric Wong2006-08-081-12/+12
| | | | | | | | | * less-commonly compiled things like ao/mvp outputs * Adding -Wno-transparent-union to SPARSE_FLAGS makes it check inside decode.c, directory.c, player.c, and sig_handlers.c * remove unused variables leftover from the master process in sig_handlers.c git-svn-id: https://svn.musicpd.org/mpd/trunk@4598 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* renamce cstrtok to buffer2array. please don't rename functions; especially ↵Warren Dukes2006-08-061-11/+13
| | | | | to names that look extremely std-lib-ish. also, don't use isspace, apparently it's local dependent and potentially consideres ' ' or '\t' not to be a space, or considers other characters to be a space. git-svn-id: https://svn.musicpd.org/mpd/trunk@4574 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* merge changes from mpd-tree:Warren Dukes2006-08-061-0/+1
| | | | | | -use tree for tagTracker -eliminate the master process git-svn-id: https://svn.musicpd.org/mpd/trunk@4571 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Several fixes uncovered with -pedanticEric Wong2006-08-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | playerData.c: proper error checking directory.c: properly check myFgets() for errors (it returns NULL on error) inputPlugins/mp3_plugin.c get rid of commas at the end of enums interface.c: we weren't using long long, so strtoll isn't needed get rid of void-pointer arithmetic sllist.c: get rid of void-pointer arithmetic compress.c: get rid of C++ comments, some compilers don't accept them Note that I personally like void pointer arithmetic, but some ancient compilers don't support them :( git-svn-id: https://svn.musicpd.org/mpd/trunk@4510 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* remove deprecated myfprintf wrapperEric Wong2006-07-301-7/+7
| | | | | | | 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
* commandError() cleanups, fixup gcc checksEric Wong2006-07-301-6/+4
| | | | | | | stripped binary size reduced by 9k on my machine from making commandError a function. We'll print out error messages slightly slower before, but the smaller binary is more than worth it. git-svn-id: https://svn.musicpd.org/mpd/trunk@4488 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* interface/connection malloc reductions from mpd-keEric Wong2006-07-301-27/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch massively reduces the amount of heap allocations at the interface/command layer. Most commands with minimal output should not allocate memory from the heap at all. Things like repeatedly polling status, currentsong, and volume changes should be faster as a result, and more importantly, not a source of memory fragmentation. These changes should be safe in that there's no way for a remote-client to corrupt memory or otherwise do bad stuff to MPD, but an extra set of eyes to review would be good. Of course there's never any warranty :) No longer do we use FILE * structures in the interface, which means we don't have to allocate any new memory for most connections. Now, before you go on about losing the buffering that FILE * +implies+, remember that myfprintf() never took advantage of any of the stdio buffering features. To reduce the diff and make bugs easier to spot in the diff, I've kept myfprintf in places where we write to files (and not network interfaces). Expect myfprintf to go away entirely soon (we'll use fprintf for writing regular files). git-svn-id: https://svn.musicpd.org/mpd/trunk@4483 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* If we're going to create the db file, make sure the parent path is a directoryJ. Alexander Treuman2006-07-231-1/+16
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4437 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Make checkDirectoryDB check that the db file is a regular fileJ. Alexander Treuman2006-07-231-3/+16
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4436 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Tidying up code in checkDirectoryDBJ. Alexander Treuman2006-07-231-19/+17
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4434 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Add mpd-indent.shAvuton Olrich2006-07-201-591/+648
| | | | | | Indent the entire tree, hopefully we can keep it indented. git-svn-id: https://svn.musicpd.org/mpd/trunk@4410 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* remove the glib library dependencyEric Wong2006-07-161-1/+0
| | | | | | | | | We never used many features from it, so there's no point in keeping it and forcing people to install a non-standard library. It may be standard on many GNU/Linux distributions, but there are many other UNIXes out there. This makes life much easier for people cross-compiling (like me :) git-svn-id: https://svn.musicpd.org/mpd/trunk@4361 09075e82-0dd4-0310-85a5-a0d7c8717e4f