mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 13:11:06 +00:00
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:
parent
5c22178afd
commit
3d53a08118
6 changed files with 71 additions and 18 deletions
11
ChangeLog
11
ChangeLog
|
@ -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>
|
2004-08-11 Steve Lhomme <steve.lhomme@free.fr>
|
||||||
|
|
||||||
* win32/config.h:
|
* win32/config.h:
|
||||||
|
|
|
@ -508,10 +508,12 @@ gst_filesrc_get_mmap (GstFileSrc * src)
|
||||||
mapend = mapstart + mapsize; /* note this is the byte *after* the map */
|
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 */
|
/* check to see if we're going to overflow the end of the file */
|
||||||
if (readend > src->filelen) {
|
if (src->is_regular) {
|
||||||
if (!gst_filesrc_check_filesize (src) || readend > src->filelen) {
|
if (readend > src->filelen) {
|
||||||
readsize = src->filelen - src->curoffset;
|
if (!gst_filesrc_check_filesize (src) || readend > src->filelen) {
|
||||||
readend = src->curoffset + readsize;
|
readsize = src->filelen - src->curoffset;
|
||||||
|
readend = src->curoffset + readsize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -617,6 +617,7 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
|
||||||
if (typefind->caps) {
|
if (typefind->caps) {
|
||||||
stop_typefinding (typefind);
|
stop_typefinding (typefind);
|
||||||
} else if (typefind->possibilities == NULL) {
|
} else if (typefind->possibilities == NULL) {
|
||||||
|
error:
|
||||||
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
|
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
|
||||||
stop_typefinding (typefind);
|
stop_typefinding (typefind);
|
||||||
} else {
|
} else {
|
||||||
|
@ -633,6 +634,7 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
|
||||||
}
|
}
|
||||||
if (!walk) {
|
if (!walk) {
|
||||||
/* find out if we should seek */
|
/* find out if we should seek */
|
||||||
|
restart:
|
||||||
for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
|
for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
|
||||||
entry = (TypeFindEntry *) walk->data;
|
entry = (TypeFindEntry *) walk->data;
|
||||||
if (entry->requested_size > 0) {
|
if (entry->requested_size > 0) {
|
||||||
|
@ -661,8 +663,19 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
|
||||||
GST_DEBUG_OBJECT (typefind,
|
GST_DEBUG_OBJECT (typefind,
|
||||||
"'%s' was reset - couldn't seek to %" G_GINT64_FORMAT,
|
"'%s' was reset - couldn't seek to %" G_GINT64_FORMAT,
|
||||||
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
|
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
|
||||||
entry->requested_size = 0;
|
if (entry->probability == 0) {
|
||||||
entry->requested_offset = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -508,10 +508,12 @@ gst_filesrc_get_mmap (GstFileSrc * src)
|
||||||
mapend = mapstart + mapsize; /* note this is the byte *after* the map */
|
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 */
|
/* check to see if we're going to overflow the end of the file */
|
||||||
if (readend > src->filelen) {
|
if (src->is_regular) {
|
||||||
if (!gst_filesrc_check_filesize (src) || readend > src->filelen) {
|
if (readend > src->filelen) {
|
||||||
readsize = src->filelen - src->curoffset;
|
if (!gst_filesrc_check_filesize (src) || readend > src->filelen) {
|
||||||
readend = src->curoffset + readsize;
|
readsize = src->filelen - src->curoffset;
|
||||||
|
readend = src->curoffset + readsize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -617,6 +617,7 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
|
||||||
if (typefind->caps) {
|
if (typefind->caps) {
|
||||||
stop_typefinding (typefind);
|
stop_typefinding (typefind);
|
||||||
} else if (typefind->possibilities == NULL) {
|
} else if (typefind->possibilities == NULL) {
|
||||||
|
error:
|
||||||
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
|
GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
|
||||||
stop_typefinding (typefind);
|
stop_typefinding (typefind);
|
||||||
} else {
|
} else {
|
||||||
|
@ -633,6 +634,7 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
|
||||||
}
|
}
|
||||||
if (!walk) {
|
if (!walk) {
|
||||||
/* find out if we should seek */
|
/* find out if we should seek */
|
||||||
|
restart:
|
||||||
for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
|
for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
|
||||||
entry = (TypeFindEntry *) walk->data;
|
entry = (TypeFindEntry *) walk->data;
|
||||||
if (entry->requested_size > 0) {
|
if (entry->requested_size > 0) {
|
||||||
|
@ -661,8 +663,19 @@ gst_type_find_element_chain (GstPad * pad, GstData * data)
|
||||||
GST_DEBUG_OBJECT (typefind,
|
GST_DEBUG_OBJECT (typefind,
|
||||||
"'%s' was reset - couldn't seek to %" G_GINT64_FORMAT,
|
"'%s' was reset - couldn't seek to %" G_GINT64_FORMAT,
|
||||||
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
|
GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
|
||||||
entry->requested_size = 0;
|
if (entry->probability == 0) {
|
||||||
entry->requested_offset = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ static guint64 max = 0;
|
||||||
static GstClock *s_clock;
|
static GstClock *s_clock;
|
||||||
static GstElement *pipeline;
|
static GstElement *pipeline;
|
||||||
gboolean caught_intr = FALSE;
|
gboolean caught_intr = FALSE;
|
||||||
|
gboolean caught_error = FALSE;
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
idle_func (gpointer data)
|
idle_func (gpointer data)
|
||||||
|
@ -85,8 +86,8 @@ idle_func (gpointer data)
|
||||||
min = MIN (min, diff);
|
min = MIN (min, diff);
|
||||||
max = MAX (max, diff);
|
max = MAX (max, diff);
|
||||||
|
|
||||||
if (!busy || caught_intr || (max_iterations > 0
|
if (!busy || caught_intr || caught_error ||
|
||||||
&& iterations >= max_iterations)) {
|
(max_iterations > 0 && iterations >= max_iterations)) {
|
||||||
char *s_iterations;
|
char *s_iterations;
|
||||||
char *s_sum;
|
char *s_sum;
|
||||||
char *s_ave;
|
char *s_ave;
|
||||||
|
@ -308,6 +309,7 @@ print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
|
||||||
g_free (str);
|
g_free (str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
found_tag (GObject * pipeline, GstElement * source, GstTagList * tags)
|
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);
|
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
|
#ifndef DISABLE_FAULT_HANDLER
|
||||||
/* we only use sighandler here because the registers are not important */
|
/* we only use sighandler here because the registers are not important */
|
||||||
static void
|
static void
|
||||||
|
@ -481,7 +490,7 @@ main (int argc, char *argv[])
|
||||||
} else {
|
} else {
|
||||||
fprintf (stderr, _("ERROR: pipeline could not be constructed.\n"));
|
fprintf (stderr, _("ERROR: pipeline could not be constructed.\n"));
|
||||||
}
|
}
|
||||||
exit (1);
|
return 1;
|
||||||
} else if (error) {
|
} else if (error) {
|
||||||
fprintf (stderr, _("WARNING: erroneous pipeline: %s\n"), error->message);
|
fprintf (stderr, _("WARNING: erroneous pipeline: %s\n"), error->message);
|
||||||
fprintf (stderr, _(" Trying to run anyway.\n"));
|
fprintf (stderr, _(" Trying to run anyway.\n"));
|
||||||
|
@ -497,8 +506,7 @@ main (int argc, char *argv[])
|
||||||
if (tags) {
|
if (tags) {
|
||||||
g_signal_connect (pipeline, "found-tag", G_CALLBACK (found_tag), NULL);
|
g_signal_connect (pipeline, "found-tag", G_CALLBACK (found_tag), NULL);
|
||||||
}
|
}
|
||||||
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
|
g_signal_connect (pipeline, "error", G_CALLBACK (error_cb), NULL);
|
||||||
NULL);
|
|
||||||
|
|
||||||
#ifndef GST_DISABLE_LOADSAVE
|
#ifndef GST_DISABLE_LOADSAVE
|
||||||
if (savefile) {
|
if (savefile) {
|
||||||
|
@ -513,7 +521,7 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
if (real_pipeline == NULL) {
|
if (real_pipeline == NULL) {
|
||||||
fprintf (stderr, _("ERROR: the 'pipeline' element wasn't found.\n"));
|
fprintf (stderr, _("ERROR: the 'pipeline' element wasn't found.\n"));
|
||||||
exit (1);
|
return 1;
|
||||||
}
|
}
|
||||||
gst_bin_add (GST_BIN (real_pipeline), pipeline);
|
gst_bin_add (GST_BIN (real_pipeline), pipeline);
|
||||||
pipeline = real_pipeline;
|
pipeline = real_pipeline;
|
||||||
|
@ -537,6 +545,10 @@ main (int argc, char *argv[])
|
||||||
gst_element_wait_state_change (pipeline);
|
gst_element_wait_state_change (pipeline);
|
||||||
g_print ("got the state change.\n");
|
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);
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue