#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include "gstspideridentity.h"
#include "gstspider.h"
static void
gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident)
{
- GstBuffer *buf=NULL;
+ GstBuffer *buf = NULL;
GstBuffer *typefindbuf = NULL;
gboolean getmorebuf = TRUE;
GList *type_list;
GstCaps *caps;
/* this should possibly be a property */
- guint bufsizelimit = 4096;
+ guint bufsizelimit = 40960;
g_return_if_fail (GST_IS_SPIDER_IDENTITY (ident));
buf = gst_pad_pull (ident->sink);
/* if it's an event... */
- while (GST_IS_EVENT (buf)) {
+ if (GST_IS_EVENT (buf)) {
switch (GST_EVENT_TYPE (GST_EVENT (buf))){
case GST_EVENT_EOS:
getmorebuf = FALSE;
break;
default:
gst_pad_event_default (ident->sink, GST_EVENT (buf));
- buf = gst_pad_pull (ident->sink);
+ buf = gst_pad_pull (ident->sink);
break;
}
/* handle DISCONT events, please */
}
- typefindbuf = buf;
- getmorebuf = FALSE;
- /* FIXME merging doesn't work for some reason so
- * we'll just typefind with the first element
if (!typefindbuf){
typefindbuf = buf;
- gst_buffer_ref(buf);
- }
- else {
+ } else {
GstBuffer *oldbuf = typefindbuf;
typefindbuf = gst_buffer_merge(typefindbuf, buf);
gst_buffer_unref(oldbuf);
gst_buffer_unref(buf);
}
- */
}
if (!typefindbuf){
- goto end;
+ return;
+ } else {
+ buf = typefindbuf;
}
/* maybe there are already valid caps now? */
}
type_list = g_list_next (type_list);
}
- gst_element_error(GST_ELEMENT(ident), "Could not find media type", NULL);
+ gst_element_error(GST_ELEMENT(ident), GST_ERROR_INVALID_DATA,
+ g_strdup (_("Could not find data type")),
+ g_strdup_printf ("spider element %s couldn't typefind the data stream",
+ GST_ELEMENT_NAME (ident)));
gst_buffer_unref(buf);
buf = GST_BUFFER (gst_event_new (GST_EVENT_EOS));
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include "gstfakesink.h"
return GST_STATE_SUCCESS;
error:
- gst_element_error (element, "failed state change as requested");
+ gst_element_gerror (element, GST_ERROR_NO_ERROR,
+ g_strdup (_("user selected error")),
+ g_strdup ("failed state change as requested"));
return GST_STATE_FAILURE;
}
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include <gst/gst.h>
#include <errno.h>
sink->file = fopen (sink->filename, "w");
if (sink->file == NULL) {
- gst_element_error (GST_ELEMENT (sink),
- "Error opening file %s: %s",
- sink->filename, g_strerror(errno));
+ gst_element_gerror (GST_ELEMENT (sink), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), sink->filename),
+ g_strdup_printf ("Error opening file \"%s\": %s", sink->filename, g_strerror(errno)));
return FALSE;
}
if (fclose (sink->file) != 0)
{
- gst_element_error (GST_ELEMENT (sink),
- "Error closing file %s: %s",
- sink->filename, g_strerror(errno));
+ gst_element_gerror (GST_ELEMENT (sink), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), sink->filename),
+ g_strdup_printf ("Error closing file \"%s\": %s", sink->filename, g_strerror(errno)));
}
else {
GST_FLAG_UNSET (sink, GST_FILESINK_OPEN);
if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH)
if (fflush (filesink->file))
- gst_element_error (GST_ELEMENT (filesink),
- "Error flushing file %s: %s",
- filesink->filename, g_strerror(errno));
+ gst_element_gerror (GST_ELEMENT (filesink), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not write to file \"%s\""), filesink->filename),
+ g_strdup_printf ("Error flushing file \"%s\": %s",
+ filesink->filename, g_strerror(errno)));
switch (GST_EVENT_SEEK_METHOD(event))
{
}
case GST_EVENT_FLUSH:
if (fflush (filesink->file)) {
- gst_element_error (GST_ELEMENT (filesink),
- "Error flushing file %s: %s",
- filesink->filename, g_strerror(errno));
+ gst_element_gerror (GST_ELEMENT (filesink), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not write to file \"%s\""), filesink->filename),
+ g_strdup_printf ("Error flushing file \"%s\": %s",
+ filesink->filename, g_strerror(errno)));
}
break;
case GST_EVENT_EOS:
GST_BUFFER_SIZE (buf) - bytes_written,
filesink->file);
if (wrote <= 0) {
- gst_element_error (GST_ELEMENT (filesink),
- "Only %d of %d bytes written: %s",
- bytes_written, GST_BUFFER_SIZE (buf),
- strerror (errno));
+ gst_element_gerror (GST_ELEMENT (filesink), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not write to file \"%s\""), filesink->filename),
+ g_strdup_printf ("Only %d of %d bytes written: %s", bytes_written,
+ GST_BUFFER_SIZE (buf), strerror (errno)));
break;
}
bytes_written += wrote;
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include <gst/gst.h>
#include "gstfilesrc.h"
mmapregion = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset);
if (mmapregion == NULL) {
- gst_element_error (GST_ELEMENT (src), "couldn't map file");
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("could not open file %s"), src->filename),
+ g_strdup_printf ("couldn't map file %s", src->filename));
return NULL;
}
else if (mmapregion == MAP_FAILED) {
g_return_val_if_fail (buf != NULL, NULL);
ret = read (src->fd, GST_BUFFER_DATA (buf), readsize);
+ GST_BUFFER_SIZE (buf) = ret;
if (ret < 0){
- gst_element_error (GST_ELEMENT (src), "reading file (%s)",
- strerror (errno), NULL);
- return NULL;
- }
- if (ret < readsize) {
- gst_element_error (GST_ELEMENT (src), "unexpected end of file", NULL);
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not read file \"%s\""), src->filename),
+ g_strdup_printf ("Error during file reading: %s", strerror (errno)));
return NULL;
}
/* open the file */
src->fd = open (src->filename, O_RDONLY);
if (src->fd < 0) {
- gst_element_error (GST_ELEMENT (src), "opening file \"%s\" (%s)",
- src->filename, strerror (errno), NULL);
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->filename),
+ g_strdup_printf ("Error opening file \"%s\": %s", src->filename, strerror (errno)));
return FALSE;
} else {
/* check if it is a regular file, otherwise bail out */
fstat(src->fd, &stat_results);
if (!S_ISREG(stat_results.st_mode)) {
- gst_element_error (GST_ELEMENT (src), "opening file \"%s\" failed. it isn't a regular file",
- src->filename, NULL);
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->filename),
+ g_strdup_printf ("opening file \"%s\" failed. it isn't a regular file",
+ src->filename));
close(src->fd);
return FALSE;
}
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include "gstidentity.h"
identity->error_after--;
if (identity->error_after == 0) {
gst_buffer_unref (buf);
- gst_element_error (GST_ELEMENT (identity), "errored after iterations as requested");
+ gst_element_error (GST_ELEMENT (identity), GST_ERROR_NO_ERROR,
+ g_strdup (_("user selected error")),
+ g_strdup ("errored after iterations as requested"));
return;
}
}
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <errno.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include "gstmultidisksrc.h"
if (src->fd < 0) {
perror ("open");
- gst_element_error (GST_ELEMENT (src), g_strconcat("opening file \"", src->currentfilename, "\"", NULL));
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->currentfilename),
+ g_strdup_printf ("error opening file \"%s\": %s", src->currentfilename, strerror (errno)));
return FALSE;
} else {
/* find the file length */
lseek (src->fd, 0, SEEK_SET);
/* map the file into memory */
src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0);
- madvise (src->map,src->size, 2);
/* collapse state if that failed */
if (src->map == NULL) {
close (src->fd);
- gst_element_error (GST_ELEMENT (src),"mmapping file");
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->currentfilename),
+ g_strdup_printf ("error mmapping file \"%s\": %s",
+ src->currentfilename, strerror (errno)));
return FALSE;
}
+ madvise (src->map, src->size, 2);
GST_FLAG_SET (src, GST_MULTIDISKSRC_OPEN);
src->new_seek = TRUE;
}
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <errno.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include "gstmultidisksrc.h"
if (src->fd < 0) {
perror ("open");
- gst_element_error (GST_ELEMENT (src), g_strconcat("opening file \"", src->currentfilename, "\"", NULL));
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->currentfilename),
+ g_strdup_printf ("error opening file \"%s\": %s", src->currentfilename, strerror (errno)));
return FALSE;
} else {
/* find the file length */
lseek (src->fd, 0, SEEK_SET);
/* map the file into memory */
src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0);
- madvise (src->map,src->size, 2);
/* collapse state if that failed */
if (src->map == NULL) {
close (src->fd);
- gst_element_error (GST_ELEMENT (src),"mmapping file");
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->currentfilename),
+ g_strdup_printf ("error mmapping file \"%s\": %s",
+ src->currentfilename, strerror (errno)));
return FALSE;
}
+ madvise (src->map, src->size, 2);
GST_FLAG_SET (src, GST_MULTIDISKSRC_OPEN);
src->new_seek = TRUE;
}
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include "gstpipefilter.h"
GST_DEBUG ("pipefilter: %s received event", GST_ELEMENT_NAME (pipefilter));
if (close (pipefilter->fdin[1]) < 0)
- perror("close");
+ GST_DEBUG ("close");
if (close (pipefilter->fdout[0]) < 0)
- perror("close");
+ GST_DEBUG ("close");
return TRUE;
}
readbytes = read(pipefilter->fdout[0], GST_BUFFER_DATA(newbuf), pipefilter->bytes_per_read);
GST_DEBUG ("read %ld bytes", readbytes);
if (readbytes < 0) {
- perror("read");
- gst_element_error(GST_ELEMENT(pipefilter),"reading");
+ gst_element_gerror (GST_ELEMENT(pipefilter), GST_ERROR_DEVICE,
+ g_strdup (_("Could not process data")),
+ g_strdup_printf ("Error reading from pipe: %s", strerror (errno)));
return NULL;
}
/* if we didn't get as many bytes as we asked for, we're at EOF */
writebytes = write(pipefilter->fdin[1],data,size);
GST_DEBUG ("written %ld bytes", writebytes);
if (writebytes < 0) {
- perror("write");
- gst_element_error(GST_ELEMENT(pipefilter),"writing");
+ gst_element_gerror (GST_ELEMENT(pipefilter), GST_ERROR_DEVICE, g_strdup (""), g_strdup ("writing"));
return;
}
gst_buffer_unref(buf);
if((src->childpid = fork()) == -1)
{
- perror("fork");
- gst_element_error(GST_ELEMENT(src),"forking");
+ gst_element_gerror (GST_ELEMENT(src), GST_ERROR_UNKNOWN, g_strdup (""), g_strdup ("forking"));
return FALSE;
}
dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
execvp(src->command[0], &src->command[0]);
/* will only reach if error */
- perror("exec");
- gst_element_error(GST_ELEMENT(src),"starting child process");
+ gst_element_gerror (GST_ELEMENT(src), GST_ERROR_UNKNOWN, g_strdup (""), g_strdup ("starting child process"));
return FALSE;
}
static void gst_element_dispose (GObject *object);
static GstElementStateReturn gst_element_change_state (GstElement *element);
-static void gst_element_error_func (GstElement* element, GstElement *source, gchar *errormsg);
+static void gst_element_error_func (GstElement* element, GstElement *source, GError *error, gchar *errormsg);
#ifndef GST_DISABLE_LOADSAVE
static xmlNodePtr gst_element_save_thyself (GstObject *object, xmlNodePtr parent);
static GstObjectClass *parent_class = NULL;
static guint gst_element_signals[LAST_SIGNAL] = { 0 };
+static GQuark gst_element_error_quark;
GType gst_element_get_type (void)
{
gst_element_signals[ERROR] =
g_signal_new ("error", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstElementClass, error), NULL, NULL,
- gst_marshal_VOID__OBJECT_STRING, G_TYPE_NONE, 2,
- G_TYPE_OBJECT, G_TYPE_STRING);
+ gst_marshal_VOID__OBJECT_POINTER_STRING, G_TYPE_NONE, 3,
+ G_TYPE_OBJECT, G_TYPE_POINTER, G_TYPE_STRING);
gst_element_signals[EOS] =
g_signal_new ("eos", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstElementClass,eos), NULL, NULL,
klass->elementfactory = NULL;
klass->padtemplates = NULL;
klass->numpadtemplates = 0;
+
+ gst_element_error_quark = g_quark_from_static_string ("GstError");
}
static void
static void
gst_element_error_func (GstElement* element, GstElement *source,
- gchar *errormsg)
+ GError *error, gchar *errormsg)
{
/* tell the parent */
if (GST_OBJECT_PARENT (element)) {
- GST_CAT_DEBUG (GST_CAT_EVENT, "forwarding error \"%s\" from %s to %s",
+ GST_CAT_LOG (GST_CAT_EVENT, "forwarding error \"%s\" from %s to %s",
errormsg, GST_ELEMENT_NAME (element),
GST_OBJECT_NAME (GST_OBJECT_PARENT (element)));
gst_object_ref (GST_OBJECT (element));
g_signal_emit (G_OBJECT (GST_OBJECT_PARENT (element)),
- gst_element_signals[ERROR], 0, source, errormsg);
+ gst_element_signals[ERROR], 0, source, error, errormsg);
gst_object_unref (GST_OBJECT (element));
}
}
* It results in the "error" signal.
*/
void
-gst_element_error (GstElement *element, const gchar *error, ...)
+gst_element_error_detailed (GstElement *element, const gchar *file, const gchar *function,
+ gint line, GstErrorType type,
+ const gchar *error_message, const gchar *detailed)
{
- va_list var_args;
- gchar *string;
+ gchar *really_detailed;
+ GError *error;
/* checks */
g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (error != NULL);
- /* create error message */
- va_start (var_args, error);
- string = g_strdup_vprintf (error, var_args);
- va_end (var_args);
- GST_CAT_INFO (GST_CAT_EVENT, "ERROR in %s: %s", GST_ELEMENT_NAME (element), string);
-
/* if the element was already in error, stop now */
if (GST_FLAG_IS_SET (element, GST_ELEMENT_ERROR)) {
- GST_CAT_INFO (GST_CAT_EVENT, "recursive ERROR detected in %s", GST_ELEMENT_NAME (element));
- g_free (string);
+ GST_CAT_INFO_OBJECT (GST_CAT_EVENT, element, "recursive ERROR detected, skipping");
return;
}
-
GST_FLAG_SET (element, GST_ELEMENT_ERROR);
+
+ /* create detailed error message */
+ if (!function || function[0] == '\0') {
+ really_detailed = g_strdup_printf ("Error in line %d in file %s: %s", line, file, detailed);
+ } else {
+ really_detailed = g_strdup_printf ("Error in line %d in file %s: %s", line, file, detailed);
+ }
+ /* create the GError */
+ error = g_error_new_literal (gst_element_error_quark, type, error_message);
/* emit the signal, make sure the element stays available */
gst_object_ref (GST_OBJECT (element));
- g_signal_emit (G_OBJECT (element), gst_element_signals[ERROR], 0, element, string);
+ g_signal_emit (G_OBJECT (element), gst_element_signals[ERROR], 0, element, error, really_detailed);
/* tell the scheduler */
if (element->sched) {
/* cleanup */
gst_object_unref (GST_OBJECT (element));
- g_free (string);
+ g_free (really_detailed);
}
/**
void (*state_change) (GstElement *element, GstElementState old, GstElementState state);
void (*new_pad) (GstElement *element, GstPad *pad);
void (*pad_removed) (GstElement *element, GstPad *pad);
- void (*error) (GstElement *element, GstElement *source, gchar *error);
+ void (*error) (GstElement *element, GstElement *source, GError *error, gchar *detailed_description);
void (*eos) (GstElement *element);
/* local pointers for get/set */
void gst_element_set_eos (GstElement *element);
-void gst_element_error (GstElement *element, const gchar *error, ...);
+#define gst_element_error(element,type,translated,detailed) G_STMT_START{\
+ gchar *translated_str = translated; \
+ gchar *detailed_str = detailed; \
+ GST_ERROR_OBJECT (element, detailed_str); \
+ gst_element_error_detailed (element, __FILE__, GST_FUNCTION, __LINE__, type, translated_str, detailed_str); \
+ g_free (translated_str); \
+ g_free (detailed_str); \
+}G_STMT_END
+/* FIXME: remove the next define before releasing 0.8 */
+#if GST_VERSION_MINOR < 8
+#define gst_element_gerror gst_element_error
+#else
+#define gst_element_gerror(element,type,translated,detailed) G_STMT_START{\
+ g_warning ("gst_element_gerror should be replaced by gst_element_error"); \
+ gst_element_error (element,type,translated,detailed); \
+}G_STMT_END
+#endif
+
+void gst_element_error_detailed (GstElement *element,
+ const gchar *file,
+ const gchar *function,
+ gint line,
+ GstErrorType type,
+ const gchar *error_message,
+ const gchar *detailed_error);
gboolean gst_element_is_locked_state (GstElement *element);
void gst_element_set_locked_state (GstElement *element, gboolean locked_state);
VOID:OBJECT
VOID:OBJECT,PARAM
VOID:OBJECT,POINTER
+VOID:OBJECT,POINTER,STRING
VOID:OBJECT,STRING
VOID:INT,INT
VOID:INT64
g_return_if_fail ((GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC) &&
(GST_RPAD_DIRECTION (realsink) == GST_PAD_SINK));
- if (GST_RPAD_UNLINKFUNC (srcpad)) {
- GST_RPAD_UNLINKFUNC (srcpad) (srcpad);
+ if (GST_RPAD_UNLINKFUNC (realsrc)) {
+ GST_RPAD_UNLINKFUNC (realsrc) (GST_PAD_CAST (realsrc));
}
- if (GST_RPAD_UNLINKFUNC (sinkpad)) {
- GST_RPAD_UNLINKFUNC (sinkpad) (sinkpad);
+ if (GST_RPAD_UNLINKFUNC (realsink)) {
+ GST_RPAD_UNLINKFUNC (realsink) (GST_PAD_CAST (realsink));
}
/* get the schedulers before we unlink */
/* report error */
parent = gst_pad_get_parent (pad);
- gst_element_error (parent, "negotiation failed on pad %s:%s",
- GST_DEBUG_PAD_NAME (pad));
+ gst_element_gerror (parent, GST_ERROR_CAPS_NEGOTIATION, g_strdup (_("Cannot decode the given data type")),
+ g_strdup_printf ("negotiation failed on pad %s:%s", GST_DEBUG_PAD_NAME (pad)));
return FALSE;
}
peer = GST_RPAD_PEER (pad);
if (!peer) {
- gst_element_error (GST_PAD_PARENT (pad),
- "pull on pad %s:%s but it was unlinked",
- GST_ELEMENT_NAME (GST_PAD_PARENT (pad)),
- GST_PAD_NAME (pad), NULL);
+ gst_element_gerror (GST_PAD_PARENT (pad), GST_ERROR_PIPELINE,
+ g_strdup (_("application error: GStreamer was used wrong")),
+ g_strdup_printf ("pull on pad %s:%s but it was unlinked", GST_DEBUG_PAD_NAME (pad)));
}
else {
restart:
}
/* no null buffers allowed */
- gst_element_error (GST_PAD_PARENT (pad),
- "NULL buffer during pull on %s:%s",
- GST_DEBUG_PAD_NAME (pad));
+ gst_element_gerror (GST_PAD_PARENT (pad), GST_ERROR_PIPELINE,
+ g_strdup (_("application error: GStreamer was used wrong")),
+ g_strdup_printf ("NULL buffer during pull on %s:%s", GST_DEBUG_PAD_NAME (pad)));
} else {
- gst_element_error (GST_PAD_PARENT (pad),
- "internal error: pull on pad %s:%s "
+ gst_element_gerror (GST_PAD_PARENT (pad), GST_ERROR_PIPELINE,
+ g_strdup (_("application error: GStreamer was used wrong")),
+ g_strdup_printf ("internal error: pull on pad %s:%s "
"but the peer pad %s:%s has no gethandler",
- GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer));
+ GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer)));
}
}
return GST_BUFFER (gst_event_new (GST_EVENT_INTERRUPT));
#define GST_PAD_PAD_TEMPLATE(pad) (((GstPad *)(pad))->padtemplate)
/* GstRealPad */
-#define GST_RPAD_DIRECTION(pad) (((GstRealPad *)(pad))->direction)
-#define GST_RPAD_CAPS(pad) (((GstRealPad *)(pad))->caps)
-#define GST_RPAD_FILTER(pad) (((GstRealPad *)(pad))->filter)
-#define GST_RPAD_APPFILTER(pad) (((GstRealPad *)(pad))->appfilter)
-#define GST_RPAD_PEER(pad) (((GstRealPad *)(pad))->peer)
-#define GST_RPAD_CHAINFUNC(pad) (((GstRealPad *)(pad))->chainfunc)
-#define GST_RPAD_CHAINHANDLER(pad) (((GstRealPad *)(pad))->chainhandler)
-#define GST_RPAD_GETFUNC(pad) (((GstRealPad *)(pad))->getfunc)
-#define GST_RPAD_GETHANDLER(pad) (((GstRealPad *)(pad))->gethandler)
-#define GST_RPAD_EVENTFUNC(pad) (((GstRealPad *)(pad))->eventfunc)
-#define GST_RPAD_EVENTHANDLER(pad) (((GstRealPad *)(pad))->eventhandler)
-#define GST_RPAD_CONVERTFUNC(pad) (((GstRealPad *)(pad))->convertfunc)
-#define GST_RPAD_QUERYFUNC(pad) (((GstRealPad *)(pad))->queryfunc)
-#define GST_RPAD_INTLINKFUNC(pad) (((GstRealPad *)(pad))->intlinkfunc)
-#define GST_RPAD_FORMATSFUNC(pad) (((GstRealPad *)(pad))->formatsfunc)
-#define GST_RPAD_QUERYTYPEFUNC(pad) (((GstRealPad *)(pad))->querytypefunc)
-#define GST_RPAD_EVENTMASKFUNC(pad) (((GstRealPad *)(pad))->eventmaskfunc)
-
-#define GST_RPAD_LINKFUNC(pad) (((GstRealPad *)(pad))->linkfunc)
-#define GST_RPAD_UNLINKFUNC(pad) (((GstRealPad *)(pad))->unlinkfunc)
-#define GST_RPAD_GETCAPSFUNC(pad) (((GstRealPad *)(pad))->getcapsfunc)
-#define GST_RPAD_BUFFERPOOLFUNC(pad) (((GstRealPad *)(pad))->bufferpoolfunc)
+#define GST_RPAD_DIRECTION(pad) (GST_REAL_PAD(pad)->direction)
+#define GST_RPAD_CAPS(pad) (GST_REAL_PAD(pad)->caps)
+#define GST_RPAD_FILTER(pad) (GST_REAL_PAD(pad)->filter)
+#define GST_RPAD_APPFILTER(pad) (GST_REAL_PAD(pad)->appfilter)
+#define GST_RPAD_PEER(pad) (GST_REAL_PAD(pad)->peer)
+#define GST_RPAD_CHAINFUNC(pad) (GST_REAL_PAD(pad)->chainfunc)
+#define GST_RPAD_CHAINHANDLER(pad) (GST_REAL_PAD(pad)->chainhandler)
+#define GST_RPAD_GETFUNC(pad) (GST_REAL_PAD(pad)->getfunc)
+#define GST_RPAD_GETHANDLER(pad) (GST_REAL_PAD(pad)->gethandler)
+#define GST_RPAD_EVENTFUNC(pad) (GST_REAL_PAD(pad)->eventfunc)
+#define GST_RPAD_EVENTHANDLER(pad) (GST_REAL_PAD(pad)->eventhandler)
+#define GST_RPAD_CONVERTFUNC(pad) (GST_REAL_PAD(pad)->convertfunc)
+#define GST_RPAD_QUERYFUNC(pad) (GST_REAL_PAD(pad)->queryfunc)
+#define GST_RPAD_INTLINKFUNC(pad) (GST_REAL_PAD(pad)->intlinkfunc)
+#define GST_RPAD_FORMATSFUNC(pad) (GST_REAL_PAD(pad)->formatsfunc)
+#define GST_RPAD_QUERYTYPEFUNC(pad) (GST_REAL_PAD(pad)->querytypefunc)
+#define GST_RPAD_EVENTMASKFUNC(pad) (GST_REAL_PAD(pad)->eventmaskfunc)
+
+#define GST_RPAD_LINKFUNC(pad) (GST_REAL_PAD(pad)->linkfunc)
+#define GST_RPAD_UNLINKFUNC(pad) (GST_REAL_PAD(pad)->unlinkfunc)
+#define GST_RPAD_GETCAPSFUNC(pad) (GST_REAL_PAD(pad)->getcapsfunc)
+#define GST_RPAD_BUFFERPOOLFUNC(pad) (GST_REAL_PAD(pad)->bufferpoolfunc)
/* GstGhostPad */
#define GST_GPAD_REALPAD(pad) (((GstGhostPad *)(pad))->realpad)
/* Generic */
-#define GST_PAD_REALIZE(pad) (GST_IS_REAL_PAD(pad) ? ((GstRealPad *)(pad)) : GST_GPAD_REALPAD(pad))
+#define GST_PAD_REALIZE(pad) (GST_IS_REAL_PAD(pad) ? GST_REAL_PAD(pad) : GST_GPAD_REALPAD(pad))
#define GST_PAD_DIRECTION(pad) GST_RPAD_DIRECTION(GST_PAD_REALIZE(pad))
#define GST_PAD_CAPS(pad) GST_RPAD_CAPS(GST_PAD_REALIZE(pad))
#define GST_PAD_PEER(pad) GST_PAD_CAST(GST_RPAD_PEER(GST_PAD_REALIZE(pad)))
if (!queue->may_deadlock) {
g_mutex_unlock (queue->qlock);
gst_data_unref (GST_DATA (buf));
- gst_element_error (GST_ELEMENT (queue), "deadlock found, source pad elements are shut down");
+ gst_element_error (GST_ELEMENT (queue), GST_ERROR_UNKNOWN,
+ g_strdup (_("Cannot go on decoding")), /* FIXME: Better ideas? */
+ g_strdup ("deadlock found, source pad elements are shut down"));
/* we don't want to goto out_unref here, since we want to clean up before calling gst_element_error */
return;
}
/* this means the other end is shut down */
if (!queue->may_deadlock) {
g_mutex_unlock (queue->qlock);
- gst_element_error (GST_ELEMENT (queue), "deadlock found, sink pad elements are shut down");
+ gst_element_error (GST_ELEMENT (queue), GST_ERROR_UNKNOWN,
+ g_strdup (_("Cannot go on decoding")), /* FIXME: Better ideas? */
+ g_strdup ("deadlock found, sink pad elements are shut down"));
goto restart;
}
else {
gst_buffer_unref (buf);
if (typefind->max_buffers && typefind->num_buffer >= typefind->max_buffers) {
- gst_element_error (GST_ELEMENT (typefind),
- "typefind could not determine type after %d buffers", typefind->num_buffer);
+ gst_element_gerror (GST_ELEMENT (typefind), GST_ERROR_INVALID_DATA,
+ g_strdup (_("The data cannot be identified")),
+ g_strdup_printf ("typefind could not determine type after %d buffers", typefind->num_buffer));
}
}
GST_RESULT_NOT_IMPL
} GstResult;
+typedef enum {
+ /* undefined error */
+ GST_ERROR_UNDEFINED,
+ /* something that does not fit into the other categories */
+ GST_ERROR_UNKNOWN,
+ /* no error (used ie for debugging purposes) */
+ GST_ERROR_NO_ERROR,
+ /* error with device or file */
+ GST_ERROR_DEVICE,
+ /* invalid data inside the stream */
+ GST_ERROR_INVALID_DATA,
+ /* pipeline is not setup correctly */
+ GST_ERROR_PIPELINE,
+ /* no way to do caps negotiation */
+ GST_ERROR_CAPS_NEGOTIATION,
+ /* internal error - used by schedulers */
+ GST_ERROR_INTERNAL
+} GstErrorType;
+
G_END_DECLS
#endif /* __GST_TYPES_H__ */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include <gst/gst.h>
}
if (loop_count == 0) {
- gst_element_error (parent,
- "(internal error) basic: maximum number of switches exceeded");
+ gst_element_gerror (parent, GST_ERROR_INTERNAL,
+ g_strdup (_("Internal error in GStreamer")),
+ g_strdup ("basic scheduler error: maximum number of switches exceeded"));
return;
}
GST_CAT_DEBUG (debug_dataflow, "new pad in mid-switch!");
pad = (GstPad *) GST_RPAD_PEER (peer);
if (!pad) {
- gst_element_error (parent, "pad unlinked");
+ gst_element_gerror (parent, GST_ERROR_PIPELINE,
+ g_strdup (_("application error")),
+ g_strdup_printf ("pad %s:%s is unlinked", GST_DEBUG_PAD_NAME (peer)));
}
parent = GST_PAD_PARENT (pad);
peer = GST_RPAD_PEER (pad);
* either, we have an error */
if (different_sched && !peer_decoupled)
{
- gst_element_error (element,
- "element \"%s\" is not decoupled but has pads "
- "in different schedulers",
- GST_ELEMENT_NAME (element), NULL);
+ gst_element_gerror (element, GST_ERROR_PIPELINE,
+ g_strdup (_("application error")),
+ g_strdup_printf ("element \"%s\" is not decoupled but has pads "
+ "in different schedulers", GST_ELEMENT_NAME (element)));
return FALSE;
}
/* ok, the peer is in a different scheduler and is decoupled,
chain->sched->context,
wrapper_function, 0, (char **) element);
if (GST_ELEMENT_THREADSTATE (element) == NULL) {
- gst_element_error (element, "could not create cothread for \"%s\"",
- GST_ELEMENT_NAME (element), NULL);
+ gst_element_gerror (element, GST_ERROR_INTERNAL,
+ g_strdup (_("internal GStreamer error")),
+ g_strdup_printf ("could not create cothread for \"%s\"", GST_ELEMENT_NAME (element)));
return FALSE;
}
GST_DEBUG ("created cothread %p for '%s'",
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include "gstfakesink.h"
return GST_STATE_SUCCESS;
error:
- gst_element_error (element, "failed state change as requested");
+ gst_element_gerror (element, GST_ERROR_NO_ERROR,
+ g_strdup (_("user selected error")),
+ g_strdup ("failed state change as requested"));
return GST_STATE_FAILURE;
}
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include <gst/gst.h>
#include <errno.h>
sink->file = fopen (sink->filename, "w");
if (sink->file == NULL) {
- gst_element_error (GST_ELEMENT (sink),
- "Error opening file %s: %s",
- sink->filename, g_strerror(errno));
+ gst_element_gerror (GST_ELEMENT (sink), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), sink->filename),
+ g_strdup_printf ("Error opening file \"%s\": %s", sink->filename, g_strerror(errno)));
return FALSE;
}
if (fclose (sink->file) != 0)
{
- gst_element_error (GST_ELEMENT (sink),
- "Error closing file %s: %s",
- sink->filename, g_strerror(errno));
+ gst_element_gerror (GST_ELEMENT (sink), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), sink->filename),
+ g_strdup_printf ("Error closing file \"%s\": %s", sink->filename, g_strerror(errno)));
}
else {
GST_FLAG_UNSET (sink, GST_FILESINK_OPEN);
if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH)
if (fflush (filesink->file))
- gst_element_error (GST_ELEMENT (filesink),
- "Error flushing file %s: %s",
- filesink->filename, g_strerror(errno));
+ gst_element_gerror (GST_ELEMENT (filesink), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not write to file \"%s\""), filesink->filename),
+ g_strdup_printf ("Error flushing file \"%s\": %s",
+ filesink->filename, g_strerror(errno)));
switch (GST_EVENT_SEEK_METHOD(event))
{
}
case GST_EVENT_FLUSH:
if (fflush (filesink->file)) {
- gst_element_error (GST_ELEMENT (filesink),
- "Error flushing file %s: %s",
- filesink->filename, g_strerror(errno));
+ gst_element_gerror (GST_ELEMENT (filesink), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not write to file \"%s\""), filesink->filename),
+ g_strdup_printf ("Error flushing file \"%s\": %s",
+ filesink->filename, g_strerror(errno)));
}
break;
case GST_EVENT_EOS:
GST_BUFFER_SIZE (buf) - bytes_written,
filesink->file);
if (wrote <= 0) {
- gst_element_error (GST_ELEMENT (filesink),
- "Only %d of %d bytes written: %s",
- bytes_written, GST_BUFFER_SIZE (buf),
- strerror (errno));
+ gst_element_gerror (GST_ELEMENT (filesink), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not write to file \"%s\""), filesink->filename),
+ g_strdup_printf ("Only %d of %d bytes written: %s", bytes_written,
+ GST_BUFFER_SIZE (buf), strerror (errno)));
break;
}
bytes_written += wrote;
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include <gst/gst.h>
#include "gstfilesrc.h"
mmapregion = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset);
if (mmapregion == NULL) {
- gst_element_error (GST_ELEMENT (src), "couldn't map file");
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("could not open file %s"), src->filename),
+ g_strdup_printf ("couldn't map file %s", src->filename));
return NULL;
}
else if (mmapregion == MAP_FAILED) {
g_return_val_if_fail (buf != NULL, NULL);
ret = read (src->fd, GST_BUFFER_DATA (buf), readsize);
+ GST_BUFFER_SIZE (buf) = ret;
if (ret < 0){
- gst_element_error (GST_ELEMENT (src), "reading file (%s)",
- strerror (errno), NULL);
- return NULL;
- }
- if (ret < readsize) {
- gst_element_error (GST_ELEMENT (src), "unexpected end of file", NULL);
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not read file \"%s\""), src->filename),
+ g_strdup_printf ("Error during file reading: %s", strerror (errno)));
return NULL;
}
/* open the file */
src->fd = open (src->filename, O_RDONLY);
if (src->fd < 0) {
- gst_element_error (GST_ELEMENT (src), "opening file \"%s\" (%s)",
- src->filename, strerror (errno), NULL);
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->filename),
+ g_strdup_printf ("Error opening file \"%s\": %s", src->filename, strerror (errno)));
return FALSE;
} else {
/* check if it is a regular file, otherwise bail out */
fstat(src->fd, &stat_results);
if (!S_ISREG(stat_results.st_mode)) {
- gst_element_error (GST_ELEMENT (src), "opening file \"%s\" failed. it isn't a regular file",
- src->filename, NULL);
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->filename),
+ g_strdup_printf ("opening file \"%s\" failed. it isn't a regular file",
+ src->filename));
close(src->fd);
return FALSE;
}
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include "gstidentity.h"
identity->error_after--;
if (identity->error_after == 0) {
gst_buffer_unref (buf);
- gst_element_error (GST_ELEMENT (identity), "errored after iterations as requested");
+ gst_element_error (GST_ELEMENT (identity), GST_ERROR_NO_ERROR,
+ g_strdup (_("user selected error")),
+ g_strdup ("errored after iterations as requested"));
return;
}
}
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <errno.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include "gstmultidisksrc.h"
if (src->fd < 0) {
perror ("open");
- gst_element_error (GST_ELEMENT (src), g_strconcat("opening file \"", src->currentfilename, "\"", NULL));
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->currentfilename),
+ g_strdup_printf ("error opening file \"%s\": %s", src->currentfilename, strerror (errno)));
return FALSE;
} else {
/* find the file length */
lseek (src->fd, 0, SEEK_SET);
/* map the file into memory */
src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0);
- madvise (src->map,src->size, 2);
/* collapse state if that failed */
if (src->map == NULL) {
close (src->fd);
- gst_element_error (GST_ELEMENT (src),"mmapping file");
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->currentfilename),
+ g_strdup_printf ("error mmapping file \"%s\": %s",
+ src->currentfilename, strerror (errno)));
return FALSE;
}
+ madvise (src->map, src->size, 2);
GST_FLAG_SET (src, GST_MULTIDISKSRC_OPEN);
src->new_seek = TRUE;
}
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <errno.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include "gstmultidisksrc.h"
if (src->fd < 0) {
perror ("open");
- gst_element_error (GST_ELEMENT (src), g_strconcat("opening file \"", src->currentfilename, "\"", NULL));
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->currentfilename),
+ g_strdup_printf ("error opening file \"%s\": %s", src->currentfilename, strerror (errno)));
return FALSE;
} else {
/* find the file length */
lseek (src->fd, 0, SEEK_SET);
/* map the file into memory */
src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0);
- madvise (src->map,src->size, 2);
/* collapse state if that failed */
if (src->map == NULL) {
close (src->fd);
- gst_element_error (GST_ELEMENT (src),"mmapping file");
+ gst_element_gerror (GST_ELEMENT (src), GST_ERROR_DEVICE,
+ g_strdup_printf (_("Could not open file \"%s\""), src->currentfilename),
+ g_strdup_printf ("error mmapping file \"%s\": %s",
+ src->currentfilename, strerror (errno)));
return FALSE;
}
+ madvise (src->map, src->size, 2);
GST_FLAG_SET (src, GST_MULTIDISKSRC_OPEN);
src->new_seek = TRUE;
}
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "gst/gst_private.h"
#include "gstpipefilter.h"
GST_DEBUG ("pipefilter: %s received event", GST_ELEMENT_NAME (pipefilter));
if (close (pipefilter->fdin[1]) < 0)
- perror("close");
+ GST_DEBUG ("close");
if (close (pipefilter->fdout[0]) < 0)
- perror("close");
+ GST_DEBUG ("close");
return TRUE;
}
readbytes = read(pipefilter->fdout[0], GST_BUFFER_DATA(newbuf), pipefilter->bytes_per_read);
GST_DEBUG ("read %ld bytes", readbytes);
if (readbytes < 0) {
- perror("read");
- gst_element_error(GST_ELEMENT(pipefilter),"reading");
+ gst_element_gerror (GST_ELEMENT(pipefilter), GST_ERROR_DEVICE,
+ g_strdup (_("Could not process data")),
+ g_strdup_printf ("Error reading from pipe: %s", strerror (errno)));
return NULL;
}
/* if we didn't get as many bytes as we asked for, we're at EOF */
writebytes = write(pipefilter->fdin[1],data,size);
GST_DEBUG ("written %ld bytes", writebytes);
if (writebytes < 0) {
- perror("write");
- gst_element_error(GST_ELEMENT(pipefilter),"writing");
+ gst_element_gerror (GST_ELEMENT(pipefilter), GST_ERROR_DEVICE, g_strdup (""), g_strdup ("writing"));
return;
}
gst_buffer_unref(buf);
if((src->childpid = fork()) == -1)
{
- perror("fork");
- gst_element_error(GST_ELEMENT(src),"forking");
+ gst_element_gerror (GST_ELEMENT(src), GST_ERROR_UNKNOWN, g_strdup (""), g_strdup ("forking"));
return FALSE;
}
dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */
execvp(src->command[0], &src->command[0]);
/* will only reach if error */
- perror("exec");
- gst_element_error(GST_ELEMENT(src),"starting child process");
+ gst_element_gerror (GST_ELEMENT(src), GST_ERROR_UNKNOWN, g_strdup (""), g_strdup ("starting child process"));
return FALSE;
}
if (!queue->may_deadlock) {
g_mutex_unlock (queue->qlock);
gst_data_unref (GST_DATA (buf));
- gst_element_error (GST_ELEMENT (queue), "deadlock found, source pad elements are shut down");
+ gst_element_error (GST_ELEMENT (queue), GST_ERROR_UNKNOWN,
+ g_strdup (_("Cannot go on decoding")), /* FIXME: Better ideas? */
+ g_strdup ("deadlock found, source pad elements are shut down"));
/* we don't want to goto out_unref here, since we want to clean up before calling gst_element_error */
return;
}
/* this means the other end is shut down */
if (!queue->may_deadlock) {
g_mutex_unlock (queue->qlock);
- gst_element_error (GST_ELEMENT (queue), "deadlock found, sink pad elements are shut down");
+ gst_element_error (GST_ELEMENT (queue), GST_ERROR_UNKNOWN,
+ g_strdup (_("Cannot go on decoding")), /* FIXME: Better ideas? */
+ g_strdup ("deadlock found, sink pad elements are shut down"));
goto restart;
}
else {