Esempio n. 1
0
File: fm.c Progetto: trazyn/dbfm
void fm_ban()
{
	pl_history(list, CMD_BAN, SID);

	list->position = -1;

	fm_run(list);

	SCREEN_UPDATE();
}
Esempio n. 2
0
	//void LoadFunction::load(multimap<string, pair<string, string> > names)
void LoadFunction::load(list<LoadFunctionElement*> names)
{
//  change data type to something like that: 
//	list< pair<string, map<string, string> > >
//  list< pair<plug-in name, <parameter-name, parameter-value> > >
//  list.at(LOAD_POS) == load plugin		//no params, yet
//  list.at(LOAD_HISTORY_POS) == load history plugin
//  list.at(CRUSTAL_DECAY_POS) == crustal decay plugin

//  and maybe put it in an extra object for easier to understand access??
//  like LoadFunctionBin??

	list< LoadFunctionElement* >::iterator names_iter = names.begin();
	load_function_component = 0;
	
	while(names_iter != names.end()){
		
		if(load_function_component > N_LOAD_COMPS)
		{
			crusde_error("Maximum Load component number (%d) exceeded. This number is a memory saving measure. \
				      Go to constants.h, increase the number N_LOAD_COMPS to your needs, recompile and rerun.", N_LOAD_COMPS);
		}
		
		SimulationCore::instance()->setLoadFunctionComponent( load_function_component );
		LoadPlugin *pl_load = new LoadPlugin( (*names_iter)->getLoadName().c_str() );
		LoadHistoryPlugin *pl_history(NULL);
		CrustalDecayPlugin *pl_decay(NULL);

		if( !(*names_iter)->getHistoryName().empty() )
		{
			pl_history = new LoadHistoryPlugin( (*names_iter)->getHistoryName().c_str() );
			pl_history->setJobName( (*names_iter)->getHistoryJob() );
		}

		if( !(*names_iter)->getDecayName().empty() )
		{
			pl_decay = new CrustalDecayPlugin( (*names_iter)->getDecayName().c_str() );
			pl_decay->setJobName( (*names_iter)->getDecayJob() );
		}

		//try loading the plugins
		try
		{
			pl_load->load( SimulationCore::instance()->getPluginFilename("load", (*names_iter)->getLoadName().c_str()) );
			if(pl_history != NULL)
			{
				pl_history->load( SimulationCore::instance()->getPluginFilename("load_history", (*names_iter)->getHistoryName().c_str()) );
			}
			if(pl_decay != NULL)
			{
				pl_decay->load( SimulationCore::instance()->getPluginFilename("crustal_decay", (*names_iter)->getDecayName().c_str()) );
			}

		}
		catch(runtime_error e)
		{
			SimulationCore::instance()->abort(e.what());
		}
		
		pl_load_map.insert(pair<LoadPlugin*, pair<LoadHistoryPlugin*, CrustalDecayPlugin*> > (pl_load, pair<LoadHistoryPlugin*, CrustalDecayPlugin*>(pl_history, pl_decay) ) );
		++names_iter;
		++load_function_component;
	}    
Esempio n. 3
0
File: fm.c Progetto: trazyn/dbfm
void fm_run(struct playlist *pl)
{
	int status;

	/* make sure only one instance of play process */
	if(playproc > 0)
	{
		signal(SIGCHLD, SIG_DFL);

		kill(playproc, SIGUSR1);

		while(playproc != waitpid(playproc, &status, 0))
		{
			if(ESRCH == errno || ECHILD == errno)
			{
				break;
			}

			exit(EXIT_FAILURE);
		}

		if(WIFEXITED(status) && EXIT_SUCCESS == WEXITSTATUS(status))
		{
			pl_history(list, ack, SID);

			ack = CMD_NEXT;

			fm_recording();
		}
		else
		{
			pl_history(list, CMD_SKIP, SID);
		}
	}

	current = (struct hash **)pl_current(pl);
	list = pl;

	switch((playproc = fork()))
	{
		case -1:
			die("failed to fork process");

		case 0:
			signal(SIGINT, SIG_IGN);
			signal(SIGUSR1, SIG_DFL);

			close(STDIN_FILENO);

			debug("PLAY: %s(%d) | %d / %d\n", 
			  				value((const struct hash **)current, "title"),
			  				value((const struct hash **)current, "sid"),
			  				list->position, list->length);
			play(URL);

			exit(EXIT_SUCCESS);
		default:
			break;
	}

	signal(SIGCHLD, fm_next);
}