mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 23:36:38 +00:00
gst/mpegstream/gstmpegpacketize.*: g_malloc() can't fail, we don't need to handle this. Same for gst_buffer_new_and_a...
Original commit message from CVS: * gst/mpegstream/gstmpegpacketize.c: (gst_mpeg_packetize_put), (read_cache): * gst/mpegstream/gstmpegpacketize.h: g_malloc() can't fail, we don't need to handle this. Same for gst_buffer_new_and_alloc(). * gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_chain): klass->send_buffer() should have the same semantics as gst_pad_push(), ie. ownership of the buffer is transfered, so we never have to unref the buffer no matter what the flow return value was.
This commit is contained in:
parent
c538a643c3
commit
7780db0401
4 changed files with 26 additions and 19 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2006-04-13 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/mpegstream/gstmpegpacketize.c: (gst_mpeg_packetize_put),
|
||||
(read_cache):
|
||||
* gst/mpegstream/gstmpegpacketize.h:
|
||||
g_malloc() can't fail, we don't need to handle this. Same for
|
||||
gst_buffer_new_and_alloc().
|
||||
|
||||
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_chain):
|
||||
klass->send_buffer() should have the same semantics as
|
||||
gst_pad_push(), ie. ownership of the buffer is transfered,
|
||||
so we never have to unref the buffer no matter what the flow
|
||||
return value was.
|
||||
|
||||
2006-04-10 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* common/check.mak:
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
/*#define GST_DEBUG_ENABLED */
|
||||
#include "gstmpegpacketize.h"
|
||||
|
||||
GstMPEGPacketize *
|
||||
|
@ -69,7 +68,7 @@ gst_mpeg_packetize_tell (GstMPEGPacketize * packetize)
|
|||
return packetize->cache_byte_pos + packetize->cache_head;
|
||||
}
|
||||
|
||||
gboolean
|
||||
void
|
||||
gst_mpeg_packetize_put (GstMPEGPacketize * packetize, GstBuffer * buf)
|
||||
{
|
||||
int cache_len = packetize->cache_tail - packetize->cache_head;
|
||||
|
@ -86,8 +85,6 @@ gst_mpeg_packetize_put (GstMPEGPacketize * packetize, GstBuffer * buf)
|
|||
|
||||
/* allocate new cache - do not realloc to avoid copying data twice */
|
||||
new_cache = g_malloc (packetize->cache_size);
|
||||
if (new_cache == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* copy the data to the beginning of the new cache and update the cache info */
|
||||
memcpy (new_cache, packetize->cache + packetize->cache_head, cache_len);
|
||||
|
@ -114,7 +111,6 @@ gst_mpeg_packetize_put (GstMPEGPacketize * packetize, GstBuffer * buf)
|
|||
packetize->cache_tail += GST_BUFFER_SIZE (buf);
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static guint
|
||||
|
@ -145,8 +141,6 @@ read_cache (GstMPEGPacketize * packetize, guint length, GstBuffer ** outbuf)
|
|||
return GST_FLOW_RESEND;
|
||||
|
||||
*outbuf = gst_buffer_new_and_alloc (length);
|
||||
if (*outbuf == NULL)
|
||||
return GST_FLOW_ERROR;
|
||||
|
||||
memcpy (GST_BUFFER_DATA (*outbuf), packetize->cache + packetize->cache_head,
|
||||
length);
|
||||
|
|
|
@ -71,7 +71,7 @@ GstMPEGPacketize* gst_mpeg_packetize_new (GstPad *pad, GstMPEGPacketizeType
|
|||
void gst_mpeg_packetize_destroy (GstMPEGPacketize *packetize);
|
||||
|
||||
guint64 gst_mpeg_packetize_tell (GstMPEGPacketize *packetize);
|
||||
gboolean gst_mpeg_packetize_put (GstMPEGPacketize *packetize, GstBuffer * buf);
|
||||
void gst_mpeg_packetize_put (GstMPEGPacketize *packetize, GstBuffer * buf);
|
||||
GstFlowReturn gst_mpeg_packetize_read (GstMPEGPacketize *packetize, GstBuffer ** outbuf);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -321,6 +321,7 @@ gst_mpeg_parse_send_buffer (GstMPEGParse * mpeg_parse, GstBuffer * buffer,
|
|||
GST_ELEMENT_ERROR (GST_ELEMENT (mpeg_parse),
|
||||
CORE, NEGOTIATION, (NULL), ("failed to set caps"));
|
||||
gst_caps_unref (caps);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
gst_caps_unref (caps);
|
||||
|
@ -689,12 +690,10 @@ gst_mpeg_parse_chain (GstPad * pad, GstBuffer * buffer)
|
|||
GstClockTime time;
|
||||
guint64 size;
|
||||
|
||||
if (!gst_mpeg_packetize_put (mpeg_parse->packetize, buffer)) {
|
||||
gst_buffer_unref (buffer);
|
||||
goto done;
|
||||
}
|
||||
gst_mpeg_packetize_put (mpeg_parse->packetize, buffer);
|
||||
buffer = NULL;
|
||||
|
||||
while (1) {
|
||||
do {
|
||||
result = gst_mpeg_packetize_read (mpeg_parse->packetize, &buffer);
|
||||
if (result == GST_FLOW_RESEND) {
|
||||
/* there was not enough data in packetizer cache */
|
||||
|
@ -772,8 +771,13 @@ gst_mpeg_parse_chain (GstPad * pad, GstBuffer * buffer)
|
|||
GST_FLOW_OK);
|
||||
time = CLASS (mpeg_parse)->adjust_ts (mpeg_parse,
|
||||
MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr));
|
||||
|
||||
if (CLASS (mpeg_parse)->send_buffer)
|
||||
result = CLASS (mpeg_parse)->send_buffer (mpeg_parse, buffer, time);
|
||||
else
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
buffer = NULL;
|
||||
|
||||
/* Calculate the expected next SCR. */
|
||||
if (mpeg_parse->current_scr != MP_INVALID_SCR) {
|
||||
|
@ -809,12 +813,7 @@ gst_mpeg_parse_chain (GstPad * pad, GstBuffer * buffer)
|
|||
", total since SCR: %" G_GINT64_FORMAT ", br: %" G_GINT64_FORMAT
|
||||
", next SCR: %" G_GINT64_FORMAT, size, bss, br, mpeg_parse->next_scr);
|
||||
}
|
||||
|
||||
if (result != GST_FLOW_OK && result != GST_FLOW_NOT_LINKED) {
|
||||
gst_buffer_unref (buffer);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
} while (!GST_FLOW_IS_FATAL (result));
|
||||
|
||||
done:
|
||||
gst_object_unref (mpeg_parse);
|
||||
|
|
Loading…
Reference in a new issue