Lines Matching +full:r +full:- +full:xp
1 /* Hey Emacs, this is -*-C-*-
3 * linuxaudiodev.c -- Linux audio device for python.
62 { 8, AFMT_MU_LAW, "logarithmic mu-law 8-bit audio" },
63 { 8, AFMT_A_LAW, "logarithmic A-law 8-bit audio" },
64 { 8, AFMT_U8, "linear unsigned 8-bit audio" },
65 { 8, AFMT_S8, "linear signed 8-bit audio" },
66 { 16, AFMT_U16_BE, "linear unsigned 16-bit big-endian audio" },
67 { 16, AFMT_U16_LE, "linear unsigned 16-bit little-endian audio" },
68 { 16, AFMT_S16_BE, "linear signed 16-bit big-endian audio" },
69 { 16, AFMT_S16_LE, "linear signed 16-bit little-endian audio" },
70 { 16, AFMT_S16_NE, "linear signed 16-bit native-endian audio" },
82 lad_t *xp; in newladobject() local
99 if (strcmp(mode, "r") == 0) in newladobject()
104 PyErr_SetString(LinuxAudioError, "mode should be 'r' or 'w'"); in newladobject()
113 * is that the former uses logarithmic mu-law encoding and the in newladobject()
114 * latter uses 8-bit unsigned encoding. in newladobject()
123 if ((fd = open(basedev, imode)) == -1) { in newladobject()
127 if (imode == O_WRONLY && ioctl(fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) { in newladobject()
131 if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) { in newladobject()
136 if ((xp = PyObject_New(lad_t, &Ladtype)) == NULL) { in newladobject()
140 xp->x_fd = fd; in newladobject()
141 xp->x_mode = imode; in newladobject()
142 xp->x_icount = xp->x_ocount = 0; in newladobject()
143 xp->x_afmts = afmts; in newladobject()
144 return xp; in newladobject()
148 lad_dealloc(lad_t *xp) in lad_dealloc() argument
151 if (xp->x_fd != -1) in lad_dealloc()
152 close(xp->x_fd); in lad_dealloc()
153 PyObject_Del(xp); in lad_dealloc()
169 if ((count = read(self->x_fd, cp, size)) < 0) { in lad_read()
174 self->x_icount += count; in lad_read()
193 FD_SET(self->x_fd, &write_set_fds); in lad_write()
198 select_retval = select(self->x_fd+1, NULL, &write_set_fds, NULL, &tv); in lad_write()
201 if ((rv = write(self->x_fd, cp, size)) == -1) { in lad_write()
209 self->x_ocount += rv; in lad_write()
210 size -= rv; in lad_write()
226 if (self->x_fd >= 0) { in lad_close()
227 close(self->x_fd); in lad_close()
228 self->x_fd = -1; in lad_close()
236 return PyInt_FromLong(self->x_fd); in lad_fileno()
279 if ((self->x_afmts & audio_types[n].a_fmt) == 0) { in lad_setparameters()
286 if (ioctl(self->x_fd, SNDCTL_DSP_SETFMT, in lad_setparameters()
287 &audio_types[n].a_fmt) == -1) { in lad_setparameters()
291 if (ioctl(self->x_fd, SNDCTL_DSP_CHANNELS, &nchannels) == -1) { in lad_setparameters()
295 if (ioctl(self->x_fd, SNDCTL_DSP_SPEED, &rate) == -1) { in lad_setparameters()
310 if (ioctl(self->x_fd, SNDCTL_DSP_SETFMT, &fmt) < 0) in _ssize()
311 return -errno; in _ssize()
329 return -EOPNOTSUPP; in _ssize()
331 if (ioctl(self->x_fd, SNDCTL_DSP_CHANNELS, nchannels) < 0) in _ssize()
332 return -errno; in _ssize()
349 if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { in lad_bufsize()
368 if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { in lad_obufcount()
372 return PyInt_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) / in lad_obufcount()
388 if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) { in lad_obuffree()
399 if (ioctl(self->x_fd, SNDCTL_DSP_SYNC, NULL) == -1) { in lad_flush()
412 if (self->x_mode == O_RDONLY) in lad_getptr()
416 if (ioctl(self->x_fd, req, &info) == -1) { in lad_getptr()
438 lad_getattr(lad_t *xp, char *name) in lad_getattr() argument
440 return Py_FindMethod(lad_methods, (PyObject *)xp, name); in lad_getattr()
485 if (PyModule_AddIntConstant(m, "AFMT_MU_LAW", (long)AFMT_MU_LAW) == -1) in initlinuxaudiodev()
487 if (PyModule_AddIntConstant(m, "AFMT_A_LAW", (long)AFMT_A_LAW) == -1) in initlinuxaudiodev()
489 if (PyModule_AddIntConstant(m, "AFMT_U8", (long)AFMT_U8) == -1) in initlinuxaudiodev()
491 if (PyModule_AddIntConstant(m, "AFMT_S8", (long)AFMT_S8) == -1) in initlinuxaudiodev()
493 if (PyModule_AddIntConstant(m, "AFMT_U16_BE", (long)AFMT_U16_BE) == -1) in initlinuxaudiodev()
495 if (PyModule_AddIntConstant(m, "AFMT_U16_LE", (long)AFMT_U16_LE) == -1) in initlinuxaudiodev()
497 if (PyModule_AddIntConstant(m, "AFMT_S16_BE", (long)AFMT_S16_BE) == -1) in initlinuxaudiodev()
499 if (PyModule_AddIntConstant(m, "AFMT_S16_LE", (long)AFMT_S16_LE) == -1) in initlinuxaudiodev()
501 if (PyModule_AddIntConstant(m, "AFMT_S16_NE", (long)AFMT_S16_NE) == -1) in initlinuxaudiodev()