annotate Modules/sunaudiodev.c @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 2f2760c3dd90
children 2c29b8982643
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 /***********************************************************
2061
172ba04a5191 Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
172ba04a5191 Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
3 The Netherlands.
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 All Rights Reserved
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
8 documentation for any purpose and without fee is hereby granted,
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 provided that the above copyright notice appear in all copies and that
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
10 both that copyright notice and this permission notice appear in
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
12 Centrum or CWI or Corporation for National Research Initiatives or
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
13 CNRI not be used in advertising or publicity pertaining to
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
14 distribution of the software without specific, written prior
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
15 permission.
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
17 While CWI is the initial source for this software, a modified version
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
18 is made available by the Corporation for National Research Initiatives
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
19 (CNRI) at the Internet address ftp://ftp.python.org.
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
20
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 4298
diff changeset
28 PERFORMANCE OF THIS SOFTWARE.
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 ******************************************************************/
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 /* Sad objects */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
33
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
34 #include "Python.h"
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 #include "structmember.h"
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
36
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
37 #ifdef HAVE_SYS_AUDIOIO_H
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
38 #define SOLARIS
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
39 #endif
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
40
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
41 #ifdef HAVE_UNISTD_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
42 #include <unistd.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
43 #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
44
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
45 #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
46 #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
47 #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
48
1313
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
49 #include <stropts.h>
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 #include <sys/ioctl.h>
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
51 #ifdef SOLARIS
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
52 #include <sys/audioio.h>
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
53 #else
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 #include <sun/audioio.h>
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
55 #endif
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
56
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 /* #define offsetof(str,mem) ((int)(((str *)0)->mem)) */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
58
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 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
60 PyObject_HEAD
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 int x_fd; /* The open file */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 int x_icount; /* # samples read */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 int x_ocount; /* # samples written */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 int x_isctl; /* True if control device */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
65
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 } sadobject;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
67
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 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
69 PyObject_HEAD
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 audio_info_t ai;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 } sadstatusobject;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
72
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
73 staticforward PyTypeObject Sadtype;
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 staticforward PyTypeObject Sadstatustype;
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
75 static sadstatusobject *sads_alloc(); /* Forward */
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
76
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
77 static PyObject *SunAudioError;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
78
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
79 #define is_sadobject(v) ((v)->ob_type == &Sadtype)
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 #define is_sadstatusobject(v) ((v)->ob_type == &Sadstatustype)
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
81
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 static sadobject *
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 newsadobject(arg)
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
84 PyObject *arg;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 sadobject *xp;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 int fd;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 char *mode;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 int imode;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
90
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 /* Check arg for r/w/rw */
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
92 if (!PyArg_Parse(arg, "s", &mode))
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
93 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
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101 imode = -1;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 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
103 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
104 "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
105 return NULL;
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
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
108 /* Open the correct device */
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
109 if (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
110 /* XXXX Check that this works */
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
111 fd = open("/dev/audioctl", 2);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
112 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
113 fd = open("/dev/audio", imode);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
114 if (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
115 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
116 return NULL;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
117 }
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 /* Create and initialize the object */
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
120 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
121 if (xp == NULL) {
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
122 close(fd);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
123 return NULL;
4919
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
124 }
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
125 xp->x_fd = fd;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
126 xp->x_icount = xp->x_ocount = 0;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
127 xp->x_isctl = (imode < 0);
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
128
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
129 return xp;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
130 }
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 /* Sad methods */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
133
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
134 static void
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
135 sad_dealloc(xp)
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
136 sadobject *xp;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
137 {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
138 close(xp->x_fd);
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 PyMem_DEL(xp);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
140 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
141
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
142 static PyObject *
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
143 sad_read(self, args)
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
144 sadobject *self;
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
145 PyObject *args;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
146 {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
147 int size, count;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
148 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
149 PyObject *rv;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
150
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
151 if (!PyArg_Parse(args, "i", &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
152 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
153 rv = PyString_FromStringAndSize(NULL, 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
154 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
155 return NULL;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
156
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
157 if (!(cp = PyString_AsString(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
158 goto finally;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
159
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
160 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
161 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
162 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
163 goto finally;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 }
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
165 #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
166 /* 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
167 * 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
168 * 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
169 */
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
170 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
171 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
172 #endif
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
173 self->x_icount += count;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
174 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
175
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 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
177 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
178 return NULL;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
179 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
180
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
181 static PyObject *
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
182 sad_write(self, args)
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
183 sadobject *self;
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
184 PyObject *args;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
185 {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
186 char *cp;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
187 int count, size;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
188
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
189 if (!PyArg_Parse(args, "s#", &cp, &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
190 return NULL;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
191
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
192 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
193 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
194 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
195 return NULL;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
196 }
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
197 #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
198 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
199 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
200 #endif
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
201 self->x_ocount += count;
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 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
204 return Py_None;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
205 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
206
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
207 static PyObject *
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
208 sad_getinfo(self, args)
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 sadobject *self;
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 PyObject *args;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
211 {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
212 sadstatusobject *rv;
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 (!PyArg_Parse(args, ""))
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 return NULL;
4919
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
216 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
217 return NULL;
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
218
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
219 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
220 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
221 Py_DECREF(rv);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
222 return NULL;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
223 }
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
224 return (PyObject *)rv;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
225 }
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 static PyObject *
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
228 sad_setinfo(self, arg)
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
229 sadobject *self;
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 sadstatusobject *arg;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
231 {
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
232 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
233 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
234 "Must be sun audio status object");
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
235 return NULL;
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 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
238 PyErr_SetFromErrno(SunAudioError);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
239 return NULL;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
240 }
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
241 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
242 return Py_None;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
243 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
244
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
245 static PyObject *
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
246 sad_ibufcount(self, args)
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
247 sadobject *self;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
248 PyObject *args;
885
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 audio_info_t ai;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
251
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
252 if (!PyArg_Parse(args, ""))
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 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
254 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
255 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
256 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
257 }
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 PyInt_FromLong(ai.record.samples - self->x_icount);
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
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
261 static PyObject *
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
262 sad_obufcount(self, args)
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
263 sadobject *self;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
264 PyObject *args;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
265 {
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
266 audio_info_t ai;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
267
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
268 if (!PyArg_Parse(args, ""))
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 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
271 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
272 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
273 }
5295
2f2760c3dd90 Bugfix by Sjoerd:
Guido van Rossum <guido@python.org>
parents: 4919
diff changeset
274 /* x_ocount is in bytes, wheras play.samples is in frames */
2f2760c3dd90 Bugfix by Sjoerd:
Guido van Rossum <guido@python.org>
parents: 4919
diff changeset
275 /* we want frames */
2f2760c3dd90 Bugfix by Sjoerd:
Guido van Rossum <guido@python.org>
parents: 4919
diff changeset
276 return PyInt_FromLong(self->x_ocount / (ai.play.channels *
2f2760c3dd90 Bugfix by Sjoerd:
Guido van Rossum <guido@python.org>
parents: 4919
diff changeset
277 ai.play.precision / 8) -
2f2760c3dd90 Bugfix by Sjoerd:
Guido van Rossum <guido@python.org>
parents: 4919
diff changeset
278 ai.play.samples);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
279 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
280
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
281 static PyObject *
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
282 sad_drain(self, args)
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
283 sadobject *self;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
284 PyObject *args;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
285 {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
286
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
287 if (!PyArg_Parse(args, ""))
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
288 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
289 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
290 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
291 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
292 }
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 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
294 return Py_None;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
295 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
296
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
297 #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
298 static PyObject *
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
299 sad_getdev(self, args)
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
300 sadobject *self;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
301 PyObject *args;
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
302 {
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
303 struct audio_device ad;
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
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 if (!PyArg_Parse(args, ""))
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
306 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
307 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
308 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
309 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
310 }
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
311 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
312 }
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
313 #endif
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
314
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
315 static PyObject *
1313
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
316 sad_flush(self, args)
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
317 sadobject *self;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
318 PyObject *args;
1313
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
319 {
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
320
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
321 if (!PyArg_Parse(args, ""))
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
322 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
323 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
324 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
325 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
326 }
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 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
328 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
329 }
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
330
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
331 static PyObject *
1313
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
332 sad_close(self, args)
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
333 sadobject *self;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
334 PyObject *args;
1313
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
335 {
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
336
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
337 if (!PyArg_Parse(args, ""))
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
338 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
339 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
340 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
341 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
342 }
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 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
344 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
345 }
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
346
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
347 static PyMethodDef sad_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
348 { "read", (PyCFunction)sad_read },
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
349 { "write", (PyCFunction)sad_write },
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
350 { "ibufcount", (PyCFunction)sad_ibufcount },
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
351 { "obufcount", (PyCFunction)sad_obufcount },
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
352 #define CTL_METHODS 4
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
353 { "getinfo", (PyCFunction)sad_getinfo },
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
354 { "setinfo", (PyCFunction)sad_setinfo },
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
355 { "drain", (PyCFunction)sad_drain },
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
356 { "flush", (PyCFunction)sad_flush },
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
357 #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
358 { "getdev", (PyCFunction)sad_getdev },
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
359 #endif
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
360 { "close", (PyCFunction)sad_close },
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
361 {NULL, NULL} /* sentinel */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
362 };
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
363
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
364 static PyObject *
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
365 sad_getattr(xp, name)
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
366 sadobject *xp;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
367 char *name;
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
368 {
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
369 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
370 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
371 (PyObject *)xp, name);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
372 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
373 return Py_FindMethod(sad_methods, (PyObject *)xp, name);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
374 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
375
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
376 /* ----------------------------------------------------------------- */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
377
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
378 static sadstatusobject *
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
379 sads_alloc() {
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
380 return PyObject_NEW(sadstatusobject, &Sadstatustype);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
381 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
382
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
383 static void
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
384 sads_dealloc(xp)
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
385 sadstatusobject *xp;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
386 {
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
387 PyMem_DEL(xp);
885
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
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
390 #define OFF(x) offsetof(audio_info_t,x)
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
391 static struct memberlist sads_ml[] = {
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
392 { "i_sample_rate", T_UINT, OFF(record.sample_rate) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
393 { "i_channels", T_UINT, OFF(record.channels) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
394 { "i_precision", T_UINT, OFF(record.precision) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
395 { "i_encoding", T_UINT, OFF(record.encoding) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
396 { "i_gain", T_UINT, OFF(record.gain) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
397 { "i_port", T_UINT, OFF(record.port) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
398 { "i_samples", T_UINT, OFF(record.samples) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
399 { "i_eof", T_UINT, OFF(record.eof) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
400 { "i_pause", T_UBYTE, OFF(record.pause) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
401 { "i_error", T_UBYTE, OFF(record.error) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
402 { "i_waiting", T_UBYTE, OFF(record.waiting) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
403 { "i_open", T_UBYTE, OFF(record.open) , RO},
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
404 { "i_active", T_UBYTE, OFF(record.active) , RO},
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
405 #ifdef SOLARIS
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
406 { "i_buffer_size", T_UINT, OFF(record.buffer_size) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
407 { "i_balance", T_UBYTE, OFF(record.balance) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
408 { "i_avail_ports", T_UINT, OFF(record.avail_ports) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
409 #endif
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
410
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
411 { "o_sample_rate", T_UINT, OFF(play.sample_rate) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
412 { "o_channels", T_UINT, OFF(play.channels) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
413 { "o_precision", T_UINT, OFF(play.precision) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
414 { "o_encoding", T_UINT, OFF(play.encoding) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
415 { "o_gain", T_UINT, OFF(play.gain) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
416 { "o_port", T_UINT, OFF(play.port) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
417 { "o_samples", T_UINT, OFF(play.samples) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
418 { "o_eof", T_UINT, OFF(play.eof) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
419 { "o_pause", T_UBYTE, OFF(play.pause) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
420 { "o_error", T_UBYTE, OFF(play.error) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
421 { "o_waiting", T_UBYTE, OFF(play.waiting) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
422 { "o_open", T_UBYTE, OFF(play.open) , RO},
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
423 { "o_active", T_UBYTE, OFF(play.active) , RO},
1418
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
424 #ifdef SOLARIS
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
425 { "o_buffer_size", T_UINT, OFF(play.buffer_size) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
426 { "o_balance", T_UBYTE, OFF(play.balance) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
427 { "o_avail_ports", T_UINT, OFF(play.avail_ports) },
b1bb74a2b593 Port to Solaris 2.3.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1313
diff changeset
428 #endif
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
429
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
430 { "monitor_gain", T_UINT, OFF(monitor_gain) },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
431 { NULL, 0, 0},
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
432 };
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
433
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
434 static PyObject *
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
435 sads_getattr(xp, name)
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
436 sadstatusobject *xp;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
437 char *name;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
438 {
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
439 return PyMember_Get((char *)&xp->ai, sads_ml, name);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
440 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
441
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
442 static int
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
443 sads_setattr(xp, name, v)
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
444 sadstatusobject *xp;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
445 char *name;
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 PyObject *v;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
447 {
1031
7a11a70f7f44 classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents: 885
diff changeset
448
7a11a70f7f44 classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents: 885
diff changeset
449 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
450 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
451 "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
452 return -1;
1031
7a11a70f7f44 classobject.c moduleobject.c stdwinmodule.c xxobject.c:
Guido van Rossum <guido@python.org>
parents: 885
diff changeset
453 }
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
454 return PyMember_Set((char *)&xp->ai, sads_ml, name, v);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
455 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
456
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
457 /* ------------------------------------------------------------------- */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
458
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 static PyTypeObject Sadtype = {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
461 PyObject_HEAD_INIT(&PyType_Type)
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
462 0, /*ob_size*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
463 "sun_audio_device", /*tp_name*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
464 sizeof(sadobject), /*tp_size*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
465 0, /*tp_itemsize*/
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
466 /* methods */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
467 (destructor)sad_dealloc, /*tp_dealloc*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
468 0, /*tp_print*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
469 (getattrfunc)sad_getattr, /*tp_getattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
470 0, /*tp_setattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
471 0, /*tp_compare*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
472 0, /*tp_repr*/
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
473 };
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
474
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
475 static PyTypeObject Sadstatustype = {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
476 PyObject_HEAD_INIT(&PyType_Type)
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
477 0, /*ob_size*/
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
478 "sun_audio_device_status", /*tp_name*/
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
479 sizeof(sadstatusobject), /*tp_size*/
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
480 0, /*tp_itemsize*/
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
481 /* methods */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
482 (destructor)sads_dealloc, /*tp_dealloc*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
483 0, /*tp_print*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
484 (getattrfunc)sads_getattr, /*tp_getattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
485 (setattrfunc)sads_setattr, /*tp_setattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
486 0, /*tp_compare*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1418
diff changeset
487 0, /*tp_repr*/
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
488 };
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
489 /* ------------------------------------------------------------------- */
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
490
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
491 static PyObject *
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
492 sadopen(self, args)
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
493 PyObject *self;
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
494 PyObject *args;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
495 {
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
496 return (PyObject *)newsadobject(args);
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
497 }
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
498
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
499 static PyMethodDef sunaudiodev_methods[] = {
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
500 { "open", sadopen },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
501 { 0, 0 },
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
502 };
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
503
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
504 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
505 initsunaudiodev()
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
506 {
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
507 PyObject *m, *d;
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
508
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
509 m = Py_InitModule("sunaudiodev", sunaudiodev_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
510 d = PyModule_GetDict(m);
775a7d0c2960 Renamed, however there is no test case. I did test some of the module
Barry Warsaw <barry@python.org>
parents: 4652
diff changeset
511 SunAudioError = PyString_FromString("sunaudiodev.error");
4919
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
512 if (SunAudioError)
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
513 PyDict_SetItemString(d, "error", SunAudioError);
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
514 if (PyErr_Occurred())
f8e5bc5351a9 Plugged a couple of potential return value problems, memory leaks, and
Barry Warsaw <barry@python.org>
parents: 4708
diff changeset
515 Py_FatalError("can't initialize sunaudiodev module");
885
266de59de8a9 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
516 }