当前位置: 首页>>代码示例>>C++>>正文


C++ clean_up函数代码示例

本文整理汇总了C++中clean_up函数的典型用法代码示例。如果您正苦于以下问题:C++ clean_up函数的具体用法?C++ clean_up怎么用?C++ clean_up使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了clean_up函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main( int argc, char* args[] ) {
    bool quit = false;
    if ( init() == false ) {
        return 1;
    }

    if ( load_files() == false ) {
        return 1;
    }

    //Make the timer 
    Timer myTimer;

    //Generate the message surfaces
    startStop = TTF_RenderText_Solid( font, "Press S to start or stop the timer", textColor );
    pauseMessage = TTF_RenderText_Solid( font, "Press P to pause or unpause the timer", textColor );

    //Start the timer
    myTimer.start();

    //While the user hasn't quit
    while ( quit == false ) {
        while ( SDL_PollEvent( &event ) ) {
            if ( event.type == SDL_KEYDOWN ) {
                if ( event.key.keysym.sym == SDLK_s) {
                    if ( myTimer.is_started() == true ) {
                        myTimer.stop();
                    } else {
                        myTimer.start();
                    }
                }

                if ( event.key.keysym.sym == SDLK_p ) {
                    if ( myTimer.is_paused() == true ) {
                        myTimer.unpause();
                    } else {
                        myTimer.pause();
                    }
                }

                
            } else if ( event.type == SDL_QUIT ) {
                quit = true;
            }
        }

        apply_surface( 0, 0, background, screen );
        apply_surface( ( SCREEN_WIDTH -  startStop->w ) / 2, 200, startStop, screen );
        apply_surface( ( SCREEN_WIDTH - pauseMessage->w ) / 2, 250, pauseMessage, screen );

        //The timer's time as a string
        std::stringstream time;

        time << "Timer: " << myTimer.get_ticks() / 1000.f;

        seconds = TTF_RenderText_Solid( font, time.str().c_str(), textColor );

        apply_surface( ( SCREEN_WIDTH - seconds->w ) / 2, 0, seconds, screen );

        SDL_FreeSurface( seconds );

        if ( SDL_Flip( screen ) == -1 ) {
            return 1;
        }
        
    }

    //Clean up
    clean_up();
    return 0;
        
}
开发者ID:Ebadly,项目名称:2D-Side-Scroller,代码行数:72,代码来源:adv_timing.cpp

示例2: main

int main( int argc, char* args[] )
{
    //Quit flag
    bool quit = false;

    //The ship that will be used
    Ship myShip;

    //Keeps track of time since last rendering
    Timer delta;

    //Initialize
    if( init() == false )
    {
        return 1;
    }

    //Load the files
    if( load_files() == false )
    {
        return 1;
    }

    //Start delta timer
    delta.start();

    //While the user hasn't quit
    while( quit == false )
    {
        //While there's events to handle
        while( SDL_PollEvent( &event ) )
        {
            //Handle events for the ship
            myShip.handle_input();

            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }

        //Move the ship
        myShip.move( delta.get_ticks() );

        //Restart delta timer
        delta.start();

        //Fill the screen white
        //SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF ) );

        //Show the ship on the screen
        myShip.show();

        //Update the screen
        if( SDL_Flip( screen ) == -1 )
        {
            return 1;
        }
    }

    //Clean up
    clean_up();

    return 0;
}
开发者ID:benphelps,项目名称:2D-Space-Shooter,代码行数:67,代码来源:ship.cpp

示例3: main

