rtp{vorbis,theora}{pay,depay}: Cosmetic cleanup

* use g_list_free_full(), don't iterate elements maually when freeing
* call gst_rtp_*_pay_clear_packet(), don't duplicate its code
* use gst_buffer_unref() to clarify that it is buffers being released,
  instead of refering directly to gst_mini_object_unref()

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=755277
This commit is contained in:
Sebastian Rasmussen 2015-09-19 17:04:07 +02:00 committed by Sebastian Dröge
parent 869e21bd82
commit 2d7bfc1314
3 changed files with 12 additions and 44 deletions

View file

@ -153,22 +153,17 @@ gst_rtp_theora_pay_clear_packet (GstRtpTheoraPay * rtptheorapay)
if (rtptheorapay->packet) if (rtptheorapay->packet)
gst_buffer_unref (rtptheorapay->packet); gst_buffer_unref (rtptheorapay->packet);
rtptheorapay->packet = NULL; rtptheorapay->packet = NULL;
g_list_free_full (rtptheorapay->packet_buffers,
g_list_foreach (rtptheorapay->packet_buffers, (GFunc) gst_mini_object_unref, (GDestroyNotify) gst_buffer_unref);
NULL);
g_list_free (rtptheorapay->packet_buffers);
rtptheorapay->packet_buffers = NULL; rtptheorapay->packet_buffers = NULL;
} }
static void static void
gst_rtp_theora_pay_cleanup (GstRtpTheoraPay * rtptheorapay) gst_rtp_theora_pay_cleanup (GstRtpTheoraPay * rtptheorapay)
{ {
g_list_foreach (rtptheorapay->headers, (GFunc) gst_mini_object_unref, NULL);
g_list_free (rtptheorapay->headers);
rtptheorapay->headers = NULL;
gst_rtp_theora_pay_clear_packet (rtptheorapay); gst_rtp_theora_pay_clear_packet (rtptheorapay);
g_list_free_full (rtptheorapay->headers, (GDestroyNotify) gst_buffer_unref);
rtptheorapay->headers = NULL;
if (rtptheorapay->config_data) if (rtptheorapay->config_data)
g_free (rtptheorapay->config_data); g_free (rtptheorapay->config_data);
rtptheorapay->config_data = NULL; rtptheorapay->config_data = NULL;
@ -283,13 +278,7 @@ gst_rtp_theora_pay_init_packet (GstRtpTheoraPay * rtptheorapay, guint8 TDT,
{ {
GST_DEBUG_OBJECT (rtptheorapay, "starting new packet, TDT: %d", TDT); GST_DEBUG_OBJECT (rtptheorapay, "starting new packet, TDT: %d", TDT);
if (rtptheorapay->packet) gst_rtp_theora_pay_clear_packet (rtptheorapay);
gst_buffer_unref (rtptheorapay->packet);
g_list_foreach (rtptheorapay->packet_buffers, (GFunc) gst_mini_object_unref,
NULL);
g_list_free (rtptheorapay->packet_buffers);
rtptheorapay->packet_buffers = NULL;
/* new packet allocate max packet size */ /* new packet allocate max packet size */
rtptheorapay->packet = rtptheorapay->packet =

View file

@ -113,26 +113,14 @@ gst_rtp_vorbis_depay_init (GstRtpVorbisDepay * rtpvorbisdepay)
static void static void
free_config (GstRtpVorbisConfig * conf) free_config (GstRtpVorbisConfig * conf)
{ {
GList *headers; g_list_free_full (conf->headers, (GDestroyNotify) gst_buffer_unref);
for (headers = conf->headers; headers; headers = g_list_next (headers)) {
GstBuffer *header = GST_BUFFER_CAST (headers->data);
gst_buffer_unref (header);
}
g_list_free (conf->headers);
g_free (conf); g_free (conf);
} }
static void static void
free_indents (GstRtpVorbisDepay * rtpvorbisdepay) free_indents (GstRtpVorbisDepay * rtpvorbisdepay)
{ {
GList *walk; g_list_free_full (rtpvorbisdepay->configs, (GDestroyNotify) free_config);
for (walk = rtpvorbisdepay->configs; walk; walk = g_list_next (walk)) {
free_config ((GstRtpVorbisConfig *) walk->data);
}
g_list_free (rtpvorbisdepay->configs);
rtpvorbisdepay->configs = NULL; rtpvorbisdepay->configs = NULL;
} }

View file

@ -145,21 +145,17 @@ gst_rtp_vorbis_pay_clear_packet (GstRtpVorbisPay * rtpvorbispay)
if (rtpvorbispay->packet) if (rtpvorbispay->packet)
gst_buffer_unref (rtpvorbispay->packet); gst_buffer_unref (rtpvorbispay->packet);
rtpvorbispay->packet = NULL; rtpvorbispay->packet = NULL;
g_list_foreach (rtpvorbispay->packet_buffers, (GFunc) gst_mini_object_unref, g_list_free_full (rtpvorbispay->packet_buffers,
NULL); (GDestroyNotify) gst_buffer_unref);
g_list_free (rtpvorbispay->packet_buffers);
rtpvorbispay->packet_buffers = NULL; rtpvorbispay->packet_buffers = NULL;
} }
static void static void
gst_rtp_vorbis_pay_cleanup (GstRtpVorbisPay * rtpvorbispay) gst_rtp_vorbis_pay_cleanup (GstRtpVorbisPay * rtpvorbispay)
{ {
g_list_foreach (rtpvorbispay->headers, (GFunc) gst_mini_object_unref, NULL);
g_list_free (rtpvorbispay->headers);
rtpvorbispay->headers = NULL;
gst_rtp_vorbis_pay_clear_packet (rtpvorbispay); gst_rtp_vorbis_pay_clear_packet (rtpvorbispay);
g_list_free_full (rtpvorbispay->headers, (GDestroyNotify) gst_buffer_unref);
rtpvorbispay->headers = NULL;
if (rtpvorbispay->config_data) if (rtpvorbispay->config_data)
g_free (rtpvorbispay->config_data); g_free (rtpvorbispay->config_data);
rtpvorbispay->config_data = NULL; rtpvorbispay->config_data = NULL;
@ -277,12 +273,7 @@ gst_rtp_vorbis_pay_init_packet (GstRtpVorbisPay * rtpvorbispay, guint8 VDT,
{ {
GST_LOG_OBJECT (rtpvorbispay, "starting new packet, VDT: %d", VDT); GST_LOG_OBJECT (rtpvorbispay, "starting new packet, VDT: %d", VDT);
if (rtpvorbispay->packet) gst_rtp_vorbis_pay_clear_packet (rtpvorbispay);
gst_buffer_unref (rtpvorbispay->packet);
g_list_foreach (rtpvorbispay->packet_buffers, (GFunc) gst_mini_object_unref,
NULL);
g_list_free (rtpvorbispay->packet_buffers);
rtpvorbispay->packet_buffers = NULL;
/* new packet allocate max packet size */ /* new packet allocate max packet size */
rtpvorbispay->packet = rtpvorbispay->packet =