ALSA: pause gives error when state is invalid

This commit is contained in:
Andrew Kelley 2015-09-11 20:33:40 -07:00
parent 4a0b3579d4
commit 2a68f63079
2 changed files with 7 additions and 0 deletions

View file

@ -1015,6 +1015,7 @@ SOUNDIO_EXPORT int soundio_outstream_clear_buffer(struct SoundIoOutStream *outst
/// * #SoundIoErrorIncompatibleDevice - device does not support /// * #SoundIoErrorIncompatibleDevice - device does not support
/// pausing/unpausing. This error code might not be returned even if the /// pausing/unpausing. This error code might not be returned even if the
/// device does not support pausing/unpausing. /// device does not support pausing/unpausing.
/// * #SoundIoErrorInvalid - outstream not opened and started
SOUNDIO_EXPORT int soundio_outstream_pause(struct SoundIoOutStream *outstream, bool pause); SOUNDIO_EXPORT int soundio_outstream_pause(struct SoundIoOutStream *outstream, bool pause);
/// Obtain the total number of seconds that the next frame written after the /// Obtain the total number of seconds that the next frame written after the

View file

@ -1459,8 +1459,14 @@ static int outstream_clear_buffer_alsa(SoundIoPrivate *si,
} }
static int outstream_pause_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) { static int outstream_pause_alsa(struct SoundIoPrivate *si, struct SoundIoOutStreamPrivate *os, bool pause) {
if (!si)
return SoundIoErrorInvalid;
SoundIoOutStreamAlsa *osa = &os->backend_data.alsa; SoundIoOutStreamAlsa *osa = &os->backend_data.alsa;
if (!osa->handle)
return SoundIoErrorInvalid;
if (osa->is_paused == pause) if (osa->is_paused == pause)
return 0; return 0;