[Python-checkins] python/dist/src/Modules ossaudiodev.c,1.23,1.24

gward@users.sourceforge.net gward@users.sourceforge.net
2003年3月09日 19:17:13 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv4076/Modules
Modified Files:
	ossaudiodev.c 
Log Message:
<sys/soundcard.h> seems to exist on both Linux and FreeBSD, so include
it instead of the OS-specific <linux/soundcard.h> or <machine/soundcard.h>.
Mixers devices have an ioctl-only interface, no read/write -- so the
flags passed to open() don't really matter. Thus, drop the 'mode'
parameter to openmixer() (ie. second arg to newossmixerobject()) and
always open mixers with O_RDWR.
Index: ossaudiodev.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/ossaudiodev.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** ossaudiodev.c	13 Feb 2003 13:27:07 -0000	1.23
--- ossaudiodev.c	10 Mar 2003 03:17:06 -0000	1.24
***************
*** 30,46 ****
 #endif
 
- 
 #include <sys/ioctl.h>
 #if defined(linux)
- #include <linux/soundcard.h>
 
 typedef unsigned long uint32_t;
 
 #elif defined(__FreeBSD__)
- #include <machine/soundcard.h>
 
! #ifndef SNDCTL_DSP_CHANNELS
! #define SNDCTL_DSP_CHANNELS SOUND_PCM_WRITE_CHANNELS
! #endif
 
 #endif
--- 30,45 ----
 #endif
 
 #include <sys/ioctl.h>
+ #include <sys/soundcard.h>
+ 
 #if defined(linux)
 
 typedef unsigned long uint32_t;
 
 #elif defined(__FreeBSD__)
 
! # ifndef SNDCTL_DSP_CHANNELS
! # define SNDCTL_DSP_CHANNELS SOUND_PCM_WRITE_CHANNELS
! # endif
 
 #endif
***************
*** 170,178 ****
 newossmixerobject(PyObject *arg)
 {
! char *basedev = NULL, *mode = NULL;
! int fd, imode;
 oss_mixer_t *self;
 
! if (!PyArg_ParseTuple(arg, "|ss", &basedev, &mode)) {
 return NULL;
 }
--- 169,177 ----
 newossmixerobject(PyObject *arg)
 {
! char *basedev = NULL;
! int fd;
 oss_mixer_t *self;
 
! if (!PyArg_ParseTuple(arg, "|s", &basedev)) {
 return NULL;
 }
***************
*** 184,203 ****
 }
 
! if (mode == NULL || strcmp(mode, "r") == 0)
! imode = O_RDONLY;
! else if (strcmp(mode, "w") == 0)
! imode = O_WRONLY;
! else if (strcmp(mode, "rw") == 0)
! imode = O_RDWR;
! else {
! PyErr_SetString(OSSAudioError, "mode must be 'r', 'w', or 'rw'");
! return NULL;
! }
! 
! if ((fd = open(basedev, imode)) == -1) {
 PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev);
 return NULL;
 }
! 
 if ((self = PyObject_New(oss_mixer_t, &OSSMixerType)) == NULL) {
 close(fd);
--- 183,191 ----
 }
 
! if ((fd = open(basedev, O_RDWR)) == -1) {
 PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev);
 return NULL;
 }
! 
 if ((self = PyObject_New(oss_mixer_t, &OSSMixerType)) == NULL) {
 close(fd);

AltStyle によって変換されたページ (->オリジナル) /