/*
 *  main()
 *  ----
 *  Start up GLUT and tell it what to do
 */
int main(int argc,char* argv[])
{
  initializeGlobals();
  /* screencast specific variables */
  windowName = "OpenGL screenscasts 14: Textures part 1";
  screencastID = 14;
  dim = 4;
  fov = 50;
  th = -25;
  ph = 15;
  ecX = -0.4;
  ecZ = -2.0;
  distance = 2;

  glutInit(&argc,argv);
  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
  glutInitWindowSize(windowWidth,windowHeight);
  glutCreateWindow(windowName);

  glutDisplayFunc(display);
  glutReshapeFunc(displayReshape);
  glutKeyboardFunc(windowKey);
  glutSpecialFunc(windowSpecial);

  initializeTextures();

  redisplayAll();
  glutMainLoop();
  return 0;
}
/*
 *  main()
 *  ----
 *  Start up GLUT and tell it what to do
 */
int main(int argc,char* argv[])
{
  initializeGlobals();
  /* screencast specific variables */
  windowName = "OpenGL screenscasts 17: Animation part 2";
  screencastID = 17;
  toggleAxes = 0;
  toggleAnimation = 0;

  glutInit(&argc,argv);
  glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
  glutInitWindowSize(windowWidth,windowHeight);
  glutInitWindowPosition(450,350);
  glutCreateWindow(windowName);

  glutDisplayFunc(display);
  glutReshapeFunc(displayReshape);
  glutKeyboardFunc(windowKey);
  glutSpecialFunc(windowSpecial);

  initializeTextures();
  initializeObjs();
  timer(toggleAnimation);

  redisplayAll();
  glutMainLoop();
  return 0;
}
void GameDragonsphere::startGame() {
	_scene._priorSceneId = 0;
	_scene._currentSceneId = -1;
	_scene._nextSceneId = 101;

	initializeGlobals();
}
int mainService(int argc, char *argv[])
{
	char	sourceURL[1024] = "";
	char	configFile[1024] = "";
	int		c = 0;
	int 	numEncoders = 1;


    char    currentlogFile[1024] = "";
	char	logPrefix[255] = "streamTranscoder";

    sprintf(configFile, "%s", logPrefix);
    sprintf(currentlogFile, "%s", logPrefix);

    setgLogFile(&gMain, currentlogFile);
    setConfigFileName(&gMain, configFile);

	addConfigVariable(&gMain, "SourceURL");
	addConfigVariable(&gMain, "NumEncoders");
	addConfigVariable(&gMain, "AutomaticReconnectSecs");
	addConfigVariable(&gMain, "AutoConnect");
	addConfigVariable(&gMain, "LogLevel");
	addConfigVariable(&gMain, "LogFile");


    readConfigFile(&gMain, 0);

	strcpy(sourceURL, gMain.gSourceURL);

    for(int i = 0; i < gMain.gNumEncoders; i++) {
        if(!g[i]) {
            g[i] = (edcastGlobals *) malloc(sizeof(edcastGlobals));
            memset(g[i], '\000', sizeof(edcastGlobals));
        }

        g[i]->encoderNumber = i + 1;
        setgLogFile(g[i], gMain.gLogFile);
        setConfigFileName(g[i], gMain.gConfigFileName);
		addBasicEncoderSettings(g[i]);
        initializeGlobals(g[i]);
        edcast_init(g[i]);
		connectToServer(g[i]);
    }

	pthread_create(&sourceThread, NULL, &startSourceThread, sourceURL);
	pthread_create(&reconnectThread, NULL, &startReconnectThread, NULL);
	pthread_create(&decodeThread, NULL, &startDecodeThread, NULL);
	pthread_join(sourceThread, NULL);
	pthread_join(decodeThread, NULL);
	return 1;
}
Beispiel #5
0
int main(int argc, char * argv[])
{
    // Initialize
    initializeGlobals();
    
    // Temporary String
    char *foobar;
    
    FILE* fin; // Input
    FILE* fout; // Output
    
    // No input file. Use default.
    if(argc < 2) {
        fin = fopen("Scanner.in","rb");
        fout = fopen("Scanner.out","wb");
    }
    // Just an input file. Use declared string
    else if(argc == 2) {
        argc--; argv++;
        foobar = *argv;
        fin = fopen(foobar, "rb");
        
        argc--; argv++;
        foobar = *argv;
        fout = fopen(foobar,"wb");
    }
    // TBD: Flag indicating something special in the run.
    else {
        debug("Error: Parameter Format. Please try again!\n");
        return 1;
    }
    
    // Check for Input File Error
    if(fin == NULL) {
        debug("Error: Input file did not open correctly!\n");
        return 1;
    }
    
    runScanner(fin, fout);
    
    fclose(fin);
    fclose(fout);
    return 0;
}
Beispiel #6
0
/*! Main function run from the command line
    @param argc     argument count (the number of arguments given)
    @param argv     argument values (the array of arguments given)
    @return         the return code of the program (EXIT_SUCCESS for a successful output, another code for an error)
*/
int main (int argc, char* argv[]) {
    if (argc >= 2) {
        initializeGlobals();
        expression* parsed = parse(argv[1]);
        expression* evaluated;
        if (errors == NULL) {
            evaluated = evaluate(parsed);
        } else {
            evaluated = newExpressionOfType(TYPE_NIL);
        }
        char* printed = printExpression(evaluated);
        char* errortext = printErrors();
        printf("%s\n%s", printed, errortext);
        free(printed);
        freeExpr(evaluated);
        freeGlobals();
        return EXIT_SUCCESS;
    } else {
        return EXIT_NO_ARGS;
    }
}
Beispiel #7
0
void Game::run() {
	initializeGlobals();

	// If requested, load a savegame instead of showing the intro
	if (ConfMan.hasKey("save_slot")) {
		int saveSlot = ConfMan.getInt("save_slot");
		if (saveSlot >= 0 && saveSlot <= 999)
			_loadGameSlot = saveSlot;
	}

	_statusFlag = true;

	if (_loadGameSlot == -1) {
		startGame();
	}

	// Get the initial starting time for the first scene
	_scene._frameStartTime = _vm->_events->getFrameCounter();

	if (!_vm->shouldQuit())
		gameLoop();
}
Beispiel #8
0
void GamePhantom::startGame() {
	initializeGlobals();
}
Beispiel #9
0
int main(int argc, char *argv[])
{

	initializeGlobals();

	EFFECT effect = NONE;

	if ( argc < 2 )
	{
		std::cout << "Insufficient arguments.\n"; 
		usage();
		exit(EXIT_FAILURE);
	}
	
	if ( argc == 3 ) {
		switch ( (int)*argv[2] ) {
			case (int)'0': effect = VOX; break;
			case (int)'1': effect = LOOP; break;
			case (int)'2': effect = SPIRAL; break;
			case (int)'3': effect = FOUNTAIN; break;
			case (int)'4': effect = SPHERE; break;
		}
	} else
		effect = SPHERE;

	/* Initialize */

	void (*renderer)(std::vector<float> specL, std::vector<float> specR);

	if ( effect == SPIRAL ) {
		renderer = analyzeSpectrumSpiral;
		SPECTRUMSIZE = 512;
	} else if ( effect == VOX ) {
		renderer = analyzeSpectrumVox;
		SPECTRUMSIZE = 128;
	} else if ( effect == LOOP ) {
		renderer = analyzeSpectrumLoop;
		SPECTRUMSIZE = 512;
	} else if ( effect == FOUNTAIN ) {
		renderer = analyzeSpectrumFountain;
		SPECTRUMSIZE = 512;
	} else if ( effect == SPHERE ) {
		renderer = analyzeSpectrumSphere;
		SPECTRUMSIZE = 512;
	} else {
		usage();
		exit(EXIT_FAILURE);
	}
	
	FmodHandler fmodHandler(argv[1],renderer,(int)SPECTRUMSIZE);

	fmodHandler.play();
	if (!initScene(effect)) {exit(EXIT_FAILURE);}
	srand ( time(NULL) );
	
	//Initialize cubes
	initCubes(effect);

	/* Main Event Loop. */
	int running = GL_TRUE;
	while (running)
	{
		draw(); 
		fmodHandler.update();
		running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);
	}
	
	/* Shut down */
	glfwTerminate();
	fmodHandler.release();
	
	return 0;
}
stream_encoder::stream_encoder() {
	config=new edcastGlobals;
	initializeGlobals(config);
}
int 
OddcastWnd::handleChildNotify (int msg, int objId, int param1, int param2)
{

	if (msg != ChildNotify::BUTTON_LEFTPUSH)
		return 0;
	int ret;

	switch(objId) 
	{
	case ODDCAST_VU:
		if (m_vu_on_off) {
			m_vu_on_off = 0;
		}
		else {
			m_vu_on_off = 1;
		}
		break;

	case ODDCAST_CONNECT:
		if (getIsConnected()) {
			disconnectFromServer();
			setForceStop(1);
			if (getLiveRecordingSetFlag()) {
				stopRecording();
			}
			setCurrentSongTitle("");
			m_connect->setButtonText("Connect", EXB_BUTTON_FONT_SIZE);
			gAvgRight = 0;
			gAvgLeft = 0;
			invalidate();

		}
		else {
			char	message[1024] = "";
			char	error[1024] = "";
			int ret = 1;
#ifdef WIN32
			if (getWMAFlag()) {
				ret = startWMAServer(message,error);
			}
#endif
			if (ret == 0) {
				MessageBox(NULL,message, NULL, MB_OK);
				MessageBox(NULL,error, NULL, MB_OK);
			}
			else {
				if (startOddcast(NULL)) {
//				gThreadHandle = CreateThread(NULL, 0, startOddcast, NULL, 0, &gThreadID);
					m_connect->setButtonText("Stop", EXB_BUTTON_FONT_SIZE);
				}
			}
		}
		break;
	case ODDCAST_CONFIG:
		if (!getIsConnected()) {
			STARTUPINFO si = {0};
			PROCESS_INFORMATION pi = {0};

			si.cb = sizeof (si);
			si.lpReserved = si.lpDesktop = si.lpTitle = NULL;
			si.dwFlags = STARTF_USESHOWWINDOW;
			si.wShowWindow = SW_SHOW;
			si.cbReserved2 = 0;
			si.lpReserved2 = 0;
			DWORD dwError;

			CreateProcess (NULL, "oddcast_editConfig.exe", 
			  NULL, NULL, 
			  TRUE, CREATE_NEW_CONSOLE, 
			  NULL, NULL, 
			  &si, &pi); 

			WaitForSingleObject (pi.hProcess, INFINITE);
			initializeGlobals();
			transcode_init();
		}
		else {
			MessageBox(NULL, "Sorry, but you cannot edit the settings while connected", "Error", MB_OK);
		}
		break;
	}
	return 1;
}
int main(void) {
    int sumOfTurnaroundTimes = 0;
    int doneReading = 0;
    int i;
    
    /* read in all process data and populate processes array with the results */
    initializeGlobals();
	while (doneReading=readProcess(&processes[numberOfProcesses]))  {
	   if(doneReading==1)  numberOfProcesses ++;
	   if(numberOfProcesses > MAX_PROCESSES) break;
	}

    /* handle invalid number of processes in input */
    if (numberOfProcesses == 0) {
        fprintf(stderr, "Error: no processes specified in input.\n");
        return -1;
    } else if (numberOfProcesses > MAX_PROCESSES) {
        fprintf(stderr, "Error: too many processes specified in input; "
                        "they cannot number more than %d.\n", MAX_PROCESSES);
        return -1;
    }
    
    /* sort the processes array ascending by arrival time */
    qsort(processes, numberOfProcesses, sizeof(process), compareByArrival);
    
    /* run the simulation */
    while (1) {
        moveIncomingProcesses();  /* admit any newly arriving processes */
        moveRunningProcesses();   /* move procs that shouldn't be running */
        moveWaitingProcesses();   /* move procs finished waiting to ready-Q */
        moveReadyProcesses();     /* move ready procs into any free cpu slots */
        
        updateWaitingProcesses(); /* update burst progress for waiting procs */
        updateReadyProcesses();   /* update waiting time for ready procs */
        updateRunningProcesses(); /* update burst progress for running procs */
        
        cpuTimeUtilized += runningProcesses();

        /* terminate simulation when:
            - no processes are running
            - no more processes await entry into the system
            - there are no waiting processes
        */
        if (runningProcesses() == 0 &&
            incomingProcesses() == 0 &&
            waitingQueue.size == 0) break;

        simulationTime++;
    }
    
     for (i = 0; i < numberOfProcesses; i++)
    	printf("Process #%d: Arrival=%d, Start=%d, End=%d, Waiting=%d\n", 
    		processes[i].pid, processes[i].arrivalTime, processes[i].startTime, processes[i].endTime, processes[i].waitingTime);
    
    /* compute and output performance metrics */
    for (i=0;i<numberOfProcesses;i++) {
        sumOfTurnaroundTimes += processes[i].endTime - processes[i].arrivalTime;
        totalWaitingTime += processes[i].waitingTime;
    }
    printf("totalWaitingTime = %d\nnumberOfProcesses = %d\n", totalWaitingTime, numberOfProcesses);
    printf("Average waiting time                 : %.2f units\n"
           "Average turnaround time              : %.2f units\n"
           "Time all processes finished          : %d\n"
           "Average CPU utilization              : %.1f%%\n"
           "Number of context switches           : %d\n",
           totalWaitingTime / (double) numberOfProcesses,
           sumOfTurnaroundTimes / (double) numberOfProcesses,
           simulationTime,
           100.0 * cpuTimeUtilized / simulationTime,
           totalContextSwitches);
    
    printf("PID(s) of last process(es) to finish :");
    for (i=0;i<numberOfProcesses;i++) {
        if (processes[i].endTime == simulationTime) {
            printf(" %d", processes[i].pid);
        }
    }
    printf("\n");
    return 0;
}
int main(int argc, char *argv[])
{
	char	sourceURL[1024] = "";
	char	configFile[1024] = "";
	int		c = 0;
	int 	numEncoders = 1;
	bool	background = false;

	while ((c = getopt(argc, argv, "bnh")) != -1) {
		switch (c) {
			case 'h':
				usage();
				break;
			case 'b':
				background = true;
				nostdout = true;
			case 'n':
				nostdout = true;
				break;
			default:
				usage();
		}
	}

	if (background) {
		fprintf(stderr, "Backgrounding process...\n");
		/* Shamelessly ripped from ICES */
		int ret = 0;
		/* Start up new session, to lose old session and process group */
		switch (fork()) {
			case 0: 	break; /* child continues */
			case -1: 	perror ("fork"); 
						ret = -1;
			default:
						exit (ret);
		}

		/* Disassociate process group and controlling terminal */
		setsid();

		/* Become a NON-session leader so that a */
		/* control terminal can't be reacquired */
		switch (fork()) {
			case 0: 	break; /* child continues */
			case -1: 	perror ("fork"); 
						ret = -1;
			default:
						exit (ret);
		}
	}

    char    currentlogFile[1024] = "";
    char    logPrefix[255] = "streamTranscoder";

	int		configFilesCreated = 0;
	int		encoderconfigFilesCreated = 0;

    
    sprintf(configFile, "%s", logPrefix);
    sprintf(currentlogFile, "%s", logPrefix);

    setDefaultLogFileName(currentlogFile);
    setgLogFile(&gMain, currentlogFile);
    setConfigFileName(&gMain, configFile);
    addConfigVariable(&gMain, "SourceURL");
    addConfigVariable(&gMain, "NumEncoders");
    addConfigVariable(&gMain, "AutomaticReconnectSecs");
    addConfigVariable(&gMain, "AutoConnect");
    addConfigVariable(&gMain, "LogLevel");
    addConfigVariable(&gMain, "LogFile");

    char    tmpLog[1024] = "";
	sprintf(tmpLog, "%s_%d.cfg", logPrefix, 0);
	if (!file_exists(tmpLog)) {
		printf("Creating config file %s\n", tmpLog);
		configFilesCreated = 1;
	}
	
    readConfigFile(&gMain, 0);


    for(int i = 0; i < gMain.gNumEncoders; i++) {
        if(!g[i]) {
            g[i] = (oddcastGlobals *) malloc(sizeof(oddcastGlobals));
            memset(g[i], '\000', sizeof(oddcastGlobals));
        	initializeGlobals(g[i]);
            addBasicEncoderSettings(g[i]);
        }
		else {
        	initializeGlobals(g[i]);
		}
    

        g[i]->encoderNumber = i + 1;
        char    currentlogFile[1024] = "";
        char    logPrefix[255] = "streamTranscoder";

        sprintf(currentlogFile, "%s_%d", logPrefix, g[i]->encoderNumber);

        setDefaultLogFileName(currentlogFile);
        setgLogFile(g[i], currentlogFile);
        setConfigFileName(g[i], gMain.gConfigFileName);

		sprintf(tmpLog, "%s.cfg", currentlogFile);
		if (!file_exists(tmpLog)) {
			printf("Creating config file %s\n", tmpLog);
			configFilesCreated = 1;
			encoderconfigFilesCreated = 1;
		}

        oddcastv3_init(g[i]);
    }

	if (configFilesCreated) {
		printf("One or more config files were created.\n");
		printf("Source settings are contained in %s_0.cfg\n", logPrefix);
		printf("All encoder settings are contained in %s_X.cfg, where X is the encoder number.\n", logPrefix);
		printf("\nYou must manually edit these config files before continuing.\n");
		if (encoderconfigFilesCreated) {
			printf("Your next step should probably be to ****edit %s_X.cfg where X = 1 to number of encoders**** you've defined, then rerun streamTranscoder\n", logPrefix);
		}
		else {
			printf("Your next step should probably be to ****edit %s_0.cfg and change the number of encoders****, then rerun streamTranscoder\n", logPrefix);
		}
		exit(1);
	}
    outputStatusCallback(&gMain, (void *)"Ready to connect");

	for(int i = 0; i < gMain.gNumEncoders; i++) {
		if (!connectToServer(g[i])) {
			char buf[255] = "";
			sprintf(buf, "Disconnected from server");
			g[i]->forcedDisconnect = true;
			g[i]->forcedDisconnectSecs = time(&(g[i]->forcedDisconnectSecs));
			g[i]->serverStatusCallback(g[i], (void *) buf);
		}
	}


	pthread_create(&sourceThread, NULL, &startSourceThread, gMain.gSourceURL);
	pthread_create(&reconnectThread, NULL, &startReconnectThread, NULL);
	pthread_create(&decodeThread, NULL, &startDecodeThread, NULL);

	sleep(2);
	if (!nostdout) {
		printf("streamTranscoder started.\n");
	}
	pthread_join(sourceThread, NULL);
	pthread_join(decodeThread, NULL);
	if (!nostdout) {
		fprintf(stdout, "Done...\n");
	}
	
}