Esempio n. 1
0
/**
 * errorSyntax for RTGetOpt users.
 *
 * @returns RTEXITCODE_SYNTAX.
 *
 * @param   fCategory          The usage category of the command.
 * @param   fSubCategory         The usage sub-category of the command.
 * @param   rc              The RTGetOpt return code.
 * @param   pValueUnion     The value union.
 */
RTEXITCODE errorGetOptEx(USAGECATEGORY fCategory, uint32_t fSubCategory, int rc, union RTGETOPTUNION const *pValueUnion)
{
    /*
     * Check if it is an unhandled standard option.
     */
    if (rc == 'V')
    {
        RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision());
        return RTEXITCODE_SUCCESS;
    }

    if (rc == 'h')
    {
        showLogo(g_pStdErr);
#ifndef VBOX_ONLY_DOCS
        if (g_fInternalMode)
            printUsageInternal(fCategory, g_pStdOut);
        else
            printUsage(fCategory, fSubCategory, g_pStdOut);
#endif
        return RTEXITCODE_SUCCESS;
    }

    /*
     * General failure.
     */
    showLogo(g_pStdErr); // show logo even if suppressed
#ifndef VBOX_ONLY_DOCS
    if (g_fInternalMode)
        printUsageInternal(fCategory, g_pStdErr);
    else
        printUsage(fCategory, fSubCategory, g_pStdErr);
#endif /* !VBOX_ONLY_DOCS */

    if (rc == VINF_GETOPT_NOT_OPTION)
        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid parameter '%s'", pValueUnion->psz);
    if (rc > 0)
    {
        if (RT_C_IS_PRINT(rc))
            return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option -%c", rc);
        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid option case %i", rc);
    }
    if (rc == VERR_GETOPT_UNKNOWN_OPTION)
        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown option: %s", pValueUnion->psz);
    if (rc == VERR_GETOPT_INVALID_ARGUMENT_FORMAT)
        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid argument format: %s", pValueUnion->psz);
    if (pValueUnion->pDef)
        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%s: %Rrs", pValueUnion->pDef->pszLong, rc);
    return RTMsgErrorExit(RTEXITCODE_SYNTAX, "%Rrs", rc);
}
Esempio n. 2
0
void showUsage(_TCHAR* exeName)
{
	_TCHAR exeName2[MAX_PATH];
	_tsplitpath(exeName, NULL, NULL, exeName2, NULL);
	showLogo();
	printf("\nUsage:\n\t%s <wav_file> <bitstream_file> [options]\n", exeName2);
	printf("Options:\n");
	printf("\t--br       - Set bitrate (CBR) to <bitrate> bps. Default is 128000\n");
	printf("\t--mono     - Encode as Mono\n");
	printf("\t--ps       - Enable Parametric Stereo (bitrates up to 56000)\n");
	printf("\t--is       - Independent Stereo, disables Joint Stereo M/S coding\n");
	printf("\t--dc       - Prefer Dual Channels\n");
	printf("\t--he       - Encode as HE-AAC (bitrate up to 128000/213335)\n");
	printf("\t--lc       - Encode as LC-AAC (bitrate up to 320000)\n");
	printf("\t--high     - Encode as HE-AAC with High Bitrates \n\t\t    (bitrates up to 256000, multichannel is not supported)\n");
	printf("\t--speech   - Tune for Speech\n");
	printf("\t--pns      - Enable Perceptual Noise Subsitution (PNS)\n");
	printf("\t--mpeg2aac - Force MPEG2 AAC stream\n");
	printf("\t--mpeg4aac - Force MPEG4 AAC stream\n");
	printf("\t--rawpcm    <rate> <cnt> <bp> - Signal RAW PCM input instead of WAV\n");
	printf("\t\t    <rate> - Samplerate in Hz (32000, 44100 or 48000)\n");
	printf("\t\t    <cnt>  - Channels count (1 or 2)\n");     // and multichannel ?
	printf("\t\t    <bp>   - Bit's per sample (8 or 16)\n");  // 8 not supported in wav ?
	printf("WARNING: this encoder can read and encode data from stdin:\n\t use - as input filename\n");
	printf("The output can be a raw .aac file or a MPEG4 ISO compilant .mp4/.m4a\n(libmp4v2.dll [from Winamp folder] must be in the same directory)\n");
}
Esempio n. 3
0
int main() {
 
  /* Declaring variables */
  char guessWord[10]; /* The word that needs to be guessed */
  int wordlength;	/* Calculate the length of the guessWord */
  int errors = 0; /* Error amount, if its higher than 10 the loop stops */
  char c;	/* Player 2's guess */
  int guessedLetter = 0; /* Boolean Int. 0 = incorrect letter, 1 = correct letter */
  
  printf("Player 1 - Enter a word (max 10 characters): ");
  fgets(guessWord, 11, stdin);
  /* remove newline, if present */
  wordlength = strlen(guessWord)-1;
  if( guessWord[wordlength] == '\n') 
      guessWord[wordlength] = '\0';

  /* Creating the dotword (name: currentWord) */
  char* currentWord = malloc( wordlength );
  int t;
  for (t = 0; t <= wordlength; t++) {
    if (t == wordlength) {
      currentWord[t] = '\0';
    } else {
      currentWord[t] =  '.';
    }
  }
  
  showLogo();
  showStartMsg();
  printf("Player 2 - This is the word to guess: %s\n", currentWord);
  printf("Enter the letter you want to guess: ");
  
  /* As long as the word hasn't been guessed or the errors are lower than 10: */
  while( (strcmp(currentWord, guessWord) != 0) && (errors < 10) ){
    c = getchar(); /* Retrieving the user entry */
	getchar();
	/* Checking whether entered letter (c) occurs in guessWord */
	int i;
    for (i = 0; i < wordlength; i++) {
      if (guessWord[i] == c) {
        currentWord[i] = c;
        guessedLetter = 1;
      }
    }
    /* Actions taken if the letter c doesn't occur in the guessWord and when it does */
    if (guessedLetter == 0) {
      printf("\nThat letter was incorrect.\n\n");
	  errors++;
    } else {
      printf("\nThat letter was correct.\n\n");
	  guessedLetter = 0; /* resetting guessedLetter */
     }
    /* Display the gallows and number of errors */
    printf("%s%s\n\n", "The word including the letters you guessed: ", currentWord);
    showGallows(errors);

  } // end while
  
return 0;
}
Esempio n. 4
0
/**
 * Print a usage synopsis and the syntax error message.
 * @returns RTEXITCODE_SYNTAX.
 */
