Mercurial > cpython-lru_cache-weakref
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 |
| rev | line source |
|---|---|
| 885 | 1 |
| 2 /* Sad objects */ | |
| 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 | 5 #include "structmember.h" |
| 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 | 16 #include <sys/ioctl.h> |
| 1418 | 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 | 19 #else |
| 885 | 20 #include <sun/audioio.h> |
| 1418 | 21 #endif |
| 885 | 22 |
| 23 /* #define offsetof(str,mem) ((int)(((str *)0)->mem)) */ | |
| 24 | |
| 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 | 27 int x_fd; /* The open file */ |
| 28 int x_icount; /* # samples read */ | |
| 29 int x_ocount; /* # samples written */ | |
| 30 int x_isctl; /* True if control device */ | |
| 31 | |
| 32 } sadobject; | |
| 33 | |
| 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 | 36 audio_info_t ai; |
| 37 } sadstatusobject; | |
| 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 | 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 | 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 | 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 | 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 | 51 { |
| 52 sadobject *xp; | |
| 53 int fd; | |
| 54 char *mode; | |
| 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 | 59 |
| 60 /* Check arg for r/w/rw */ | |
| 22709 | 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 | 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 | 75 } |
| 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 | 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 | 106 |
| 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 | 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 | 113 xp->x_fd = fd; |
| 114 xp->x_icount = xp->x_ocount = 0; | |
| 115 xp->x_isctl = (imode < 0); | |
| 116 | |
| 117 return xp; | |
| 118 } | |
| 119 | |
| 120 /* Sad methods */ | |
| 121 | |
| 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 | 124 { |
| 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 | 127 } |
| 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 | 131 { |
| 132 int size, count; | |
| 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 | 135 |
| 22709 | 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 | 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 | 144 |
| 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 | 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 | 158 self->x_icount += count; |
| 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 | 164 } |
| 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 | 168 { |
| 169 char *cp; | |
| 170 int count, size; | |
| 171 | |
| 22709 | 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 | 174 |
| 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 | 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 | 184 self->x_ocount += count; |
| 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 | 188 } |
| 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 | 191 sad_getinfo(sadobject *self) |
| 885 | 192 { |
| 193 sadstatusobject *rv; | |
| 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 | 201 return NULL; |
| 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 | 204 } |
| 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 | 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 | 212 return NULL; |
| 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 | 216 return NULL; |
| 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 | 220 } |
| 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 | 223 sad_ibufcount(sadobject *self) |
| 885 | 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 | 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 | 232 } |
| 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 | 235 sad_obufcount(sadobject *self) |
| 885 | 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 | 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 | 244 /* we want frames */ |
| 245 return PyInt_FromLong(self->x_ocount / (ai.play.channels * | |
| 246 ai.play.precision / 8) - | |
| 247 ai.play.samples); | |
| 885 | 248 } |
| 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 | 251 sad_drain(sadobject *self) |
| 885 | 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 | 259 } |
| 260 | |
| 1418 | 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 | 263 sad_getdev(sadobject *self) |
| 1418 | 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 | 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 | 272 } |
| 273 #endif | |
| 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 | 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 | 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 | 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 | 306 { "read", (PyCFunction)sad_read, METH_VARARGS }, |
| 307 { "write", (PyCFunction)sad_write, METH_VARARGS }, | |
| 308 { "ibufcount", (PyCFunction)sad_ibufcount, METH_NOARGS }, | |
| 309 { "obufcount", (PyCFunction)sad_obufcount, METH_NOARGS }, | |
| 885 | 310 #define CTL_METHODS 4 |
| 22709 | 311 { "getinfo", (PyCFunction)sad_getinfo, METH_NOARGS }, |
| 312 { "setinfo", (PyCFunction)sad_setinfo, METH_O}, | |
| 313 { "drain", (PyCFunction)sad_drain, METH_NOARGS }, | |
| 314 { "flush", (PyCFunction)sad_flush, METH_NOARGS }, | |
| 1418 | 315 #ifdef SOLARIS |
| 22709 | 316 { "getdev", (PyCFunction)sad_getdev, METH_NOARGS }, |
| 1418 | 317 #endif |
| 22709 | 318 { "close", (PyCFunction)sad_close, METH_NOARGS }, |
| 319 { "fileno", (PyCFunction)sad_fileno, METH_NOARGS }, | |
| 885 | 320 {NULL, NULL} /* sentinel */ |
| 321 }; | |
| 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 | 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 | 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 | 331 } |
| 332 | |
| 333 /* ----------------------------------------------------------------- */ | |
| 334 | |
| 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 | 338 } |
| 339 | |
| 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 | 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 | 344 } |
| 345 | |
| 346 #define OFF(x) offsetof(audio_info_t,x) | |
| 347 static struct memberlist sads_ml[] = { | |
| 348 { "i_sample_rate", T_UINT, OFF(record.sample_rate) }, | |
| 349 { "i_channels", T_UINT, OFF(record.channels) }, | |
| 350 { "i_precision", T_UINT, OFF(record.precision) }, | |
| 351 { "i_encoding", T_UINT, OFF(record.encoding) }, | |
| 352 { "i_gain", T_UINT, OFF(record.gain) }, | |
| 353 { "i_port", T_UINT, OFF(record.port) }, | |
| 354 { "i_samples", T_UINT, OFF(record.samples) }, | |
| 355 { "i_eof", T_UINT, OFF(record.eof) }, | |
| 356 { "i_pause", T_UBYTE, OFF(record.pause) }, | |
| 357 { "i_error", T_UBYTE, OFF(record.error) }, | |
| 358 { "i_waiting", T_UBYTE, OFF(record.waiting) }, | |
| 359 { "i_open", T_UBYTE, OFF(record.open) , RO}, | |
| 360 { "i_active", T_UBYTE, OFF(record.active) , RO}, | |
| 1418 | 361 #ifdef SOLARIS |
| 362 { "i_buffer_size", T_UINT, OFF(record.buffer_size) }, | |
| 363 { "i_balance", T_UBYTE, OFF(record.balance) }, | |
| 364 { "i_avail_ports", T_UINT, OFF(record.avail_ports) }, | |
| 365 #endif | |
| 885 | 366 |
| 367 { "o_sample_rate", T_UINT, OFF(play.sample_rate) }, | |
| 368 { "o_channels", T_UINT, OFF(play.channels) }, | |
| 369 { "o_precision", T_UINT, OFF(play.precision) }, | |
| 370 { "o_encoding", T_UINT, OFF(play.encoding) }, | |
| 371 { "o_gain", T_UINT, OFF(play.gain) }, | |
| 372 { "o_port", T_UINT, OFF(play.port) }, | |
| 373 { "o_samples", T_UINT, OFF(play.samples) }, | |
| 374 { "o_eof", T_UINT, OFF(play.eof) }, | |
| 375 { "o_pause", T_UBYTE, OFF(play.pause) }, | |
| 376 { "o_error", T_UBYTE, OFF(play.error) }, | |
| 377 { "o_waiting", T_UBYTE, OFF(play.waiting) }, | |
| 378 { "o_open", T_UBYTE, OFF(play.open) , RO}, | |
| 379 { "o_active", T_UBYTE, OFF(play.active) , RO}, | |
| 1418 | 380 #ifdef SOLARIS |
| 381 { "o_buffer_size", T_UINT, OFF(play.buffer_size) }, | |
| 382 { "o_balance", T_UBYTE, OFF(play.balance) }, | |
| 383 { "o_avail_ports", T_UINT, OFF(play.avail_ports) }, | |
| 384 #endif | |
| 885 | 385 |
| 386 { "monitor_gain", T_UINT, OFF(monitor_gain) }, | |
| 387 { NULL, 0, 0}, | |
| 388 }; | |
| 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 | 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 | 394 } |
| 395 | |
| 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 | 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 | 406 } |
| 407 | |
| 408 /* ------------------------------------------------------------------- */ | |
| 409 | |
| 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 | 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 | 423 }; |
| 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 | 428 sizeof(sadstatusobject), /*tp_size*/ |
| 429 0, /*tp_itemsize*/ | |
| 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 | 437 }; |
| 438 /* ------------------------------------------------------------------- */ | |
| 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 | 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 | 444 } |
| 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 | 447 { "open", sadopen, METH_VARARGS }, |
| 885 | 448 { 0, 0 }, |
| 449 }; | |
| 450 | |
| 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 | 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 | 467 } |
