This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
Subject: Re: RealPlayer 5.0 and "rpopen" -- How do you make it work? From: Steve Borho <sborho@ststech.com> Date: Wed, 5 May 1999 12:12:52 -0500 On Wed, May 05, 1999 at 06:14:55AM -0500, Benjamin Sher wrote: > I downloaded the "rpopen" patch by Jeff. I untarred it, but I have no > idea how to compile it. I am sure it's very simple, but I am afraid to > try it without an expert's advice. I'll walk you through it: gauss% tar xzvf rpopen.tar.gz rpopen/ rpopen/open.c rpopen/open.so rpopen/rplayer rpopen/GPL rpopen/Makefile gauss% cd rpopen ~/rpopen gauss% gauss% ls GPL Makefile open.c open.so rplayer Just looking at the filenames, I see this package comes with the GPL license (always good), a Makefile, a single C source file, a shared library, and a shell script (rplayer). The shell script looks like it's intended to be run as a replacement, here's what it looks like: gauss% cat rplayer #!/bin/ash dir=/usr/local/bin/rvplayer5.0 export LD_LIBRARY_PATH=$dir LD_PRELOAD=$dir/open.so exec $dir/rvplayer "$@" So it claims it's an ash script... ash? why ash? do I have ash? gauss% which ash /bin/ash phew. I'm good. Ok, it set's $dir to where rvplayer was installed (this line will have to be tweaked if rvplayer was installed somewhere else on your machine), sets the LD_LIBRARY_PATH and LD_PRELOAD environment variables (I'll get to those in a moment), then runs the real rvplayer. The LD_LIBRARY_PATH and LD_PRELOAD variables are used to override the normal dynamic library linking mechanisms. They're being used here to tell the linux library loader to load open.so before it opens any other libraries. By loading open.so first, it effectively overrides any library calls which are defined there. The nasty exec line does two things: 1) the "$@" syntax is a shell scriptism that stands for "all the command line arguments", so that if you called the rplayer script with the names of 5 real audio sites it will pass those names onto rvplayer. 2) the 'exec' phrase means simply: replace my program (rplayer) with this new program (rvplayer). It's analogous to 'quit this program, then startup this other one'. In practice it works much differently, but that is the net effect. Ok, so basically, rplayer is a 'wrapper' script which preloads the open.so library and then runs the real rvplayer. Cool, so what does open.so do? Well, let's look: gauss% cat open.c /* rpopen: a shared object to work around an incompatibility Copyright 1998, Jeff DeFouw This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define O_NONBLOCK 04000 extern int __open(const char *pathname, int flags, unsigned short mode); int open(const char *pathname, int flags, unsigned short mode) { if (!strcmp("/dev/dsp", pathname)) flags &= ~O_NONBLOCK; return(__open(pathname, flags, mode)); } Sweet, what a hack! It defines a new open() function that ignores all the normal function calls except for when you open the dsp device file. In that case it masks off the O_NONBLOCK bit and then passes it on like normal. Apparently the 2.1 kernel changed the behaviour of blocking in that device driver. So in summary, this package doesn't have a README file, but if it did it would read something like this: To compile, simply run 'make'. open.so is a very simple library so I've included a compiled version for your convenience. To use this hack, simply copy the compiled open.so into the directory where rvplayer was installed, edit the rplayer script to taste, then copy rplayer into your path somewhere and use it instead of rvplayer. ===