dvbsuboverlay: Make the libdvbsub callback handler responsible for memory cleanup

We want to allow queueing of raw region image data in the gst plugin side,
and keep the data around until we pop the item from the queue. So make
the callback handler responsible for memory cleanup, if one is installed.
This commit is contained in:
Mart Raudsepp 2010-12-01 04:28:02 +02:00 committed by Edward Hervey
parent 4a68decb52
commit aca7237878
2 changed files with 18 additions and 4 deletions

View file

@ -1352,9 +1352,23 @@ _dvb_sub_parse_end_of_display_set (DvbSub * dvb_sub, guint16 page_id,
sub->num_rects = i;
if (priv->callbacks.new_data)
if (priv->callbacks.new_data) {
priv->callbacks.new_data (dvb_sub, pts, sub, priv->page_time_out,
priv->user_data);
} else {
/* No-one responsible to clean up memory, so do it ourselves */
/* FIXME: Just don't bother with all this palette image creation in the first place then... */
dvb_subtitles_free (sub);
}
return 1; /* FIXME: The caller of this function is probably supposed to do something with the return value */
}
void
dvb_subtitles_free (DVBSubtitles * sub)
{
int i;
DVBSubtitleRect *rect;
/* Now free up all the temporary memory we allocated */
for (i = 0; i < sub->num_rects; ++i) {
@ -1366,8 +1380,6 @@ _dvb_sub_parse_end_of_display_set (DvbSub * dvb_sub, guint16 page_id,
}
g_free (sub->rects);
g_slice_free (DVBSubtitles, sub);
return 1; /* FIXME: The caller of this function is probably supposed to do something with the return value */
}
/**

View file

@ -111,7 +111,8 @@ typedef struct DVBSubtitles {
* is the #DvbSub instance this callback originates from; @subs is the set of
* subtitle objects that should be display for no more than @page_time_out
* seconds at @pts; @user_data is the same user_data as was passed through
* dvb_sub_set_callbacks();
* dvb_sub_set_callbacks(); The callback handler is responsible for eventually
* cleaning up the subpicture data @subs with a call to dvb_subtitles_free()
*
* A set of callbacks that can be installed on the #DvbSub with
* dvb_sub_set_callbacks().
@ -126,6 +127,7 @@ GType dvb_sub_get_type (void) G_GNUC_CONST;
DvbSub *dvb_sub_new (void);
gint dvb_sub_feed_with_pts (DvbSub *dvb_sub, guint64 pts, guint8 *data, gint len);
void dvb_sub_set_callbacks (DvbSub *dvb_sub, DvbSubCallbacks *callbacks, gpointer user_data);
void dvb_subtitles_free (DVBSubtitles *sub);
void dvb_sub_set_global_log_cb (void (*log_cb) (GLogLevelFlags log_level, const gchar *format, va_list args, gpointer user_data),
gpointer user_data);