From: Takashi Iwai Date: Tue, 27 Jul 2004 16:04:54 +0000 (+0000) Subject: Fixes by Florian Schmidt : X-Git-Tag: v1.0.6~3 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=e9655acfea3a5bc319a5c9a9befe61334c58bc4e;p=alsa-oss.git Fixes by Florian Schmidt : - Checks more device file names for fopen() wrappers. - Fixed manpage. --- diff --git a/alsa/alsa-oss.c b/alsa/alsa-oss.c index 49768d5..c8892bc 100644 --- a/alsa/alsa-oss.c +++ b/alsa/alsa-oss.c @@ -104,6 +104,26 @@ static int open_max; 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 @@ int open(const char *file, int oflag, ...) 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 @@ int open(const char *file, int oflag, ...) 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 @@ int select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, 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); diff --git a/alsa/aoss.1 b/alsa/aoss.1 index ae55bfc..64ec383 100644 --- a/alsa/aoss.1 +++ b/alsa/aoss.1 @@ -30,7 +30,6 @@ pcm.dsp0 { 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