Example #1
0
/**
 * @brief Some arguments must be handled before other, for allocation or specific purpose ; here is their handling
 *
 * @param desc the Description we are about to change to handle the special args
 * @param argc the number of arguments passed to the program
 * @param argv the strings table of arguments passed to the program
 * @return 1 if we have to abort the command line handling, 0 else
 */
static inline int Option_handleSpecialArgs (SDescription *desc, int argc, char *argv[])
{
	int opt;
	long val;

    //By default set resume to 0
    Description_setResumeId (desc, 0);
	
	// First, we have to load resume stuff if any
	optind = 1;
	while ((opt = getopt_long (argc, argv, "", option_list, NULL)) != -1) { // Is the resume id specified?
		if(opt == 'z')
		{
			val = Option_transformArgument (optarg);
			Description_setResumeId (desc, val);
		}
	}
	
	optind = 1;
	while ((opt = getopt_long (argc, argv, "", option_list, NULL)) != -1) { // Are we resuming?
		if(opt == 'R')
		{
			if (resumeLoad (desc) == -1 || resumeLoadCounters (desc) == -1) // Failed to resume
			{
				Log_output(-1, "Error: Failed to resume.\n");
				exit(EXIT_FAILURE);
			}
			else	// Resumed successfully
			{
				resumeEnableResuming ();
				Description_setResuming (desc, 1);
				desc->number_of_resumes++;
				Log_output (-1, "Loaded resume values successfully. (%dnth resume)\n", desc->number_of_resumes);
			}

			return 1;
		}
	}
	
	/* Special argument : Config file ; if any, we have to load it before loading other command line arglist */
	optind = 1;
	while ((opt = getopt_long (argc, argv, "", option_list, NULL)) != -1) { // Check in the command line arglist
		if(opt == 'C')
		{
			Description_setConfigFile (desc, optarg);
			
			/* Then, if any, we have to parse special args before those of the command line */
			if (Config_parseXMLSpecialArgs (desc, desc->configFileName) == -1) {
				Log_output (-1, "An error occured while parsing XML config file.\n");
				exit (EXIT_FAILURE);
			}
		}
	}
	
	/* Special argument : nbVectors : it must be allocated before dealing with anything else
		(calling setNbVectors () do a lot of allocation stuff) */
	optind = 1;
	while ((opt = getopt_long (argc, argv, "", option_list, NULL)) != -1) { // Check in the command line arglist
		if(opt == 'n')
		{
			val = Option_transformArgument (optarg);
			Description_setNbVectors (desc, val);
		}
	}
	
	/* Special argument : nbEvalLib : it must be allocated before dealing with anything else
		(calling setNbEvalLib () do a lot of allocation stuff) */
	optind = 1;
	while ((opt = getopt_long (argc, argv, "", option_list, NULL)) != -1) { // Check in the command line arglist
		if(opt == 'E')
		{
			Description_parseEvaluationLibraryInput (desc, optarg);
		}
	}
	
	/* In the end, if anybody defined the nbVector argument, let's define it ourself */
	if (Description_getNbVectors (desc) == DEFAULT_NB_VECTORS)
	{
		Description_setNbVectors (desc, 1);
	}
	
	return 0;
}
void MediaPlayerPrivateAVFoundation::setPreload(MediaPlayer::Preload preload)
{
    m_preload = preload;
    if (m_delayingLoad && m_preload != MediaPlayer::None)
        resumeLoad();
}