[MPlayer-users] [Patch] Disable file syatem driver cache

Zongyao Qu zongyao.qu at gmail.com
Fri Dec 16 03:38:11 CET 2011


Sorry I don't know how to post a attachment, 
so I copy-paste the content in the post.


--- /Temp/str407A.tmp/stream_file-745838-left.c
	Fri Dec 16 11:18:15 2011
+++ /Develop/mplayer-for-MPlayerX/stream/stream_file.c
	Fri Dec 16 11:15:40 2011
@@ -175,6 +175,10 @@
       m_struct_free(&stream_opts,opts);
       return STREAM_ERROR;
     }
+	// turn os file caching off
+	fcntl( f, F_NOCACHE, 1 );
+	// enable read ahead
+	fcntl( f, F_RDAHEAD, 1 );
   }
 
   len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET);

[ This patch is especially useful for Mac OSX, but I am
not sure how about Linux and other OSs. ]

In Mac, the driver will fill the unused memory 
for caching, by default.

So if a huge file(1080P, etc) is played, driver will 
use up all the memory, and if there are other apps ask
for memory, page swap will happen.

This is not a leak, but it seams driver won't release
that cache, until I reboot it, or unmount the
volume in which the cached media file is.

So I think disabling the driver caching for Mac seams to
be a good idea, BUT accordingly, the soft cache must be
always ON, otherwise, it will be lagging.

So if this patch is accepted, I think the side effect
should also be written somewhere.



More information about the MPlayer-users mailing list