int main(int argc, char* args[]) {

  //make sure the program waits for a quit
  bool quit = false;

  if (!init()) {
    std::cerr << "failed to initialize SDL" << std::endl;
    return 1;
  }

  //load files
  if(!load_files()) {
    std::cerr << "failed to load images" << std::endl;
    return 1;
  }

  //top left
  clip[0].x = 0;
  clip[0].y = 0;
  clip[0].w = 100;
  clip[0].h = 100;

  //top right
  clip[1].x = 100;
  clip[1].y = 0;
  clip[1].w = 100;
  clip[1].h = 100;

  //bottom left
  clip[2].x = 0;
  clip[2].y = 100;
  clip[2].w = 100;
  clip[2].h = 100;

  //bottom right
  clip[3].x = 100;
  clip[3].y = 100;
  clip[3].w = 100;
  clip[3].h = 100;

  SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF) );

  //apply image to screen
  //  apply_surface(0, 0, background, screen);
  apply_surface(0, 0, image, screen, &clip[0]);
  apply_surface(540, 0, image, screen, &clip[1]);
  apply_surface(0, 380, image, screen, &clip[2]);
  apply_surface(540, 380, image, screen, &clip[3]);

  //update screen
  if ( SDL_Flip(screen) == -1) {
    std::cerr << "error flipping screen" << std::endl;
    return 1;
  }

  //Pause
  while(!quit) {
    while( SDL_PollEvent(&event) ) {
      //if user quits
      if(event.type==SDL_QUIT) {
	//quit program
	quit = true;
      }
    }
  }
  clean_up();

  return 0;    
}
开发者ID:kfinelli,项目名称:learn-sdl,代码行数:69,代码来源:sprite.cpp

示例4: main

int
main (int argc, char *argv[])
{
	ret_t               ret;
	cherokee_boolean_t  single_time;
	const char         *config_file_path;

	/* Find the worker exec
	 */
	figure_worker_path (argv[0]);

	/* Sanity check
	 */
	ret = check_worker_version (argv[0]);
	if (ret != ret_ok)
		exit (EXIT_ERROR);

	set_signals();
	single_time = is_single_execution (argc, argv);

	/* Figure out some stuff
	 */
	config_file_path = figure_config_file (argc, argv);
	use_valgrind     = figure_use_valgrind (argc, argv);
	pid_file_path    = figure_pid_file_path (config_file_path);
	worker_uid       = figure_worker_uid (config_file_path);
	worker_retcode   = -1;

	/* Turn into a daemon
	 */
	if (! single_time) {
		may_daemonize (argc, argv);
		pid_file_save (pid_file_path, getpid());
	}

	/* Launch the spawning thread
	 */
#ifdef HAVE_SYSV_SEMAPHORES
	if (! single_time) {
		ret = spawn_init();
		if (ret != ret_ok) {
			PRINT_MSG_S ("(warning) Couldn't initialize spawn mechanism.\n");
		}
	}
#endif

	while (true) {
		graceful_restart = false;

		pid = process_launch (cherokee_worker, argv);
		if (pid < 0) {
			PRINT_MSG ("(critical) Couldn't launch '%s'\n", cherokee_worker);
			exit (EXIT_ERROR);
		}

		ret = process_wait (pid);
		if (single_time)
			break;

		usleep ((ret == ret_ok) ?
			DELAY_RESTARTING :
			DELAY_ERROR);
	}

	if (! single_time) {
		clean_up();
	}

	return (worker_retcode == 0) ? EXIT_OK : EXIT_ERROR;
}
开发者ID:Daniel15,项目名称:webserver,代码行数:70,代码来源:main.c

示例5: main


//.........这里部分代码省略.........

                if(event.key.keysym.sym == SDLK_1 && debug == true)//Adjusting velocity via the 1 number key in debuging mode
                {
                    bullet.xVelocity += 100;
                    bullet.yVelocity += 100;
                }
                else if(event.key.keysym.sym == SDLK_2 && debug == true)//Adjusting velocity via the 2 number key in debuging mode
                {
                    bullet.xVelocity -= 100;
                    bullet.yVelocity -= 100;
                }
                else if(event.key.keysym.sym == SDLK_F1)//Enabling or disabling debuging mode ( information of velocities)
                {
                    if(debug == false)
                    {
                        debug = true;
                    }
                    else
                    {
                        debug = false;
                    }

                }
            }

            control.handle_input();//Handle the paddle's movement

            if(event.type == SDL_QUIT)
            {
                quit = true;
            }
        }

        deltaTicks = SDL_GetTicks() - startTicks;//Frame rate
        control.move(deltaTicks);
        bullet.move(control.player,tiles,deltaTicks,destroyedTile);//Moving the ball

        SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0x00, 0x00, 0x00 ) );//Black color every frame


        for( int t = 0; t < TOTAL_TILES; t++ )
        {
           if(destroyedTile[t] == 0)
           {
               tiles[ t ]->show();

           }
        }

        control.show();
        bullet.show();

        sprintf(ballVelX,"xVel %d",bullet.xVelocity);//Formating text to be displayed for the HUD
        sprintf(ballVelY,"yVel %d",bullet.yVelocity);
        sprintf(playerLife,"Life : %d",bullet.life);

        showBallvelocityX = TTF_RenderText_Solid(font,ballVelX,textColor);
        showBallvelocityY = TTF_RenderText_Solid(font,ballVelY,textColor);

        life = TTF_RenderText_Solid(font,playerLife,textColor);

        apply_surface(20, 10, life, screen );

        if(debug == true)
        {
            apply_surface(20, 50, showBallvelocityX, screen );
            apply_surface(20, 70, showBallvelocityY, screen );
            SDL_FreeSurface(showBallvelocityY);
            SDL_FreeSurface(showBallvelocityX);
        }

        startTicks = SDL_GetTicks();
        deltaTicks = 0;


        for( int t = 0; t < TOTAL_TILES; t++ )//Checking how many tiles are destroyed in the game
        {
           if(destroyedTile[t] == 1)
           {
               tilesDestroyed++;
           }
        }


        if(bullet.life == 0 || tilesDestroyed == TOTAL_TILES)//Close the game if life drops to zero or all the tiles are destroyed in the game
        {
            quit = true;
        }

        if( SDL_Flip( screen ) == -1 )
        {
            return 1;
        }
    }


    clean_up();
    return 0;

}
开发者ID:ThanosRestas,项目名称:Breakout-SDL,代码行数:101,代码来源:main.cpp

