Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 gbsplay (0.0.93-3) unstable; urgency=medium
 .
   * Bump standards version to 4.1.3.
   * Bump debhelper version to 11.
   * debian/source/format: added.
Author: Gürkan Myczko <gurkan@phys.ethz.ch>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2018-01-05

--- gbsplay-0.0.93.orig/configure
+++ gbsplay-0.0.93/configure
@@ -655,6 +655,16 @@ if [ "$use_alsa" != no ]; then
     remember_use alsa
     check_include alsa/asoundlib.h
     use_alsa=$have_alsa_asoundlib_h
+    cc_check "checking for ESTRPIPE support" have_estrpipe <<EOF
+#include <errno.h>
+#include <alsa/asoundlib.h>
+int main(int argc, char **argv)
+{
+    if (ESTRPIPE == 0)
+        return 1;  /* Never reached. */
+    return 0;
+}
+EOF
     recheck_use alsa
 fi
 
@@ -947,6 +957,7 @@ __EOF__
     plugout_x STDOUT
     use_x I18N
     use_x REGPARM
+    have_x ESTRPIPE
     echo "#endif"
 ) > config.h
 
--- gbsplay-0.0.93.orig/plugout_alsa.c
+++ gbsplay-0.0.93/plugout_alsa.c
@@ -94,13 +94,22 @@ static long regparm alsa_open(enum plugo
 	return 0;
 }
 
+static long is_suspended(snd_pcm_sframes_t retval)
+{
+#ifdef HAVE_ESTRPIPE
+	return retval == -ESTRPIPE;
+#else
+	return snd_pcm_state(pcm_handle) == SND_PCM_STATE_SUSPENDED;
+#endif
+}
+
 static ssize_t regparm alsa_write(const void *buf, size_t count)
 {
 	snd_pcm_sframes_t retval;
 
 	do {
 		retval = snd_pcm_writei(pcm_handle, buf, count / 4);
-		if (retval != -ESTRPIPE)
+		if (!is_suspended(retval))
 			break;
 
 		/* resume from suspend */
