Kaydet (Commit) 3ffa59b1 authored tarafından Thomas Wouters's avatar Thomas Wouters

Rework channelnumber/samplesize detetion code's output variables a bit to

convince gcc (4.0.x) the variables are never used uninitialized (and raising
a proper exception if they ever are.)
üst 7464b43e
...@@ -332,7 +332,6 @@ _ssize(lad_t *self, int *nchannels, int *ssize) ...@@ -332,7 +332,6 @@ _ssize(lad_t *self, int *nchannels, int *ssize)
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
*nchannels = 0;
if (ioctl(self->x_fd, SNDCTL_DSP_CHANNELS, nchannels) < 0) if (ioctl(self->x_fd, SNDCTL_DSP_CHANNELS, nchannels) < 0)
return -errno; return -errno;
return 0; return 0;
...@@ -345,11 +344,11 @@ static PyObject * ...@@ -345,11 +344,11 @@ static PyObject *
lad_bufsize(lad_t *self, PyObject *args) lad_bufsize(lad_t *self, PyObject *args)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels, ssize; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":bufsize")) return NULL; if (!PyArg_ParseTuple(args, ":bufsize")) return NULL;
if (_ssize(self, &nchannels, &ssize) < 0) { if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) {
PyErr_SetFromErrno(LinuxAudioError); PyErr_SetFromErrno(LinuxAudioError);
return NULL; return NULL;
} }
...@@ -366,12 +365,12 @@ static PyObject * ...@@ -366,12 +365,12 @@ static PyObject *
lad_obufcount(lad_t *self, PyObject *args) lad_obufcount(lad_t *self, PyObject *args)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels, ssize; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":obufcount")) if (!PyArg_ParseTuple(args, ":obufcount"))
return NULL; return NULL;
if (_ssize(self, &nchannels, &ssize) < 0) { if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) {
PyErr_SetFromErrno(LinuxAudioError); PyErr_SetFromErrno(LinuxAudioError);
return NULL; return NULL;
} }
...@@ -389,12 +388,12 @@ static PyObject * ...@@ -389,12 +388,12 @@ static PyObject *
lad_obuffree(lad_t *self, PyObject *args) lad_obuffree(lad_t *self, PyObject *args)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels, ssize; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":obuffree")) if (!PyArg_ParseTuple(args, ":obuffree"))
return NULL; return NULL;
if (_ssize(self, &nchannels, &ssize) < 0) { if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) {
PyErr_SetFromErrno(LinuxAudioError); PyErr_SetFromErrno(LinuxAudioError);
return NULL; return NULL;
} }
......
...@@ -569,7 +569,6 @@ _ssize(oss_audio_t *self, int *nchannels, int *ssize) ...@@ -569,7 +569,6 @@ _ssize(oss_audio_t *self, int *nchannels, int *ssize)
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
*nchannels = 0;
if (ioctl(self->fd, SNDCTL_DSP_CHANNELS, nchannels) < 0) if (ioctl(self->fd, SNDCTL_DSP_CHANNELS, nchannels) < 0)
return -errno; return -errno;
return 0; return 0;
...@@ -582,11 +581,11 @@ static PyObject * ...@@ -582,11 +581,11 @@ static PyObject *
oss_bufsize(oss_audio_t *self, PyObject *args) oss_bufsize(oss_audio_t *self, PyObject *args)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels, ssize; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":bufsize")) return NULL; if (!PyArg_ParseTuple(args, ":bufsize")) return NULL;
if (_ssize(self, &nchannels, &ssize) < 0) { if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
return NULL; return NULL;
} }
...@@ -603,12 +602,12 @@ static PyObject * ...@@ -603,12 +602,12 @@ static PyObject *
oss_obufcount(oss_audio_t *self, PyObject *args) oss_obufcount(oss_audio_t *self, PyObject *args)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels, ssize; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":obufcount")) if (!PyArg_ParseTuple(args, ":obufcount"))
return NULL; return NULL;
if (_ssize(self, &nchannels, &ssize) < 0) { if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
return NULL; return NULL;
} }
...@@ -626,12 +625,12 @@ static PyObject * ...@@ -626,12 +625,12 @@ static PyObject *
oss_obuffree(oss_audio_t *self, PyObject *args) oss_obuffree(oss_audio_t *self, PyObject *args)
{ {
audio_buf_info ai; audio_buf_info ai;
int nchannels, ssize; int nchannels=0, ssize=0;
if (!PyArg_ParseTuple(args, ":obuffree")) if (!PyArg_ParseTuple(args, ":obuffree"))
return NULL; return NULL;
if (_ssize(self, &nchannels, &ssize) < 0) { if (_ssize(self, &nchannels, &ssize) < 0 || !nchannels || !ssize) {
PyErr_SetFromErrno(PyExc_IOError); PyErr_SetFromErrno(PyExc_IOError);
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment