mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-05 15:08:48 +00:00
Sync with my copy before wtay starts hacking...
Original commit message from CVS: Sync with my copy before wtay starts hacking... Decided to keep the GstBuffer name through most code because it's really messy otherwise, and it doesn't really mean much either way. Saves lots of stupid casting. fakesrc num_buffers=N ! fakesink ends with a segfault on EOS right now, not tracked down yet.
This commit is contained in:
parent
e435484b29
commit
bd13c9eb8e
8 changed files with 59 additions and 27 deletions
|
@ -206,9 +206,9 @@ gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParam
|
|||
/**
|
||||
* gst_fakesink_chain:
|
||||
* @pad: the pad this faksink is connected to
|
||||
* @buf: the buffer that has to be absorbed
|
||||
* @buffer: the buffer or event that has to be absorbed
|
||||
*
|
||||
* take the buffer from the pad and unref it without doing
|
||||
* Take the buffer or event from the pad and unref it without doing
|
||||
* anything with it.
|
||||
*/
|
||||
static void
|
||||
|
@ -221,12 +221,16 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
|
|||
g_return_if_fail (buf != NULL);
|
||||
|
||||
fakesink = GST_FAKESINK (gst_pad_get_parent (pad));
|
||||
|
||||
if (GST_IS_EVENT(buf)) {
|
||||
g_print("fakesink: have event!\n");
|
||||
}
|
||||
|
||||
if (!fakesink->silent)
|
||||
g_print("fakesink: chain ******* (%s:%s)< (%d bytes, %lld) \n",
|
||||
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
|
||||
|
||||
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0,
|
||||
buf);
|
||||
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
|
||||
|
||||
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf);
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
@ -248,4 +252,5 @@ gst_fakesink_event (GstPad *pad, GstEventType event, guint64 timestamp, guint32
|
|||
if (event == GST_EVENT_EOS) {
|
||||
GST_DEBUG(GST_CAT_EVENT, "have EOS\n");
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -334,8 +334,8 @@ gst_fakesrc_get(GstPad *pad)
|
|||
g_return_val_if_fail (GST_IS_FAKESRC (src), NULL);
|
||||
|
||||
if (src->num_buffers == 0) {
|
||||
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
|
||||
return NULL;
|
||||
g_print("fakesrc: sending EOS\n");
|
||||
return GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS));
|
||||
}
|
||||
else {
|
||||
if (src->num_buffers > 0)
|
||||
|
@ -344,8 +344,8 @@ gst_fakesrc_get(GstPad *pad)
|
|||
|
||||
if (src->eos) {
|
||||
GST_INFO (0, "fakesrc is setting eos on pad");
|
||||
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
|
||||
return NULL;
|
||||
g_print("fakesrc: sending EOS\n");
|
||||
return GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS));
|
||||
}
|
||||
|
||||
buf = gst_buffer_new();
|
||||
|
@ -397,8 +397,7 @@ gst_fakesrc_loop(GstElement *element)
|
|||
|
||||
if (src->eos) {
|
||||
GST_INFO (0, "fakesrc is setting eos on pad");
|
||||
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
|
||||
return;
|
||||
gst_pad_push(pad, GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS)));
|
||||
}
|
||||
|
||||
buf = gst_buffer_new();
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include <gst/gstdparam.h>
|
||||
#include <gst/gstdparammanager.h>
|
||||
#include <gst/gsttimecache.h>
|
||||
#include <gst/gstevent.h>
|
||||
|
||||
#include <gst/gstparse.h>
|
||||
#include <gst/gstextratypes.h>
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "gstbuffer.h"
|
||||
|
||||
|
||||
GType _gst_buffer_type;
|
||||
|
||||
static GMemChunk *_gst_buffer_chunk;
|
||||
static GMutex *_gst_buffer_chunk_lock;
|
||||
|
||||
|
@ -34,6 +36,17 @@ void
|
|||
_gst_buffer_initialize (void)
|
||||
{
|
||||
int buffersize = sizeof(GstBuffer);
|
||||
static const GTypeInfo buffer_info = {
|
||||
0, // sizeof(class),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0, // sizeof(object),
|
||||
0,
|
||||
NULL,
|
||||
};
|
||||
|
||||
// round up to the nearest 32 bytes for cache-line and other efficiencies
|
||||
buffersize = (((buffersize-1) / 32) + 1) * 32;
|
||||
|
@ -42,6 +55,8 @@ _gst_buffer_initialize (void)
|
|||
buffersize * 32, G_ALLOC_AND_FREE);
|
||||
|
||||
_gst_buffer_chunk_lock = g_mutex_new ();
|
||||
|
||||
_gst_buffer_type = g_type_register_static (G_TYPE_INT, "GstBuffer", &buffer_info, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,6 +76,8 @@ gst_buffer_new(void)
|
|||
g_mutex_unlock (_gst_buffer_chunk_lock);
|
||||
GST_INFO (GST_CAT_BUFFER,"creating new buffer %p",buffer);
|
||||
|
||||
GST_DATA_TYPE(buffer) = _gst_buffer_type;
|
||||
|
||||
buffer->lock = g_mutex_new ();
|
||||
#ifdef HAVE_ATOMIC_H
|
||||
atomic_set (&buffer->refcount, 1);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#ifndef __GST_BUFFER_H__
|
||||
#define __GST_BUFFER_H__
|
||||
|
||||
#include <gst/gstdata.h>
|
||||
#include <gst/gstobject.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -39,9 +40,11 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern GType _gst_buffer_type;
|
||||
|
||||
#define GST_BUFFER(buf) \
|
||||
((GstBuffer *)(buf))
|
||||
#define GST_TYPE_BUFFER (_gst_buffer_type)
|
||||
#define GST_BUFFER(buf) ((GstBuffer *)(buf))
|
||||
#define GST_IS_BUFFER(buf) (GST_DATA_TYPE(buf) == GST_TYPE_BUFFER)
|
||||
|
||||
#define GST_BUFFER_FLAGS(buf) \
|
||||
(GST_BUFFER(buf)->flags)
|
||||
|
@ -93,6 +96,8 @@ typedef void (*GstBufferCopyFunc) (GstBuffer *srcbuf,GstBuffer *dstbuf);
|
|||
#include <gst/gstbufferpool.h>
|
||||
|
||||
struct _GstBuffer {
|
||||
GstData data_type;
|
||||
|
||||
/* locking */
|
||||
GMutex *lock;
|
||||
|
||||
|
|
|
@ -41,8 +41,9 @@ typedef enum {
|
|||
|
||||
extern GType _gst_event_type;
|
||||
|
||||
#define GST_TYPE_EVENT (_gst_event_type)
|
||||
#define GST_EVENT(event) ((GstEvent*)(event))
|
||||
#define GST_IS_EVENT(event) (GST_DATA_TYPE(event) == _gst_event_type)
|
||||
#define GST_IS_EVENT(event) (GST_DATA_TYPE(event) == GST_TYPE_EVENT)
|
||||
|
||||
#define GST_EVENT_TYPE(event) (GST_EVENT(event)->type)
|
||||
|
||||
|
|
|
@ -206,9 +206,9 @@ gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParam
|
|||
/**
|
||||
* gst_fakesink_chain:
|
||||
* @pad: the pad this faksink is connected to
|
||||
* @buf: the buffer that has to be absorbed
|
||||
* @buffer: the buffer or event that has to be absorbed
|
||||
*
|
||||
* take the buffer from the pad and unref it without doing
|
||||
* Take the buffer or event from the pad and unref it without doing
|
||||
* anything with it.
|
||||
*/
|
||||
static void
|
||||
|
@ -221,12 +221,16 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
|
|||
g_return_if_fail (buf != NULL);
|
||||
|
||||
fakesink = GST_FAKESINK (gst_pad_get_parent (pad));
|
||||
|
||||
if (GST_IS_EVENT(buf)) {
|
||||
g_print("fakesink: have event!\n");
|
||||
}
|
||||
|
||||
if (!fakesink->silent)
|
||||
g_print("fakesink: chain ******* (%s:%s)< (%d bytes, %lld) \n",
|
||||
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
|
||||
|
||||
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0,
|
||||
buf);
|
||||
GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
|
||||
|
||||
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf);
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
@ -248,4 +252,5 @@ gst_fakesink_event (GstPad *pad, GstEventType event, guint64 timestamp, guint32
|
|||
if (event == GST_EVENT_EOS) {
|
||||
GST_DEBUG(GST_CAT_EVENT, "have EOS\n");
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -334,8 +334,8 @@ gst_fakesrc_get(GstPad *pad)
|
|||
g_return_val_if_fail (GST_IS_FAKESRC (src), NULL);
|
||||
|
||||
if (src->num_buffers == 0) {
|
||||
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
|
||||
return NULL;
|
||||
g_print("fakesrc: sending EOS\n");
|
||||
return GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS));
|
||||
}
|
||||
else {
|
||||
if (src->num_buffers > 0)
|
||||
|
@ -344,8 +344,8 @@ gst_fakesrc_get(GstPad *pad)
|
|||
|
||||
if (src->eos) {
|
||||
GST_INFO (0, "fakesrc is setting eos on pad");
|
||||
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
|
||||
return NULL;
|
||||
g_print("fakesrc: sending EOS\n");
|
||||
return GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS));
|
||||
}
|
||||
|
||||
buf = gst_buffer_new();
|
||||
|
@ -397,8 +397,7 @@ gst_fakesrc_loop(GstElement *element)
|
|||
|
||||
if (src->eos) {
|
||||
GST_INFO (0, "fakesrc is setting eos on pad");
|
||||
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
|
||||
return;
|
||||
gst_pad_push(pad, GST_BUFFER(gst_event_empty_new (GST_EVENT_EOS)));
|
||||
}
|
||||
|
||||
buf = gst_buffer_new();
|
||||
|
|
Loading…
Reference in a new issue