Tiny Core Linux

Tiny Core Extensions => TCE Q&A Forum => Topic started by: gavs on September 24, 2010, 02:31:53 PM

Title: mpd: problem starting
Post by: gavs on September 24, 2010, 02:31:53 PM
I am using TC3.1. I installed alsa.tcz and it started OK. I installed mpd.tcz and mpd-doc.tcz, copied the mpd.conf file, modified to specify user=tc, port=6600 and directories for music, playlists, database and log, I created directories and put 3 flac files in the music directory. When I try to start mpd I get the following error:

error while loading shared libraries: libvpx.so.0: cannot map zero-fill pages: cannot allocate memory

Please advise how I can overcome this error and start mpd.

Thank you.
Title: Re: mpd: problem starting
Post by: curaga on September 24, 2010, 02:42:26 PM
The vp8 lib seems to want 514mb of ram. Also seems to be fixed in upstream, so you could PM the libvpx maintainer.
Title: Re: mpd: problem starting
Post by: gavs on September 24, 2010, 03:02:34 PM
Thank you for the prompt response. I am using an older computer with 256mb ram. Sorry for being naive, what do you mean by "you could PM the libvpx maintainer"?
Title: Re: mpd: problem starting
Post by: Lee on September 24, 2010, 03:49:09 PM
PM = private message, a function of the forum software running this message base.  A private message doesn't appear here in the message boards, but the recipient will get an email notification that he has a message waiting (in case he does not frequently visit the forums).

"the libvpx maintainer" = the person who packaged/submitted the libvpx.tcz extension.  You can find this in the .info file for the extension. ("Robert Schumann", in this case).  If you get no response after a few days, mention as much here in this thread.

Of course, there currently is no forum user named "Robert Schumann", so I suppose he used his full name in the info file and uses a nickname here in the forums.

Robert? ...
Title: Re: mpd: problem starting
Post by: Arslan S. on September 24, 2010, 04:12:06 PM

Of course, there currently is no forum user named "Robert Schumann", so I suppose he used his full name in the info file and uses a nickname here in the forums.

Robert? ...


I think Robert Schumann's forum nick is gutmensch
Title: Re: mpd: problem starting
Post by: curaga on September 25, 2010, 02:27:50 AM
Of course I wonder why a _music_ daemon is linked to a video lib at all..
Title: Re: mpd: problem starting
Post by: tinypoodle on September 25, 2010, 04:25:00 AM
Perhaps by design to provide sound track of a video file only?

I can very vaguely remember certain apps being able to output sound only, but accepting video formats as input. Of course that would come at a price of a certain overhead.
Title: Re: mpd: problem starting
Post by: TaoTePuh on September 25, 2010, 03:51:35 PM
libvpx comes as a dependency of ffmpeg-ffserver. Why it is needed by ffmpeg, I do not know.
Title: Re: mpd: problem starting
Post by: gutmensch on September 25, 2010, 07:33:56 PM
New libvpx version 0.9.2-45 from git is on the way ;-)
Title: Re: mpd: problem starting
Post by: TaoTePuh on September 25, 2010, 08:00:20 PM
I can not reproduce this behavior in TC 3.0 :

                    RAM [KB]
start TC            125692
load mpd            160320
load ncmpcpp        164888
start mpd           190356
start ncmpc         193472
play 24-bit FLAC    197542

=> mpd + ncmpc + flac file uses about 70MB.

But I have observed the following:
Little by little, more and more memory is allocated. Regardless of file type (mp3, flac ...). After ~ 30 min, free gives 324244 (used), so about +124 MB. When I stop the player, it stops. When I start the player again, it goes on. Killing mpd, does not bring back the allocated memory.

Memory leak ?
Or is there a file which is growing up in ramfs ?

How can I debug this?
Title: Re: mpd: problem starting
Post by: tinypoodle on September 25, 2010, 11:28:13 PM
Before measuring of each value do a:
Code: [Select]
sudo cache-clear
Title: Re: mpd: problem starting
Post by: curaga on September 26, 2010, 10:37:22 AM
Perhaps by design to provide sound track of a video file only?

I can very vaguely remember certain apps being able to output sound only, but accepting video formats as input. Of course that would come at a price of a certain overhead.

