From 2a68f630794ac86092211d4eca609103e39c4ef0 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 11 Sep 2015 20:33:40 -0700 Subject: [PATCH] ALSA: pause gives error when state is invalid --- soundio/soundio.h | 1 + src/alsa.cpp | 6 ++++++ 2 files changed, 7 insertions(+) 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;