The patch below makes /etc/init.d/mpd start the MusicPlayerDaemon in
a more normal way:
1- it stops it from rebuilding the database at every start (which can take
   a very very long time on large databases).
2- it stops it from going through the trouble to create the music
   database directory (even if it exists, as long as its empty you won't
   be able to do much with it anyway).
3- it stops it from messing up the playlist (adding all the songs in the
   universe to it) and from starting to play that messed up list
   forcefully right away (convenient when your machine happens to reboot
   at 3am).
4- it uses `nice' if available to boost `mpd's priority to reduce the
   likelihood of skipping.  In my experience (using this mpd on a small
   home-router box), this is indispensible to avoid skipping, and I have
   never noticed it affecting the general performance and responsiveness
   of the machine.

Points 1 and 3 are really important for most normal uses I can think of.
Point 2 is not important.
Point 4 is important for my use case, tho maybe less so for others;
Still, within the context of OpenWRT, I expect it's common to run on
slow machines where "nice" is necessary to avoid skipping, so I think it
deserves to be used by default.


        Stefan


Index: sound/mpd/files/mpd.init
===================================================================
--- sound/mpd/files/mpd.init    (révision 19649)
+++ sound/mpd/files/mpd.init    (copie de travail)
@@ -4,27 +4,22 @@
 
 start() {
        #create mpd directories
-       md=`grep music_directory /etc/mpd.conf | cut -d "\"" -f 2 | sed 
"s/~/\/root/g"`
-       if [ ! -d $md ]; then
-               mkdir -p $md
-       fi
        pld=`grep playlist_directory /etc/mpd.conf | cut -d "\"" -f 2 | sed 
"s/~/\/root/g"`
        if [ ! -d $pld ]; then
                mkdir -p $pld
        fi
-       #create mpd db
-       /usr/bin/mpd --stdout --create-db
 
-       #optional export for mpc
-       #export MPD_HOST=127.0.0.1
-
+        # Set the initial volume to something manageable
+        amixer set PCM 40
+
        #start mpd
-       /usr/bin/mpd
-
-       #generate playlist and start to play
-       /usr/bin/mpc listall | /usr/bin/mpc add -
-       /usr/bin/mpc play
-       /usr/bin/mpc repeat
+        if [ -x /bin/nice ]; then
+            # This has real-time constraints, so let's at least tell the OS
+            # that this should have higher priority to avoid skipping
+            # when doing other things in the background.
+            nice="nice -n -10"
+        fi
+        $nice /usr/bin/mpd
 }
 
 stop() {

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to