Пример #1
0
void xy_shutdown() {
    free(run_cmd);
    close_display(globals->dpy);
    log_info(globals->log, SHUTDOWN_MSG);
    logging_terminate();
    exit(EXIT_SUCCESS);
}
Пример #2
0
void retro_deinit(void)
{
   close_audio();
   close_voice();
   close_display();
   retro_destroybmp();
}
Пример #3
0
void clean_shutdown()
{
	close_results();
	close_display();
	clean_open_devices();
	clear_all_devices();
	clear_all_cpus();

	return;
}
Пример #4
0
/*
 * Vstupní bod programu
 */
int main(int argc, char *argv[])
{
    progname = argv[0];

    open_display();
    create_resources(argc, argv);
    event_loop();
    close_display();
   
    return 0;
}
Пример #5
0
int
main (int argc, char **argv)
{
  GstElement *pipeline;
  GstBus *bus;

#ifndef GST_DISABLE_PARSE
  GError *error = NULL;
#endif

  gst_init (&argc, &argv);

  if (argc != 2) {
    g_print ("Usage: %s \"pipeline description with launch format\"\n",
        argv[0]);
    g_print ("The pipeline should contain an element implementing XOverlay.\n");
    g_print ("Example: %s \"videotestsrc ! ximagesink\"\n", argv[0]);
    return -1;
  }
#ifdef GST_DISABLE_PARSE
  g_print ("GStreamer was built without pipeline parsing capabilities.\n");
  g_print
      ("Please rebuild GStreamer with pipeline parsing capabilities activated to use this example.\n");
  return 1;
#else
  pipeline = gst_parse_launch (argv[1], &error);
  if (error) {
    g_print ("Error while parsing pipeline description: %s\n", error->message);
    return -1;
  }
#endif

  loop = g_main_loop_new (NULL, FALSE);

  open_display ();

  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, pipeline);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* We want to get out after */
  //g_timeout_add (500000, (GSourceFunc) terminate_playback, pipeline);
  g_timeout_add (10000, (GSourceFunc) pause_playback, pipeline);
  g_timeout_add (20000, (GSourceFunc) start_playback, pipeline);

  g_main_loop_run (loop);

  close_display ();

  g_main_loop_unref (loop);

  return 0;
}
Пример #6
0
/*-----------------------------------------------------------------*/
main (int argc, char **argv)
{
       static char bits[256];

       if (argc!=2)
          {
          printf ("BARGRA <codigo>\n");
          exit(1);
          }

       open_display  ();
       monta_bar     (argv[1], bits);
       print_i25     (bits);
       getch();
       close_display ();

       return(0);
}
Пример #7
0
/*============================================================================*/
void run()
{
	while(!key_done) {
		if (key_debug) {
			app_data.debug=1;
			set_textmode();
			mute_audio();
			mute_voice();
/*			debug(); TODO il faut le remettre plus tard, je lai enelve juste pour les warnings*/
			grmode();
			app_data.debug=0;
			o2em_init_keyboard();
			init_sound_stream();
		}
		cpu_exec();
	}
	close_audio();
	close_voice();
	close_display();
	/*o2em_clean_quit(EXIT_SUCCESS);*/
}
Пример #8
0
void run(void){
	while(!key_done) {

		if (key_debug) {
			app_data.debug=1;
			set_textmode();
			mute_audio();
			mute_voice();
			debug();
			grmode();
			app_data.debug=0;
			init_keyboard();
			init_sound_stream();
		}			

		cpu_exec();

	}
	close_audio();
	close_voice();
	close_display();
}
Пример #9
0
/*
 * Vstupní bod programu
 */