示例6: main

int main( int argc, char* args[] )
{
    //Quit flag
    bool quit = false;

    //The square
    Square mySquare;

    //The frame rate regulator
    Timer fps;

    //Initialize
    if( init() == false )
    {
        return 1;
    }

    //Load the files
    if( load_files() == false )
    {
        return 1;
    }

    //Set the wall
    wall.x = 300;
    wall.y = 40;
    wall.w = 40;
    wall.h = 400;

    //While the user hasn't quit
    while( quit == false )
    {
        //Start the frame timer
        fps.start();

        //While there's events to handle
        while( SDL_PollEvent( &event ) )
        {
            //Handle events for the square
            mySquare.handle_input();

            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }

        //Move the square
        mySquare.move();

        //Fill the screen white
        SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF ) );

        //Show the wall
        SDL_FillRect( screen, &wall, SDL_MapRGB( screen->format, 0x77, 0x77, 0x77 ) );

        //Show the square on the screen
        mySquare.show();

        //Update the screen
        if( SDL_Flip( screen ) == -1 )
        {
            return 1;
        }

        //Cap the frame rate
        if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
        {
            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
        }
    }

    //Clean up
    clean_up();

    return 0;
}
开发者ID:jcavalu3,项目名称:SDL,代码行数:79,代码来源:lesson17.cpp

示例7: cluster_shutdown

static void
cluster_shutdown(int nsig)
{
    clean_up(0);
}
开发者ID:krig,项目名称:sbd,代码行数:5,代码来源:sbd-cluster.c

示例8: main

int main( int argc, char* args[] )
{
    //Initialize
    if( init() == false )
    {
        return 1;
    }

    SDL_Surface* images[4];
    image = load_image("vida.png");
    images[0]=load_image( "run01.png" );
    images[1]=load_image( "run02.png" );
    images[2]=load_image( "run03.png" );
    images[3]=load_image( "run04.png" );

    int a=50;
    int b=50;
    bool cont = true;
    int x=0;
    while(cont){

        if(x>3){
            x=0;
        }
        //If there was a problem in loading the image
        if( images == NULL )
        {
            return 1;
        }

        SDL_Event event;
        //While there's events to handle
        while( SDL_PollEvent( &event ) )
        {
            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
//                quit = true;
                cont = false;
            }
        }

        Uint8 *keystates = SDL_GetKeyState( NULL );

        if(keystates[SDLK_RIGHT]){
            a += 10;
        }

        if(keystates[SDLK_LEFT]){
            a -= 10;
        }

        if(keystates[SDLK_UP]){
            b -= 10;
        }

        if(keystates[SDLK_DOWN]){
            b += 10;
        }

        //Apply the surface to the screen
        apply_surface(0,0, image,screen);
        apply_surface( a, b, images[x], screen );

        //Update the screen
        if( SDL_Flip( screen ) == -1 )
        {
            return 1;
        }





        //Wait 2 seconds
        SDL_Delay( 20 );

        x++;
    }
    //Free the surface and quit SDL
    clean_up();

    return 0;
}
开发者ID:iko21,项目名称:tarea5,代码行数:85,代码来源:main.cpp

