annotate Modules/svmodule.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 f926263fb654
children 2c29b8982643
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.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.
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
4
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
5 All Rights Reserved
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
6
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2061
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: 2061
diff changeset
8 documentation for any purpose and without fee is hereby granted,
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.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: 2061
diff changeset
10 both that copyright notice and this permission notice appear in
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.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: 2061
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: 2061
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: 2061
diff changeset
14 distribution of the software without specific, written prior
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2061
diff changeset
15 permission.
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
16
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2061
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: 2061
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: 2061
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: 2061
diff changeset
20
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 2061
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: 2061
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: 2061
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: 2061
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: 2061
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: 2061
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: 2061
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: 2061
diff changeset
28 PERFORMANCE OF THIS SOFTWARE.
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
29
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
30 ******************************************************************/
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
31
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
32 /* SV module -- interface to the Indigo video board */
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
33
4762
f926263fb654 Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents: 4712
diff changeset
34 /* WARNING! This module is for hardware that we don't have any more,
f926263fb654 Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents: 4712
diff changeset
35 so it hasn't been tested. It has been converted to the new coding
f926263fb654 Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents: 4712
diff changeset
36 style, and it is possible that this conversion has broken something
f926263fb654 Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents: 4712
diff changeset
37 -- user beware! */
f926263fb654 Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents: 4712
diff changeset
38
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
39 #include <sys/time.h>
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
40 #include <svideo.h>
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
41 #include "Python.h"
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
42 #include "compile.h"
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
43 #include "yuv.h" /* for YUV conversion functions */
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
44
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
45 typedef struct {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
46 PyObject_HEAD
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
47 SV_nodeP ob_svideo;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
48 svCaptureInfo ob_info;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
49 } svobject;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
50
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
51 typedef struct {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
52 PyObject_HEAD
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
53 void *ob_capture;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
54 int ob_mustunlock;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
55 svCaptureInfo ob_info;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
56 svobject *ob_svideo;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
57 } captureobject;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
58
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
59 static PyObject *SvError; /* exception sv.error */
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
60
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
61 static PyObject *newcaptureobject Py_PROTO((svobject *, void *, int));
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
62
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
63 /* Set a SV-specific error from svideo_errno and return NULL */
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
64 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
65 sv_error()
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
66 {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
67 PyErr_SetString(SvError, svStrerror(svideo_errno));
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
68 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
69 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
70
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
71 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
72 svc_conversion(self, args, function, factor)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
73 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
74 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
75 void (*function)();
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
76 float factor;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
77 {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
78 PyObject *output;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
79 int invert;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
80 char* outstr;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
81
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
82 if (!PyArg_Parse(args, "i", &invert))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
83 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
84
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
85 if (!(output = PyString_FromStringAndSize(
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
86 NULL,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
87 (int)(self->ob_info.width * self->ob_info.height * factor))))
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
88 {
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
89 return NULL;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
90 }
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
91 if (!(outstr = PyString_AsString(output))) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
92 Py_DECREF(output);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
93 return NULL;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
94 }
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
95
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
96 (*function)((boolean)invert, self->ob_capture,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
97 outstr,
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
98 self->ob_info.width, self->ob_info.height);
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
99
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
100 return output;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
101 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
102
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
103 /*
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
104 * 3 functions to convert from Starter Video YUV 4:1:1 format to
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
105 * Compression Library 4:2:2 Duplicate Chroma format.
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
106 */
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
107 static PyObject *
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
108 svc_YUVtoYUV422DC(self, args)
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
109 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
110 PyObject *args;
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
111 {
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
112 if (self->ob_info.format != SV_YUV411_FRAMES) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
113 PyErr_SetString(SvError, "data has bad format");
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
114 return NULL;
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
115 }
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
116 return svc_conversion(self, args, yuv_sv411_to_cl422dc, 2.0);
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
117 }
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
118
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
119 static PyObject *
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
120 svc_YUVtoYUV422DC_quarter(self, args)
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
121 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
122 PyObject *args;
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
123 {
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
124 if (self->ob_info.format != SV_YUV411_FRAMES) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
125 PyErr_SetString(SvError, "data has bad format");
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
126 return NULL;
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
127 }
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
128 return svc_conversion(self, args,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
129 yuv_sv411_to_cl422dc_quartersize, 0.5);
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
130 }
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
131
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
132 static PyObject *
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
133 svc_YUVtoYUV422DC_sixteenth(self, args)
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
134 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
135 PyObject *args;
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
136 {
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
137 if (self->ob_info.format != SV_YUV411_FRAMES) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
138 PyErr_SetString(SvError, "data has bad format");
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
139 return NULL;
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
140 }
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
141 return svc_conversion(self, args,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
142 yuv_sv411_to_cl422dc_sixteenthsize, 0.125);
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
143 }
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
144
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
145 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
146 svc_YUVtoRGB(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
147 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
148 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
149 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
150 switch (self->ob_info.format) {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
151 case SV_YUV411_FRAMES:
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
152 case SV_YUV411_FRAMES_AND_BLANKING_BUFFER:
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
153 break;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
154 default:
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
155 PyErr_SetString(SvError, "data had bad format");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
156 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
157 }
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
158 return svc_conversion(self, args, svYUVtoRGB, (float) sizeof(long));
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
159 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
160
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
161 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
162 svc_RGB8toRGB32(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
163 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
164 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
165 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
166 if (self->ob_info.format != SV_RGB8_FRAMES) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
167 PyErr_SetString(SvError, "data has bad format");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
168 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
169 }
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
170 return svc_conversion(self, args, svRGB8toRGB32, (float) sizeof(long));
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
171 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
172
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
173 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
174 svc_InterleaveFields(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
175 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
176 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
177 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
178 if (self->ob_info.format != SV_RGB8_FRAMES) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
179 PyErr_SetString(SvError, "data has bad format");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
180 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
181 }
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
182 return svc_conversion(self, args, svInterleaveFields, 1.0);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
183 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
184
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
185 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
186 svc_GetFields(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
187 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
188 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
189 {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
190 PyObject *f1 = NULL;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
191 PyObject *f2 = NULL;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
192 PyObject *ret = NULL;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
193 int fieldsize;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
194 char* obcapture;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
195
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
196 if (self->ob_info.format != SV_RGB8_FRAMES) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
197 PyErr_SetString(SvError, "data has bad format");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
198 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
199 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
200
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
201 fieldsize = self->ob_info.width * self->ob_info.height / 2;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
202 obcapture = (char*)self->ob_capture;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
203
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
204 if (!(f1 = PyString_FromStringAndSize(obcapture, fieldsize)))
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
205 goto finally;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
206 if (!(f2 = PyString_FromStringAndSize(obcapture + fieldsize,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
207 fieldsize)))
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
208 goto finally;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
209 ret = Py_BuildValue("(OO)", f1, f2);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
210
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
211 finally:
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
212 Py_XDECREF(f1);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
213 Py_XDECREF(f2);
1207
b564bd4e57e1 * ceval.c: ifdef out the last argument passing compat hack.
Guido van Rossum <guido@python.org>
parents: 1198
diff changeset
214 return ret;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
215 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
216
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
217 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
218 svc_UnlockCaptureData(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
219 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
220 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
221 {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
222 if (!PyArg_Parse(args, ""))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
223 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
224
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
225 if (!self->ob_mustunlock) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
226 PyErr_SetString(SvError, "buffer should not be unlocked");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
227 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
228 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
229
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
230 if (svUnlockCaptureData(self->ob_svideo->ob_svideo, self->ob_capture))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
231 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
232
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
233 self->ob_mustunlock = 0;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
234
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
235 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
236 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
237 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
238
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
239 #ifdef USE_GL
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
240 #include <gl.h>
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
241
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
242 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
243 svc_lrectwrite(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
244 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
245 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
246 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
247 Screencoord x1, x2, y1, y2;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
248
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
249 if (!PyArg_Parse(args, "(hhhh)", &x1, &x2, &y1, &y2))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
250 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
251
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
252 lrectwrite(x1, x2, y1, y2, (unsigned long *) self->ob_capture);
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
253
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
254 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
255 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
256 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
257 #endif
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
258
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
259 static PyObject *
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
260 svc_writefile(self, args)
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
261 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
262 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
263 {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
264 PyObject *file;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
265 int size;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
266 FILE* fp;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
267
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
268 if (!PyArg_Parse(args, "O", &file))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
269 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
270
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
271 if (!PyFile_Check(file)) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
272 PyErr_SetString(SvError, "not a file object");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
273 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
274 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
275
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
276 if (!(fp = PyFile_AsFile(file)))
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
277 return NULL;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
278
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
279 size = self->ob_info.width * self->ob_info.height;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
280
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
281 if (fwrite(self->ob_capture, sizeof(long), size, fp) != size) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
282 PyErr_SetString(SvError, "writing failed");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
283 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
284 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
285
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
286 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
287 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
288 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
289
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
290 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
291 svc_FindVisibleRegion(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
292 captureobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
293 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
294 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
295 void *visible;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
296 int width;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
297
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
298 if (!PyArg_Parse(args, ""))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
299 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
300
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
301 if (svFindVisibleRegion(self->ob_svideo->ob_svideo,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
302 self->ob_capture, &visible,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
303 self->ob_info.width))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
304 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
305
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
306 if (visible == NULL) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
307 PyErr_SetString(SvError, "data in wrong format");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
308 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
309 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
310
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
311 return newcaptureobject(self->ob_svideo, visible, 0);
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
312 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
313
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
314 static PyMethodDef capture_methods[] = {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
315 {"YUVtoRGB", (PyCFunction)svc_YUVtoRGB},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
316 {"RGB8toRGB32", (PyCFunction)svc_RGB8toRGB32},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
317 {"InterleaveFields", (PyCFunction)svc_InterleaveFields},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
318 {"UnlockCaptureData", (PyCFunction)svc_UnlockCaptureData},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
319 {"FindVisibleRegion", (PyCFunction)svc_FindVisibleRegion},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
320 {"GetFields", (PyCFunction)svc_GetFields},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
321 {"YUVtoYUV422DC", (PyCFunction)svc_YUVtoYUV422DC},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
322 {"YUVtoYUV422DC_quarter",(PyCFunction)svc_YUVtoYUV422DC_quarter},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
323 {"YUVtoYUV422DC_sixteenth",(PyCFunction)svc_YUVtoYUV422DC_sixteenth},
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
324 #ifdef USE_GL
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
325 {"lrectwrite", (PyCFunction)svc_lrectwrite},
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
326 #endif
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
327 {"writefile", (PyCFunction)svc_writefile},
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
328 {NULL, NULL} /* sentinel */
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
329 };
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
330
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
331 static void
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
332 capture_dealloc(self)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
333 captureobject *self;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
334 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
335 if (self->ob_capture != NULL) {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
336 if (self->ob_mustunlock)
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
337 (void)svUnlockCaptureData(self->ob_svideo->ob_svideo,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
338 self->ob_capture);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
339 self->ob_capture = NULL;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
340 Py_DECREF(self->ob_svideo);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
341 self->ob_svideo = NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
342 }
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
343 PyMem_DEL(self);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
344 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
345
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
346 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
347 capture_getattr(self, name)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
348 svobject *self;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
349 char *name;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
350 {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
351 return Py_FindMethod(capture_methods, (PyObject *)self, name);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
352 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
353
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
354 PyTypeObject Capturetype = {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
355 PyObject_HEAD_INIT(&PyType_Type)
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
356 0, /*ob_size*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
357 "capture", /*tp_name*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
358 sizeof(captureobject), /*tp_size*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
359 0, /*tp_itemsize*/
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
360 /* methods */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
361 (destructor)capture_dealloc, /*tp_dealloc*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
362 0, /*tp_print*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
363 (getattrfunc)capture_getattr, /*tp_getattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
364 0, /*tp_setattr*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
365 0, /*tp_compare*/
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
366 0, /*tp_repr*/
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
367 };
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
368
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
369 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
370 newcaptureobject(self, ptr, mustunlock)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
371 svobject *self;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
372 void *ptr;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
373 int mustunlock;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
374 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
375 captureobject *p;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
376
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
377 p = PyObject_NEW(captureobject, &Capturetype);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
378 if (p == NULL)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
379 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
380 p->ob_svideo = self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
381 Py_INCREF(self);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
382 p->ob_capture = ptr;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
383 p->ob_mustunlock = mustunlock;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
384 p->ob_info = self->ob_info;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
385 return (PyObject *) p;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
386 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
387
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
388 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
389 sv_GetCaptureData(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
390 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
391 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
392 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
393 void *ptr;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
394 long fieldID;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
395 PyObject *res, *c;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
396
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
397 if (!PyArg_Parse(args, ""))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
398 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
399
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
400 if (svGetCaptureData(self->ob_svideo, &ptr, &fieldID))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
401 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
402
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
403 if (ptr == NULL) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
404 PyErr_SetString(SvError, "no data available");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
405 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
406 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
407
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
408 c = newcaptureobject(self, ptr, 1);
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
409 if (c == NULL)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
410 return NULL;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
411 res = Py_BuildValue("(Oi)", c, fieldID);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
412 Py_DECREF(c);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
413 return res;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
414 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
415
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
416 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
417 sv_BindGLWindow(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
418 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
419 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
420 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
421 long wid;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
422 int mode;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
423
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
424 if (!PyArg_Parse(args, "(ii)", &wid, &mode))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
425 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
426
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
427 if (svBindGLWindow(self->ob_svideo, wid, mode))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
428 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
429
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
430 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
431 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
432 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
433
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
434 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
435 sv_EndContinuousCapture(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
436 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
437 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
438 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
439
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
440 if (!PyArg_Parse(args, ""))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
441 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
442
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
443 if (svEndContinuousCapture(self->ob_svideo))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
444 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
445
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
446 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
447 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
448 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
449
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
450 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
451 sv_IsVideoDisplayed(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
452 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
453 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
454 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
455 int v;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
456
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
457 if (!PyArg_Parse(args, ""))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
458 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
459
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
460 v = svIsVideoDisplayed(self->ob_svideo);
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
461 if (v == -1)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
462 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
463
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
464 return PyInt_FromLong((long) v);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
465 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
466
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
467 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
468 sv_OutputOffset(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
469 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
470 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
471 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
472 int x_offset;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
473 int y_offset;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
474
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
475 if (!PyArg_Parse(args, "(ii)", &x_offset, &y_offset))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
476 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
477
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
478 if (svOutputOffset(self->ob_svideo, x_offset, y_offset))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
479 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
480
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
481 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
482 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
483 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
484
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
485 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
486 sv_PutFrame(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
487 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
488 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
489 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
490 char *buffer;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
491
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
492 if (!PyArg_Parse(args, "s", &buffer))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
493 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
494
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
495 if (svPutFrame(self->ob_svideo, buffer))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
496 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
497
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
498 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
499 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
500 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
501
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
502 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
503 sv_QuerySize(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
504 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
505 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
506 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
507 int w;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
508 int h;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
509 int rw;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
510 int rh;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
511
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
512 if (!PyArg_Parse(args, "(ii)", &w, &h))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
513 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
514
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
515 if (svQuerySize(self->ob_svideo, w, h, &rw, &rh))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
516 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
517
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
518 return Py_BuildValue("(ii)", (long) rw, (long) rh);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
519 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
520
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
521 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
522 sv_SetSize(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
523 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
524 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
525 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
526 int w;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
527 int h;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
528
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
529 if (!PyArg_Parse(args, "(ii)", &w, &h))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
530 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
531
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
532 if (svSetSize(self->ob_svideo, w, h))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
533 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
534
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
535 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
536 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
537 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
538
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
539 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
540 sv_SetStdDefaults(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
541 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
542 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
543 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
544
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
545 if (!PyArg_Parse(args, ""))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
546 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
547
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
548 if (svSetStdDefaults(self->ob_svideo))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
549 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
550
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
551 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
552 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
553 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
554
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
555 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
556 sv_UseExclusive(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
557 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
558 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
559 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
560 boolean onoff;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
561 int mode;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
562
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
563 if (!PyArg_Parse(args, "(ii)", &onoff, &mode))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
564 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
565
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
566 if (svUseExclusive(self->ob_svideo, onoff, mode))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
567 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
568
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
569 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
570 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
571 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
572
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
573 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
574 sv_WindowOffset(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
575 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
576 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
577 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
578 int x_offset;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
579 int y_offset;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
580
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
581 if (!PyArg_Parse(args, "(ii)", &x_offset, &y_offset))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
582 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
583
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
584 if (svWindowOffset(self->ob_svideo, x_offset, y_offset))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
585 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
586
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
587 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
588 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
589 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
590
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
591 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
592 sv_CaptureBurst(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
593 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
594 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
595 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
596 int bytes, i;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
597 svCaptureInfo info;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
598 void *bitvector = NULL;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
599 PyObject *videodata = NULL;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
600 PyObject *bitvecobj = NULL;
4762
f926263fb654 Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents: 4712
diff changeset
601 PyObject *res = NULL;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
602 static PyObject *evenitem, *odditem;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
603
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
604 if (!PyArg_Parse(args, "(iiiii)", &info.format,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
605 &info.width, &info.height,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
606 &info.size, &info.samplingrate))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
607 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
608
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
609 switch (info.format) {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
610 case SV_RGB8_FRAMES:
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
611 bitvector = malloc(SV_BITVEC_SIZE(info.size));
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
612 break;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
613 case SV_YUV411_FRAMES_AND_BLANKING_BUFFER:
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
614 break;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
615 default:
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
616 PyErr_SetString(SvError, "illegal format specified");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
617 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
618 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
619
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
620 if (svQueryCaptureBufferSize(self->ob_svideo, &info, &bytes)) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
621 res = sv_error();
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
622 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
623 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
624
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
625 if (!(videodata = PyString_FromStringAndSize(NULL, bytes)))
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
626 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
627
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
628 /* XXX -- need to do something about the bitvector */
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
629 {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
630 char* str = PyString_AsString(videodata);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
631 if (!str)
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
632 goto finally;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
633
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
634 if (svCaptureBurst(self->ob_svideo, &info, str, bitvector)) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
635 res = sv_error();
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
636 goto finally;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
637 }
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
638 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
639
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
640 if (bitvector) {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
641 if (evenitem == NULL) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
642 if (!(evenitem = PyInt_FromLong(0)))
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
643 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
644 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
645 if (odditem == NULL) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
646 if (!(odditem = PyInt_FromLong(1)))
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
647 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
648 }
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
649 if (!(bitvecobj = PyTuple_New(2 * info.size)))
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
650 goto finally;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
651
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
652 for (i = 0; i < 2 * info.size; i++) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
653 int sts;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
654
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
655 if (SV_GET_FIELD(bitvector, i) == SV_EVEN_FIELD) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
656 Py_INCREF(evenitem);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
657 sts = PyTuple_SetItem(bitvecobj, i, evenitem);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
658 } else {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
659 Py_INCREF(odditem);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
660 sts = PyTuple_SetItem(bitvecobj, i, odditem);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
661 }
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
662 if (sts < 0)
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
663 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
664 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
665 } else {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
666 bitvecobj = Py_None;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
667 Py_INCREF(Py_None);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
668 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
669
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
670 res = Py_BuildValue("((iiiii)OO)", info.format,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
671 info.width, info.height,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
672 info.size, info.samplingrate,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
673 videodata, bitvecobj);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
674
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
675 finally:
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
676 if (bitvector)
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
677 free(bitvector);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
678
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
679 Py_XDECREF(videodata);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
680 Py_XDECREF(bitvecobj);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
681 return res;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
682 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
683
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
684 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
685 sv_CaptureOneFrame(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
686 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
687 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
688 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
689 svCaptureInfo info;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
690 int format, width, height;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
691 int bytes;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
692 PyObject *videodata = NULL;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
693 PyObject *res = NULL;
4762
f926263fb654 Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents: 4712
diff changeset
694 char *str;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
695
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
696 if (!PyArg_Parse(args, "(iii)", &format, &width, &height))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
697 return NULL;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
698
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
699 info.format = format;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
700 info.width = width;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
701 info.height = height;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
702 info.size = 0;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
703 info.samplingrate = 0;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
704 if (svQueryCaptureBufferSize(self->ob_svideo, &info, &bytes))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
705 return sv_error();
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
706
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
707 if (!(videodata = PyString_FromStringAndSize(NULL, bytes)))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
708 return NULL;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
709
4762
f926263fb654 Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents: 4712
diff changeset
710 str = PyString_AsString(videodata);
f926263fb654 Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents: 4712
diff changeset
711 if (!str)
f926263fb654 Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents: 4712
diff changeset
712 goto finally;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
713
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
714 if (svCaptureOneFrame(self->ob_svideo, format, &width, &height, str)) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
715 res = sv_error();
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
716 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
717 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
718
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
719 res = Py_BuildValue("(iiO)", width, height, videodata);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
720
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
721 finally:
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
722 Py_XDECREF(videodata);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
723 return res;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
724 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
725
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
726 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
727 sv_InitContinuousCapture(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
728 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
729 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
730 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
731 svCaptureInfo info;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
732
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
733 if (!PyArg_Parse(args, "(iiiii)", &info.format,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
734 &info.width, &info.height,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
735 &info.size, &info.samplingrate))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
736 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
737
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
738 if (svInitContinuousCapture(self->ob_svideo, &info))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
739 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
740
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
741 self->ob_info = info;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
742
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
743 return Py_BuildValue("(iiiii)", info.format, info.width, info.height,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
744 info.size, info.samplingrate);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
745 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
746
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
747 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
748 sv_LoadMap(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
749 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
750 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
751 {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
752 PyObject *rgb;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
753 PyObject *res = NULL;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
754 rgb_tuple *mapp = NULL;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
755 int maptype;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
756 int i, j; /* indices */
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
757
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
758 if (!PyArg_Parse(args, "(iO)", &maptype, &rgb))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
759 return NULL;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
760
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
761 if (!PyList_Check(rgb) || PyList_Size(rgb) != 256) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
762 PyErr_BadArgument();
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
763 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
764 }
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
765
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
766 if (!(mapp = PyMem_NEW(rgb_tuple, 256)))
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
767 return PyErr_NoMemory();
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
768
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
769 for (i = 0; i < 256; i++) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
770 PyObject* v = PyList_GetItem(rgb, i);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
771 if (!v)
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
772 goto finally;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
773
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
774 if (!PyTuple_Check(v) || PyTuple_Size(v) != 3) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
775 PyErr_BadArgument();
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
776 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
777 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
778 for (j = 0; j < 3; j++) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
779 PyObject* cell = PyTuple_GetItem(v, j);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
780 if (!cell)
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
781 goto finally;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
782
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
783 if (!PyInt_Check(cell)) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
784 PyErr_BadArgument();
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
785 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
786 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
787 switch (j) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
788 case 0: mapp[i].red = PyInt_AsLong(cell); break;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
789 case 1: mapp[i].blue = PyInt_AsLong(cell); break;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
790 case 2: mapp[i].green = PyInt_AsLong(cell); break;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
791 }
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
792 if (PyErr_Occurred())
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
793 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
794 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
795 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
796
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
797 if (svLoadMap(self->ob_svideo, maptype, mapp)) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
798 res = sv_error();
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
799 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
800 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
801
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
802 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
803 res = Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
804
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
805 finally:
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
806 PyMem_DEL(mapp);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
807 return res;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
808 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
809
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
810 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
811 sv_CloseVideo(self, args)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
812 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
813 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
814 {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
815 if (!PyArg_Parse(args, ""))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
816 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
817
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
818 if (svCloseVideo(self->ob_svideo))
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
819 return sv_error();
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
820
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
821 self->ob_svideo = NULL;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
822 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
823 return Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
824 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
825
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
826 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
827 doParams(self, args, func, modified)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
828 svobject *self;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
829 PyObject *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
830 int (*func)(SV_nodeP, long *, int);
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
831 int modified;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
832 {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
833 PyObject *list;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
834 PyObject *res = NULL;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
835 long *PVbuffer = NULL;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
836 long length;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
837 int i;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
838
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
839 if (!PyArg_Parse(args, "O", &list))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
840 return NULL;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
841
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
842 if (!PyList_Check(list)) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
843 PyErr_BadArgument();
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
844 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
845 }
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
846
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
847 if ((length = PyList_Size(list)) < 0)
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
848 return NULL;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
849
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
850 PVbuffer = PyMem_NEW(long, length);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
851 if (PVbuffer == NULL)
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
852 return PyErr_NoMemory();
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
853
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
854 for (i = 0; i < length; i++) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
855 PyObject *v = PyList_GetItem(list, i);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
856 if (!v)
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
857 goto finally;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
858
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
859 if (!PyInt_Check(v)) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
860 PyErr_BadArgument();
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
861 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
862 }
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
863 PVbuffer[i] = PyInt_AsLong(v);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
864 /* can't just test the return value, because what if the
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
865 value was -1?!
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
866 */
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
867 if (PVbuffer[i] == -1 && PyErr_Occurred())
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
868 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
869 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
870
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
871 if ((*func)(self->ob_svideo, PVbuffer, length)) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
872 res = sv_error();
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
873 goto finally;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
874 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
875
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
876 if (modified) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
877 for (i = 0; i < length; i++) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
878 PyObject* v = PyInt_FromLong(PVbuffer[i]);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
879 if (!v || PyList_SetItem(list, i, v) < 0)
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
880 goto finally;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
881 }
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
882 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
883
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
884 Py_INCREF(Py_None);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
885 res = Py_None;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
886
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
887 finally:
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
888 PyMem_DEL(PVbuffer);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
889 return res;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
890 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
891
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
892 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
893 sv_GetParam(self, args)
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
894 PyObject *self, *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
895 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
896 return doParams(self, args, svGetParam, 1);
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
897 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
898
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
899 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
900 sv_GetParamRange(self, args)
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
901 PyObject *self, *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
902 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
903 return doParams(self, args, svGetParamRange, 1);
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
904 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
905
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
906 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
907 sv_SetParam(self, args)
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
908 PyObject *self, *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
909 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
910 return doParams(self, args, svSetParam, 0);
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
911 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
912
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
913 static PyMethodDef svideo_methods[] = {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
914 {"BindGLWindow", (PyCFunction)sv_BindGLWindow},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
915 {"EndContinuousCapture",(PyCFunction)sv_EndContinuousCapture},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
916 {"IsVideoDisplayed", (PyCFunction)sv_IsVideoDisplayed},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
917 {"OutputOffset", (PyCFunction)sv_OutputOffset},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
918 {"PutFrame", (PyCFunction)sv_PutFrame},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
919 {"QuerySize", (PyCFunction)sv_QuerySize},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
920 {"SetSize", (PyCFunction)sv_SetSize},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
921 {"SetStdDefaults", (PyCFunction)sv_SetStdDefaults},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
922 {"UseExclusive", (PyCFunction)sv_UseExclusive},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
923 {"WindowOffset", (PyCFunction)sv_WindowOffset},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
924 {"InitContinuousCapture",(PyCFunction)sv_InitContinuousCapture},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
925 {"CaptureBurst", (PyCFunction)sv_CaptureBurst},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
926 {"CaptureOneFrame", (PyCFunction)sv_CaptureOneFrame},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
927 {"GetCaptureData", (PyCFunction)sv_GetCaptureData},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
928 {"CloseVideo", (PyCFunction)sv_CloseVideo},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
929 {"LoadMap", (PyCFunction)sv_LoadMap},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
930 {"GetParam", (PyCFunction)sv_GetParam},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
931 {"GetParamRange", (PyCFunction)sv_GetParamRange},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
932 {"SetParam", (PyCFunction)sv_SetParam},
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
933 {NULL, NULL} /* sentinel */
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
934 };
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
935
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
936 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
937 sv_conversion(self, args, function, inputfactor, factor)
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
938 PyObject *self, *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
939 void (*function)();
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
940 int inputfactor;
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
941 float factor;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
942 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
943 int invert, width, height, inputlength;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
944 char *input, *str;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
945 PyObject *output;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
946
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
947 if (!PyArg_Parse(args, "(is#ii)", &invert,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
948 &input, &inputlength, &width, &height))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
949 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
950
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
951 if (width * height * inputfactor > inputlength) {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
952 PyErr_SetString(SvError, "input buffer not long enough");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
953 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
954 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
955
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
956 if (!(output = PyString_FromStringAndSize(NULL,
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
957 (int)(width * height * factor))))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
958 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
959
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
960 str = PyString_AsString(output);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
961 if (!str) {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
962 Py_DECREF(output);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
963 return NULL;
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
964 }
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
965 (*function)(invert, input, str, width, height);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
966
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
967 return output;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
968 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
969
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
970 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
971 sv_InterleaveFields(self, args)
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
972 PyObject *self, *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
973 {
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
974 return sv_conversion(self, args, svInterleaveFields, 1, 1.0);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
975 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
976
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
977 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
978 sv_RGB8toRGB32(self, args)
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
979 PyObject *self, *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
980 {
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
981 return sv_conversion(self, args, svRGB8toRGB32, 1, (float) sizeof(long));
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
982 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
983
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
984 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
985 sv_YUVtoRGB(self, args)
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
986 PyObject *self, *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
987 {
1253
685b31fe89c6 Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents: 1207
diff changeset
988 return sv_conversion(self, args, svYUVtoRGB, 2, (float) sizeof(long));
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
989 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
990
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
991 static void
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
992 svideo_dealloc(self)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
993 svobject *self;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
994 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
995 if (self->ob_svideo != NULL)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
996 (void) svCloseVideo(self->ob_svideo);
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
997 PyMem_DEL(self);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
998 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
999
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1000 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1001 svideo_getattr(self, name)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1002 svobject *self;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1003 char *name;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1004 {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1005 return Py_FindMethod(svideo_methods, (PyObject *)self, name);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1006 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1007
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1008 PyTypeObject Svtype = {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1009 PyObject_HEAD_INIT(&PyType_Type)
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1010 0, /*ob_size*/
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1011 "sv", /*tp_name*/
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1012 sizeof(svobject), /*tp_size*/
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1013 0, /*tp_itemsize*/
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1014 /* methods */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
1015 (destructor)svideo_dealloc, /*tp_dealloc*/
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1016 0, /*tp_print*/
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1253
diff changeset
1017 (getattrfunc)svideo_getattr, /*tp_getattr*/
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1018 0, /*tp_setattr*/
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1019 0, /*tp_compare*/
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1020 0, /*tp_repr*/
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1021 };
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1022
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1023 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1024 newsvobject(svp)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1025 SV_nodeP svp;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1026 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1027 svobject *p;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1028
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1029 p = PyObject_NEW(svobject, &Svtype);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1030 if (p == NULL)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1031 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1032 p->ob_svideo = svp;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1033 p->ob_info.format = 0;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1034 p->ob_info.size = 0;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1035 p->ob_info.width = 0;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1036 p->ob_info.height = 0;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1037 p->ob_info.samplingrate = 0;
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1038 return (PyObject *) p;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1039 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1040
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1041 static PyObject *
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1042 sv_OpenVideo(self, args)
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1043 PyObject *self, *args;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1044 {
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1045 SV_nodeP svp;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1046
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1047 if (!PyArg_Parse(args, ""))
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1048 return NULL;
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1049
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1050 svp = svOpenVideo();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1051 if (svp == NULL)
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1052 return sv_error();
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1053
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1054 return newsvobject(svp);
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1055 }
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1056
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1057 static PyMethodDef sv_methods[] = {
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1058 {"InterleaveFields", (PyCFunction)sv_InterleaveFields},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1059 {"RGB8toRGB32", (PyCFunction)sv_RGB8toRGB32},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1060 {"YUVtoRGB", (PyCFunction)sv_YUVtoRGB},
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1061 {"OpenVideo", (PyCFunction)sv_OpenVideo},
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1062 {NULL, NULL} /* Sentinel */
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1063 };
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1064
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1065 void
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1066 initsv()
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1067 {
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1068 PyObject *m, *d;
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1069
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1070 m = Py_InitModule("sv", sv_methods);
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1071 d = PyModule_GetDict(m);
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1072
4712
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1073 SvError = PyString_FromString("sv.error");
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1074 if (SvError == NULL || PyDict_SetItemString(d, "error", SvError) != 0)
0253ef267b68 Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents: 4503
diff changeset
1075 Py_FatalError("can't define sv.error");
1179
9ae65ee09735 Various changes.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1076 }