annotate Modules/sunaudiodev.c @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents 52294af4b663
children fd25030223b0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 /* Sad objects */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
4 #include "Python.h"
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #include "structmember.h"
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
7 #ifdef HAVE_SYS_AUDIOIO_H
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
8 #define SOLARIS
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
9 #endif
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
10
4652
3d87cb1b3d17 Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
11 #ifdef HAVE_FCNTL_H
3d87cb1b3d17 Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
12 #include <fcntl.h>
3d87cb1b3d17 Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
13 #endif
3d87cb1b3d17 Make gcc -Wall happy; remove dummy variable (can't see where it's needed).
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
14
1313
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
15 #include <stropts.h>
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 #include <sys/ioctl.h>
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
17 #ifdef SOLARIS
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
18 #include <sys/audioio.h>
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
19 #else
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 #include <sun/audioio.h>
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
21 #endif
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 /* #define offsetof(str,mem) ((int)(((str *)0)->mem)) */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 typedef struct {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
26 PyObject_HEAD
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 int x_fd; /* The open file */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 int x_icount; /* # samples read */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 int x_ocount; /* # samples written */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 int x_isctl; /* True if control device */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 } sadobject;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
33
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 typedef struct {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
35 PyObject_HEAD
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 audio_info_t ai;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 } sadstatusobject;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
38
24280
1598a1e473e2 staticforward bites the dust.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 22709
diff changeset
39 static PyTypeObject Sadtype;
1598a1e473e2 staticforward bites the dust.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 22709
diff changeset
40 static PyTypeObject Sadstatustype;
13690
c09c0171474f ANSIfy some more forward declarations.
Thomas Wouters <thomas@python.org>
parents: 13651
diff changeset
41 static sadstatusobject *sads_alloc(void); /* Forward */
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
42
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
43 static PyObject *SunAudioError;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
44
44350
26384b8180c7 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
45 #define is_sadobject(v) (Py_TYPE(v) == &Sadtype)
26384b8180c7 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
46 #define is_sadstatusobject(v) (Py_TYPE(v) == &Sadstatustype)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
47
9466
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
48
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 static sadobject *
13520
27d87e072bfb ANSI-fication (fixed on parameter list I messed up in the patch)
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
50 newsadobject(PyObject *args)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 sadobject *xp;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 int fd;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 char *mode;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 int imode;
9466
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
56 char* basedev;
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
57 char* ctldev;
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
58 char* opendev;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
59
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 /* Check arg for r/w/rw */
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
61 if (!PyArg_ParseTuple(args, "s", &mode))
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
62 return NULL;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
63 if (strcmp(mode, "r") == 0)
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
64 imode = 0;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
65 else if (strcmp(mode, "w") == 0)
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
66 imode = 1;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
67 else if (strcmp(mode, "rw") == 0)
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
68 imode = 2;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
69 else if (strcmp(mode, "control") == 0)
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
70 imode = -1;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 else {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
72 PyErr_SetString(SunAudioError,
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
73 "Mode should be one of 'r', 'w', 'rw' or 'control'");
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
74 return NULL;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
76
9466
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
77 /* Open the correct device. The base device name comes from the
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
78 * AUDIODEV environment variable first, then /dev/audio. The
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
79 * control device tacks "ctl" onto the base device name.
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
80 */
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
81 basedev = getenv("AUDIODEV");
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
82 if (!basedev)
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
83 basedev = "/dev/audio";
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
84 ctldev = PyMem_NEW(char, strlen(basedev) + 4);
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
85 if (!ctldev) {
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
86 PyErr_NoMemory();
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
87 return NULL;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 }
9466
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
89 strcpy(ctldev, basedev);
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
90 strcat(ctldev, "ctl");
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
91
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
92 if (imode < 0) {
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
93 opendev = ctldev;
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
94 fd = open(ctldev, 2);
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
95 }
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
96 else {
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
97 opendev = basedev;
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
98 fd = open(basedev, imode);
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
99 }
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
100 if (fd < 0) {
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
101 PyErr_SetFromErrnoWithFilename(SunAudioError, opendev);
20922
7a991d012cd6 Fix memory leak. This is part of SF patch #478006.
Fred Drake <fdrake@acm.org>
parents: 14375
diff changeset
102 PyMem_DEL(ctldev);
9466
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
103 return NULL;
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
104 }
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
105 PyMem_DEL(ctldev);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
106
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 /* Create and initialize the object */
12576
1c7c2dd1beb1 Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents: 9466
diff changeset
108 xp = PyObject_New(sadobject, &Sadtype);
4919
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
109 if (xp == NULL) {
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
110 close(fd);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
111 return NULL;
4919
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
112 }
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
113 xp->x_fd = fd;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
114 xp->x_icount = xp->x_ocount = 0;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
115 xp->x_isctl = (imode < 0);
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
116
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
117 return xp;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
119
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
120 /* Sad methods */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
121
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
122 static void
13520
27d87e072bfb ANSI-fication (fixed on parameter list I messed up in the patch)
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
123 sad_dealloc(sadobject *xp)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
124 {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
125 close(xp->x_fd);
12576
1c7c2dd1beb1 Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents: 9466
diff changeset
126 PyObject_Del(xp);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
127 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
128
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
129 static PyObject *
13520
27d87e072bfb ANSI-fication (fixed on parameter list I messed up in the patch)
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
130 sad_read(sadobject *self, PyObject *args)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
131 {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
132 int size, count;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
133 char *cp;
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
134 PyObject *rv;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
135
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
136 if (!PyArg_ParseTuple(args, "i:read", &size))
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
137 return NULL;
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
138 rv = PyString_FromStringAndSize(NULL, size);
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
139 if (rv == NULL)
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
140 return NULL;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
141
47527
52294af4b663 This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents: 47294
diff changeset
142 if (!(cp = PyString_AsString(rv)))
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
143 goto finally;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
144
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
145 count = read(self->x_fd, cp, size);
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
146 if (count < 0) {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
147 PyErr_SetFromErrno(SunAudioError);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
148 goto finally;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
149 }
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
150 #if 0
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
151 /* TBD: why print this message if you can handle the condition?
4919
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
152 * assume it's debugging info which we can just as well get rid
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
153 * of. in any case this message should *not* be using printf!
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
154 */
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
155 if (count != size)
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
156 printf("sunaudio: funny read rv %d wtd %d\n", count, size);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
157 #endif
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
158 self->x_icount += count;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
159 return rv;
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
160
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
161 finally:
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
162 Py_DECREF(rv);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
163 return NULL;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
165
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
166 static PyObject *
13520
27d87e072bfb ANSI-fication (fixed on parameter list I messed up in the patch)
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
167 sad_write(sadobject *self, PyObject *args)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
168 {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
169 char *cp;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
170 int count, size;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
171
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
172 if (!PyArg_ParseTuple(args, "s#:write", &cp, &size))
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
173 return NULL;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
174
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
175 count = write(self->x_fd, cp, size);
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
176 if (count < 0) {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
177 PyErr_SetFromErrno(SunAudioError);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
178 return NULL;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
179 }
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
180 #if 0
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
181 if (count != size)
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
182 printf("sunaudio: funny write rv %d wanted %d\n", count, size);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
183 #endif
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
184 self->x_ocount += count;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
185
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
186 Py_INCREF(Py_None);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
187 return Py_None;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
188 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
189
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
190 static PyObject *
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
191 sad_getinfo(sadobject *self)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
192 {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
193 sadstatusobject *rv;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
194
4919
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
195 if (!(rv = sads_alloc()))
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
196 return NULL;
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
197
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
198 if (ioctl(self->x_fd, AUDIO_GETINFO, &rv->ai) < 0) {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
199 PyErr_SetFromErrno(SunAudioError);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
200 Py_DECREF(rv);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
201 return NULL;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
202 }
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
203 return (PyObject *)rv;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
204 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
205
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
206 static PyObject *
13520
27d87e072bfb ANSI-fication (fixed on parameter list I messed up in the patch)
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
207 sad_setinfo(sadobject *self, sadstatusobject *arg)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
208 {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
209 if (!is_sadstatusobject(arg)) {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
210 PyErr_SetString(PyExc_TypeError,
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
211 "Must be sun audio status object");
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
212 return NULL;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
213 }
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
214 if (ioctl(self->x_fd, AUDIO_SETINFO, &arg->ai) < 0) {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
215 PyErr_SetFromErrno(SunAudioError);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
216 return NULL;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
217 }
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
218 Py_INCREF(Py_None);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
219 return Py_None;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
220 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
221
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
222 static PyObject *
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
223 sad_ibufcount(sadobject *self)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
224 {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
225 audio_info_t ai;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
226
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
227 if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
228 PyErr_SetFromErrno(SunAudioError);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
229 return NULL;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
230 }
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
231 return PyInt_FromLong(ai.record.samples - self->x_icount);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
232 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
233
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
234 static PyObject *
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
235 sad_obufcount(sadobject *self)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
236 {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
237 audio_info_t ai;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
238
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
239 if (ioctl(self->x_fd, AUDIO_GETINFO, &ai) < 0) {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
240 PyErr_SetFromErrno(SunAudioError);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
241 return NULL;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
242 }
13620
5b727ab37092 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents: 13520
diff changeset
243 /* x_ocount is in bytes, whereas play.samples is in frames */
5295
2f2760c3dd90 Bugfix by Sjoerd:
Guido van Rossum <guido@python.org>
parents: 4919
diff changeset
244 /* we want frames */
2f2760c3dd90 Bugfix by Sjoerd:
Guido van Rossum <guido@python.org>
parents: 4919
diff changeset
245 return PyInt_FromLong(self->x_ocount / (ai.play.channels *
2f2760c3dd90 Bugfix by Sjoerd:
Guido van Rossum <guido@python.org>
parents: 4919
diff changeset
246 ai.play.precision / 8) -
2f2760c3dd90 Bugfix by Sjoerd:
Guido van Rossum <guido@python.org>
parents: 4919
diff changeset
247 ai.play.samples);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
248 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
249
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
250 static PyObject *
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
251 sad_drain(sadobject *self)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
252 {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
253 if (ioctl(self->x_fd, AUDIO_DRAIN, 0) < 0) {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
254 PyErr_SetFromErrno(SunAudioError);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
255 return NULL;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
256 }
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
257 Py_INCREF(Py_None);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
258 return Py_None;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
259 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
260
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
261 #ifdef SOLARIS
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
262 static PyObject *
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
263 sad_getdev(sadobject *self)
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
264 {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
265 struct audio_device ad;
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
266
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
267 if (ioctl(self->x_fd, AUDIO_GETDEV, &ad) < 0) {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
268 PyErr_SetFromErrno(SunAudioError);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
269 return NULL;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
270 }
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
271 return Py_BuildValue("(sss)", ad.name, ad.version, ad.config);
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
272 }
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
273 #endif
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
274
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
275 static PyObject *
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
276 sad_flush(sadobject *self)
1313
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
277 {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
278 if (ioctl(self->x_fd, I_FLUSH, FLUSHW) < 0) {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
279 PyErr_SetFromErrno(SunAudioError);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
280 return NULL;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
281 }
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
282 Py_INCREF(Py_None);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
283 return Py_None;
1313
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
284 }
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
285
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
286 static PyObject *
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
287 sad_close(sadobject *self)
1313
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
288 {
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
289
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
290 if (self->x_fd >= 0) {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
291 close(self->x_fd);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
292 self->x_fd = -1;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
293 }
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
294 Py_INCREF(Py_None);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
295 return Py_None;
1313
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
296 }
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
297
9466
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
298 static PyObject *
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
299 sad_fileno(sadobject *self)
9466
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
300 {
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
301 return PyInt_FromLong(self->x_fd);
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
302 }
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
303
6a244e64b3e6 audio(7I) suggests that applications do the following to get the
Barry Warsaw <barry@python.org>
parents: 6367
diff changeset
304
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
305 static PyMethodDef sad_methods[] = {
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
306 { "read", (PyCFunction)sad_read, METH_VARARGS },
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
307 { "write", (PyCFunction)sad_write, METH_VARARGS },
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
308 { "ibufcount", (PyCFunction)sad_ibufcount, METH_NOARGS },
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
309 { "obufcount", (PyCFunction)sad_obufcount, METH_NOARGS },
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
310 #define CTL_METHODS 4
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
311 { "getinfo", (PyCFunction)sad_getinfo, METH_NOARGS },
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
312 { "setinfo", (PyCFunction)sad_setinfo, METH_O},
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
313 { "drain", (PyCFunction)sad_drain, METH_NOARGS },
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
314 { "flush", (PyCFunction)sad_flush, METH_NOARGS },
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
315 #ifdef SOLARIS
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
316 { "getdev", (PyCFunction)sad_getdev, METH_NOARGS },
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
317 #endif
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
318 { "close", (PyCFunction)sad_close, METH_NOARGS },
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
319 { "fileno", (PyCFunction)sad_fileno, METH_NOARGS },
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
320 {NULL, NULL} /* sentinel */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
321 };
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
322
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
323 static PyObject *
13520
27d87e072bfb ANSI-fication (fixed on parameter list I messed up in the patch)
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
324 sad_getattr(sadobject *xp, char *name)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
325 {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
326 if (xp->x_isctl)
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
327 return Py_FindMethod(sad_methods+CTL_METHODS,
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
328 (PyObject *)xp, name);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
329 else
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
330 return Py_FindMethod(sad_methods, (PyObject *)xp, name);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
331 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
332
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
333 /* ----------------------------------------------------------------- */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
334
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
335 static sadstatusobject *
13690
c09c0171474f ANSIfy some more forward declarations.
Thomas Wouters <thomas@python.org>
parents: 13651
diff changeset
336 sads_alloc(void) {
12576
1c7c2dd1beb1 Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents: 9466
diff changeset
337 return PyObject_New(sadstatusobject, &Sadstatustype);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
338 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
339
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
340 static void
13520
27d87e072bfb ANSI-fication (fixed on parameter list I messed up in the patch)
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
341 sads_dealloc(sadstatusobject *xp)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
342 {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
343 PyMem_DEL(xp);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
344 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
345
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
346 #define OFF(x) offsetof(audio_info_t,x)
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
347 static struct memberlist sads_ml[] = {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
348 { "i_sample_rate", T_UINT, OFF(record.sample_rate) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
349 { "i_channels", T_UINT, OFF(record.channels) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
350 { "i_precision", T_UINT, OFF(record.precision) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
351 { "i_encoding", T_UINT, OFF(record.encoding) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
352 { "i_gain", T_UINT, OFF(record.gain) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
353 { "i_port", T_UINT, OFF(record.port) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
354 { "i_samples", T_UINT, OFF(record.samples) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
355 { "i_eof", T_UINT, OFF(record.eof) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
356 { "i_pause", T_UBYTE, OFF(record.pause) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
357 { "i_error", T_UBYTE, OFF(record.error) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
358 { "i_waiting", T_UBYTE, OFF(record.waiting) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
359 { "i_open", T_UBYTE, OFF(record.open) , RO},
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
360 { "i_active", T_UBYTE, OFF(record.active) , RO},
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
361 #ifdef SOLARIS
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
362 { "i_buffer_size", T_UINT, OFF(record.buffer_size) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
363 { "i_balance", T_UBYTE, OFF(record.balance) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
364 { "i_avail_ports", T_UINT, OFF(record.avail_ports) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
365 #endif
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
366
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
367 { "o_sample_rate", T_UINT, OFF(play.sample_rate) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
368 { "o_channels", T_UINT, OFF(play.channels) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
369 { "o_precision", T_UINT, OFF(play.precision) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
370 { "o_encoding", T_UINT, OFF(play.encoding) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
371 { "o_gain", T_UINT, OFF(play.gain) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
372 { "o_port", T_UINT, OFF(play.port) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
373 { "o_samples", T_UINT, OFF(play.samples) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
374 { "o_eof", T_UINT, OFF(play.eof) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
375 { "o_pause", T_UBYTE, OFF(play.pause) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
376 { "o_error", T_UBYTE, OFF(play.error) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
377 { "o_waiting", T_UBYTE, OFF(play.waiting) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
378 { "o_open", T_UBYTE, OFF(play.open) , RO},
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
379 { "o_active", T_UBYTE, OFF(play.active) , RO},
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
380 #ifdef SOLARIS
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
381 { "o_buffer_size", T_UINT, OFF(play.buffer_size) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
382 { "o_balance", T_UBYTE, OFF(play.balance) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
383 { "o_avail_ports", T_UINT, OFF(play.avail_ports) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
384 #endif
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
385
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
386 { "monitor_gain", T_UINT, OFF(monitor_gain) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
387 { NULL, 0, 0},
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
388 };
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
389
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
390 static PyObject *
13520
27d87e072bfb ANSI-fication (fixed on parameter list I messed up in the patch)
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
391 sads_getattr(sadstatusobject *xp, char *name)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
392 {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
393 return PyMember_Get((char *)&xp->ai, sads_ml, name);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
394 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
395
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
396 static int
13520
27d87e072bfb ANSI-fication (fixed on parameter list I messed up in the patch)
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
397 sads_setattr(sadstatusobject *xp, char *name, PyObject *v)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
398 {
1031
7a11a70f7f44 classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents: 885
diff changeset
399
7a11a70f7f44 classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents: 885
diff changeset
400 if (v == NULL) {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
401 PyErr_SetString(PyExc_TypeError,
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
402 "can't delete sun audio status attributes");
4298
6f7090a82645 Correct typo: return -1 for error, not 0
Guido van Rossum <guido@python.org>
parents: 2569
diff changeset
403 return -1;
1031
7a11a70f7f44 classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents: 885
diff changeset
404 }
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
405 return PyMember_Set((char *)&xp->ai, sads_ml, name, v);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
406 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
407
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
408 /* ------------------------------------------------------------------- */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
409
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
410
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
411 static PyTypeObject Sadtype = {
42334
e70cdce0e8b2 Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 36324
diff changeset
412 PyVarObject_HEAD_INIT(&PyType_Type, 0)
21313
91dd223829c6 Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents: 20922
diff changeset
413 "sunaudiodev.sun_audio_device", /*tp_name*/
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
414 sizeof(sadobject), /*tp_size*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
415 0, /*tp_itemsize*/
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
416 /* methods */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
417 (destructor)sad_dealloc, /*tp_dealloc*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
418 0, /*tp_print*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
419 (getattrfunc)sad_getattr, /*tp_getattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
420 0, /*tp_setattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
421 0, /*tp_compare*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
422 0, /*tp_repr*/
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
423 };
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
424
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
425 static PyTypeObject Sadstatustype = {
42334
e70cdce0e8b2 Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 36324
diff changeset
426 PyVarObject_HEAD_INIT(&PyType_Type, 0)
21313
91dd223829c6 Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents: 20922
diff changeset
427 "sunaudiodev.sun_audio_device_status", /*tp_name*/
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
428 sizeof(sadstatusobject), /*tp_size*/
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
429 0, /*tp_itemsize*/
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
430 /* methods */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
431 (destructor)sads_dealloc, /*tp_dealloc*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
432 0, /*tp_print*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
433 (getattrfunc)sads_getattr, /*tp_getattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
434 (setattrfunc)sads_setattr, /*tp_setattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
435 0, /*tp_compare*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
436 0, /*tp_repr*/
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
437 };
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
438 /* ------------------------------------------------------------------- */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
439
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
440 static PyObject *
13520
27d87e072bfb ANSI-fication (fixed on parameter list I messed up in the patch)
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 13256
diff changeset
441 sadopen(PyObject *self, PyObject *args)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
442 {
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
443 return (PyObject *)newsadobject(args);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
444 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
445
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
446 static PyMethodDef sunaudiodev_methods[] = {
22709
3aa4bf7ac31e Remove METH_OLDARGS:
Neal Norwitz <nnorwitz@gmail.com>
parents: 21757
diff changeset
447 { "open", sadopen, METH_VARARGS },
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
448 { 0, 0 },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
449 };
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
450
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
451 void
13651
8a063423e0b7 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents: 13620
diff changeset
452 initsunaudiodev(void)
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
453 {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
454 PyObject *m, *d;
47068
ae16e94bb03a Deprecate sunaudiodev/SUNAUDIODEV for removal in 3.0.
Brett Cannon <bcannon@gmail.com>
parents: 44350
diff changeset
455
ae16e94bb03a Deprecate sunaudiodev/SUNAUDIODEV for removal in 3.0.
Brett Cannon <bcannon@gmail.com>
parents: 44350
diff changeset
456 if (PyErr_WarnPy3k("the sunaudiodev module has been removed in "
ae16e94bb03a Deprecate sunaudiodev/SUNAUDIODEV for removal in 3.0.
Brett Cannon <bcannon@gmail.com>
parents: 44350
diff changeset
457 "Python 3.0", 2) < 0)
ae16e94bb03a Deprecate sunaudiodev/SUNAUDIODEV for removal in 3.0.
Brett Cannon <bcannon@gmail.com>
parents: 44350
diff changeset
458 return;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
459
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
460 m = Py_InitModule("sunaudiodev", sunaudiodev_methods);
36324
1af7f719ed28 Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents: 24280
diff changeset
461 if (m == NULL)
1af7f719ed28 Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents: 24280
diff changeset
462 return;
4708
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
463 d = PyModule_GetDict(m);
6367
2c29b8982643 Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents: 5295
diff changeset
464 SunAudioError = PyErr_NewException("sunaudiodev.error", NULL, NULL);
4919
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
465 if (SunAudioError)
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
466 PyDict_SetItemString(d, "error", SunAudioError);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
467 }