int main(int argc, char *argv[])
{
    progname = argv[0];

    if(argc != 3)
        usage();

    if(!strcmp(argv[1], "Forget"))
        bit_gravity = ForgetGravity;
    else if(!strcmp(argv[1], "Static"))
        bit_gravity = StaticGravity;
    else if(!strcmp(argv[1], "NorthWest"))
        bit_gravity = NorthWestGravity;
    else if(!strcmp(argv[1], "North"))
        bit_gravity = NorthGravity;
    else if(!strcmp(argv[1], "NorthEast"))
        bit_gravity = NorthEastGravity;
    else if(!strcmp(argv[1], "West"))
        bit_gravity = WestGravity;
    else if(!strcmp(argv[1], "Center"))
        bit_gravity = CenterGravity;
    else if(!strcmp(argv[1], "East"))
        bit_gravity = EastGravity;
    else if(!strcmp(argv[1], "SouthWest"))
        bit_gravity = SouthWestGravity;
    else if(!strcmp(argv[1], "South"))
        bit_gravity = SouthGravity;
    else if(!strcmp(argv[1], "SouthEast"))
        bit_gravity = SouthEastGravity;
    else
        usage();

    if(!strcmp(argv[2], "Unmap"))
        win_gravity = UnmapGravity;
    else if(!strcmp(argv[2], "Static"))
        win_gravity = StaticGravity;
    else if(!strcmp(argv[2], "NorthWest"))
        win_gravity = NorthWestGravity;
    else if(!strcmp(argv[2], "North"))
        win_gravity = NorthGravity;
    else if(!strcmp(argv[2], "NorthEast"))
        win_gravity = NorthEastGravity;
    else if(!strcmp(argv[2], "West"))
        win_gravity = WestGravity;
    else if(!strcmp(argv[2], "Center"))
        win_gravity = CenterGravity;
    else if(!strcmp(argv[2], "East"))
        win_gravity = EastGravity;
    else if(!strcmp(argv[2], "SouthWest"))
        win_gravity = SouthWestGravity;
    else if(!strcmp(argv[2], "South"))
        win_gravity = SouthGravity;
    else if(!strcmp(argv[2], "SouthEast"))
        win_gravity = SouthEastGravity;
    else
        usage();

    open_display();
    create_resources(argc, argv);
    event_loop();
    close_display();

    return 0;
}
Пример #10
0
int main(int argc,char **argv)
{
    int major_ver, minor_ver;
    VAStatus va_status;
    pthread_t thread1;
    int ret;
    char c;
    int i;
    char str_src_fmt[5], str_dst_fmt[5];

    static struct option long_options[] =
                 {
                   {"fmt1",  required_argument,       NULL, '1'},
                   {"fmt2",  required_argument,       NULL, '2'},
                   {0, 0, 0, 0}
                 };

    while ((c =getopt_long(argc,argv,"w:h:g:r:d:f:tcep?n:1:2:v", long_options, NULL)) != EOF) {
        switch (c) {
            case '?':
                printf("putsurface <options>\n");
                printf("           -g <widthxheight+x_location+y_location> window geometry\n");
                printf("           -w/-h resolution of surface\n");
                printf("           -r <framerate>\n");
                printf("           -d the dimension of black/write square box, default is 32\n");
                printf("           -t multi-threads\n");
                printf("           -c test clipbox\n");
                printf("           -f <1/2> top field, or bottom field\n");
                printf("           -1 source format (fourcc) for color conversion test\n");
                printf("           -2 dest   format (fourcc) for color conversion test\n");
                printf("           --fmt1 same to -1\n");
                printf("           --fmt2 same to -2\n");
                printf("           -v verbose output\n");
                exit(0);
                break;
            case 'g':
                ret = sscanf(optarg, "%dx%d+%d+%d", &win_width, &win_height, &win_x, &win_y);
                if (ret != 4) {
                    printf("invalid window geometry, must be widthxheight+x_location+y_location\n");
                    exit(0);
                } else
                    printf("Create window at (%d, %d), width = %d, height = %d\n",
                           win_x, win_y, win_width, win_height);
                break;
            case 'r':
                frame_rate = atoi(optarg);
                break;
            case 'w':
                surface_width = atoi(optarg);
                break;
            case 'h':
                surface_height = atoi(optarg);
                break;
            case 'n':
                frame_num_total = atoi(optarg);
                break;
            case 'd':
                box_width = atoi(optarg);
                break;
            case 't':
                multi_thread = 1;
                printf("Two threads to do vaPutSurface\n");
                break;
            case 'e':
                check_event = 0;
                break;
            case 'p':
                put_pixmap = 1;
                break;
            case 'c':
                test_clip = 1;
                break;
            case 'f':
                if (atoi(optarg) == 1) {
                    printf("Display TOP field\n");
                    display_field = VA_TOP_FIELD;
                } else if (atoi(optarg) == 2) {
                    printf("Display BOTTOM field\n");
                    display_field = VA_BOTTOM_FIELD;
                } else
                    printf("The validate input for -f is: 1(top field)/2(bottom field)\n");
                break;
            case '1':
                sscanf(optarg, "%s", str_src_fmt);
                csc_src_fourcc = map_str_to_vafourcc (str_src_fmt);
                
				if (!csc_src_fourcc) {
                    printf("invalid fmt1: %s\n", str_src_fmt );
                    exit(0);
                }
                break;
            case '2':
                sscanf(optarg, "%s", str_dst_fmt);
                csc_dst_fourcc = map_str_to_vafourcc (str_dst_fmt);
                
				if (!csc_dst_fourcc) {
                    printf("invalid fmt1: %s\n", str_dst_fmt );
                    exit(0);
                }
                break;
            case 'v':
                verbose = 1;
                printf("Enable verbose output\n");
                break;
        }
    }

    if (csc_src_fourcc && csc_dst_fourcc) {
        test_color_conversion = 1;
    }
    
    win_display = (void *)open_display();
    if (win_display == NULL) {
        fprintf(stderr, "Can't open the connection of display!\n");
        exit(-1);
    }
    create_window(win_display, win_x, win_y, win_width, win_height);

    va_dpy = vaGetDisplay(win_display);
    va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
    CHECK_VASTATUS(va_status, "vaInitialize");

    if (test_color_conversion) {
        ret = csc_preparation();
    }
    if (!test_color_conversion || !ret ) {
        va_status = vaCreateSurfaces(
            va_dpy,
            VA_RT_FORMAT_YUV420, surface_width, surface_height,
            &surface_id[0], SURFACE_NUM,
            NULL, 0
        );
	}
    CHECK_VASTATUS(va_status, "vaCreateSurfaces");
    if (multi_thread == 0) /* upload the content for all surfaces */
        upload_source_YUV_once_for_all();
    
    if (check_event)
        pthread_mutex_init(&gmutex, NULL);
   
    for(i = 0; i< SURFACE_NUM; i++)
        pthread_mutex_init(&surface_mutex[i], NULL);
    
    if (multi_thread == 1) 
        ret = pthread_create(&thread1, NULL, putsurface_thread, (void*)drawable_thread1);

    putsurface_thread((void *)drawable_thread0);

    if (multi_thread == 1) 
        pthread_join(thread1, (void **)&ret);
    printf("thread1 is free\n");

    if (test_color_conversion) {
        // destroy temp surface/image
        va_status = vaDestroySurfaces(va_dpy, &csc_render_surface, 1);
        CHECK_VASTATUS(va_status,"vaDestroySurfaces");
        
        va_status = vaDestroyImage(va_dpy, csc_dst_fourcc_image.image_id);
        CHECK_VASTATUS(va_status,"vaDestroyImage");
    }

    if (vpp_config_id != VA_INVALID_ID) {
        vaDestroyConfig (va_dpy, vpp_config_id);
        vpp_config_id = VA_INVALID_ID;
    }

    vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM);    
    vaTerminate(va_dpy);

    free(va_image_formats);
    free(va_surface_attribs);
    close_display(win_display);
    
    return 0;
}
Пример #11
0
int hslink_input(user_data_rec *udta,           /* current user data record */
                 int argc,                      /* argument count */
                 char *argv[])                  /* argument values */
{
        /* allocate application workspace if needed */
        if (udta->substt == 0)
        {
                udta->appws = (workspace_rec*)mem_alloc(sizeof(workspace_rec));
                if (udta->appws == 0)
                {
                        cprintf("Cannot allocate workspace for user %d!\r\n",usrnum);
                        return 0;
                }
        }

        /* current workspace to application workspace for this user */
        current_hsws = udta->appws;

        /* process current substate */
        switch (udta->substt)
        {
        case 0:
                if (top_init())
                {
                        udta->substt = 0;
                        break;
                }

                set_defaults();

                if (argc == 1)
                {
                        usage("No command line given\r\n","");
                        udta->substt = 0;
                        break;
                }

                if (process_options(argc,argv))
                {
                        usage("No command line given\r\n","");
                        udta->substt = 0;
                        break;
                }

                ComOpen();

                WS.Option.ComSpeed = ComGetSpeed();
                if (!WS.Option.EffSpeed)
                        WS.Option.EffSpeed = WS.Option.ComSpeed;

                /* we're now ready for SlowHandshake to work */
                WS.IoLevel = 0;

                /* allocate up to 10k for file buffers, but no more */
                WS.buffer_sizes = mem_avail()-1000>10240: 10240:mem_avail()-1000;

                /* display opening screen */
                prepare_display();
                process_filespecs(argc,argv);

                /* verify hardware handshake status */
                if (!ComGetCts() && !WS.Option.ForceCts)
                {
                        cprintf("CTS signal missing!  Please use -HC or -FC option.\r\n");
                        WS.Option.CtsHandshake = 0;
                }

                udta->substt = 1;
                break;

        case 1:
                /* wait for ready handshake with remote */
                service_receive();
                udta->substt = wait_for_ready()? 1:2;
                break;

        case 2:
                /* select first file in batch and begin transmit */
                udta->curnode = WS.first_send;
                udta->substt = 3;
                break;

        case 3:
                /* end of batch? change to state 4 */
                if (udta->curnode == NULL)
                {
                        udta->substt = 4;
                        PSEND("%d file%s transmitted.\r\n",WS.files_sent,
                                                           WS.files_sent==1?"":"s");
                        break;
                }

                service_receive();
                if (transmit_file(udta->curnode->name))
                        break;          /* remain in state 3 */

                /* advance to next file in the batch */
                udta->curnode = udta->curnode->next;
                break;

        case 4:
                /* wait for remaining receive activity to terminate */
                service_receive();
                udta->substt = finish_receive()? 4:5;
                break;

        case 5:
                /* close down link */
                udta->substt = terminate_link()? 5:6;
                break;

        case 6:
                /* process exit codes */
                if (ComCarrierLost())
                        set_cancel_link(CANCEL_CARRIER_LOST);
                if ((WS.files_received+WS.files_sent) ==0)
                        set_cancel_link(CANCEL_NO_FILES);

                ComClose();
                close_display();
                cprintf("HS/Link finished! (t:%d r:%d)",WS.files_sent,WS.files_received);
                cprintf("  Exit code = %d\r\n",(int)WS.cancel_link);
                udta->substt = 0;
                break;
        }

        /* if substt is 0 we are done and need to free the workspace */
        if (udta->substt == 0)
        {
                current_hsws = 0;
                mem_free(udta->appws);
                udta->appws = 0;
        }

        /* otherwise we need more calls- return non 0 */
        return udta->substt;
}
Пример #12
0
void
main (int argc, string argv[])
{
  int code;
  string font_name = read_command_line (argc, argv);
  bitmap_font_type f = get_bitmap_font (font_name, atou (dpi));
  string font_basename = basename (font_name);

  /* Initializing the display might involve forking a process.  We
     wouldn't want that process to get copies of open output files,
     since then when it exited, random stuff might get written to the
     end of the file.  */
  init_display (f);

  if (logging)
    log_file = xfopen (concat (font_basename, ".log"), "w");

  if (strlen (BITMAP_FONT_COMMENT (f)) > 0)
    REPORT1 ("{%s}\n", BITMAP_FONT_COMMENT (f));

  if (output_name == NULL)
    output_name = font_basename;

  bzr_start_output (output_name, f);

  /* The main loop: for each character, find the outline of the shape,
     then fit the splines to it.  */
  for (code = starting_char; code <= ending_char; code++)
    {
      pixel_outline_list_type pixels;
      spline_list_array_type splines;
      char_info_type *c = get_char (font_name, code);
    
      if (c == NULL) continue;

      REPORT1 ("[%u ", code);
      if (logging)
	{
	  LOG ("\n\n\f");
	  print_char (log_file, *c);
	}

      x_start_char (*c);
      pixels = find_outline_pixels (*c);
      /* `find_outline_pixels' uses corners as the coordinates, instead
         of the pixel centers.  So we have to increase the bounding box.  */
      CHAR_MIN_COL (*c)--; CHAR_MAX_COL (*c)++;
      CHAR_MIN_ROW (*c)--; CHAR_MAX_ROW (*c)++;

      REPORT ("|");
      splines = fitted_splines (pixels);

      bzr_output_char (*c, splines);
      
      /* Flush output before displaying the character, in case the user
         is interested in looking at it and the online version
         simultaneously.  */
      flush_log_output ();

      x_output_char (*c, splines);
      REPORT ("]\n");

      /* If the character was empty, it won't have a bitmap.  */
      if (BITMAP_BITS (CHAR_BITMAP (*c)) != NULL)
        free_bitmap (&CHAR_BITMAP (*c));

      free_pixel_outline_list (&pixels);
      free_spline_list_array (&splines);
    }

  bzr_finish_output ();
  close_display ();

  close_font (font_name);

  exit (0);
}
Пример #13
0
int
main (int   argc,
      char *argv[])
{
    CurrentState *state;
    const char   *home_dir;
    char         *config_file;
    int           opt, sock;

    setlocale (LC_ALL, "");
    bindtextdomain (PACKAGE, LOCALEDIR);
    textdomain (PACKAGE);

    program_name = argv[0];

    while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != -1) {
        switch (opt) {
        case 'v':
            verbosity++;
            break;
        case 0400 + 'h':
            print_usage ();
            return 0;
        case 0400 + 'v':
            print_version ();
            return 0;
        case '?':
            fprintf (stderr,
                     _("Try `%s --help' for more information.\n"),
                     program_name);
            return 1;
        }
    }

    home_dir = getenv ("HOME");
    if (! home_dir) {
        fprintf (stderr, "%s: %s\n", program_name,
                 _("unable to find HOME in environment"));
        return 1;
    }

    print_version ();
    printf ("\n");

    if (ne_sock_init ()) {
        fprintf (stderr, "%s: %s\n", program_name,
                 _("unable to initialise http library"));
        return 1;
    }


    state = malloc (sizeof (CurrentState));
    memset (state, 0, sizeof (CurrentState));
    state->host = NULL;
    state->auth_host = NULL;
    state->email = NULL;
    state->password = NULL;
    state->cookie = NULL;
    state->car_position = NULL;
    state->car_info = NULL;

    config_file = malloc (strlen (home_dir) + 7);
    sprintf (config_file, "%s/.f1rc", home_dir);

    if (read_config (state, config_file))
        return 1;

    if ((! state->email) || (! state->password)) {
        if (get_config (state) || write_config (state, config_file))
            return 1;
    }

    if (! state->host)
        state->host = DEFAULT_HOST;
    if (! state->auth_host)
        state->auth_host = DEFAULT_HOST;

    free (config_file);

    do
    {
        state->cookie = obtain_auth_cookie (state->auth_host, state->email, state->password);
    }
    while (! state->cookie);

    for (;;) {
        int ret;

        sock = open_stream (state->host, 4321);
        if (sock < 0) {
            close_display ();
            fprintf (stderr, "%s: %s: %s\n", program_name,
                     _("unable to open data stream"),
                     strerror (errno));
            return 2;
        }

        state->key = 0;
        state->frame = 0;
        state->event_no = 0;
        state->event_type = RACE_EVENT;
        state->epoch_time = 0;
        state->remaining_time = 0;
        state->laps_completed = 0;
        state->total_laps = 0;
        state->flag = GREEN_FLAG;

        state->track_temp = 0;
        state->air_temp = 0;
        state->wind_speed = 0;
        state->humidity = 0;
        state->pressure = 0;
        state->wind_direction = 0;

        if (state->fl_car) free (state->fl_car);
        state->fl_car = calloc(3, sizeof(char));
        if (state->fl_driver) free (state->fl_driver);
        state->fl_driver = calloc(15, sizeof(char));
        if (state->fl_time) free (state->fl_time);
        state->fl_time = calloc(9, sizeof(char));
        if (state->fl_lap) free (state->fl_lap);
        state->fl_lap = calloc(3, sizeof(char));

        state->num_cars = 0;
        if (state->car_position) {
            free (state->car_position);
            state->car_position = NULL;
        }
        if (state->car_info) {
            free (state->car_info);
            state->car_info = NULL;
        }

        reset_decryption (state);

        while ((ret = read_stream (state, sock)) > 0) {
            if (handle_keys (state) < 0) {
                close_display ();
                close (sock);
                return 0;
            }
        }

        if (ret < 0) {
            close_display ();
            fprintf (stderr, "%s: %s: %s\n", program_name,
                     _("error reading from data stream"),
                     strerror (errno));
            return 2;
        }

        close (sock);
        info (1, _("Reconnecting ...\n"));
    }
}
Пример #14
0
// Quit the program
void quit(BOOL script)
{
	// If main status window is open, close it
	if (main_status)
	{
		CloseProgressWindow(main_status);
		main_status=0;
	}

	if (GUI)
	{
		// Clear 'startup' flag for scripts
		GUI->flags&=~GUIF_DONE_STARTUP;

		// Close commodities
		cx_remove(GUI->cx);

		// Update environment settings
		env_update_settings(1);

		// Stop notify request
		RemoveNotifyRequest(GUI->notify_req);
		GUI->notify_req=0;

		// Is there a hide appicon?
		if (GUI->hide_appicon)
		{
			RemoveAppIcon(GUI->hide_appicon);
			FreeCachedDiskObject(GUI->hide_diskobject);
		}

		// Or an appmenuitem?
		if (GUI->hide_appitem) RemoveAppMenuItem(GUI->hide_appitem);

		// Launch shutdown script
		if (script)
			RunScript(SCRIPT_SHUTDOWN,0);

		// Set quit flag
		GUI->flags|=GUIF_PENDING_QUIT;

		// Shut the display down
		close_display(CLOSE_ALL,TRUE);

		// Send quit notifications
		quit_notify();

		// Stop notifications
		stop_file_notify(GUI->pattern_notify);
		stop_file_notify(GUI->font_notify);
		stop_file_notify(GUI->modules_notify);
		stop_file_notify(GUI->commands_notify);
		stop_file_notify(GUI->env_notify);
		stop_file_notify(GUI->desktop_notify);
		stop_file_notify(GUI->filetype_notify);

		// Free application port
		if (GUI->appmsg_port)
		{
			DOpusAppMessage *amsg;
			RemPort(GUI->appmsg_port);
			while ((amsg=(DOpusAppMessage *)GetMsg(GUI->appmsg_port)))
				ReplyAppMessage(amsg);
			DeleteMsgPort(GUI->appmsg_port);
			GUI->appmsg_port=0;

			// Remove public semaphore
			RemSemaphore((struct SignalSemaphore *)&pub_semaphore);
		}

		// Flush IPC port
		IPC_Flush(&main_ipc);

		// Close all processes
		IPC_ListQuit(&GUI->lister_list,&main_ipc,0,TRUE);
		IPC_ListQuit(&GUI->group_list,&main_ipc,0,TRUE);
		IPC_ListQuit(&GUI->buttons_list,&main_ipc,0,TRUE);
		IPC_ListQuit(&GUI->startmenu_list,&main_ipc,0,TRUE);
		IPC_ListQuit(&GUI->process_list,&main_ipc,0,TRUE);
		IPC_ListQuit(&GUI->function_list,&main_ipc,0,TRUE);

		// Free buffers
		buffers_clear(0);

		// Remove all handlers
		RemFunctionTrap("*","#?");

		// Free filetypes
		FreeMemHandle(GUI->filetype_memory);

		// Flush the filetype cache
		ClearFiletypeCache();

		// Free lister toolbar
		FreeToolBar(GUI->toolbar);

		// Free menus and hotkeys
		CloseButtonBank(GUI->lister_menu);
		CloseButtonBank(GUI->hotkeys);

		// Free user menus
		CloseButtonBank(GUI->user_menu);
		FreeVec(GUI->user_menu_data);

		// Free backdrop list
		backdrop_free(GUI->backdrop);

		// Free icons
		if (GUI->lister_icon) FreeCachedDiskObject(GUI->lister_icon);
		if (GUI->button_icon) FreeCachedDiskObject(GUI->button_icon);

		// Free arrow image
		CloseImage(GUI->toolbar_arrow_image);

#ifdef __amigaos3__
		FreeVec(arrow_hi_data_chip);
		FreeVec(arrow_lo_data_chip);
		FreeVec(small_arrow_chip);
		FreeVec(big_arrow_chip);
#ifndef USE_SCREENTITLE
		FreeVec(moon_big_data_chip);
		FreeVec(moon_small_data_chip);
#endif
		FreeVec(command_arrow_chip);
		FreeVec(parent_arrow_chip);
#endif

		// Free screen signal
		if (GUI->screen_signal!=-1) FreeSignal(GUI->screen_signal);

		// Delete notify port
		if (GUI->notify_port) DeleteMsgPort(GUI->notify_port);

		// Free position memory
		FreeMemHandle(GUI->position_memory);

		// Free command history
		Att_RemList(GUI->command_history,0);

		// Delete icon positioning port
		DeleteMsgPort(GUI->iconpos_port);

		// Free popup menu
		PopUpFreeHandle(GUI->desktop_menu);

		// Clear requester pattern hook in library
		if (GUI->flags2&GUIF2_BACKFILL_SET)
			SetReqBackFill(0,0);
	}

	// Free scripts
	FreeScripts();

	// Free environment
	environment_free(environment);
	
	// Delete main message ports
	IPC_Flush(&main_ipc);
	DeleteMsgPort(main_ipc.command_port);
	DeleteMsgPort(main_ipc.reply_port);

	// Pause here for a couple of seconds to let everything clean up
	Delay(3*50);

	// Free global data
	FreeMemHandle(global_memory_pool);

	// Delete any temporary files
	delete_temp_files(0);

	// Free locale data
	free_locale_data(&locale);

	// Close input device
	if (InputBase) {
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IInput);
	#endif
	CloseDevice((struct IORequest *)&input_req);
	}

	// Close timer device
	if (TimerBase) {
	#ifdef __amigaos4__
	DropInterface((struct Interface *)ITimer);
	#endif
	CloseDevice((struct IORequest *)&timer_req);
	}

	// Close console device
	if (ConsoleDevice) {
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IConsole);
	#endif
	CloseDevice((struct IORequest *)&console_req);
	}

	// Close libraries
	#ifdef __amigaos4__
	DropInterface((struct Interface *)Imu);
	#endif
	CloseLibrary(muBase);
	
