mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
implement translatable error messages using gerror.
Original commit message from CVS: implement translatable error messages using gerror. Includes bugfixes for: - crash when unlinking Ghostpads - make *_PAD_* macros use glib casts - make spider typefinding merge buffers correctly
This commit is contained in:
parent
ce8fe777e6
commit
be1eaa4de3
25 changed files with 294 additions and 179 deletions
|
@ -23,6 +23,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include "gstspideridentity.h"
|
||||
#include "gstspider.h"
|
||||
|
@ -413,14 +414,14 @@ gst_spider_identity_src_loop (GstSpiderIdentity *ident)
|
|||
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));
|
||||
|
||||
|
@ -434,7 +435,7 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *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;
|
||||
|
@ -449,25 +450,20 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident)
|
|||
/* 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? */
|
||||
|
@ -500,7 +496,10 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident)
|
|||
}
|
||||
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));
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include "gstfakesink.h"
|
||||
|
||||
|
@ -406,7 +407,9 @@ gst_fakesink_change_state (GstElement *element)
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <errno.h>
|
||||
|
@ -222,9 +223,9 @@ gst_filesink_open_file (GstFileSink *sink)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -242,9 +243,9 @@ gst_filesink_close_file (GstFileSink *sink)
|
|||
|
||||
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);
|
||||
|
@ -340,9 +341,10 @@ gst_filesink_handle_event (GstPad *pad, GstEvent *event)
|
|||
|
||||
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))
|
||||
{
|
||||
|
@ -372,9 +374,10 @@ gst_filesink_handle_event (GstPad *pad, GstEvent *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:
|
||||
|
@ -423,10 +426,10 @@ gst_filesink_chain (GstPad *pad, GstBuffer *buf)
|
|||
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;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include "gstfilesrc.h"
|
||||
|
@ -398,7 +399,9 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
|
|||
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) {
|
||||
|
@ -635,13 +638,11 @@ gst_filesrc_get_read (GstFileSrc *src)
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -702,8 +703,9 @@ gst_filesrc_open_file (GstFileSrc *src)
|
|||
/* 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 */
|
||||
|
@ -712,8 +714,10 @@ gst_filesrc_open_file (GstFileSrc *src)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include "gstidentity.h"
|
||||
|
||||
|
@ -249,7 +250,9 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf)
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,12 @@
|
|||
#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"
|
||||
|
||||
|
@ -253,7 +255,9 @@ gboolean gst_multidisksrc_open_file (GstMultiDiskSrc *src, GstPad *srcpad)
|
|||
|
||||
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 */
|
||||
|
@ -261,13 +265,16 @@ gboolean gst_multidisksrc_open_file (GstMultiDiskSrc *src, GstPad *srcpad)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -26,10 +26,12 @@
|
|||
#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"
|
||||
|
||||
|
@ -253,7 +255,9 @@ gboolean gst_multidisksrc_open_file (GstMultiDiskSrc *src, GstPad *srcpad)
|
|||
|
||||
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 */
|
||||
|
@ -261,13 +265,16 @@ gboolean gst_multidisksrc_open_file (GstMultiDiskSrc *src, GstPad *srcpad)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include "gstpipefilter.h"
|
||||
|
||||
|
@ -148,9 +149,9 @@ gst_pipefilter_handle_event (GstPad *pad, GstEvent *event)
|
|||
|
||||
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;
|
||||
}
|
||||
|
@ -178,8 +179,9 @@ gst_pipefilter_get (GstPad *pad)
|
|||
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 */
|
||||
|
@ -216,8 +218,7 @@ gst_pipefilter_chain (GstPad *pad,GstBuffer *buf)
|
|||
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);
|
||||
|
@ -272,8 +273,7 @@ gst_pipefilter_open_file (GstPipefilter *src)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -286,8 +286,7 @@ gst_pipefilter_open_file (GstPipefilter *src)
|
|||
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;
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ static void gst_element_real_get_property (GObject *object, guint prop_id, GVa
|
|||
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);
|
||||
|
@ -70,6 +70,7 @@ GType _gst_element_type = 0;
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -121,8 +122,8 @@ gst_element_class_init (GstElementClass *klass)
|
|||
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,
|
||||
|
@ -143,6 +144,8 @@ gst_element_class_init (GstElementClass *klass)
|
|||
klass->elementfactory = NULL;
|
||||
klass->padtemplates = NULL;
|
||||
klass->numpadtemplates = 0;
|
||||
|
||||
gst_element_error_quark = g_quark_from_static_string ("GstError");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1788,17 +1791,17 @@ gst_element_unlink (GstElement *src, GstElement *dest)
|
|||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -2079,33 +2082,36 @@ gst_element_convert (GstElement *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) {
|
||||
|
@ -2125,7 +2131,7 @@ gst_element_error (GstElement *element, const gchar *error, ...)
|
|||
|
||||
/* cleanup */
|
||||
gst_object_unref (GST_OBJECT (element));
|
||||
g_free (string);
|
||||
g_free (really_detailed);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -182,7 +182,7 @@ struct _GstElementClass {
|
|||
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 */
|
||||
|
@ -327,7 +327,31 @@ gboolean gst_element_convert (GstElement *element,
|
|||
|
||||
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);
|
||||
|
|
|
@ -6,6 +6,7 @@ VOID:POINTER
|
|||
VOID:OBJECT
|
||||
VOID:OBJECT,PARAM
|
||||
VOID:OBJECT,POINTER
|
||||
VOID:OBJECT,POINTER,STRING
|
||||
VOID:OBJECT,STRING
|
||||
VOID:INT,INT
|
||||
VOID:INT64
|
||||
|
|
32
gst/gstpad.c
32
gst/gstpad.c
|
@ -864,11 +864,11 @@ gst_pad_unlink (GstPad *srcpad,
|
|||
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 */
|
||||
|
@ -2077,8 +2077,8 @@ gst_pad_recover_caps_error (GstPad *pad, GstCaps *allowed)
|
|||
|
||||
/* 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;
|
||||
}
|
||||
|
@ -2381,10 +2381,9 @@ gst_pad_pull (GstPad *pad)
|
|||
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:
|
||||
|
@ -2405,15 +2404,16 @@ 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));
|
||||
|
|
44
gst/gstpad.h
44
gst/gstpad.h
|
@ -247,34 +247,34 @@ struct _GstGhostPadClass {
|
|||
#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_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) (((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_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)))
|
||||
|
|
|
@ -413,7 +413,9 @@ restart:
|
|||
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;
|
||||
}
|
||||
|
@ -493,7 +495,9 @@ restart:
|
|||
/* 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 {
|
||||
|
|
|
@ -236,8 +236,9 @@ end:
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,25 @@ typedef enum {
|
|||
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__ */
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
|
@ -451,8 +452,9 @@ gst_basic_scheduler_chainhandler_proxy (GstPad * pad, GstBuffer * buf)
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -519,7 +521,9 @@ gst_basic_scheduler_gethandler_proxy (GstPad * pad)
|
|||
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);
|
||||
|
@ -650,10 +654,10 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain)
|
|||
* 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,
|
||||
|
@ -719,8 +723,9 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain)
|
|||
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'",
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include "gstfakesink.h"
|
||||
|
||||
|
@ -406,7 +407,9 @@ gst_fakesink_change_state (GstElement *element)
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <errno.h>
|
||||
|
@ -222,9 +223,9 @@ gst_filesink_open_file (GstFileSink *sink)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -242,9 +243,9 @@ gst_filesink_close_file (GstFileSink *sink)
|
|||
|
||||
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);
|
||||
|
@ -340,9 +341,10 @@ gst_filesink_handle_event (GstPad *pad, GstEvent *event)
|
|||
|
||||
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))
|
||||
{
|
||||
|
@ -372,9 +374,10 @@ gst_filesink_handle_event (GstPad *pad, GstEvent *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:
|
||||
|
@ -423,10 +426,10 @@ gst_filesink_chain (GstPad *pad, GstBuffer *buf)
|
|||
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;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include "gstfilesrc.h"
|
||||
|
@ -398,7 +399,9 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size)
|
|||
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) {
|
||||
|
@ -635,13 +638,11 @@ gst_filesrc_get_read (GstFileSrc *src)
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -702,8 +703,9 @@ gst_filesrc_open_file (GstFileSrc *src)
|
|||
/* 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 */
|
||||
|
@ -712,8 +714,10 @@ gst_filesrc_open_file (GstFileSrc *src)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include "gstidentity.h"
|
||||
|
||||
|
@ -249,7 +250,9 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf)
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,12 @@
|
|||
#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"
|
||||
|
||||
|
@ -253,7 +255,9 @@ gboolean gst_multidisksrc_open_file (GstMultiDiskSrc *src, GstPad *srcpad)
|
|||
|
||||
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 */
|
||||
|
@ -261,13 +265,16 @@ gboolean gst_multidisksrc_open_file (GstMultiDiskSrc *src, GstPad *srcpad)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -26,10 +26,12 @@
|
|||
#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"
|
||||
|
||||
|
@ -253,7 +255,9 @@ gboolean gst_multidisksrc_open_file (GstMultiDiskSrc *src, GstPad *srcpad)
|
|||
|
||||
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 */
|
||||
|
@ -261,13 +265,16 @@ gboolean gst_multidisksrc_open_file (GstMultiDiskSrc *src, GstPad *srcpad)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include "gst/gst_private.h"
|
||||
|
||||
#include "gstpipefilter.h"
|
||||
|
||||
|
@ -148,9 +149,9 @@ gst_pipefilter_handle_event (GstPad *pad, GstEvent *event)
|
|||
|
||||
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;
|
||||
}
|
||||
|
@ -178,8 +179,9 @@ gst_pipefilter_get (GstPad *pad)
|
|||
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 */
|
||||
|
@ -216,8 +218,7 @@ gst_pipefilter_chain (GstPad *pad,GstBuffer *buf)
|
|||
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);
|
||||
|
@ -272,8 +273,7 @@ gst_pipefilter_open_file (GstPipefilter *src)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -286,8 +286,7 @@ gst_pipefilter_open_file (GstPipefilter *src)
|
|||
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;
|
||||
|
||||
}
|
||||
|
|
|
@ -413,7 +413,9 @@ restart:
|
|||
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;
|
||||
}
|
||||
|
@ -493,7 +495,9 @@ restart:
|
|||
/* 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 {
|
||||
|
|
Loading…
Reference in a new issue