Commit cccc097c authored by Wim Taymans's avatar Wim Taymans

API docs. revived _buffer_ref_by_count fast types for scheduler and bin.

Original commit message from CVS:
API docs.
revived _buffer_ref_by_count
fast types for scheduler and bin.
error checking on plugin features;
removed some prototypes that were not implemented (gst_pipeline_iterate
comes to mind)
remove gst_pad_event until we know what it's supposed to do.
remove sinesrc, it wasn't compiles anymore, so...
updates to various elements that used the old event API.
parent 710d1ae0
......@@ -192,10 +192,12 @@ cothread_setfunc (cothread_state *thread,
* cothread_main:
* @ctx: cothread context to find main thread of
*
* Get the main thread.
*
* Returns: the #cothread_state of the main (0th) thread
*/
cothread_state*
cothread_main(cothread_context *ctx)
cothread_main (cothread_context *ctx)
{
GST_DEBUG (0,"returning %p, the 0th cothread\n",ctx->threads[0]);
return ctx->threads[0];
......@@ -204,10 +206,12 @@ cothread_main(cothread_context *ctx)
/**
* cothread_current_main:
*
* Get the main thread in the current pthread.
*
* Returns: the #cothread_state of the main (0th) thread in the current pthread
*/
cothread_state*
cothread_current_main(void)
cothread_current_main (void)
{
cothread_context *ctx = pthread_getspecific(_cothread_key);
return ctx->threads[0];
......@@ -242,10 +246,14 @@ cothread_stub (void)
/**
* cothread_getcurrent:
*
* Get the current cothread id
*
* Returns: the current cothread id
*/
int cothread_getcurrent(void) __attribute__ ((no_instrument_function));
int cothread_getcurrent(void) {
int cothread_getcurrent (void) __attribute__ ((no_instrument_function));
int
cothread_getcurrent (void)
{
cothread_context *ctx = pthread_getspecific(_cothread_key);
if (!ctx) return -1;
return ctx->current;
......
......@@ -39,8 +39,7 @@ noinst_HEADERS = \
gstfdsink.h \
gstpipefilter.h \
gsttee.h \
gstaggregator.h \
gstsinesrc.h
gstaggregator.h
CFLAGS += -O2 -Wall
LDFLAGS += -lm
......
......@@ -290,10 +290,7 @@ gst_disksrc_get (GstPad *pad)
/* deal with EOF state */
if (src->curoffset >= src->size) {
GST_DEBUG (0,"map offset %ld >= size %ld --> eos\n", src->curoffset, src->size);
gst_pad_event(pad, GST_EVENT_EOS, 0LL, 0);
buf = gst_buffer_new();
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_EOS);
return buf;
return GST_BUFFER(gst_event_new (GST_EVENT_EOS));
}
// FIXME use a bufferpool
......
......@@ -203,8 +203,7 @@ gst_multidisksrc_get (GstPad *pad)
gst_multidisksrc_close_file(src);
if (!src->listptr) {
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return FALSE;
return GST_BUFFER(gst_event_new (GST_EVENT_EOS));
}
list = src->listptr;
......
......@@ -203,8 +203,7 @@ gst_multidisksrc_get (GstPad *pad)
gst_multidisksrc_close_file(src);
if (!src->listptr) {
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return FALSE;
return GST_BUFFER(gst_event_new (GST_EVENT_EOS));
}
list = src->listptr;
......
......@@ -64,7 +64,7 @@ static void gst_pipefilter_get_property (GObject *object, guint prop_id, GVal
static GstBuffer* gst_pipefilter_get (GstPad *pad);
static void gst_pipefilter_chain (GstPad *pad, GstBuffer *buf);
static gboolean gst_pipefilter_handle_event (GstPad *pad, void *event);
static gboolean gst_pipefilter_handle_event (GstPad *pad, GstEvent *event);
static GstElementStateReturn gst_pipefilter_change_state (GstElement *element);
......@@ -134,7 +134,7 @@ gst_pipefilter_init (GstPipefilter *pipefilter)
}
static gboolean
gst_pipefilter_handle_event (GstPad *pad, void *event)
gst_pipefilter_handle_event (GstPad *pad, GstEvent *event)
{
GstPipefilter *pipefilter;
......@@ -180,8 +180,8 @@ gst_pipefilter_get (GstPad *pad)
}
/* if we didn't get as many bytes as we asked for, we're at EOF */
if (readbytes == 0) {
gst_pad_event (pad, GST_EVENT_EOS, 0LL, 0);
return NULL;
return GST_BUFFER(gst_event_new (GST_EVENT_EOS));
}
GST_BUFFER_OFFSET(newbuf) = pipefilter->curoffset;
......
This diff is collapsed.
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstsinesrc.h:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_SINESRC_H__
#define __GST_SINESRC_H__
#include <config.h>
#include <gst/gst.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
GstElementDetails gst_sinesrc_details;
#define GST_TYPE_SINESRC \
(gst_sinesrc_get_type())
#define GST_SINESRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SINESRC,GstSineSrc))
#define GST_SINESRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SINESRC,GstSineSrcClass))
#define GST_IS_SINESRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SINESRC))
#define GST_IS_SINESRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SINESRC))
typedef struct _GstSineSrc GstSineSrc;
typedef struct _GstSineSrcClass GstSineSrcClass;
struct _GstSineSrc {
GstElement element;
/* pads */
GstPad *srcpad;
/* parameters */
gfloat volume;
gfloat freq;
gfloat vol_scale;
/* lookup table data */
gfloat *table_data;
gdouble table_pos;
gdouble table_inc;
gint table_size;
gdouble table_interp;
gint table_lookup;
gint table_lookup_next;
/* audio parameters */
gint format;
gint samplerate;
gint buffer_size;
gulong seq;
gboolean newcaps;
};
struct _GstSineSrcClass {
GstElementClass parent_class;
};
GType gst_sinesrc_get_type(void);
gboolean gst_sinesrc_factory_init (GstElementFactory *factory);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GST_SINESRC_H__ */
......@@ -34,6 +34,7 @@
#include "gstthread.h"
#include "gstqueue.h"
#include "gstautoplug.h"
#include "gstscheduler.h"
#ifndef GST_DISABLE_TYPEFIND
#include "gsttypefind.h"
#endif
......@@ -117,6 +118,8 @@ gst_init (int *argc, char **argv[])
gst_elementfactory_get_type ();
gst_element_get_type ();
gst_typefactory_get_type ();
gst_schedule_get_type ();
gst_bin_get_type ();
#ifndef GST_DISABLE_AUTOPLUG
gst_autoplugfactory_get_type ();
#endif
......
......@@ -335,11 +335,11 @@ gst_autoplugfactory_create (GstAutoplugFactory *factory)
g_return_val_if_fail (factory != NULL, NULL);
gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory));
if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) {
g_return_val_if_fail (factory->type != 0, NULL);
g_return_val_if_fail (factory->type != 0, NULL);
new = GST_AUTOPLUG (g_object_new(factory->type,NULL));
new = GST_AUTOPLUG (g_object_new(factory->type,NULL));
}
return new;
}
......
......@@ -36,6 +36,7 @@ GstElementDetails gst_bin_details = {
"(C) 1999",
};
GType _gst_bin_type = 0;
static void gst_bin_dispose (GObject *object);
......@@ -74,9 +75,7 @@ static guint gst_bin_signals[LAST_SIGNAL] = { 0 };
GType
gst_bin_get_type (void)
{
static GType bin_type = 0;
if (!bin_type) {
if (!_gst_bin_type) {
static const GTypeInfo bin_info = {
sizeof(GstBinClass),
NULL,
......@@ -89,9 +88,9 @@ gst_bin_get_type (void)
(GInstanceInitFunc)gst_bin_init,
NULL
};
bin_type = g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0);
_gst_bin_type = g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0);
}
return bin_type;
return _gst_bin_type;
}
static void
......
......@@ -32,17 +32,22 @@ extern "C" {
#endif /* __cplusplus */
extern GstElementDetails gst_bin_details;
#define GST_TYPE_BIN \
(gst_bin_get_type())
#define GST_BIN(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BIN,GstBin))
#define GST_BIN_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BIN,GstBinClass))
#define GST_IS_BIN(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BIN))
#define GST_IS_BIN_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BIN))
extern GType _gst_bin_type;
#define GST_TYPE_BIN (_gst_bin_type)
# define GST_IS_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BIN))
# define GST_IS_BIN_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BIN))
#define GST_BIN_FAST(obj) ((GstBin*)(obj))
#define GST_BIN_CLASS_FAST(klass) ((GstBinClass*)(klass))
#ifdef GST_TYPE_PARANOID
# define GST_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BIN, GstBin))
# define GST_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BIN, GstBinClass))
#else
# define GST_BIN GST_BIN_FAST
# define GST_BIN_CLASS GST_BIN_CLASS_FAST
#endif
typedef enum {
/* this bin is a manager of child elements, i.e. a pipeline or thread */
......
......@@ -102,8 +102,10 @@ gst_buffer_new (void)
/**
* gst_buffer_new_from_pool:
* @pool: the buffer pool to use
* @offset: the offset of the new buffer
* @size: the size of the new buffer
*
* Create a new buffer using the specified bufferpool.
* Create a new buffer using the specified bufferpool, offset and size.
*
* Returns: new buffer
*/
......@@ -314,6 +316,30 @@ gst_buffer_ref (GstBuffer *buffer)
#endif
}
/**
* gst_buffer_ref_by_count:
* @buffer: the GstBuffer to reference
* @count: a number
*
* Increment the refcount of this buffer by the given number.
*/
void
gst_buffer_ref_by_count (GstBuffer *buffer, gint count)
{
g_return_if_fail (buffer != NULL);
g_return_if_fail (count > 0);
#ifdef HAVE_ATOMIC_H
g_return_if_fail (atomic_read (&(buffer->refcount)) > 0);
atomic_add (count, &(buffer->refcount));
#else
g_return_if_fail (buffer->refcount > 0);
GST_BUFFER_LOCK (buffer);
buffer->refcount += count;
GST_BUFFER_UNLOCK (buffer);
#endif
}
/**
* gst_buffer_unref:
* @buffer: the GstBuffer to unref
......@@ -388,8 +414,8 @@ gst_buffer_copy (GstBuffer *buffer)
return newbuf;
}
/*
* gst_buffer_is_span_fast
/**
* gst_buffer_is_span_fast:
* @buf1: first source buffer
* @buf2: second source buffer
*
......@@ -439,7 +465,7 @@ gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len)
// make sure buf1 has a lower address than buf2
if (buf1->data > buf2->data) {
GstBuffer *tmp = buf1;
g_print ("swapping buffers\n");
//g_print ("swapping buffers\n");
buf1 = buf2;
buf2 = tmp;
}
......@@ -450,7 +476,7 @@ gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len)
newbuf = gst_buffer_create_sub (buf1->parent, buf1->data - (buf1->parent->data) + offset, len);
}
else {
g_print ("slow path taken in buffer_span\n");
//g_print ("slow path taken in buffer_span\n");
// otherwise we simply have to brute-force copy the buffers
newbuf = gst_buffer_new ();
......
......@@ -36,7 +36,6 @@
//
#include <gst/gstdata.h>
#include <gst/gstobject.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
......@@ -137,8 +136,8 @@ struct _GstBuffer {
gpointer pool_private;
/* utility function pointers */
GstBufferFreeFunc free; // free the data associated with the buffer
GstBufferCopyFunc copy; // copy the data from one buffer to another
GstBufferFreeFunc free; /* free the data associated with the buffer */
GstBufferCopyFunc copy; /* copy the data from one buffer to another */
};
/* initialisation */
......@@ -152,6 +151,7 @@ GstBuffer* gst_buffer_create_sub (GstBuffer *parent, guint32 offset, guint32 si
/* refcounting */
void gst_buffer_ref (GstBuffer *buffer);
void gst_buffer_ref_by_count (GstBuffer *buffer, gint count);
void gst_buffer_unref (GstBuffer *buffer);
/* destroying the buffer */
......@@ -163,7 +163,7 @@ GstBuffer* gst_buffer_copy (GstBuffer *buffer);
/* merge, span, or append two buffers, intelligently */
GstBuffer* gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2);
GstBuffer* gst_buffer_span (GstBuffer *buf1,guint32 offset,GstBuffer *buf2,guint32 len);
GstBuffer* gst_buffer_append (GstBuffer *buf, GstBuffer *buf2);
GstBuffer* gst_buffer_append (GstBuffer *buffer, GstBuffer *append);
gboolean gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2);
......
......@@ -191,7 +191,7 @@ gst_buffer_pool_set_buffer_free_function (GstBufferPool *pool,
/**
* gst_buffer_pool_set_buffer_copy_function:
* @pool: the pool to set the buffer copy function for
* @destroy: the copy function
* @copy: the copy function
*
* Sets the function that will be called when a buffer is copied.
*
......@@ -207,7 +207,7 @@ gst_buffer_pool_set_buffer_copy_function (GstBufferPool *pool,
}
/**
* gst_buffer_pool_set_pool_destroy_hook:
* gst_buffer_pool_set_destroy_hook:
* @pool: the pool to set the destroy hook for
* @destroy: the destroy function
*
......@@ -243,14 +243,13 @@ gst_buffer_pool_set_user_data (GstBufferPool *pool,
/**
* gst_buffer_pool_get_user_data:
* @pool: the pool to get the user data from
* @user_data: any user data to be passed to the create/destroy buffer functions
* and the destroy hook
*
* gets user data
*
* Returns: The user data of this bufferpool
*/
gpointer
gst_buffer_pool_get_user_data (GstBufferPool *pool,
gpointer user_data)
gst_buffer_pool_get_user_data (GstBufferPool *pool)
{
g_return_val_if_fail (pool != NULL, NULL);
......
......@@ -70,7 +70,7 @@ GstBufferPool* gst_buffer_pool_new (void);
/* refcounting */
void gst_buffer_pool_ref (GstBufferPool *pool);
void gst_buffer_pool_ref_by_count (GstBufferPool *pool, int count);
void gst_buffer_pool_unref (GstBufferPool *buffer);
void gst_buffer_pool_unref (GstBufferPool *pool);
/* setting create and destroy functions */
void gst_buffer_pool_set_buffer_new_function (GstBufferPool *pool,
......@@ -83,8 +83,7 @@ void gst_buffer_pool_set_destroy_hook (GstBufferPool *pool,
GstBufferPoolDestroyHook destroy);
void gst_buffer_pool_set_user_data (GstBufferPool *pool,
gpointer user_data);
gpointer gst_buffer_pool_get_user_data (GstBufferPool *pool,
gpointer user_data);
gpointer gst_buffer_pool_get_user_data (GstBufferPool *pool);
/* destroying the buffer pool */
void gst_buffer_pool_destroy (GstBufferPool *pool);
......
......@@ -57,6 +57,13 @@ gst_clock_new (gchar *name)
return clock;
}
/**
* gst_clock_get_system:
*
* Get the global system clock
*
* Returns: the global clock
*/
GstClock*
gst_clock_get_system(void)
{
......@@ -67,6 +74,14 @@ gst_clock_get_system(void)
return the_system_clock;
}
/**
* gst_clock_register:
* @clock: the name of the clock to register to
* @obj: the object registering to the clock
*
* State that an object is interested in listening to the
* given clock
*/
void
gst_clock_register (GstClock *clock, GstObject *obj)
{
......@@ -77,6 +92,13 @@ gst_clock_register (GstClock *clock, GstObject *obj)
}
}
/**
* gst_clock_set:
* @clock: The clock to set
* @time: the time to set
*
* Set the time of the given clock to time.
*/
void
gst_clock_set (GstClock *clock, GstClockTime time)
{
......@@ -92,6 +114,16 @@ gst_clock_set (GstClock *clock, GstClockTime time)
time, now, clock->start_time);
}
/**
* gst_clock_current_diff:
* @clock: the clock to calculate the diff against
* @time: the time
*
* Calculate the difference between the given clock and the
* given time
*
* Returns: the clock difference
*/
GstClockTimeDiff
gst_clock_current_diff (GstClock *clock, GstClockTime time)
{
......@@ -106,6 +138,13 @@ gst_clock_current_diff (GstClock *clock, GstClockTime time)
return GST_CLOCK_DIFF (time, now);
}
/**
* gst_clock_reset:
* @clock: the clock to reset
*
* Reset the given clock. The of the clock will be adjusted back
* to 0.
*/
void
gst_clock_reset (GstClock *clock)
{
......@@ -120,6 +159,14 @@ gst_clock_reset (GstClock *clock)
g_mutex_unlock (clock->lock);
}
/**
* gst_clock_wait:
* @clock: the clock to wait on
* @time: the time to wait for
* @obj: the object performing the wait
*
* Wait for a specific clock tick on the given clock.
*/
void
gst_clock_wait (GstClock *clock, GstClockTime time, GstObject *obj)
{
......
......@@ -794,12 +794,20 @@ gst_element_error (GstElement *element, const gchar *error)
}
/**
* gst_element_get_state:
* @element: element to get state of
*
* Gets the state of the element.
*
* Returns: The element state
*/
GstElementState
gst_element_get_state (GstElement *elem)
gst_element_get_state (GstElement *element)
{
g_return_val_if_fail (GST_IS_ELEMENT (elem), GST_STATE_VOID_PENDING);
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_VOID_PENDING);
return GST_STATE (elem);
return GST_STATE (element);
}
/**
......@@ -969,23 +977,6 @@ gst_element_dispose (GObject *object)
G_OBJECT_CLASS (parent_class)->dispose (object);
}
/*
static gchar *_gst_element_type_names[] = {
"invalid",
"none",
"char",
"uchar",
"bool",
"int",
"uint",
"long",
"ulong",
"float",
"double",
"string",
};
*/
#ifndef GST_DISABLE_LOADSAVE
/**
* gst_element_save_thyself:
......@@ -1260,7 +1251,17 @@ gst_element_signal_eos (GstElement *element)
}
const gchar *gst_element_statename(GstElementState state) {
/**
* gst_element_statename:
* @state: The state to get the name of
*
* Gets a string representing the given state.
*
* Returns: a string with the statename.
*/
const gchar*
gst_element_statename (GstElementState state)
{
switch (state) {
#ifdef GST_DEBUG_COLOR
case GST_STATE_VOID_PENDING: return "NONE_PENDING";break;
......
......@@ -177,7 +177,7 @@ struct _GstElementClass {
GstPad* (*request_new_pad) (GstElement *element, GstPadTemplate *templ, const gchar* name);
};
void gst_element_class_add_padtemplate (GstElementClass *element, GstPadTemplate *templ);
void gst_element_class_add_padtemplate (GstElementClass *klass, GstPadTemplate *templ);
GType gst_element_get_type (void);
#define gst_element_destroy(element) gst_object_destroy (GST_OBJECT (element))
......@@ -214,7 +214,7 @@ void gst_element_disconnect (GstElement *src, const gchar *srcpadname,
void gst_element_signal_eos (GstElement *element);
GstElementState gst_element_get_state (GstElement *elem);
GstElementState gst_element_get_state (GstElement *element);
/* called by the app to set the state of the element */
gint gst_element_set_state (GstElement *element, GstElementState state);
const gchar * gst_element_statename (GstElementState state);
......
......@@ -229,17 +229,17 @@ gst_elementfactory_create (GstElementFactory *factory,
GST_DEBUG (GST_CAT_ELEMENTFACTORY,"creating element from factory \"%s\" with name \"%s\" and type %d\n",
GST_OBJECT_NAME (factory), name, factory->type);
gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory));
if (!gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory)))
return NULL;
if (factory->type == 0)
{
if (factory->type == 0) {
/* FIXME: g_critical is glib-2.0, not glib-1.2
g_critical ("Factory for `%s' has no type",
*/
g_warning ("Factory for `%s' has no type",
gst_object_get_name (GST_OBJECT (factory)));
return NULL;
}
}
// create an instance of the element
element = GST_ELEMENT(g_object_new(factory->type,NULL));
......
......@@ -50,13 +50,20 @@ _gst_event_initialize (void)
_gst_event_chunk = g_mem_chunk_new ("GstEvent", eventsize,
eventsize * 32, G_ALLOC_AND_FREE);
_gst_event_chunk_lock = g_mutex_new ();
// register the type
_gst_event_type = g_type_register_static (G_TYPE_INT, "GstEvent", &event_info, 0);
}
/**
* gst_event_new:
* @type: The type of the new event
*
* Allocate a new event of the given type.
*
* Returns: A new event.
*/
GstEvent*
gst_event_new (GstEventType type)
{
......@@ -73,6 +80,12 @@ gst_event_new (GstEventType type)
return event;
}
/**
* gst_event_free:
* @event: The event to free
*
* Free the given element.
*/
void
gst_event_free (GstEvent* event)
{
...