RTEXITCODE errorSyntaxEx(USAGECATEGORY fCategory, uint32_t fSubCategory, const char *pszFormat, ...)
{
    va_list args;
    showLogo(g_pStdErr); // show logo even if suppressed
#ifndef VBOX_ONLY_DOCS
    if (g_fInternalMode)
        printUsageInternal(fCategory, g_pStdErr);
    else
        printUsage(fCategory, fSubCategory, g_pStdErr);
#endif /* !VBOX_ONLY_DOCS */
    va_start(args, pszFormat);
    RTStrmPrintf(g_pStdErr, "\nSyntax error: %N\n", pszFormat, &args);
    va_end(args);
    return RTEXITCODE_SYNTAX;
}
Esempio n. 5
0
void resetGame() {
	bird_flag = FALSE;
	bird_gravity.w = 0;
	
	showLogo();
	
	gameState = GAME_STATE_INTRO;
	score = 0;
	hideScore();
	
	hidePipe();
	
	set_sprite_prop(0, 0x00);
	set_sprite_prop(1, 0x00);
	
	bird_x = 0;
	bird_y = 0;
}
Esempio n. 6
0
int tetrixStateLogo::updateScene(void)
{
	inputKey();
	if(!m_logoChecker)
	{
		m_referTetrix->RENDER showLogo();
		m_logoChecker = true;
	}
	if(!m_exampleChecker)
	{
		m_referTetrix->RENDER exampleBlock();
		m_exampleChecker = true;
	}
	else if(m_referTetrix->gameTimer(RESET_EXAMPLE_TIMER))
	{
		m_exampleChecker = false;
	}
	return m_returnState;
}
ShutdownUI::ShutdownUI() :
    MWindow((QWidget *)NULL),
    realized(false),
    sceneWindow(0),
    timer(new QTimer(this)),
    label1(0),
    label2(0),
    logo(0),
    layout(0),
    feedback(0)
{
    setWindowTitle("ShutdownUI");
    setObjectName("ShutdownUIWindow");

    // Pre-create/load the shutdown UI content to show it quickly when requested
    QTimer::singleShot(5000, this, SLOT(realize()));

    connect(timer, SIGNAL(timeout()), this, SLOT(showLogo()));
}
Esempio n. 8
0
Common::Error TeenAgentEngine::run() {
	Resources *res = Resources::instance();
	if (!res->loadArchives(_gameDescription))
		return Common::kUnknownError;

	Common::EventManager *_event = _system->getEventManager();

	initGraphics(320, 200, false);

	scene = new Scene;
	inventory = new Inventory;
	console = new Console(this);

	scene->init(this, _system);
	inventory->init(this);

	init();

	CursorMan.pushCursor(res->dseg.ptr(0x00da), 8, 12, 0, 0, 1);

	syncSoundSettings();

	_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, music, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, false);
	setMusic(1);
	music->start();

	int load_slot = Common::ConfigManager::instance().getInt("save_slot");
	if (load_slot >= 0) {
		loadGameState(load_slot);
	} else {
		if (!showCDLogo())
			return Common::kNoError;
		if (!showLogo())
			return Common::kNoError;
		if (!showMetropolis())
			return Common::kNoError;
		scene->intro = true;
		scene_busy = true;
		processCallback(0x24c);
	}

	CursorMan.showMouse(true);

	uint32 game_timer = 0;
	uint32 mark_timer = 0;

	Common::Event event;
	Common::Point mouse;
	uint32 timer = _system->getMillis();

	do {
		Object *current_object = scene->findObject(mouse);

		while (_event->pollEvent(event)) {
			if (event.type == Common::EVENT_RTL) {
				deinit();
				return Common::kNoError;
			}

			if ((!scene_busy && inventory->processEvent(event)) || scene->processEvent(event))
				continue;

			//debug(0, "event");
			switch (event.type) {
			case Common::EVENT_KEYDOWN:
				if ((event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d) ||
					event.kbd.ascii == '~' || event.kbd.ascii == '#') {
					console->attach();
				} else if (event.kbd.hasFlags(0) && event.kbd.keycode == Common::KEYCODE_F5) {
					openMainMenuDialog();
				} if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_f) {
					_mark_delay = _mark_delay == 80? 40: 80;
					debug(0, "mark_delay = %u", _mark_delay);
				}
				break;
			case Common::EVENT_LBUTTONDOWN:
				if (scene->getId() < 0)
					break;
				examine(event.mouse, current_object);
				break;
			case Common::EVENT_RBUTTONDOWN:
				//if (current_object)
				//	debug(0, "%d, %s", current_object->id, current_object->name.c_str());
				if (scene->getId() < 0)
					break;

				if (current_object == NULL)
					break;

				if (res->dseg.get_byte(0) == 3 && current_object->id == 1) {
					processCallback(0x5189); //boo!
					break;
				}
				if (res->dseg.get_byte(0) == 4 && current_object->id == 5) {
					processCallback(0x99e0); //getting an anchor
					break;
				}
				use(current_object);
				break;
			case Common::EVENT_MOUSEMOVE:
				mouse = event.mouse;
				break;
			default:
				;
			}
		}

		//game delays: slow 16, normal 11, fast 5, crazy 1
		//mark delays: 4 * (3 - hero_speed), normal == 1
		//game delays in 1/100th of seconds
		uint32 new_timer = _system->getMillis();
		uint32 delta = new_timer - timer;
		timer = new_timer;

		bool tick_game = game_timer <= delta;
		if (tick_game)
			game_timer = _game_delay - ((delta - game_timer) % _game_delay);
		else
			game_timer -= delta;

		bool tick_mark = mark_timer <= delta;
		if (tick_mark)
			mark_timer = _mark_delay - ((delta - mark_timer) % _mark_delay);
		else
			mark_timer -= delta;

		if (tick_game || tick_mark) {
			bool b = scene->render(tick_game, tick_mark, delta);
			if (!inventory->active() && !b && action != kActionNone) {
				processObject();
				action = kActionNone;
				dst_object = NULL;
			}
			scene_busy = b;
		}
		_system->showMouse(scene->getMessage().empty() && !scene_busy);

		bool busy = inventory->active() || scene_busy;

		Graphics::Surface *surface = _system->lockScreen();

		if (!busy) {
			InventoryObject *selected_object = inventory->selectedObject();
			if (current_object || selected_object) {
				Common::String name;
				if (selected_object) {
					name += selected_object->name;
					name += " & ";
				}
				if (current_object)
					name += current_object->name;

				uint w = res->font7.render(NULL, 0, 0, name, 0xd1);
				res->font7.render(surface, (320 - w) / 2, 180, name, 0xd1, true);
#if 0
				if (current_object) {
					current_object->rect.render(surface, 0x80);
					current_object->actor_rect.render(surface, 0x81);
				}
#endif
			}
		}

		inventory->render(surface, tick_game? 1: 0);

		_system->unlockScreen();

		_system->updateScreen();

		console->onFrame();

		uint32 next_tick = MIN(game_timer, mark_timer);
		if (next_tick > 0) {
			_system->delayMillis(next_tick > 40? 40: next_tick);
		}
	} while (!shouldQuit());

	deinit();
	return Common::kNoError;
}
Esempio n. 9
0
//Prints the main menu and change the selection when selection key is pressed
void mainmenu(int i)
{
    //Clears the screen
    system("cls");

    //prints the Logo
    showLogo();

    //draws a hangman
    drawhangman(99);

    //Prints the main menu depending on the cursor's position
    switch(i)
    {
        case 1 :
            printf("\n\t\t\tWelcome to Hangman\n");
            printf("\n\t\t\t[*] Singleplayer");
            printf("\n\t\t\t[] Multiplayer");
            printf("\n\t\t\t[] Battle Mode");
            printf("\n\t\t\t[] How to Play");
            printf("\n\t\t\t[] Credit");
            printf("\n\t\t\t[] Exit");
            break;
        case 2 :
            printf("\n\t\t\tWelcome to Hangman\n");
            printf("\n\t\t\t[] Singleplayer");
            printf("\n\t\t\t[*] Multiplayer");
            printf("\n\t\t\t[] Battle Mode");
            printf("\n\t\t\t[] How to Play");
            printf("\n\t\t\t[] Credit");
            printf("\n\t\t\t[] Exit");
            break;
        case 3 :
            printf("\n\t\t\tWelcome to Hangman\n");
            printf("\n\t\t\t[] Singleplayer");
            printf("\n\t\t\t[] Multiplayer");
            printf("\n\t\t\t[*] Battle Mode");
            printf("\n\t\t\t[] How to Play");
            printf("\n\t\t\t[] Credit");
            printf("\n\t\t\t[] Exit");
            break;
        case 4 :
            printf("\n\t\t\tWelcome to Hangman\n");
            printf("\n\t\t\t[] Singleplayer");
            printf("\n\t\t\t[] Multiplayer");
            printf("\n\t\t\t[] Battle Mode");
            printf("\n\t\t\t[*] How to Play");
            printf("\n\t\t\t[] Credit");
            printf("\n\t\t\t[] Exit");
            break;
        case 5 :
            printf("\n\t\t\tWelcome to Hangman\n");
            printf("\n\t\t\t[] Singleplayer");
            printf("\n\t\t\t[] Multiplayer");
            printf("\n\t\t\t[] Battle Mode");
            printf("\n\t\t\t[] How to Play");
            printf("\n\t\t\t[*] Credit");
            printf("\n\t\t\t[] Exit");
            break;
        case 6 :
            printf("\n\t\t\tWelcome to Hangman\n");
            printf("\n\t\t\t[] Singleplayer");
            printf("\n\t\t\t[] Multiplayer");
            printf("\n\t\t\t[] Battle Mode");
            printf("\n\t\t\t[] How to Play");
            printf("\n\t\t\t[] Credit");
            printf("\n\t\t\t[*] Exit");

        //If the selection is at the lowest or highest then put it to am appropriate position
        default :
            if(i > 6)
            {
                cursor = i = 1;
                mainmenu(cursor);
            }
            else if(i < 1)
            {
                cursor = i = 6;
                mainmenu(cursor);
            }
    }

    printf("\n\tUse the arrow keys to select the menu and ENTER to confirm.");
}
Esempio n. 10
0
int _tmain(int argc, _TCHAR* argv[])
{
	int nChannelCount;
	int nSampleRate;
	int nBitrate=128000;
	int nBitsPerSample=16;
	int nChannelMode=2; //0-Multichannel, 1-Mono, 2-Stereo, 3-IS, 4-PS, 5-DC
	int bMPEG4AAC=9;    // Let the encoder choice: with enc_aacplus.dll 1.24 was 4 but with 1.26 was MPEG2
	int mp4mode = 0;
	int bNoPS = 0;
	int bRawPCM = 0;
	int bSpeech = 0;
	int bPNS = 0;
	int nType=1;        //0- he, 1 - lc, 2 - he-high, 3-PS
	DWORD dwBytesRead;
	_TCHAR szTempDir[MAX_PATH];
	char szTempName[MAX_PATH];
	char lpPathBuffer[BUFSIZE];

	_TCHAR * strOutputFileName = NULL;
	_TCHAR * strInputFileName = NULL;
	FILE*  hInput=NULL;
	FILE*  hOutput=NULL;
	wavHeader wav;

	_tsetlocale(LC_ALL, _T(""));

	if(argc<2)
	{
		showUsage(argv[0]);
		return ERROR_INSUFFICIENT_ARGS;
	}

	strInputFileName	= argv[1];
	strOutputFileName	= argv[2];

	// let's parse command line
	for(int i=3;i<argc;++i)
	{
		if(0==_tcscmp(_T("--rawpcm"), argv[i]))
		{
			nSampleRate=_tstoi(argv[++i]);
			nChannelCount=_tstoi(argv[++i]);
			nBitsPerSample=_tstoi(argv[++i]);
			bRawPCM=1;
			continue;
		}

		if(0==_tcscmp(_T("--mono"), argv[i]))
		{
			nChannelMode=1;
			continue;
		}
		if(0==_tcscmp(_T("--ps"), argv[i]))
		{
			bNoPS=1;
			nType=0;
			//nChannelMode=4; assigned only if bitrate <=56000
			continue;
		}
		if(0==_tcscmp(_T("--is"), argv[i]))
		{
			nChannelMode=3;
			continue;
		}
		if(0==_tcscmp(_T("--dc"), argv[i]))
		{
			nChannelMode=5;
			continue;
		}
		if(0==_tcscmp(_T("--he"), argv[i]))
		{
			nType=0;
			continue;
		}
		if(0==_tcscmp(_T("--lc"), argv[i]))
		{
			nType=1;
			continue;
		}
		if(0==_tcscmp(_T("--high"), argv[i]))
		{
			nType=2;
			continue;
		}
		if(0==_tcscmp(_T("--br"), argv[i]))
		{
			nBitrate=_tstoi(argv[++i]);
			continue;
		}
		if(0==_tcscmp(_T("--mpeg2aac"), argv[i]))
		{
			bMPEG4AAC=0;
			continue;
		}
		if(0==_tcscmp(_T("--mpeg4aac"), argv[i]))
		{
			bMPEG4AAC=1;
			continue;
		}
		if(0==_tcscmp(_T("--speech"), argv[i]))
		{
			bSpeech=1;
			continue;
		}
		if(0==_tcscmp(_T("--pns"), argv[i]))
		{
			bPNS=1;
			continue;
		}
	}

	showLogo();

	int bStdIn = 0==_tcscmp(_T("-"), strInputFileName)?1:0;
	// let's open WAV file
	if(bStdIn)
	{
		#ifdef WIN32
		setmode(fileno(stdin), O_BINARY);
		#endif
		hInput = stdin;
	}
	else
	{
		hInput = _tfopen(strInputFileName,_T("rb"));
	}

	if(!hInput)
	{
		printf("Can't open input file!\n");
		return ERROR_CANNOT_OPEN_INFILE;
	};

	if(0==bRawPCM)
	{
		// let's read WAV HEADER
		memset(&wav, 0, sizeof(wav));
		if(fread(&wav, 1, sizeof(wav), hInput)!=sizeof(wav))
		{
			// Can't read wav header
			fclose(hInput);
			printf("Input file must be WAV PCM!\n");
			return ERROR_CANNOT_LOAD_DECODER;
		}

		if(	wav.chunkid!=0x46464952
			|| wav.rifftype!=0x45564157
			|| wav.fmt!=0x20746D66
			|| wav.fmtsize!=0x00000010
			|| wav.bps!=16
			|| (wav.srate!=32000 && wav.srate!=44100 && wav.srate!=48000 )
			|| wav.ccode!=0x0001)
		{
			// unsupported or invalid wav format
			fclose(hInput);
			printf("Invalid or unsuppored WAV file format (must be 16 bit PCM)\n");
			return ERROR_INCOMPATABLE_DECODER;
		}

		nBitsPerSample	= wav.bps;
		nChannelCount	= wav.nch;
		nSampleRate	= wav.srate;
	}

	int bitrates[3][6] =
	{
		{
		 //he - mono,	 stereo,			6ch
		8000, 64000,	16000, 128000,	96000, 213335
		},
		{
		 //lc - mono,	 stereo,			6ch
		8000, 160000,	16000, 320000,	160000, 320000
		},
		{
		 //hi - mono,	 stereo,			6ch
		64000, 160000,	96000, 256000,	8000, 256000
		}
	};

	int maxBitrate=0;
	int minBitrate=0;

	switch(nChannelCount)
	{
		case 1:
			minBitrate = bitrates[nType][0];
			maxBitrate = bitrates[nType][1];
			break;
		case 2:
			minBitrate = bitrates[nType][2];
			maxBitrate = bitrates[nType][3];
			break;
		default:
			minBitrate = bitrates[nType][4];
			maxBitrate = bitrates[nType][5];
			break;
	}

	const _TCHAR* channelModes[] = {_T("Multichannel"), _T("Mono"), _T("Stereo"), _T("Independant Stereo"), _T("Parametric Stereo"), _T("Dual Channels")};
	const _TCHAR* codecName[] = {_T("HE-AAC"),_T("LC-AAC"),_T("HE-AAC High"),_T("HE-AAC+PS")};
	const _TCHAR* BooleanResult[] = {_T("No"), _T("Yes")};

	nBitrate		= min(max(minBitrate, nBitrate), maxBitrate);

	nChannelMode	= 1==nChannelCount ? 1:((2==nChannelCount) ? ( (nBitrate<=56000 && 0==nType && 1==bNoPS) ? 4:nChannelMode):0);

	if (4==nChannelMode)// only for printf
		nType=3;

	// just to be sure that we have the correct mode
	_TCHAR *ext = PathFindExtension(strOutputFileName);
	if(ext) {
		if(!_tcsicmp(ext,_T(".m4a")) || !_tcsicmp(ext,_T(".mp4"))) mp4mode = 1;
	}

	// let's write used config:
	_tprintf(_T("\nInput file: %s\nOutput file: %s\nSampleRate: %d\nChannelCount: %d\nBitsPerSample: %d\nBitrate: %d\nChannelMode: %s\nEngine: %s\nTune For Speech: %s\nPNS: %s\nMP4 Output: %s\n"),
		strInputFileName, strOutputFileName, nSampleRate, nChannelCount,nBitsPerSample , nBitrate, channelModes[nChannelMode], codecName[nType], BooleanResult[bSpeech?1:0], BooleanResult[bPNS?1:0], BooleanResult[mp4mode?1:0]);
	fflush(stdout);

	if (4==nChannelMode) //back
		nType=0;

	//create temp file name
#ifdef UNICODE
	_TCHAR tempFileW[MAX_PATH];
#endif
	GetTempPath(
		MAX_PATH,   // length of the buffer
        szTempDir);      // buffer for path
#ifdef UNICODE
	GetTempFileName(szTempDir, // directory for temp files
        NULL,                    // temp file name prefix
        0,                        // create unique name
        tempFileW);              // buffer for name
	wcstombs_s(NULL,szTempName,MAX_PATH,tempFileW,(MAX_PATH)*sizeof(_TCHAR));
#else
	GetTempFileName(szTempDir, // directory for temp files
        NULL,                    // temp file name prefix
        0,                        // create unique name
        szTempName);              // buffer for name
#endif

	AudioCoder * encoder=NULL;
	AudioCoder *(*finishAudio3)(_TCHAR *fn, AudioCoder *c)=NULL;
	void (*prepareToFinish)(_TCHAR *filename, AudioCoder *coder)=NULL;
	AudioCoder* (*createAudio3)(int nch, int srate, int bps, unsigned int srct, unsigned int *outt, char *configfile)=NULL;
	HMODULE encplug = LoadLibrary(_T("enc_aacplus.dll"));
	if(NULL == encplug)
	{
		fclose(hInput);
		printf("Can't find enc_aacplus.dll!\n");
		return ERROR_CANNOT_LOAD_ENCODER;
	}
	*(void **)&createAudio3 = (void *)GetProcAddress(encplug, "CreateAudio3");
	if( NULL == createAudio3)
	{
		FreeLibrary(encplug);
		fclose(hInput);
		printf("Can't find CreateAudio3 in enc_aacplus.dll!\n");
		return ERROR_CANNOT_LOAD_DECODER;
	}
#ifdef UNICODE
	*(void **)&finishAudio3=(void *)GetProcAddress(encplug,"FinishAudio3W");
	*(void **)&prepareToFinish=(void *)GetProcAddress(encplug,"PrepareToFinishW");
#else
	*(void **)&finishAudio3=(void *)GetProcAddress(encplug,"FinishAudio3");
	*(void **)&prepareToFinish=(void *)GetProcAddress(encplug,"PrepareToFinish");
#endif

	{
		//const char* codecSection[] = {"audio_aacplus","audio_aac","audio_aacplushigh"};
		FILE * tmp = fopen(szTempName,"wt");
		fprintf(tmp, "[audio%s_aac%s]\nsamplerate=%u\nchannelmode=%u\nbitrate=%u\nv2enable=1\nbitstream=%i\nsignallingmode=0\nspeech=%i\npns=%i\n",
			      mp4mode?"_mp4":"",1==nType?"":2==nType?"plushigh":"plus", nSampleRate, nChannelMode, nBitrate, bMPEG4AAC?5:0, bSpeech?1:0, bPNS?1:0);
		fclose(tmp);

		unsigned int outt = 0;
		if (1==nType)
			outt = mp4mode ? mmioFOURCC('M','4','A',' ') : mmioFOURCC('A','A','C','r');
		else if (2==nType)
			outt = mp4mode ? mmioFOURCC('M','4','A','H') : mmioFOURCC('A','A','C','H');
		else
			outt = mp4mode ? mmioFOURCC('M','4','A','+') : mmioFOURCC('A','A','C','P');
		encoder=createAudio3(nChannelCount,nSampleRate, nBitsPerSample ,mmioFOURCC('P','C','M',' '),&outt,szTempName);
		DeleteFileA(szTempName);
	}


	if(NULL==encoder)
	{
		FreeLibrary(encplug);
		fclose(hInput);
		printf("Can't create encoder!\n");
		return ERROR_CANNOT_OPEN_ENCODER;
	}

	hOutput = _tfopen(strOutputFileName, _T("wb"));

	if (!hOutput)
        {
		delete encoder;
		FreeLibrary(encplug);
		fclose(hInput);
		printf("Can't create output file!\n");
	        return ERROR_CANNOT_OPEN_OUTFILE;
        }

	// encode
	printf("Encoding...");
	int toRead = (2*nChannelCount*2*1024);
	toRead = (sizeof(lpPathBuffer)/toRead)*toRead;
	while(0!=(dwBytesRead = fread(lpPathBuffer, 1, toRead, hInput)))
        {
		_encode(hOutput, encoder, dwBytesRead, lpPathBuffer, bMPEG4AAC);
        }
	printf("\rFinalizing...");

	// finalize encoding
	if(prepareToFinish) prepareToFinish(strOutputFileName,encoder);
	_finalize(hOutput, encoder, lpPathBuffer, bMPEG4AAC);
	fclose(hOutput);
	if (finishAudio3) finishAudio3(strOutputFileName,encoder);
	fclose(hInput);
	delete encoder;
	FreeLibrary(encplug);

	if(mp4mode) {
		struct __stat64 statbuf;
		if(!_tstat64(strOutputFileName,&statbuf)) {
			if(!_tfopen_s(&hOutput,strOutputFileName,_T("r+b"))) {
				optimizeAtoms(hOutput,statbuf.st_size);
			}
			if(hOutput) fclose(hOutput);
		}
	}

	// shut down
	printf("\rDone           \n");
	return TRANSCODE_FINISHED_OK;
}
Esempio n. 11
0
Miku_Oled::Miku_Oled()
{
  buffer=buf+1;
  buf[0]=0x40;
  showLogo();
}
Esempio n. 12
0
int play(void) 
{
	 
	void result(char [],char []);
	static struct sigaction act; 
	act.sa_handler = SIG_IGN; 
	sigfillset(&(act.sa_mask)); 
	sigaction(SIGTSTP, &act, 0);

	signal(SIGUSR1,playerWinhandler);
	signal(SIGUSR2,playerWinhandler);

	struct sockaddr_in server = {AF_INET, 8001}; 
	server.sin_addr.s_addr = inet_addr("127.0.0.1"); 

	int sockfd,i; 
	int row,column,choice;
	int iclientRead; 		
	char input; 
	char a[2][40];
	char pid[4];
	char clientRead[3][3];
	char clientWrite[1];
	

	char numberBoard [3][3] = {							// to display positions to choose from
	 		         		{'1','2','3'},
		        			{'4','5','6'},
		       				{'7','8','9'}
	       		          }; 

        char playBoard [3][3] =   {							// to display the actual game status
			         		{' ',' ',' '},
						{' ',' ',' '},
		       				{' ',' ',' '}
	                          };


	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
	{
		perror("Socket Call Failed");
		exit(1);
	}

	if ( connect (sockfd, (struct sockaddr *)&server, SIZE) == -1) 
	{ 
		perror("Connect Call Failed"); 
		exit(1); 
	} 
	
	read(sockfd,a,sizeof(a));
	printf("%s\n",a[0]);

	if(strcmp(a[1],"0")==0)
	{
		int num1 = getpid();
		sprintf(pid,"%d",num1);
		write(sockfd, pid, sizeof(pid));	
		read(sockfd,a,sizeof(a));
		printf("%s\n",a[0]);
		showLogo();
	}

	if(strcmp(a[1],"2")==0)
	{
	int num2 = getpid();
	sprintf(pid,"%d",num2);
	write(sockfd, pid, sizeof(pid));	
	}
	
	if (strcmp(a[1],"1")!=0)
	{
		
		showLogo();		
		mapBoard(numberBoard);	
		printf("\n    Number Board\n\n");
		for(;;)
			{
			printf("\nPlayer %d,Please enter the number of the square where you want to place your '%c': \n",(strcmp(a[1], "1")==0)?1:2,(strcmp(a[1], "1")==0)?'X':'O');
			scanf("%s",clientWrite);

			choice = atoi(clientWrite);
			row = --choice/3;
			column = choice%3;
		
			if(choice<0 || choice>9 || playBoard [row][column]>'9'|| playBoard [row][column]=='X' || playBoard [row][column]=='O')
				printf("Invalid Input. Please Enter again.\n\n");
		
			else
			{
				playBoard[row][column] = (strcmp(a[1], "1")==0)?'X':'O';					
				break;
			}
			}	

		write(sockfd, clientWrite, sizeof(clientWrite));	
		system("clear");
		showLogo();
		mapBoard(playBoard);
		printf("\nCurrent Play Board\n\n");
	}

	for(input = 'x';;) 
	{ 	
		if (input == '\n') 
		{	if (te==0)
			{
				mapBoard(numberBoard);	
				printf("\n    Number Board\n\n");
			}					
			for(;;)
			{	
				if (te==0)
				{
					printf("\nPlayer %d, Now your turn .. Please enter the number of the square where you want to place your '%c': \n",(strcmp(a[1], "1")==0)?1:2,(strcmp(a[1], "1")==0)?'X':'O');
					scanf("%s",clientWrite);
			
					choice = atoi(clientWrite);
					row = --choice/3;
					column = choice%3;
			
					if(choice<0 || choice>9 || playBoard [row][column]>'9'|| playBoard [row][column]=='X' || playBoard [row][column]=='O')
						printf("Invalid Input. Please Enter again.\n\n");
		
					else
					{
						playBoard[row][column] = (strcmp(a[1], "1")==0)?'X':'O';
						break;
					}
				}
			}	
			
			write(sockfd, clientWrite, sizeof(clientWrite));
			system("clear");
			showLogo();
			mapBoard(playBoard);
			printf("\nCurrent Play Board\n\n");
			if (te==1)
				{
				printf("Player 1 Wins!!\n");
				exit(0);
				}
   			if (te==2)
				{
				printf("Player 2 Wins!!\n");
				exit(0);
   				}
		}

		if (read(sockfd, clientRead, sizeof(clientRead)) >0) 
		{
			system("clear");
			showLogo();
			memcpy(playBoard, clientRead, sizeof(playBoard));	// copy the contents of the array received from server side in playBoard array
			mapBoard(playBoard);
			printf("\nCurrent Play Board\n\n");
			input = '\n';
			if (te==1)
				{
				printf("Player 1 Wins!!\n");
				exit(0);
				}
   			if (te==2)
				{
				printf("Player 2 Wins!!\n");
				exit(0);
   				}
		}	
		else 
		{
			printf("You Win!! Thank You, Please Play Again :D\n");
			close(sockfd);
			exit(1); 
		} 
		
}
}
Esempio n. 13
0
int main(int cArgs, char **apszArgs)
{
     int rc = RTR3InitExe(cArgs, &apszArgs, 0);
     if (RT_FAILURE(rc))
         return RTMsgInitFailure(rc);

     enum
     {
         OPTION_FORMAT = 1,
         OPTION_COMMAND,
         OPTION_ARGUMENTS,
         OPTION_DESCRIPTION,
         OPTION_SERVICE_NAME,
         OPTION_ONE_SHOT,
         OPTION_STOP_COMMAND,
         OPTION_STOP_ARGUMENTS,
         OPTION_STATUS_COMMAND,
         OPTION_STATUS_ARGUMENTS
     };

     static const RTGETOPTDEF s_aOptions[] =
     {
         { "--format",             OPTION_FORMAT,
           RTGETOPT_REQ_STRING },
         { "--command",            OPTION_COMMAND,
           RTGETOPT_REQ_STRING },
         { "--arguments",          OPTION_ARGUMENTS,
           RTGETOPT_REQ_STRING },
         { "--description",        OPTION_DESCRIPTION,
           RTGETOPT_REQ_STRING },
         { "--service-name",       OPTION_SERVICE_NAME,
           RTGETOPT_REQ_STRING },
         { "--one-shot",           OPTION_ONE_SHOT,
           RTGETOPT_REQ_NOTHING },
         { "--stop-command",       OPTION_STOP_COMMAND,
           RTGETOPT_REQ_STRING },
         { "--stop-arguments",     OPTION_STOP_ARGUMENTS,
           RTGETOPT_REQ_STRING },
         { "--status-command",     OPTION_STATUS_COMMAND,
           RTGETOPT_REQ_STRING },
         { "--status-arguments",   OPTION_STATUS_ARGUMENTS,
           RTGETOPT_REQ_STRING }
     };

     int ch;
     struct SERVICEPARAMETERS Parameters = { FORMAT_NONE };
     RTGETOPTUNION ValueUnion;
     RTGETOPTSTATE GetState;
     RTGetOptInit(&GetState, cArgs, apszArgs, s_aOptions,
                  RT_ELEMENTS(s_aOptions), 1, 0);
     while ((ch = RTGetOpt(&GetState, &ValueUnion)))
     {
         switch (ch)
         {
             case 'h':
                 showUsage(apszArgs[0]);
                 return RTEXITCODE_SUCCESS;
                 break;

             case 'V':
                 showLogo();
                 return RTEXITCODE_SUCCESS;
                 break;

             case OPTION_FORMAT:
                 if (errorIfSet("--format",
                                Parameters.enmFormat != FORMAT_NONE))
                     return(RTEXITCODE_SYNTAX);
                 Parameters.enmFormat
                     = getFormat("--format", ValueUnion.psz);
                 if (Parameters.enmFormat == FORMAT_NONE)
                     return(RTEXITCODE_SYNTAX);
                 break;

             case OPTION_COMMAND:
                 if (errorIfSet("--command", Parameters.pcszCommand))
                     return(RTEXITCODE_SYNTAX);
                 Parameters.pcszCommand = ValueUnion.psz;
                 if (!checkAbsoluteFilePath("--command",
                                            Parameters.pcszCommand))
                     return(RTEXITCODE_SYNTAX);
                 break;

             case OPTION_ARGUMENTS:
                 if (errorIfSet("--arguments",
                                Parameters.pcszArguments))
                     return(RTEXITCODE_SYNTAX);
                 /* Quoting will be checked while writing out the string. */
                 Parameters.pcszArguments = ValueUnion.psz;
                 break;

             case OPTION_DESCRIPTION:
                 if (errorIfSet("--description",
                                Parameters.pcszDescription))
                     return(RTEXITCODE_SYNTAX);
                 Parameters.pcszDescription = ValueUnion.psz;
                 if (!checkPrintable("--description",
                                     Parameters.pcszDescription))
                     return(RTEXITCODE_SYNTAX);
                 break;

             case OPTION_SERVICE_NAME:
                 if (errorIfSet("--service-name",
                                Parameters.pcszServiceName))
                     return(RTEXITCODE_SYNTAX);
                 Parameters.pcszServiceName = ValueUnion.psz;
                 if (!checkGraphic("--service-name",
                                   Parameters.pcszServiceName))
                     return(RTEXITCODE_SYNTAX);
                 break;

             case OPTION_ONE_SHOT:
                 Parameters.fOneShot = true;
                 break;

             case OPTION_STOP_COMMAND:
                 if (errorIfSet("--stop-command",
                                Parameters.pcszStopCommand))
                     return(RTEXITCODE_SYNTAX);
                 Parameters.pcszStopCommand = ValueUnion.psz;
                 if (!checkAbsoluteFilePath("--stop-command",
                         Parameters.pcszStopCommand))
                     return(RTEXITCODE_SYNTAX);
                 break;

             case OPTION_STOP_ARGUMENTS:
                 if (errorIfSet("--stop-arguments",
                                Parameters.pcszStopArguments))
                     return(RTEXITCODE_SYNTAX);
                 /* Quoting will be checked while writing out the string. */
                 Parameters.pcszStopArguments = ValueUnion.psz;
                 break;

             case OPTION_STATUS_COMMAND:
                 if (errorIfSet("--status-command",
                                Parameters.pcszStatusCommand))
                     return(RTEXITCODE_SYNTAX);
                 Parameters.pcszStatusCommand = ValueUnion.psz;
                 if (!checkAbsoluteFilePath("--status-command",
                         Parameters.pcszStatusCommand))
                     return(RTEXITCODE_SYNTAX);
                 break;

             case OPTION_STATUS_ARGUMENTS:
                 if (errorIfSet("--status-arguments",
                                Parameters.pcszStatusArguments))
                     return(RTEXITCODE_SYNTAX);
                 /* Quoting will be checked while writing out the string. */
                 Parameters.pcszStatusArguments = ValueUnion.psz;
                 break;

             default:
                 return RTGetOptPrintError(ch, &ValueUnion);
         }
     }
     if (Parameters.enmFormat == FORMAT_NONE)
     {
         RTStrmPrintf(g_pStdErr, "--format must be specified.\n");
         return(RTEXITCODE_SYNTAX);
     }
     if (Parameters.pcszArguments && !Parameters.pcszCommand)
     {
         RTStrmPrintf(g_pStdErr, "--arguments requires --command to be specified.\n");
         return(RTEXITCODE_SYNTAX);
     }
     if (Parameters.pcszStopArguments && !Parameters.pcszStopCommand)
     {
         RTStrmPrintf(g_pStdErr, "--stop-arguments requires --stop-command to be specified.\n");
         return(RTEXITCODE_SYNTAX);
     }
     if (Parameters.pcszStatusArguments && !Parameters.pcszStatusCommand)
     {
         RTStrmPrintf(g_pStdErr, "--status-arguments requires --status-command to be specified.\n");
         return(RTEXITCODE_SYNTAX);
     }
     return createServiceFile(&Parameters)
            ? RTEXITCODE_SUCCESS
            : RTEXITCODE_FAILURE;
}