219 static PyObject *
220 alsapcm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
221 {
222 int res;
223 alsapcm_t *self;
224 int pcmtype = SND_PCM_STREAM_PLAYBACK;
225 int pcmmode = 0;
226 char *kw[] = { "type", "mode", "card", NULL };
227 char *cardname = NULL;
228
229 if (!PyArg_ParseTupleAndKeywords(args, kwds, "|iiz", kw,
when PyArg_ParseTupleAndKeywords() succeeds
taking False path
230 &pcmtype, &pcmmode, &cardname))
231 return NULL;
232
233 if (!(self = (alsapcm_t *)PyObject_New(alsapcm_t, &ALSAPCMType)))
when _PyObject_New() succeeds
taking False path
_PyObject_New allocated at: if (!(self = (alsapcm_t *)PyObject_New(alsapcm_t, &ALSAPCMType)))
ob_refcnt is now refs: 1 + N where N >= 0
234 return NULL;
235
236 if (pcmtype != SND_PCM_STREAM_PLAYBACK &&
when considering range: -0x80000000 <= value <= 1
taking False path
237 pcmtype != SND_PCM_STREAM_CAPTURE)
238 {
239 PyErr_SetString(ALSAAudioError, "PCM type must be PCM_PLAYBACK (0) "
240 "or PCM_CAPTURE (1)");
241 return NULL;
242 }
243 if (pcmmode < 0 || pcmmode > SND_PCM_ASYNC) {
when considering range: -0x80000000 <= value <= 2
taking False path
244 PyErr_SetString(ALSAAudioError, "Invalid PCM mode");
245 return NULL;
246 }
247 self->handle = 0;
248 self->pcmtype = pcmtype;
249 self->pcmmode = pcmmode;
250 self->cardname = translate_cardname(cardname);
251 self->channels = 2;
252 self->rate = 44100;
253 self->format = SND_PCM_FORMAT_S16_LE;
254 self->periodsize = 32;
255
256 res = snd_pcm_open(&(self->handle), self->cardname, self->pcmtype,
257 self->pcmmode);
258
259 if (res >= 0)
when considering range: -0x80000000 <= value <= -1
taking False path
260 res = alsapcm_setup(self);
261
262 if (res < 0)
taking True path
263 {
264 if (self->handle)
when treating unknown struct snd_pcm_t * * from alsaaudio.c:256 as non-NULL
taking True path
265 {
266 snd_pcm_close(self->handle);
267 self->handle = 0;
268 }
269 PyErr_SetString(ALSAAudioError, snd_strerror(res));
calling PyErr_SetString()
270 return NULL;
271 }
272 return (PyObject *)self;
273 }
ob_refcnt of '*self' is 1 too high
was expecting final ob_refcnt to be N + 0 (for some unknown N)
but final ob_refcnt is N + 1
found 5 similar trace(s) to this