I said I'd never blog

DeforaOS, NetBSD, reverse-engineering and stuff

Older stuff...

mplayer + X11 + SHM = ?
Thu Jan 3 15:21:25 CET 2008

My laptop contains a Radeon Mobility X1400 graphics card. I cannot really complain to own a recent one, but it is really annoying to not be able to use it to its full potential yet, even if I must say the radeonhd driver has made awesome progress since it started not so long ago. In a way, the lack of 3D support is probably also helping my productivity :)

If there is one thing that I need though, it's decent fullscreen video playback. I usually do it with mplayer, but since my last packages upgrade it kept crashing in some obscure inline assembly section. I have to admit I preferred to try to upgrade to the latest version instead of fixing it (which looked very painful). After a number of fights with the build system of mplayer, I finally managed to have it compile and link, and will try to gather my experience in a PR (side-note: it's confusing that the package says 1.0rc9 when the actual version is 1.0rc1).

Everything looked fine until I noticed that with some videos, fullscreen playback was really slow. The following messages were printed by mplayer whenever resizing the window big enough:

Shared memory error,disabling ( seg id error )
After analyzing the source code and enabling the call to perror("shmget") in libvo/vo_x11.c line 187, I had confirmation of the problem: "Cannot allocate memory".

It turns out NetBSD has rather severe default limitations on the maximum amount of shared memory available to the user. It can be tweaked with the following controls:

$ sysctl -a | grep shm
kern.ipc.sysvshm = 1
kern.ipc.shmmax = 33554432
kern.ipc.shmmni = 128
kern.ipc.shmseg = 128
kern.ipc.shmmaxpgs = 4096
kern.ipc.shm_use_phys = 0
But the value of kern.ipc.shmmax cannot be changed. However, kern.ipc.shmmaxpgs can, and increasing it to 4096 instead of the default 2048 finally solved the problem for me.

Come back...
Creative Commons License