libvpx is useless for that purpose, as to open the container (webm) only libmatroska would be needed.
Title: Re: mpd: problem starting
Post by: gavs on September 27, 2010, 02:47:12 PM
Thanks to all for your advice, and thanks particularly to gutmensch for updating libvpx and to TaoTePuh for clarifying the source of the dependency.

Unfortunately the updated libvpx did not resolve the problem. I continue to get the same error on the computer with 256mb ram. I tried TC3.0, prompted by comment from TaoTePuh, but got the same error message. I moved my testing (ultimately intend to use a new mini-itx as a music player feeding a USB DAC) to a computer with 512mb ram. I do not get this error any longer, but I still have not succedded in starting mpd.

I did an iso boot of TC3.1, downloaded & loaded alsa followed by mpd, created directories and modified /etc/mpd.conf to point to directories and to specify port and user tc (that is all I edited). I receive the error message:

log: problem opening log file "/home/tc/.mpd/log" (config line 37) for writing
Aborted

I figured perhaps permissions were a problem so I chaned to rwx for all (0777), but that did not fix the problem. I then commented the log line in /etc/mpd.conf (accepting default logging in syslog), but I got the following error message:

Failed to load database: Unexpected end of file
database: db file "/home/tc/.mpd/database" is not a regular file

I then tried creating the files in /tmp and modified /etc/mpd.conf accordingly. The same error messages persisted.

Any advice? (I believe the first time I used the 512mb computer I did not get these errors, but when I returned to this the next day, these errors came up. I checked for updated extensions in that interval. I believe the only relevant one is ncurses, but I do not know if that is related to these errors??)

Thank you
Title: Re: mpd: problem starting
Post by: TaoTePuh on September 27, 2010, 03:50:04 PM
Have you started mpd with sudo (sudo mpd /etc/mpd.conf)?
Have you stop mpd between attempts (sudo killall mpd)?

The database error is normal for running the first time cause there is no database file - mpd starts anyway (ps | grep mpd).

Another guess: Have you created the path "/home/tc/.mpd" with the dot before mpd?


Title: Re: mpd: problem starting
Post by: gutmensch on September 27, 2010, 04:09:38 PM
mpd doesn't need sudo since it's opening port 6600, which is available as a normal user...

