diff options
author | Havard Graff <havard.graff@gmail.com> | 2016-11-23 13:12:36 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2017-12-05 15:37:14 +0000 |
commit | e08834bff328c00b30f8d4870d670492b7971cde (patch) | |
tree | a386367b810bac4360058829829b7972ea7c2583 | |
parent | d8e7fc40b109a3bd17765250c86d0912a99152a3 (diff) |
harness: use new take_all_data() function in _dump_to_file().
-rw-r--r-- | libs/gst/check/gstharness.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/libs/gst/check/gstharness.c b/libs/gst/check/gstharness.c index faf94cfa7..09354b3ec 100644 --- a/libs/gst/check/gstharness.c +++ b/libs/gst/check/gstharness.c @@ -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); } /** |