gst/elements/gstfilesrc.c: work with non-regular files that can be mmapped (like /dev/zero)

Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
work with non-regular files that can be mmapped (like /dev/zero)
* gst/elements/gsttypefindelement.c: (gst_type_find_element_chain):
get rid of typefinds that require a seek when we can't seek instead
of trying them over and over again
* tools/gst-launch.c: (idle_func), (error_cb), (main):
return non-zero failure value when the pipeline was interrupted or
an error occurred
This commit is contained in:
Benjamin Otte 2004-08-12 09:12:13 +00:00
parent 5c22178afd
commit 3d53a08118
6 changed files with 71 additions and 18 deletions

View file

@ -1,3 +1,14 @@
2004-08-12 Benjamin Otte <in7y118@public.uni-hamburg.de>
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
work with non-regular files that can be mmapped (like /dev/zero)
* gst/elements/gsttypefindelement.c: (gst_type_find_element_chain):
get rid of typefinds that require a seek when we can't seek instead
of trying them over and over again
* tools/gst-launch.c: (idle_func), (error_cb), (main):
return non-zero failure value when the pipeline was interrupted or
an error occurred
2004-08-11 Steve Lhomme <steve.lhomme@free.fr>
* win32/config.h:

View file

@ -508,10 +508,12 @@ gst_filesrc_get_mmap (GstFileSrc * src)
mapend = mapstart + mapsize; /* note this is the byte *after* the map */
/* check to see if we're going to overflow the end of the file */
if (readend > src->filelen) {
if (!gst_filesrc_check_filesize (src) || readend > src->filelen) {
readsize = src->filelen - src->curoffset;
readend = src->curoffset + readsize;
if (src->is_regular) {
if (readend > src->filelen) {
if (!gst_filesrc_check_filesize (src) || readend > src->filelen) {
readsize = src->filelen - src->curoffset;
readend = src->curoffset + readsize;
}
}
}

View file

@ -617,6 +617,7 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
if (typefind->caps) {
stop_typefinding (typefind);
} else if (typefind->possibilities == NULL) {
error:
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
stop_typefinding (typefind);
} else {
@ -633,6 +634,7 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
}
if (!walk) {
/* find out if we should seek */
restart:
for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
entry = (TypeFindEntry *) walk->data;
if (entry->requested_size > 0) {
@ -661,8 +663,19 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
GST_DEBUG_OBJECT (typefind,
"'%s' was reset - couldn't seek to %" G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
entry->requested_size = 0;
entry->requested_offset = 0;
if (entry->probability == 0) {
free_entry (entry);
typefind->possibilities =
g_list_delete_link (typefind->possibilities, walk);
/* FIXME: too many gotos */
if (!typefind->possibilities)
goto error;
/* we modified the list, let's restart */
goto restart;
} else {
entry->requested_size = 0;
entry->requested_offset = 0;
}
}
}
}

View file

@ -508,10 +508,12 @@ gst_filesrc_get_mmap (GstFileSrc * src)
mapend = mapstart + mapsize; /* note this is the byte *after* the map */
/* check to see if we're going to overflow the end of the file */
if (readend > src->filelen) {
if (!gst_filesrc_check_filesize (src) || readend > src->filelen) {
readsize = src->filelen - src->curoffset;
readend = src->curoffset + readsize;
if (src->is_regular) {
if (readend > src->filelen) {
if (!gst_filesrc_check_filesize (src) || readend > src->filelen) {
readsize = src->filelen - src->curoffset;
readend = src->curoffset + readsize;
}
}
}

View file

@ -617,6 +617,7 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
if (typefind->caps) {
stop_typefinding (typefind);
} else if (typefind->possibilities == NULL) {
error:
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
stop_typefinding (typefind);
} else {
@ -633,6 +634,7 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
}
if (!walk) {
/* find out if we should seek */
restart:
for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
entry = (TypeFindEntry *) walk->data;
if (entry->requested_size > 0) {
@ -661,8 +663,19 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
GST_DEBUG_OBJECT (typefind,
"'%s' was reset - couldn't seek to %" G_GINT64_FORMAT,
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
entry->requested_size = 0;
entry->requested_offset = 0;
if (entry->probability == 0) {
free_entry (entry);
typefind->possibilities =
g_list_delete_link (typefind->possibilities, walk);
/* FIXME: too many gotos */
if (!typefind->possibilities)
goto error;
/* we modified the list, let's restart */
goto restart;
} else {
entry->requested_size = 0;
entry->requested_offset = 0;
}
}
}
}

View file

@ -66,6 +66,7 @@ static guint64 max = 0;
static GstClock *s_clock;
static GstElement *pipeline;
gboolean caught_intr = FALSE;
gboolean caught_error = FALSE;
gboolean
idle_func (gpointer data)
@ -85,8 +86,8 @@ idle_func (gpointer data)
min = MIN (min, diff);
max = MAX (max, diff);
if (!busy || caught_intr || (max_iterations > 0
&& iterations >= max_iterations)) {
if (!busy || caught_intr || caught_error ||
(max_iterations > 0 && iterations >= max_iterations)) {
char *s_iterations;
char *s_sum;
char *s_ave;
@ -308,6 +309,7 @@ print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
g_free (str);
}
}
static void
found_tag (GObject * pipeline, GstElement * source, GstTagList * tags)
{
@ -316,6 +318,13 @@ found_tag (GObject * pipeline, GstElement * source, GstTagList * tags)
gst_tag_list_foreach (tags, print_tag, NULL);
}
static void
error_cb (GObject * object, GstObject * source, GError * error, gchar * debug)
{
gst_element_default_error (object, source, error, debug);
caught_error = TRUE;
}
#ifndef DISABLE_FAULT_HANDLER
/* we only use sighandler here because the registers are not important */
static void
@ -481,7 +490,7 @@ main (int argc, char *argv[])
} else {
fprintf (stderr, _("ERROR: pipeline could not be constructed.\n"));
}
exit (1);
return 1;
} else if (error) {
fprintf (stderr, _("WARNING: erroneous pipeline: %s\n"), error->message);
fprintf (stderr, _(" Trying to run anyway.\n"));
@ -497,8 +506,7 @@ main (int argc, char *argv[])
if (tags) {
g_signal_connect (pipeline, "found-tag", G_CALLBACK (found_tag), NULL);
}
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
NULL);
g_signal_connect (pipeline, "error", G_CALLBACK (error_cb), NULL);
#ifndef GST_DISABLE_LOADSAVE
if (savefile) {
@ -513,7 +521,7 @@ main (int argc, char *argv[])
if (real_pipeline == NULL) {
fprintf (stderr, _("ERROR: the 'pipeline' element wasn't found.\n"));
exit (1);
return 1;
}
gst_bin_add (GST_BIN (real_pipeline), pipeline);
pipeline = real_pipeline;
@ -537,6 +545,10 @@ main (int argc, char *argv[])
gst_element_wait_state_change (pipeline);
g_print ("got the state change.\n");
}
if (caught_intr)
res = 2;
if (caught_error)
res = 3;
gst_element_set_state (pipeline, GST_STATE_NULL);
}