daemonizing as user tc works fine here and it plays well (didn't try it yet with less than 512 MB though ;) ) with either
~/.mpd/mpd.conf or
~/.mpdconf

(no need for system wide /etc/mpd.conf)

content:
port    6600
music_directory   "/mnt/sda1"
playlist_directory  "~/.mpd/playlists"
db_file    "~/.mpd/mpd.db"
log_file   "~/.mpd/mpd.log"
pid_file   "~/.mpd/mpd.pid"

Code: [Select]
$ mkdir -p ~/.mpd/playlists
Code: [Select]
$ mpd --create-db -v --stdout
Title: Re: mpd: problem starting
Post by: TaoTePuh on September 27, 2010, 04:25:42 PM
Thanks for the sudo correction. I start mpd as root (bootlocal.sh) but with "user    tc" in mpd.conf.
Title: Re: mpd: problem starting
Post by: SamK on September 28, 2010, 03:53:02 AM
...didn't try it yet with less than 512 MB though...
I'm not sure whether this help or hinders your discussion but offer my recent experience with TC3.1+MPD.  

During a testing phase over the last few days, MPD ran on a machine with 128MB RAM of which 16MB was reserved for the video graphics, leaving 112MB available for use by apps.  The music directory was an NTFS partition on an external USB HD accessed via ntfs-3g.  It contained many hundreds of directories holding many thousands of files.

MPD was started from /opt/bootsync.sh and all the configuration files were located in /opt/mpd.

Relevant contents of /opt/mpd/SamK/mpd.conf
Code: [Select]
music_directory "/mnt/sdb1"
playlist_directory "/opt/mpd/SamK/playlists"
db_file "/opt/mpd/database"
pid_file "/opt/mpd/SamK/pid"
bind_to_address "any"
port "6600"

Quote from: gavs
Failed to load database: Unexpected end of file
database: db file "/home/tc/.mpd/database" is not a regular file
This looks suspicious.  Is the problem in some way related to the way in which the database file was created and whether it was successfully created?  It might be helpful to check what type of file it is, can you do the following and post the output?
Code: [Select]
ls -l /home/tc/.mpd/database  
Title: Re: mpd: problem starting
Post by: TaoTePuh on September 28, 2010, 10:27:40 AM
Quote from: gavs
Failed to load database: Unexpected end of file
database: db file "/home/tc/.mpd/database" is not a regular file
This looks suspicious.  Is the problem in some way related to the way in which the database file was created and whether it was successfully created?  It might be helpful to check what type of file it is, can you do the following and post the output?

I have reproduced this message. It occurs when the file "database" is created manually (eg. "touch /home/tc/.mpd/database") before starting mpd. And so gavs did.

But otherwise mpd starts completely normal, begins indexing, overwrite the "wrong file" and works without restarting.
Title: Re: mpd: problem starting
Post by: gavs on September 28, 2010, 05:37:31 PM
Thank you all for your perseverance. The discussion has helped me better understand how to use mpd (e.g. as sudo vs daemonized as tc). Your comments also helped me realize what I was doing wrong. I apologize for my carelessness. I had read the note about creating necessary directories and after reading 'playlist directory' in mpdconf.example, I just assumed the log, database, pid and state lines were also for directories (though it clearly writes 'log file', 'database file', etc. My mistake was to not onlyexecute mkdir -p ~/.mpd/playlists, but to also execute mkdir -p ~/.mpd/log, etc. Things work as expected when I do not create these directories.

Regarding the issue of ram, thank you to SamK for the suggestion about /opt/bootsync.sh. I am not familiar with bootsync.sh (I have used bootlocal.sh), but I will look into this and see if I can make it work on the 256mb ram computer.

Thank you all for your assistance and advice to get mpd working on the 512mb ram computer.
Title: Re: mpd: problem starting
Post by: gutmensch on September 28, 2010, 05:58:33 PM
FWIW I tested mpd tomorrow morning with 128 MB of RAM, after loading and executing mpd there were still about 60 MB free!
You're welcome, gavs :)
Best regards,
Robert
Title: Re: mpd: problem starting
Post by: gavs on September 29, 2010, 01:50:48 PM
Both Robert and SamK reported success starting mpd with low RAM. I tried again on the 256mb computer and was unsuccessful. So, I considered trying to reproduce the behaviour of libvpx on the 512mb computer.

First I booted TC3.1 from iso with option noswap. Then I executed sudo swapoff /dev/ramzswap0 to eliminate confusion with RAM swapping. I then downloaded and loaded extensions until I brought the free memory on the 512mb computer to less than what was available on the 256mb computer. After executing sudo cache-clear the results of free indicated 0 for all swap entries and identical entries for mem and total with total=514212, used=323632, free=190580, shared=0 and buffers=12. When I tried to start mpd I obtained the libvpx memory error message.

This surprised me as I had seen some web postings indicating that the memory useage had been fixed in version libvpx-0.9.1-2.fc12 (though this was for redhat??). I think the version in TC is more recent?

In conclusion, I was able to reproduce the libvpx memory error on the 512mb computer by 'using up' sufficient memory. I wonder if Robert and SamK could check if they were using swapfiles and ramswap0 (I think the TC3.1 default is to set ramswap0 to 25% of available RAM)

Hope this experiment sheds some insight.
Title: Re: mpd: problem starting
Post by: gutmensch on September 29, 2010, 02:28:30 PM
I checked again, strace still reports libvpx is trying to map over 512 MB of memory, so with "real" 128 MB and no swap (sorry for that) it's not working. Right now I'm trying to build "stable" 0.9.2 (without git rev) and see if it changes anything  :-\
Title: Re: mpd: problem starting
Post by: gutmensch on September 29, 2010, 02:42:24 PM
according to the git tree it seems that --enable-psnr is causing this memory adressing issue, atm trying to build without it ;-)

[edit]
this seems to fix the issue, new version is submitted ;)
[/edit]
Title: Re: mpd: problem starting
Post by: SamK on September 30, 2010, 07:01:55 AM
...I wonder if Robert and SamK could check if they were using swapfiles....
I went back and inspected the test machine.  It has 128MB physical RAM + access to a 512MB swapfile.

Good catch.
 
Title: Re: mpd: problem starting
Post by: gavs on September 30, 2010, 11:04:47 AM
I was successful loading alsa+mpd+gmpc to TC3.1 on the 128mb ram computer and playing music (using ntfs-3g to access music on external usb NTFS drive).

Thanks to everyone for their advice and assistance, to the TC team for making all this possible and particular thanks to Robert for revising libvpx.