aoss patch [against cvs?]
Hi
here's a patch that builds upon my last one.. this cleans minor things up a little bit and changes the manpage.. So this is not against 1.0.5, but against 1.0.5 with my other patch applied..
Actually: is checking for the device files name in /dev/sound/ nessecary? or is every sane devfs installation required to make symlinks to /dev/ anyways?
Flo
snip-------------- [also attached]
alsa/alsa-oss.c +23 -13
@@ -104,6 +104,26 @@static int poll_fds_add =0 ;static fd_t **fds; +static int is_dsp_device (const char *pathname) +{ +if (!pathname)return 0 ; +if (strncmp (pathname,"/dev/dsp" ,8 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/adsp" ,9 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/audio" ,10 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/sound/dsp" ,14 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/sound/adsp" ,15 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/sound/audio" ,16 ) ==0 )return 1 ; +return 0 ; +} + +static int is_mixer_device (const char *pathname) +{ +if (!pathname)return 0 ; +if (strncmp (pathname,"/dev/mixer" ,10 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/sound/mixer" ,16 ) ==0 )return 1 ; +return 0 ; +} +static int oss_pcm_fcntl (int fd,int cmd, ...) {int result;
@@ -217,9 +237,7 @@ mode =va_arg (args, mode_t);va_end (args); } -if (!strncmp (file,"/dev/dsp" ,8 ) || - !strncmp (file,"/dev/adsp" ,9 ) || - !strncmp (file,"/dev/audio" ,10 )) { +if (is_dsp_device (file)) { fd =lib_oss_pcm_open (file, oflag);if (fd >=0 ) { fds[fd] =calloc (sizeof (fd_t),1 );
@@ -232,7 +250,7 @@ fds[fd]->oflags = oflag; poll_fds_add +=lib_oss_pcm_poll_fds (fd); } - }else if (!strncmp (file,"/dev/mixer" ,10 )) { + }else if (is_mixer_device (file)) { fd =lib_oss_mixer_open (file, oflag);if (fd >=0 ) { fds[fd] =calloc (sizeof (fd_t),1 );
@@ -632,19 +650,11 @@return count1; } -static int is_sound_device (const char *pathname) -{ -if (!pathname)return 0 ; -if (strncmp (pathname,"/dev/dsp" ,8 ) ==0 )return 1 ; -if (strncmp (pathname,"/dev/sound/dsp" ,14 ) ==0 )return 1 ; -return 0 ; -} -#include "stdioemu.c" FILE *fopen (const char * path,const char *mode) { -if (!is_sound_device (path)) +if (!is_dsp_device (path))return _fopen (path, mode);return fake_fopen (path, mode);
alsa/aoss.1 +0 -1
@@ -30,7 +30,6 @@ In the above configuration examples, the pcm.dsp0 definition is used to wrap calls do /dev/dsp0. You can also wrap usage of /dev/dsp1, /dev/dsp2, etc. by defining pcm.dsp1, pcm.dsp2, etc.. -In the current form, aoss is not able to wrap OSS applications that make use of libc's FILE* infrastructure (fopen() and friends) for their communication with the OSS sound driver. This is because libc uses internal versions of open() and friends which cannot be intercepted by LD_PRELOAD'ing a shared library.. .SS Arguments .TP
Signature · 2 lines
Palimm Palimm! http://affenbande.org/~tapas/
alsa/alsa-oss.c +23 -13
@@ -104,6 +104,26 @@static int poll_fds_add =0 ;static fd_t **fds; +static int is_dsp_device (const char *pathname) +{ +if (!pathname)return 0 ; +if (strncmp (pathname,"/dev/dsp" ,8 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/adsp" ,9 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/audio" ,10 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/sound/dsp" ,14 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/sound/adsp" ,15 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/sound/audio" ,16 ) ==0 )return 1 ; +return 0 ; +} + +static int is_mixer_device (const char *pathname) +{ +if (!pathname)return 0 ; +if (strncmp (pathname,"/dev/mixer" ,10 ) ==0 )return 1 ; +if (strncmp (pathname,"/dev/sound/mixer" ,16 ) ==0 )return 1 ; +return 0 ; +} +static int oss_pcm_fcntl (int fd,int cmd, ...) {int result;
@@ -217,9 +237,7 @@ mode =va_arg (args, mode_t);va_end (args); } -if (!strncmp (file,"/dev/dsp" ,8 ) || - !strncmp (file,"/dev/adsp" ,9 ) || - !strncmp (file,"/dev/audio" ,10 )) { +if (is_dsp_device (file)) { fd =lib_oss_pcm_open (file, oflag);if (fd >=0 ) { fds[fd] =calloc (sizeof (fd_t),1 );
@@ -232,7 +250,7 @@ fds[fd]->oflags = oflag; poll_fds_add +=lib_oss_pcm_poll_fds (fd); } - }else if (!strncmp (file,"/dev/mixer" ,10 )) { + }else if (is_mixer_device (file)) { fd =lib_oss_mixer_open (file, oflag);if (fd >=0 ) { fds[fd] =calloc (sizeof (fd_t),1 );
@@ -632,19 +650,11 @@return count1; } -static int is_sound_device (const char *pathname) -{ -if (!pathname)return 0 ; -if (strncmp (pathname,"/dev/dsp" ,8 ) ==0 )return 1 ; -if (strncmp (pathname,"/dev/sound/dsp" ,14 ) ==0 )return 1 ; -return 0 ; -} -#include "stdioemu.c" FILE *fopen (const char * path,const char *mode) { -if (!is_sound_device (path)) +if (!is_dsp_device (path))return _fopen (path, mode);return fake_fopen (path, mode);
alsa/aoss.1 +0 -1
@@ -30,7 +30,6 @@ In the above configuration examples, the pcm.dsp0 definition is used to wrap calls do /dev/dsp0. You can also wrap usage of /dev/dsp1, /dev/dsp2, etc. by defining pcm.dsp1, pcm.dsp2, etc.. -In the current form, aoss is not able to wrap OSS applications that make use of libc's FILE* infrastructure (fopen() and friends) for their communication with the OSS sound driver. This is because libc uses internal versions of open() and friends which cannot be intercepted by LD_PRELOAD'ing a shared library.. .SS Arguments .TP
At Fri, 23 Jul 2004 16:48:16 +0200,
Quoted 6 lines · Florian Schmidt
Hi
here's a patch that builds upon my last one.. this cleans minor things up a little bit and changes the manpage.. So this is not against 1.0.5, but against 1.0.5 with my other patch applied..
Don't we need to check /dev/dsp[0-9] and /dev/mixer[0-9]?
Quoted 3 lines
Actually: is checking for the device files name in
/dev/sound/nessecary? or is every sane devfs installation required to make symlinks to/dev/anyways?
/dev/sound is used for devfs.
Let's keep it for a while until devfs is completely obsoleted.
Takashi
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
Quoted 10 lines · On Tue, 27 Jul 2004 15:51:49 +0200 Takashi Iwai <[email protected]> wrote:
At Fri, 23 Jul 2004 16:48:16 +0200,
Quoted 6 lines · Florian Schmidt
Hi
here's a patch that builds upon my last one.. this cleans minor things up a little bit and changes the manpage.. So this is not against 1.0.5, but against 1.0.5 with my other patch applied..
Don't we need to check /dev/dsp[0-9] and /dev/mixer[0-9]?
static int is_dsp_device(const char *pathname)
{
if(!pathname) return 0;
if(strncmp(pathname,"/dev/dsp",8) == 0) return 1;
if(strncmp(pathname,"/dev/adsp",9) == 0) return 1;
if(strncmp(pathname,"/dev/audio",10) == 0) return 1;
if(strncmp(pathname,"/dev/sound/dsp",14) == 0) return 1;
if(strncmp(pathname,"/dev/sound/adsp",15) == 0) return 1;
if(strncmp(pathname,"/dev/sound/audio",16) == 0) return 1;
return 0;
}this should return 1 for /dev/dsp*, dev/adsp*, /dev/audio*, /dev/sound/dsp*, dev/sound/adsp*, /dev/sound/audio*,
and this
static int is_mixer_device(const char *pathname)
{
if(!pathname) return 0;
if(strncmp(pathname,"/dev/mixer",10) == 0) return 1;
if(strncmp(pathname,"/dev/sound/mixer",16) == 0) return 1;
return 0;
}should as well check /dev/mixer* and /dev/sound/*. I added the /dev/sound/* support because i thought that devfs users might have set their OSS apps to use the device files in /dev/sounds. The /dev/audio* support was in the original alsa-oss.c. But it's good that you ask, because i'm not sure, if this is "the right thing to do"..
I also wondered about the effect of specifying different dspN's [with N element of {"", "0", .. ,"9"}]. Afaics this doesn't really have an effect on the alsa-oss lib.. Oh i see it now.. The mapping happens in pcm.c and mixer.c. In pcm.c lib_oss_pcm_open redoes the checks.. Hmm , i have to meditate over this for a while. Regard my last patch as not mailed to the mailing list :)
Florian Schmidt
Signature · 10 lines
Palimm Palimm! http://affenbande.org/~tapas/ ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
At Tue, 27 Jul 2004 17:45:22 +0200,
Quoted 33 lines · Florian Schmidt
Quoted 10 lines · On Tue, 27 Jul 2004 15:51:49 +0200 Takashi Iwai <[email protected]> wrote:
At Fri, 23 Jul 2004 16:48:16 +0200,
Quoted 6 lines · Florian Schmidt
Hi
here's a patch that builds upon my last one.. this cleans minor things up a little bit and changes the manpage.. So this is not against 1.0.5, but against 1.0.5 with my other patch applied..
Don't we need to check /dev/dsp[0-9] and /dev/mixer[0-9]?
static int
is_dsp_device(const char *pathname){ if(!pathname) return 0; if(strncmp(pathname,"/dev/dsp",8) == 0) return 1; if(strncmp(pathname,"/dev/adsp",9) == 0) return 1; if(strncmp(pathname,"/dev/audio",10) == 0) return 1; if(strncmp(pathname,"/dev/sound/dsp",14) == 0) return 1; if(strncmp(pathname,"/dev/sound/adsp",15) == 0) return 1; if(strncmp(pathname,"/dev/sound/audio",16) == 0) return 1; return 0; }this should return 1 for
/dev/dsp*, dev/adsp*,/dev/audio*,/dev/sound/dsp*, dev/sound/adsp*,/dev/sound/audio*,and this
static int
is_mixer_device(const char *pathname)
Quoted 8 lines
{ if(!pathname) return 0; if(strncmp(pathname,"/dev/mixer",10) == 0) return 1; if(strncmp(pathname,"/dev/sound/mixer",16) == 0) return 1; return 0; }should as well check
/dev/mixer*and/dev/sound/*.
Ok, point taken.
Your patch was applied to cvs now.
thanks,
Takashi
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
Quoted 2 lines · On Tue, 27 Jul 2004 18:05:55 +0200 Takashi Iwai <[email protected]> wrote:
Ok, point taken.
Your patch was applied to cvs now.
I have to revisit this patch again to bring this device file name checking from alsa-oss.c in sync with
static int oss_mixer_open(int card, int device, int oflag, mode_t mode ATTRIBUTE_UNUSED);
in mixer.c and
int lib_oss_pcm_open(const char *file, int oflag, ...);
in pcm.c. Expect patch in the next few days.. I have to meditate over this a bit first.
Florian Schmidt
Signature · 10 lines
Palimm Palimm! http://affenbande.org/~tapas/ ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click