mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +00:00
mulaw: Some minor memleak fixes and cleanup
This commit is contained in:
parent
f0edb5fb70
commit
fb0384fa0d
2 changed files with 14 additions and 15 deletions
|
@ -101,6 +101,7 @@ gst_mulawenc_set_format (GstAudioEncoder * audioenc, GstAudioInfo * info)
|
|||
GstCaps *base_caps;
|
||||
GstStructure *structure;
|
||||
GstMuLawEnc *mulawenc = GST_MULAWENC (audioenc);
|
||||
gboolean ret;
|
||||
|
||||
mulawenc->rate = info->rate;
|
||||
mulawenc->channels = info->channels;
|
||||
|
@ -119,7 +120,10 @@ gst_mulawenc_set_format (GstAudioEncoder * audioenc, GstAudioInfo * info)
|
|||
|
||||
gst_mulawenc_set_tags (mulawenc);
|
||||
|
||||
return gst_audio_encoder_set_output_format (audioenc, base_caps);
|
||||
ret = gst_audio_encoder_set_output_format (audioenc, base_caps);
|
||||
gst_caps_unref (base_caps);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
|
|
|
@ -20,12 +20,10 @@
|
|||
#endif
|
||||
|
||||
#include <gst/check/gstcheck.h>
|
||||
#include <string.h>
|
||||
|
||||
GList *buffers = NULL;
|
||||
|
||||
GstPad *mysrcpad, *mysinkpad;
|
||||
GstElement *mulawenc = NULL;
|
||||
|
||||
static GstPad *mysrcpad, *mysinkpad;
|
||||
static GstElement *mulawenc = NULL;
|
||||
|
||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
|
@ -33,7 +31,6 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|||
GST_STATIC_CAPS ("audio/x-mulaw," "rate = (int) 8000," "channels = (int) 1")
|
||||
);
|
||||
|
||||
|
||||
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
|
@ -83,8 +80,6 @@ mulawenc_teardown (void)
|
|||
|
||||
gst_pad_set_active (mysrcpad, FALSE);
|
||||
gst_pad_set_active (mysinkpad, FALSE);
|
||||
gst_object_unref (mysrcpad);
|
||||
gst_object_unref (mysinkpad);
|
||||
gst_check_teardown_src_pad (mulawenc);
|
||||
gst_check_teardown_sink_pad (mulawenc);
|
||||
gst_check_teardown_element (mulawenc);
|
||||
|
@ -119,14 +114,14 @@ check_for_maximum_bitrate (GstPad * pad, GstEvent ** eventp, gpointer user_data)
|
|||
GST_START_TEST (test_one_buffer)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
int buf_size = 4096;
|
||||
unsigned char *dp;
|
||||
gint buf_size = 4096;
|
||||
guint8 *dp;
|
||||
|
||||
fail_unless (gst_element_set_state (mulawenc, GST_STATE_PLAYING) ==
|
||||
GST_STATE_CHANGE_SUCCESS, "could not change state to playing");
|
||||
|
||||
buffer = gst_buffer_new ();
|
||||
dp = g_malloc (buf_size);
|
||||
dp = g_malloc0 (buf_size);
|
||||
gst_buffer_append_memory (buffer,
|
||||
gst_memory_new_wrapped (0, dp, buf_size, 0, buf_size, dp, g_free));
|
||||
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
||||
|
@ -142,15 +137,15 @@ GST_END_TEST;
|
|||
GST_START_TEST (test_tags)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
int buf_size = 4096;
|
||||
unsigned char *dp;
|
||||
gint buf_size = 4096;
|
||||
guint8 *dp;
|
||||
gboolean found_maximum_bitrate = FALSE;
|
||||
|
||||
fail_unless (gst_element_set_state (mulawenc, GST_STATE_PLAYING) ==
|
||||
GST_STATE_CHANGE_SUCCESS, "could not change state to playing");
|
||||
|
||||
buffer = gst_buffer_new ();
|
||||
dp = g_malloc (buf_size);
|
||||
dp = g_malloc0 (buf_size);
|
||||
gst_buffer_append_memory (buffer,
|
||||
gst_memory_new_wrapped (0, dp, buf_size, 0, buf_size, dp, g_free));
|
||||
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
||||
|
|
Loading…
Reference in a new issue