1. 12 Apr, 2008 1 commit
    • Eric Wong's avatar
      Initial cut of fork() => pthreads() for decoder and player · 9cf66d0e
      Eric Wong authored
      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
      9cf66d0e
  2. 05 Feb, 2008 1 commit
  3. 26 Jan, 2008 2 commits
  4. 03 Jan, 2008 3 commits
  5. 28 Dec, 2007 1 commit
    • Eric Wong's avatar
      Merge branches/ew r7104 · b79f6b88
      Eric Wong authored
      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
      b79f6b88
  6. 27 Aug, 2007 1 commit
    • J. Alexander Treuman's avatar
      removing debug messages from signal handlers · 1b045d06
      J. Alexander Treuman authored
      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
      1b045d06
  7. 16 Jul, 2007 1 commit
  8. 26 May, 2007 2 commits
  9. 24 May, 2007 1 commit
  10. 26 Apr, 2007 1 commit
  11. 25 Apr, 2007 4 commits
  12. 05 Apr, 2007 1 commit
  13. 14 Jan, 2007 1 commit
  14. 26 Aug, 2006 1 commit
    • Eric Wong's avatar
      Replace strdup and {c,re,m}alloc with x* variants to check for OOM errors · 90847fc8
      Eric Wong authored
      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
      90847fc8
  15. 20 Aug, 2006 1 commit
  16. 08 Aug, 2006 1 commit
    • Eric Wong's avatar
      more sparse cleanups · f7d150a3
      Eric Wong authored
      * 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
      f7d150a3
  17. 06 Aug, 2006 2 commits
  18. 01 Aug, 2006 1 commit
    • Eric Wong's avatar
      Several fixes uncovered with -pedantic · 5aca21a5
      Eric Wong authored
      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
      5aca21a5
  19. 30 Jul, 2006 3 commits
    • Eric Wong's avatar
      remove deprecated myfprintf wrapper · 381d7232
      Eric Wong authored
      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
      381d7232
    • Eric Wong's avatar
      commandError() cleanups, fixup gcc checks · e86fd65c
      Eric Wong authored
      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
      e86fd65c
    • Eric Wong's avatar
      interface/connection malloc reductions from mpd-ke · 4cf5d04c
      Eric Wong authored
      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
      4cf5d04c
  20. 23 Jul, 2006 3 commits
  21. 20 Jul, 2006 1 commit
  22. 16 Jul, 2006 1 commit
    • Eric Wong's avatar
      remove the glib library dependency · b59aa757
      Eric Wong authored
      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
      b59aa757
  23. 14 Jul, 2006 3 commits
  24. 13 Jul, 2006 1 commit
  25. 07 Jun, 2006 1 commit
  26. 15 May, 2006 1 commit