ext/ffmpeg/: Free strings atleast when finalizing elements.

Original commit message from CVS:
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_cfg_install_property),
(gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcfg.h:
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_finalize),
(ffmpegenc_setup_working_buf), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_flush_buffers):
Free strings atleast when finalizing elements.
* tests/check/generic/libavcodec-locking.c: (GST_START_TEST),
(simple_launch_lines_suite):
Fix some leaks.
This commit is contained in:
Stefan Kost 2007-08-01 17:43:39 +00:00
parent 8e16a39836
commit 907d7e40f5
5 changed files with 65 additions and 14 deletions

View file

@ -1,3 +1,17 @@
2007-08-01 Stefan Kost <ensonic@users.sf.net>
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_cfg_install_property),
(gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcfg.h:
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_finalize),
(ffmpegenc_setup_working_buf), (gst_ffmpegenc_chain_video),
(gst_ffmpegenc_flush_buffers):
Free strings atleast when finalizing elements.
* tests/check/generic/libavcodec-locking.c: (GST_START_TEST),
(simple_launch_lines_suite):
Fix some leaks.
2007-08-01 Stefan Kost <ensonic@users.sf.net> 2007-08-01 Stefan Kost <ensonic@users.sf.net>
* configure.ac: * configure.ac:

View file

@ -1026,3 +1026,36 @@ gst_ffmpeg_cfg_fill_context (GstFFMpegEnc * ffmpegenc, AVCodecContext * context)
list = list->next; list = list->next;
} }
} }
void
gst_ffmpeg_cfg_finalize (GstFFMpegEnc * ffmpegenc)
{
GParamSpec **pspecs;
guint num_props, i;
pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (ffmpegenc),
&num_props);
for (i = 0; i < num_props; ++i) {
GParamSpec *pspec = pspecs[i];
GParamSpecData *qdata;
qdata = g_param_spec_get_qdata (pspec, quark);
/* our param specs should have such qdata */
if (!qdata)
continue;
switch (G_PARAM_SPEC_VALUE_TYPE (pspec)) {
case G_TYPE_STRING:
if(qdata->size == sizeof (gchar*)) {
g_free (G_STRUCT_MEMBER (gchar*, ffmpegenc, qdata->offset));
G_STRUCT_MEMBER (gchar*, ffmpegenc, qdata->offset) = NULL;
}
break;
default:
break;
}
}
g_free (pspecs);
}

View file

@ -35,6 +35,7 @@ gboolean gst_ffmpeg_cfg_get_property (GObject * object,
void gst_ffmpeg_cfg_fill_context (GstFFMpegEnc * ffmpegenc, AVCodecContext * context); void gst_ffmpeg_cfg_fill_context (GstFFMpegEnc * ffmpegenc, AVCodecContext * context);
void gst_ffmpeg_cfg_set_defaults (GstFFMpegEnc * ffmpegenc); void gst_ffmpeg_cfg_set_defaults (GstFFMpegEnc * ffmpegenc);
void gst_ffmpeg_cfg_finalize (GstFFMpegEnc * ffmpegenc);
G_END_DECLS G_END_DECLS

View file

@ -259,6 +259,8 @@ gst_ffmpegenc_finalize (GObject * object)
{ {
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) object; GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) object;
gst_ffmpeg_cfg_finalize (ffmpegenc);
/* close old session */ /* close old session */
if (ffmpegenc->opened) { if (ffmpegenc->opened) {
gst_ffmpeg_avcodec_close (ffmpegenc->context); gst_ffmpeg_avcodec_close (ffmpegenc->context);

View file

@ -111,12 +111,11 @@ GST_START_TEST (test_libavcodec_locks)
run_pipeline (setup_pipeline (s), s, run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING), GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN); GST_MESSAGE_UNKNOWN);
g_free (s); g_free (s);
for (i=0; i<NUM_SINKS; i++) for (i=0; i<NUM_SINKS; i++)
g_free (sink[i]); g_free (sink[i]);
g_free (sinks);
} }
GST_END_TEST Suite * GST_END_TEST Suite *
@ -138,6 +137,7 @@ simple_launch_lines_suite (void)
suite_add_tcase (s, tc_chain); suite_add_tcase (s, tc_chain);
#ifndef GST_DISABLE_PARSE
/* only run this if we haven't been configured with --disable-encoders */ /* only run this if we haven't been configured with --disable-encoders */
if (gst_default_registry_check_feature_version ("ffenc_mpeg4", if (gst_default_registry_check_feature_version ("ffenc_mpeg4",
GST_VERSION_MAJOR, GST_VERSION_MINOR, 0)) { GST_VERSION_MAJOR, GST_VERSION_MINOR, 0)) {
@ -145,6 +145,7 @@ simple_launch_lines_suite (void)
} else { } else {
g_print ("******* Skipping libavcodec_locks test, no encoder available\n"); g_print ("******* Skipping libavcodec_locks test, no encoder available\n");
} }
#endif
return s; return s;
} }