示例9: fprint_gas_data

EXPORT	void fprint_gas_data(
	FILE		*file,
	Locstate	state)
{
	(void) fprintf(file,"State information for the ");
	if (state == NULL)
	{
	    (void) fprintf(file,"NULL state 0x%p\n\n",(POINTER)state);
	    return;
	}
	if (is_obstacle_state(state)) 
	{
	    (void) fprintf(file,"OBSTACLE state 0x%p\n\n",(POINTER)state);
	    return;
	}
	(void) fprintf(file,"state 0x%p\n",(POINTER)state);
	(void) fprintf(file,"\tState Data ");
	if (is_binary_output() == YES)
	{
	    uint64_t prms;
	    float    *x;
	    int      stype = state_type(state);
	    int      failed = material_failure(state);

	    (void) fprintf(file,"\f%c",(char)Params(state)->sizest);
	    x = &Dens(state);
	    (void) fwrite((const void *)x,FLOAT,2+SMAXD,file);
	    prms = gas_param_number(Params(state));
	    (void) fwrite((const void *)&prms,sizeof(uint64_t),1,file);
	    (void) fwrite((const void *)&stype,sizeof(int),1,file);
	    (void) fwrite((const void *)&failed,sizeof(int),1,file);
#if defined(COMBUSTION_CODE)
	    switch (Composition_type(state))
	    {
	    case ZND:
	    case PTFLAME:
	        (void) fwrite((const void *)pdens(state),FLOAT,1,file);
		break;
	    case TWO_CONSTITUENT_REACTIVE:
	        (void) fwrite((const void *)pdens(state),FLOAT,2,file);
		break;
	    case PURE_NON_REACTIVE:
	    default:
	        break;
	    }
#endif /* defined(COMBUSTION_CODE) */
            if(g_composition_type() == MULTI_COMP_NON_REACTIVE)
            {
                if(Params(state) != NULL &&
                   Params(state)->n_comps != 1)
                {
                    int i;
                    for(i = 0; i < Params(state)->n_comps; i++)
                        (void) fwrite((const void *)&(pdens(state)[i]),FLOAT,1,file);
                }
            }
	    (void) fprintf(file,"\n");
	    return;
	}
	(void) fprintf(file,"\n");
	switch (state_type(state))
	{
	case GAS_STATE:
	    g_fprint_state(file,state);
	    break;

	case EGAS_STATE:
	    g_fprint_Estate(file,state);
	    break;

	case TGAS_STATE:
	    g_fprint_Tstate(file,state);
	    break;

	case FGAS_STATE:
	    g_fprint_Fstate(file,state);
	    break;

	case VGAS_STATE:
	    verbose_fprint_state(file,"",state);
	    break;

	default:
	    screen("ERROR in fprint_gas_data(), "
	           "unknown state type %d\n",state_type(state));
	    clean_up(ERROR);
	}
}		/*end fprint_gas_data*/
开发者ID:irisvogon,项目名称:fulldomain,代码行数:88,代码来源:gprstate.c

示例10: main

/** main 
 *
 */
