[MPlayer-dev-eng] [PATCH] vo_macosx: use mmap instead of shmat for MPlayerOSX

Adrian Stutz adrian at sttz.ch
Sun Oct 12 23:32:11 CEST 2008


MPlayerOSX and vo_macosx use shmget and shmat for the internal video output
to get the video image to the GUI process.
OSX globally limits the shared memory to 4MB and if other applications
already use shared memory mplayer fails to initialize vo_macosx.

Steps to reproduce:
Either make an application use up most of the shared memory or lower the
limit using:
> sudo sysctl -w kern.sysv.shmall=1
(reset back to default with "sudo sysctl -w kern.sysv.shmall=1024")
Then try to play a video with MPlayerOSX with the internal video output.
Audio starts to play but there's no video. In the console following message
gets repeated:
> vo_mplayer shmget: : Cannot allocate memory
> FATAL: Cannot initialize video driver.

Solution (see attached patches):
Use shm_open and mmap instead of shmget and shmat.
This seems to be recommended by Apple over shmat and works even with the low
limit set above.

I'm not versed in this an made the patch mostly based on the example here:
http://www.opengroup.org/onlinepubs/007908799/xsh/shm_open.html
I've tested it on Leopard and will try to test it on Tiger next week.

The idea of this patch comes from the bug report by Camillo Lists:
http://bugzilla.mplayerhq.hu/show_bug.cgi?id=1295
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vo_macosx_shm.patch
Type: application/octet-stream
Size: 2184 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20081012/5889269a/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mplayerosx_shm.patch
Type: application/octet-stream
Size: 1872 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20081012/5889269a/attachment-0001.obj>


More information about the MPlayer-dev-eng mailing list