mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
many changes to startup handling:
Original commit message from CVS: many changes to startup handling: - make gst_init_with_popt_table work like gst_init - exit program on failure, return void - add gst_init_check_with_popt_table to be the same as gst_init_with_popt_table before - work the same as gst_init_check - revert an old workaround and apply the proper fix - do not use g_error to exit the application, g_error causes a segfault. Use exit.
This commit is contained in:
parent
42b3e8c7f1
commit
95b078ac08
2 changed files with 43 additions and 59 deletions
91
gst/gst.c
91
gst/gst.c
|
@ -103,7 +103,7 @@ enum {
|
|||
/* default scheduler, can be changed in gstscheduler.h with
|
||||
* the GST_SCHEDULER_DEFAULT_NAME define.
|
||||
*/
|
||||
static const struct poptOption options[] = {
|
||||
static const struct poptOption gstreamer_options[] = {
|
||||
{NULL, NUL, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, &init_popt_callback, 0, NULL, NULL},
|
||||
{"gst-version", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_VERSION, "Print the GStreamer version", NULL},
|
||||
{"gst-fatal-warnings", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_FATAL_WARNINGS, "Make all warnings fatal", NULL},
|
||||
|
@ -134,7 +134,7 @@ static const struct poptOption options[] = {
|
|||
const struct poptOption *
|
||||
gst_init_get_popt_table (void)
|
||||
{
|
||||
return options;
|
||||
return gstreamer_options;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,7 +154,7 @@ gst_init_get_popt_table (void)
|
|||
gboolean
|
||||
gst_init_check (int *argc, char **argv[])
|
||||
{
|
||||
return gst_init_with_popt_table (argc, argv, NULL);
|
||||
return gst_init_check_with_popt_table (argc, argv, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,8 +172,7 @@ gst_init_check (int *argc, char **argv[])
|
|||
void
|
||||
gst_init (int *argc, char **argv[])
|
||||
{
|
||||
if (!gst_init_with_popt_table (argc, argv, NULL))
|
||||
g_error ("Could not initialize GStreamer !\n");
|
||||
gst_init_with_popt_table (argc, argv, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,69 +185,51 @@ gst_init (int *argc, char **argv[])
|
|||
* setting up internal path lists,
|
||||
* registering built-in elements, and loading standard plugins.
|
||||
*
|
||||
* Returns: TRUE when the initialization succeeded.
|
||||
* This function will terminate your program if it was unable to initialize
|
||||
* GStreamer for some reason. If you want your program to fall back,
|
||||
* use gst_init_check_with_popt_table() instead.
|
||||
*/
|
||||
void
|
||||
gst_init_with_popt_table (int *argc, char **argv[],
|
||||
const struct poptOption *popt_options)
|
||||
{
|
||||
if (!gst_init_check_with_popt_table (argc, argv, popt_options)) {
|
||||
g_print ("Could not initialize GStreamer !\n");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* gst_init_check_with_popt_table:
|
||||
* @argc: pointer to application's argc
|
||||
* @argv: pointer to application's argv
|
||||
* @popt_options: pointer to a popt table to append
|
||||
*
|
||||
* Initializes the GStreamer library, parsing the options,
|
||||
* setting up internal path lists,
|
||||
* registering built-in elements, and loading standard plugins.
|
||||
*
|
||||
* Returns: TRUE if GStreamer coul be initialized
|
||||
*/
|
||||
gboolean
|
||||
gst_init_with_popt_table (int *argc, char **argv[],
|
||||
gst_init_check_with_popt_table (int *argc, char **argv[],
|
||||
const struct poptOption *popt_options)
|
||||
{
|
||||
poptContext context;
|
||||
gint nextopt, i, j, nstrip;
|
||||
gchar **temp;
|
||||
const struct poptOption *options;
|
||||
struct poptOption options_with[] = {
|
||||
POPT_TABLEEND,
|
||||
POPT_TABLEEND,
|
||||
POPT_TABLEEND,
|
||||
const struct poptOption options_with[] = {
|
||||
{NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL},
|
||||
{NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) gstreamer_options, 0, "GStreamer options:", NULL},
|
||||
{NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) popt_options, 0, "Application options:", NULL},
|
||||
POPT_TABLEEND
|
||||
};
|
||||
struct poptOption options_without[] = {
|
||||
POPT_TABLEEND,
|
||||
POPT_TABLEEND,
|
||||
const struct poptOption options_without[] = {
|
||||
{NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL},
|
||||
{NULL, NUL, POPT_ARG_INCLUDE_TABLE, (struct poptOption *) gstreamer_options, 0, "GStreamer options:", NULL},
|
||||
POPT_TABLEEND
|
||||
};
|
||||
|
||||
/* This used to be done by struct initialization, but most
|
||||
* compilers don't like calling functions in a struct
|
||||
* initialization. (It's a GCC extension.) FIXME: This should
|
||||
* be reworked to look better. */
|
||||
options_with[0].longName = NULL;
|
||||
options_with[0].shortName = NUL;
|
||||
options_with[0].argInfo = POPT_ARG_INCLUDE_TABLE;
|
||||
options_with[0].arg = poptHelpOptions;
|
||||
options_with[0].val = 0;
|
||||
options_with[0].descrip = "Help options:";
|
||||
options_with[0].argDescrip = NULL;
|
||||
options_with[1].longName = NULL;
|
||||
options_with[1].shortName = NUL;
|
||||
options_with[1].argInfo = POPT_ARG_INCLUDE_TABLE;
|
||||
options_with[1].arg = (struct poptOption *) gst_init_get_popt_table();
|
||||
options_with[1].val = 0;
|
||||
options_with[1].descrip = "GStreamer options:";
|
||||
options_with[1].argDescrip = NULL;
|
||||
options_with[2].longName = NULL;
|
||||
options_with[2].shortName = NUL;
|
||||
options_with[2].argInfo = POPT_ARG_INCLUDE_TABLE;
|
||||
options_with[2].arg = (struct poptOption *) popt_options;
|
||||
options_with[2].val = 0;
|
||||
options_with[2].descrip = "Application options:";
|
||||
options_with[2].argDescrip = NULL;
|
||||
|
||||
options_without[0].longName = NULL;
|
||||
options_without[0].shortName = NUL;
|
||||
options_without[0].argInfo = POPT_ARG_INCLUDE_TABLE;
|
||||
options_without[0].arg = poptHelpOptions;
|
||||
options_without[0].val = 0;
|
||||
options_without[0].descrip = "Help options:";
|
||||
options_without[0].argDescrip = NULL;
|
||||
options_without[1].longName = NULL;
|
||||
options_without[1].shortName = NUL;
|
||||
options_without[1].argInfo = POPT_ARG_INCLUDE_TABLE;
|
||||
options_without[1].arg = (struct poptOption *) gst_init_get_popt_table();
|
||||
options_without[1].val = 0;
|
||||
options_without[1].descrip = "GStreamer options:";
|
||||
options_without[1].argDescrip = NULL;
|
||||
|
||||
if (gst_initialized)
|
||||
{
|
||||
GST_DEBUG (GST_CAT_GST_INIT, "already initialized gst\n");
|
||||
|
|
|
@ -69,7 +69,10 @@ G_BEGIN_DECLS
|
|||
/* initialize GST */
|
||||
void gst_init (int *argc, char **argv[]);
|
||||
gboolean gst_init_check (int *argc, char **argv[]);
|
||||
gboolean gst_init_with_popt_table (int *argc, char **argv[],
|
||||
void gst_init_with_popt_table (int *argc, char **argv[],
|
||||
const struct poptOption
|
||||
*popt_options);
|
||||
gboolean gst_init_check_with_popt_table (int *argc, char **argv[],
|
||||
const struct poptOption
|
||||
*popt_options);
|
||||
const struct
|
||||
|
|
Loading…
Reference in a new issue