diff --git a/soundio/soundio.h b/soundio/soundio.h index c93697b..e964636 100644 --- a/soundio/soundio.h +++ b/soundio/soundio.h @@ -1015,6 +1015,7 @@ SOUNDIO_EXPORT int soundio_outstream_clear_buffer(struct SoundIoOutStream *outst /// * #SoundIoErrorIncompatibleDevice - device does not support /// pausing/unpausing. This error code might not be returned even if the /// device does not support pausing/unpausing. +/// * #SoundIoErrorInvalid - outstream not opened and started SOUNDIO_EXPORT int soundio_outstream_pause(struct SoundIoOutStream *outstream, bool pause); /// Obtain the total number of seconds that the next frame written after the diff --git a/src/alsa.cpp b/src/alsa.cpp index 9edead3..27f55d3 100644 --- a/src/alsa.cpp +++ b/src/alsa.cpp @@ -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) { + if (!si) + return SoundIoErrorInvalid; + SoundIoOutStreamAlsa *osa = &os->backend_data.alsa; + if (!osa->handle) + return SoundIoErrorInvalid; + if (osa->is_paused == pause) return 0;