Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7745218

Browse files
committed
SF patch #489989 (Charles G Waldman) linuxaudiodev.c - fix initialization
The OSS Programmer's Reference (www.4front-tech.com) states: *Setting Sampling Parameters There are three parameters which affect the sound quality (and therefore memory and bandwidth requirements) of sampled audio data. These are: ** sample format (sometimes called number of bits) ** number of channels (mono or stereo), and ** sampling rate (speed) NOTE: It is important to always set these parameters in the above order. Setting sampling rate before the number of channels doesn't work with all devices.
1 parent b931bf3 commit 7745218

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

Modules/linuxaudiodev.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,6 @@ lad_setparameters(lad_t *self, PyObject *args)
258258
return NULL;
259259
}
260260

261-
if (ioctl(self->x_fd, SNDCTL_DSP_SPEED, &rate) == -1) {
262-
PyErr_SetFromErrno(LinuxAudioError);
263-
return NULL;
264-
}
265-
if (ioctl(self->x_fd, SNDCTL_DSP_CHANNELS, &nchannels) == -1) {
266-
PyErr_SetFromErrno(LinuxAudioError);
267-
return NULL;
268-
}
269-
270261
for (n = 0; n < n_audio_types; n++)
271262
if (fmt == audio_types[n].a_fmt)
272263
break;
@@ -294,6 +285,14 @@ lad_setparameters(lad_t *self, PyObject *args)
294285
PyErr_SetFromErrno(LinuxAudioError);
295286
return NULL;
296287
}
288+
if (ioctl(self->x_fd, SNDCTL_DSP_CHANNELS, &nchannels) == -1) {
289+
PyErr_SetFromErrno(LinuxAudioError);
290+
return NULL;
291+
}
292+
if (ioctl(self->x_fd, SNDCTL_DSP_SPEED, &rate) == -1) {
293+
PyErr_SetFromErrno(LinuxAudioError);
294+
return NULL;
295+
}
297296

298297
Py_INCREF(Py_None);
299298
return Py_None;

0 commit comments

Comments
 (0)