alsasink: Improve logging in write() function
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Tue, 24 Aug 2021 19:26:12 +0000 (15:26 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 20 Sep 2021 18:06:44 +0000 (18:06 +0000)
This moves the "written X frames" lower so that we don't trace
confusing negative values on errors and add the error code in the
"Write error" log.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1261>

ext/alsa/gstalsasink.c

index 09ee1ea..6d72788 100644 (file)
@@ -1072,9 +1072,8 @@ gst_alsasink_write (GstAudioSink * asink, gpointer data, guint length)
       GST_DELAY_SINK_UNLOCK (asink);
     }
 
-    GST_DEBUG_OBJECT (asink, "written %d frames out of %d", err, cptr);
     if (err < 0) {
-      GST_DEBUG_OBJECT (asink, "Write error: %s", snd_strerror (err));
+      GST_DEBUG_OBJECT (asink, "Write error: %s (%d)", snd_strerror (err), err);
       if (err == -EAGAIN) {
         continue;
       } else if (err == -ENODEV) {
@@ -1089,6 +1088,7 @@ gst_alsasink_write (GstAudioSink * asink, gpointer data, guint length)
         break;
     }
 
+    GST_DEBUG_OBJECT (asink, "written %d frames out of %d", err, cptr);
     ptr += snd_pcm_frames_to_bytes (alsa->handle, err);
     cptr -= err;
   }