#ifndef __amigaos3__	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)INewIcon);
	#endif
	CloseLibrary((struct Library *)NewIconBase);
#endif

	#ifdef __amigaos4__
	DropInterface((struct Interface *)ICyberGfx);
	#endif
	CloseLibrary(CyberGfxBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IAmigaGuide);
	#endif
	CloseLibrary(AmigaGuideBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IDataTypes);
	#endif
	CloseLibrary(DataTypesBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IAsl);
	#endif
	CloseLibrary(AslBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IIcon);
	#endif
	CloseLibrary(IconBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IDiskfont);
	#endif
	CloseLibrary(DiskfontBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IWorkbench);
	#endif
	CloseLibrary(WorkbenchBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)ICommodities);
	#endif
	CloseLibrary(CxBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IRexxSys);
	#endif
	CloseLibrary((struct Library *)RexxSysBase); 
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IUtility);
	#endif
	CloseLibrary(UtilityBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IGadTools);
	#endif
	CloseLibrary(GadToolsBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)ILayers);
	#endif
	CloseLibrary((struct Library *)LayersBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IGraphics);
	#endif
	CloseLibrary((struct Library *)GfxBase);
	
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IIntuition);
	#endif
	CloseLibrary((struct Library *)IntuitionBase);
	
	// Restore old current directory?
	if (old_current_dir)
	{
		UnLock(CurrentDir(old_current_dir));
	}

	// Close the dopus5.library
	#ifdef __amigaos4__
	DropInterface((struct Interface *)IDOpus);
	#endif
	CloseLibrary(DOpusBase);

	// Outahere!
	exit(0);
}
Пример #15
0
int main(int argc,char **argv)
{
    int major_ver, minor_ver;
    VAStatus va_status;
    pthread_t thread1;
    int ret;
    char c;
    int i;

    while ((c =getopt(argc,argv,"w:h:g:r:d:f:tcep?n:v") ) != EOF) {
        switch (c) {
        case '?':
            printf("putsurface <options>\n");
            printf("           -g <widthxheight+x_location+y_location> window geometry\n");
            printf("           -w/-h resolution of surface\n");
            printf("           -r <framerate>\n");
            printf("           -d the dimension of black/write square box, default is 32\n");
            printf("           -t multi-threads\n");
            printf("           -c test clipbox\n");
            printf("           -f <1/2> top field, or bottom field\n");
            printf("           -v verbose output\n");
            exit(0);
            break;
        case 'g':
            ret = sscanf(optarg, "%dx%d+%d+%d", &win_width, &win_height, &win_x, &win_y);
            if (ret != 4) {
                printf("invalid window geometry, must be widthxheight+x_location+y_location\n");
                exit(0);
            } else
                printf("Create window at (%d, %d), width = %d, height = %d\n",
                       win_x, win_y, win_width, win_height);
            break;
        case 'r':
            frame_rate = atoi(optarg);
            break;
        case 'w':
            surface_width = atoi(optarg);
            break;
        case 'h':
            surface_height = atoi(optarg);
            break;
        case 'n':
            frame_num_total = atoi(optarg);
            break;
        case 'd':
            box_width = atoi(optarg);
            break;
        case 't':
            multi_thread = 1;
            printf("Two threads to do vaPutSurface\n");
            break;
        case 'e':
            check_event = 0;
            break;
        case 'p':
            put_pixmap = 1;
            break;
        case 'c':
            test_clip = 1;
            break;
        case 'f':
            if (atoi(optarg) == 1) {
                printf("Display TOP field\n");
                display_field = VA_TOP_FIELD;
            } else if (atoi(optarg) == 2) {
                printf("Display BOTTOM field\n");
                display_field = VA_BOTTOM_FIELD;
            } else
                printf("The validate input for -f is: 1(top field)/2(bottom field)\n");
            break;
        case 'v':
            verbose = 1;
            printf("Enable verbose output\n");
            break;
        }
    }

    win_display = (void *)open_display();
    if (win_display == NULL) {
        fprintf(stderr, "Can't open the connection of display!\n");
        exit(-1);
    }
    create_window(win_display, win_x, win_y, win_width, win_height);

    va_dpy = vaGetDisplay(win_display);
    va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
    CHECK_VASTATUS(va_status, "vaInitialize");

    va_status = vaCreateSurfaces(va_dpy,surface_width, surface_height,
                                 VA_RT_FORMAT_YUV420, SURFACE_NUM, &surface_id[0]);
    CHECK_VASTATUS(va_status, "vaCreateSurfaces");
    if (multi_thread == 0) /* upload the content for all surfaces */
        upload_source_YUV_once_for_all();

    if (check_event)
        pthread_mutex_init(&gmutex, NULL);

    for(i = 0; i< SURFACE_NUM; i++)
        pthread_mutex_init(&surface_mutex[i], NULL);

    if (multi_thread == 1)
        ret = pthread_create(&thread1, NULL, putsurface_thread, (void*)drawable_thread1);

    putsurface_thread((void *)drawable_thread0);

    if (multi_thread == 1)
        pthread_join(thread1, (void **)&ret);
    printf("thread1 is free\n");

    vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM);
    vaTerminate(va_dpy);

    close_display(win_display);

    return 0;
}