harness: use new take_all_data() function in _dump_to_file().
authorHavard Graff <havard.graff@gmail.com>
Wed, 23 Nov 2016 12:12:36 +0000 (13:12 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Tue, 5 Dec 2017 15:37:14 +0000 (15:37 +0000)
libs/gst/check/gstharness.c

index faf94cf..09354b3 100644 (file)
@@ -1829,25 +1829,17 @@ gst_harness_take_all_data_as_bytes (GstHarness * h)
 void
 gst_harness_dump_to_file (GstHarness * h, const gchar * filename)
 {
-  GstHarnessPrivate *priv = h->priv;
-  FILE *fd;
-  GstBuffer *buf;
-  fd = fopen (filename, "wb");
-  g_assert (fd);
-
-  while ((buf = g_async_queue_try_pop (priv->buffer_queue))) {
-    GstMapInfo info;
-    if (gst_buffer_map (buf, &info, GST_MAP_READ)) {
-      fwrite (info.data, 1, info.size, fd);
-      gst_buffer_unmap (buf, &info);
-    } else {
-      GST_ERROR ("failed to map buffer %p", buf);
-    }
-    gst_buffer_unref (buf);
-  }
+  GError *err = NULL;
+  gpointer data;
+  gsize size;
 
-  fflush (fd);
-  fclose (fd);
+  data = gst_harness_take_all_data (h, &size);
+  if (!g_file_set_contents (filename, data ? data : "", size, &err)) {
+    g_error ("GstHarness: Failed to write data to file: %s", err->message);
+    g_clear_error (&err);
+  }
+  g_free (data);
+  g_free (data);
 }
 
 /**