int
main ( int argc, char **argv )
{
	fprintf( stderr, "lsmi-joystick" " v" VERSION "\n" );

	get_args( argc, argv );

	fprintf( stderr, "Registering MIDI port...\n" );

	seq = open_client( CLIENT_NAME );

	if ( NULL == seq )
	{
		fprintf( stderr, "Error opening alsa sequencer!\n" );
		exit( 1 );
	}

	if ( ( port = open_output_port( seq ) ) < 0 )
	{
		fprintf( stderr, "Error opening MIDI output port!\n" );
		exit( 1 );
	}

	if ( sub_name )
	{
		snd_seq_addr_t addr;

		if ( snd_seq_parse_address( seq, &addr, sub_name ) < 0 )
			fprintf( stderr, "Couldn't parse address '%s'", sub_name );
		else
		if ( snd_seq_connect_to( seq, port, addr.client, addr.port ) < 0 )
		{
			fprintf( stderr, "Error creating subscription for port %i:%i", addr.client, addr.port );
			exit( 1 );
		}
	}

	if ( daemonize )
	{
		printf( "Running as daemon...\n" );
		if ( fork() )
			exit( 0 );
		else
		{
			fclose( stdout );
			fclose( stderr );
		}
	}

	fprintf( stderr, "Initializing joystick...\n" );

	if ( -1 == ( jfd = open( joydevice, O_RDONLY ) ) )
	{
		fprintf( stderr, "Error opening event interface! (%s)\n", strerror( errno ) );
		clean_up();
		exit(1);
	}

	set_traps();

	fprintf( stderr, "Waiting for events...\n" );

	for ( ;; )
	{
		struct js_event e;
		snd_seq_event_t ev;
		static int b1;
		static int b2;

		read (jfd, &e, sizeof(struct js_event));

		snd_seq_ev_clear( &ev );

		switch (e.type)
		{
			case JS_EVENT_BUTTON:
				switch (e.number)
				{
					case 0:
						if(e.value)
							b1 = 1;
						else
						{
							b1 = 0;
							snd_seq_ev_set_pitchbend( &ev, channel, 0 );

							send_event( &ev );
						}
						break;
					case 1:
						if (e.value)
							b2 = 1;
						else
						{
							b2 = 0;
							snd_seq_ev_set_controller( &ev, channel, 1, 0 );
							send_event( &ev );
//.........这里部分代码省略.........
开发者ID:original-male,项目名称:lsmi,代码行数:101,代码来源:lsmi-joystick.c

示例11: clean_up

 ~RAII_guard() { clean_up(); }
开发者ID:Expander,项目名称:FlexibleSUSY,代码行数:1,代码来源:raii.hpp

示例12: srv_run

int srv_run(const std::string& table_prefix, bool use_sql, const std::string& conf_file)
{
	for (int i = 0; i < 8; i++)
		m_secret = m_secret << 8 ^ rand();
	m_conf_file = conf_file;
	m_database.set_name("config", table_prefix + "config");
	m_table_prefix = table_prefix;
	m_use_sql = use_sql;

	read_config();
	if (test_sql())
		return 1;
	if (m_epoll.create() == -1)
	{
		std::cerr << "epoll_create failed" << std::endl;
		return 1;
	}
	std::list<Ctcp_listen_socket> lt;
	std::list<Cudp_listen_socket> lu;
	for (auto& j : m_config.m_listen_ipas)
	{
		for (auto& i : m_config.m_listen_ports)
		{
			Csocket l;
			if (l.open(SOCK_STREAM) == INVALID_SOCKET)
				std::cerr << "socket failed: " << Csocket::error2a(WSAGetLastError()) << std::endl;
			else if (l.setsockopt(SOL_SOCKET, SO_REUSEADDR, true),
				l.bind(j, htons(i)))
				std::cerr << "bind failed: " << Csocket::error2a(WSAGetLastError()) << std::endl;
			else if (l.listen())
				std::cerr << "listen failed: " << Csocket::error2a(WSAGetLastError()) << std::endl;
			else
			{
#ifdef SO_ACCEPTFILTER
				accept_filter_arg afa;
				bzero(&afa, sizeof(afa));
				strcpy(afa.af_name, "httpready");
				if (l.setsockopt(SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)))
					std::cerr << "setsockopt failed: " << Csocket::error2a(WSAGetLastError()) << std::endl;
#elif 0 // TCP_DEFER_ACCEPT
				if (l.setsockopt(IPPROTO_TCP, TCP_DEFER_ACCEPT, 90))
					std::cerr << "setsockopt failed: " << Csocket::error2a(WSAGetLastError()) << std::endl;
#endif
				lt.push_back(Ctcp_listen_socket(l));
				if (!m_epoll.ctl(EPOLL_CTL_ADD, l, EPOLLIN | EPOLLOUT | EPOLLPRI | EPOLLERR | EPOLLHUP, &lt.back()))
					continue;
			}
			return 1;
		}
		for (auto& i : m_config.m_listen_ports)
		{
			Csocket l;
			if (l.open(SOCK_DGRAM) == INVALID_SOCKET)
				std::cerr << "socket failed: " << Csocket::error2a(WSAGetLastError()) << std::endl;
			else if (l.setsockopt(SOL_SOCKET, SO_REUSEADDR, true),
				l.bind(j, htons(i)))
				std::cerr << "bind failed: " << Csocket::error2a(WSAGetLastError()) << std::endl;
			else
			{
				lu.push_back(Cudp_listen_socket(l));
				if (!m_epoll.ctl(EPOLL_CTL_ADD, l, EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP, &lu.back()))
					continue;
			}
			return 1;
		}
	}
	clean_up();
	read_db_torrents();
	read_db_users();
	write_db_torrents();
	write_db_users();
#ifndef NDEBUG
	// test_announce();
#endif
#ifndef WIN32
	if (m_config.m_daemon)
	{
		if (daemon(true, false))
			std::cerr << "daemon failed" << std::endl;
		std::ofstream(m_config.m_pid_file.c_str()) << getpid() << std::endl;
		struct sigaction act;
		act.sa_handler = sig_handler;
		sigemptyset(&act.sa_mask);
		act.sa_flags = 0;
		if (sigaction(SIGTERM, &act, NULL))
			std::cerr << "sigaction failed" << std::endl;
		act.sa_handler = SIG_IGN;
		if (sigaction(SIGPIPE, &act, NULL))
			std::cerr << "sigaction failed" << std::endl;
	}
#endif
#ifdef EPOLL
	std::array<epoll_event, 64> events;
#else
	fd_set fd_read_set;
	fd_set fd_write_set;
	fd_set fd_except_set;
#endif
	while (!g_sig_term)
	{
//.........这里部分代码省略.........
开发者ID:blacklizard,项目名称:xbt,代码行数:101,代码来源:server.cpp

示例13: clean_up

void clean_up()
{
	for (auto& i : m_torrents)
		clean_up(i.second, srv_time() - static_cast<int>(1.5 * m_config.m_announce_interval));
	m_clean_up_time = srv_time();
}
开发者ID:blacklizard,项目名称:xbt,代码行数:6,代码来源:server.cpp

示例14: AVIBegin

int AVIBegin(const char* filename, struct AVIFile* _avi_out)
{
	AVIFile& avi = *_avi_out;
	int result = 0;

	do
	{
		if(!avi.video_added)
			break;

		if(!truncate_existing(filename))
			break;

		// open the file
		if(FAILED(AVIFileOpen(&avi.avi_file, filename, OF_CREATE | OF_WRITE, NULL)))
			break;

		// create the video stream
		memset(&avi.avi_video_header, 0, sizeof(AVISTREAMINFO));
		avi.avi_video_header.fccType = streamtypeVIDEO;
		avi.avi_video_header.dwScale = ONE_DOT_CYCLE*SNES_HCOUNTER_MAX*SNES_MAX_NTSC_VCOUNTER;
		avi.avi_video_header.dwRate = (int)NTSC_MASTER_CLOCK;
		avi.avi_video_header.dwSuggestedBufferSize = avi.bitmap_format.biSizeImage;
		if(FAILED(AVIFileCreateStream(avi.avi_file, &avi.streams[VIDEO_STREAM], &avi.avi_video_header)))
			break;

		if(use_prev_options)
		{
			avi.compress_options[VIDEO_STREAM] = saved_avi_info.compress_options[VIDEO_STREAM];
			avi.compress_options_ptr[VIDEO_STREAM] = &avi.compress_options[0];
		}
		else
		{
			// get compression options
			memset(&avi.compress_options[VIDEO_STREAM], 0, sizeof(AVICOMPRESSOPTIONS));
			avi.compress_options_ptr[VIDEO_STREAM] = &avi.compress_options[0];
			if(!AVISaveOptions(GUI.hWnd, 0, 1, &avi.streams[VIDEO_STREAM], &avi.compress_options_ptr[VIDEO_STREAM]))
				break;
		}

		// create compressed stream
		if(FAILED(AVIMakeCompressedStream(&avi.compressed_streams[VIDEO_STREAM], avi.streams[VIDEO_STREAM], &avi.compress_options[VIDEO_STREAM], NULL)))
			break;

		// set the stream format
		if(FAILED(AVIStreamSetFormat(avi.compressed_streams[VIDEO_STREAM], 0, (void*)&avi.bitmap_format, avi.bitmap_format.biSize)))
			break;

		// add sound (if requested)
		if(avi.sound_added)
		{
			// create the audio stream
			memset(&avi.avi_sound_header, 0, sizeof(AVISTREAMINFO));
			avi.avi_sound_header.fccType = streamtypeAUDIO;
			avi.avi_sound_header.dwQuality = (DWORD)-1;
			avi.avi_sound_header.dwScale = avi.wave_format.nBlockAlign;
			avi.avi_sound_header.dwRate = avi.wave_format.nAvgBytesPerSec;
			avi.avi_sound_header.dwSampleSize = avi.wave_format.nBlockAlign;
			avi.avi_sound_header.dwInitialFrames = 1;
			if(FAILED(AVIFileCreateStream(avi.avi_file, &avi.streams[AUDIO_STREAM], &avi.avi_sound_header)))
				break;

			// AVISaveOptions doesn't seem to work for audio streams
			// so here we just copy the pointer for the compressed stream
			avi.compressed_streams[AUDIO_STREAM] = avi.streams[AUDIO_STREAM];

			// set the stream format
			if(FAILED(AVIStreamSetFormat(avi.compressed_streams[AUDIO_STREAM], 0, (void*)&avi.wave_format, sizeof(WAVEFORMATEX))))
				break;
		}

		// initialize counters
		avi.video_frames = 0;
		avi.sound_samples = 0;
		avi.tBytes = 0;
		avi.ByteBuffer = 0;
		avi.audio_buffer_pos = 0;

		strncpy(saved_cur_avi_fnameandext,filename,MAX_PATH);
		strncpy(saved_avi_fname,filename,MAX_PATH);
		char* dot = strrchr(saved_avi_fname, '.');
		if(dot && dot > strrchr(saved_avi_fname, '/') && dot > strrchr(saved_avi_fname, '\\'))
		{
			strcpy(saved_avi_ext,dot);
			dot[0]='\0';
		}

		// success
		result = 1;
		avi.valid = true;

	} while(false);

	if(!result)
	{
		clean_up(&avi);
		avi.valid = false;
	}

	return result;
//.........这里部分代码省略.........
开发者ID:Kriole,项目名称:snes9x-rr,代码行数:101,代码来源:AVIOutput.cpp

示例15: main

int main(int argc, const char * argv[]) {
	
	get_ready();
	/*
	stupid_tests();
	printf("[tests.main]\tsanity check: sizeof(unsigned long) = %d\n",
					(int) sizeof(unsigned long));
	
	printf("[tests.main]\trunning tests....\n");
	
	Board board;
	setup(&board);
	printf("\n");
	printb(&board);
	printf("\n");
	
	test_to_play(&board);
	test_ply(&board);
	
	if(WIN == test_file_attacks())
		printf("[tests.file_attacks]\tpassed\n");
	else printf("[tests.file_attacks]\tFAILED!\n");
		
	if(WIN == test_rank_attacks())
		printf("[tests.rank_attacks]\tpassed\n");
	else printf("[tests.rank_attacks]\tFAILED!\n");
	
	if(WIN == test_initf())
		printf("[tests.initf]\t\tpassed\n");
	else printf("[tests.initf]\t\tFAILED!\n");
	
	if(WIN == test_tl_br_attacks())
		printf("[tests.tl_br_attacks]\tpassed\n");
	else printf("[tests.tl_br_attacks]\tFAILED!\n");
	
	if(WIN == test_knight_attacks())
		printf("[tests.knight_attacks]\tpassed\n");
	else printf("[tests.knight_attacks]\tFAILED!\n");
	
	if(WIN == test_king_attacks())
		printf("[tests.king_attacks]\tpassed\n");
	else printf("[tests.king_attacks]\tFAILED!\n");
	
	if(WIN == test_moves())
		printf("[tests.moves]\t\tpassed\n");
	else printf("[tests.moves]\t\tFAILED!\n");
	
	if(WIN == test_conversions())
		printf("[tests.conversions]\tpassed\n");
	else printf("[tests.conversions]\tFAILED!\n");
	
	if(WIN == test_apply_move())
		printf("[tests.apply_move]\tpassed\n");
	else printf("[tests.apply_move]\tFAILED!\n");
	*/
	
	if(WIN == test_search())
		printf("[tests.search]\t\tpassed\n");
	else printf("[tests.search]\t\tFAILED!\n");
	
	/* test_scout(); */
	
	clean_up();
	
	printf("\n[tests.main]\t\ttests complete\n");
	return EXIT_SUCCESS;
}
开发者ID:twolfe18,项目名称:Chess,代码行数:67,代码来源:tests.c


注:本文中的clean_up函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。