From 960b1c5b08839e6e2727ae5fcad3c00be1916583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 23 Jan 2008 10:11:44 +0000 Subject: tests/check/: Add simple unit test for the xingmux element. Original commit message from CVS: * tests/check/Makefile.am: * tests/check/elements/.cvsignore: * tests/check/elements/xingmux.c: (setup_xingmux), (cleanup_xingmux), (GST_START_TEST), (xingmux_suite), (main): * tests/check/elements/xingmux_testdata.h: Add simple unit test for the xingmux element. * gst/xingheader/gstxingmux.c: (generate_xing_header), (gst_xing_mux_finalize), (xing_reset): Fix a memleak and invalid seek tables with less than 100 MP3 frames. --- gst/xingheader/gstxingmux.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'gst') diff --git a/gst/xingheader/gstxingmux.c b/gst/xingheader/gstxingmux.c index 76f11ec8..d10006cc 100644 --- a/gst/xingheader/gstxingmux.c +++ b/gst/xingheader/gstxingmux.c @@ -319,7 +319,7 @@ generate_xing_header (GstXingMux * xing) GstXingSeekEntry *entry = (GstXingSeekEntry *) it->data; gint64 byte; - if ((entry->timestamp * 100) / duration >= percent) { + while ((entry->timestamp * 100) / duration >= percent) { byte = (entry->byte * 256) / byte_count; GST_DEBUG (" %d %% -- %d 1/256", percent, byte); *data = byte; @@ -327,6 +327,17 @@ generate_xing_header (GstXingMux * xing) percent++; } } + + if (percent < 100) { + guchar b = *(data - 1); + gint i; + + for (i = percent; i < 100; i++) { + GST_DEBUG (" %d %% -- %d 1/256", i, b); + *data = b; + data++; + } + } } GST_DEBUG ("Setting Xing flags to 0x%x\n", *xing_flags); @@ -376,6 +387,12 @@ gst_xing_mux_finalize (GObject * obj) xing->adapter = NULL; } + if (xing->seek_table) { + g_list_foreach (xing->seek_table, (GFunc) g_free, NULL); + g_list_free (xing->seek_table); + xing->seek_table = NULL; + } + G_OBJECT_CLASS (parent_class)->finalize (obj); } @@ -389,6 +406,7 @@ xing_reset (GstXingMux * xing) if (xing->seek_table) { g_list_foreach (xing->seek_table, (GFunc) g_free, NULL); + g_list_free (xing->seek_table); xing->seek_table = NULL; } -- cgit v1.2.1