]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Improve error reporting if stdout can't be written to.
authorMike Brady <mikebrady@eircom.net>
Fri, 7 Apr 2017 17:34:25 +0000 (18:34 +0100)
committerMike Brady <mikebrady@eircom.net>
Fri, 7 Apr 2017 17:34:25 +0000 (18:34 +0100)
audio_stdout.c

index 2e79f76b9e639169216007752ea74f0d174a63fb..ee4a81b3b1ec90ca90d1e14c1a637abc19f0410d 100644 (file)
@@ -40,7 +40,16 @@ static int fd = -1;
 
 static void start(int sample_rate, int sample_format) { fd = STDOUT_FILENO; }
 
-static void play(short buf[], int samples) { int ignore = write(fd, buf, samples * 4); }
+static void play(short buf[], int samples) {
+  char errorstring[1024];
+  int warned = 0;
+  int rc = write(fd, buf, samples * 4); 
+  if ((rc<0) && (warned==0)) {
+    strerror_r(errno,(char*)errorstring,1024);
+    warn("Error %d writing to stdout: \"%s\".",errno,errorstring);
+    warned = 1;
+  }
+}
 
 static void stop(void) {
   // don't close stdout