- vout_thread_t * p_vout; /* thread descriptor */
- int i_status; /* thread status */
- int i_index; /* index for array initialization */
-
- /* Allocate descriptor */
- p_vout = (vout_thread_t *) malloc( sizeof(vout_thread_t) );
- if( p_vout == NULL )
- {
- intf_ErrMsg( "vout error: vout thread creation returned %s",
- strerror(ENOMEM) );
- return( NULL );
- }
-
- /* Choose the best module */
- p_vout->p_module = module_Need( p_main->p_bank,
- MODULE_CAPABILITY_VOUT, NULL );
-
- if( p_vout->p_module == NULL )
- {
- intf_ErrMsg( "vout error: no suitable vout module" );
- free( p_vout );
- return( NULL );
- }
-
-#define f p_vout->p_module->p_functions->vout.functions.vout
- p_vout->pf_create = f.pf_create;
- p_vout->pf_init = f.pf_init;
- p_vout->pf_end = f.pf_end;
- p_vout->pf_destroy = f.pf_destroy;
- p_vout->pf_manage = f.pf_manage;
- p_vout->pf_display = f.pf_display;
- p_vout->pf_setpalette = f.pf_setpalette;
-#undef f
-
- if( p_vout->pf_setpalette == NULL )
- {
- p_vout->pf_setpalette = SetPalette;
- }
-
- /* Initialize thread properties - thread id and locks will be initialized
- * later */
- p_vout->b_die = 0;
- p_vout->b_error = 0;
- p_vout->b_active = 0;
- p_vout->pi_status = (pi_status != NULL) ? pi_status : &i_status;
- *p_vout->pi_status = THREAD_CREATE;
-
- /* Initialize some fields used by the system-dependant method - these
- * fields will probably be modified by the method, and are only
- * preferences */
- p_vout->i_changes = 0;
- p_vout->i_width = main_GetIntVariable( VOUT_WIDTH_VAR,
- VOUT_WIDTH_DEFAULT );
- p_vout->i_height = main_GetIntVariable( VOUT_HEIGHT_VAR,
- VOUT_HEIGHT_DEFAULT );
- p_vout->i_bytes_per_line = p_vout->i_width * 2;
- p_vout->i_screen_depth = 15;
- p_vout->i_bytes_per_pixel = 2;
- p_vout->f_gamma = VOUT_GAMMA;
- p_vout->b_need_render = 1;
-
- p_vout->b_grayscale = main_GetIntVariable( VOUT_GRAYSCALE_VAR,
- VOUT_GRAYSCALE_DEFAULT );
- p_vout->b_info = 0;
- p_vout->b_interface = 0;
- p_vout->b_scale = 1;
-
- intf_DbgMsg( "wished configuration: %dx%d, %d/%d bpp (%d Bpl)",
- p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
- p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line );
-
- /* Initialize idle screen */
- p_vout->last_display_date = 0;
- p_vout->last_idle_date = 0;
- p_vout->init_display_date = mdate();
- p_vout->render_time = 10000;
-
- /* Initialize statistics fields */
- p_vout->c_fps_samples = 0;
-
- /* Initialize buffer index */
- p_vout->i_buffer_index = 0;
-
- /* Initialize pictures and subpictures - translation tables and functions
- * will be initialized later in InitThread */
- for( i_index = 0; i_index < VOUT_MAX_PICTURES; i_index++)
- {
- p_vout->p_picture[i_index].i_type = EMPTY_PICTURE;
- p_vout->p_picture[i_index].i_status = FREE_PICTURE;
- }
- for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++)
- {
- p_vout->p_subpicture[i_index].i_type = EMPTY_SUBPICTURE;
- p_vout->p_subpicture[i_index].i_status= FREE_SUBPICTURE;
- }
- p_vout->i_pictures = 0;
-
- /* Create and initialize system-dependant method - this function issues its
- * own error messages */
- if( p_vout->pf_create( p_vout ) )
- {
- module_Unneed( p_main->p_bank, p_vout->p_module );
- free( p_vout );
- return( NULL );
- }
- intf_DbgMsg( "actual configuration: %dx%d, %d/%d bpp (%d Bpl), "
- "masks: 0x%x/0x%x/0x%x",
- p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
- p_vout->i_bytes_per_pixel * 8, p_vout->i_bytes_per_line,
- p_vout->i_red_mask, p_vout->i_green_mask,
- p_vout->i_blue_mask );
-
- /* Calculate shifts from system-updated masks */
- MaskToShift( &p_vout->i_red_lshift, &p_vout->i_red_rshift,
- p_vout->i_red_mask );
- MaskToShift( &p_vout->i_green_lshift, &p_vout->i_green_rshift,
- p_vout->i_green_mask );
- MaskToShift( &p_vout->i_blue_lshift, &p_vout->i_blue_rshift,
- p_vout->i_blue_mask );
-
- /* Set some useful colors */
- p_vout->i_white_pixel = RGB2PIXEL( p_vout, 255, 255, 255 );
- p_vout->i_black_pixel = RGB2PIXEL( p_vout, 0, 0, 0 );
- p_vout->i_gray_pixel = RGB2PIXEL( p_vout, 128, 128, 128 );
- p_vout->i_blue_pixel = RGB2PIXEL( p_vout, 0, 0, 50 );
-
- /* Load fonts - fonts must be initialized after the system method since
- * they may be dependant on screen depth and other thread properties */
- p_vout->p_default_font = vout_LoadFont( DATA_PATH "/" VOUT_DEFAULT_FONT );
- if( p_vout->p_default_font == NULL )
- {
- p_vout->p_default_font = vout_LoadFont( "share/" VOUT_DEFAULT_FONT );
- }
- if( p_vout->p_default_font == NULL )
- {
- intf_ErrMsg( "vout error: could not load default font" );
- p_vout->pf_destroy( p_vout );
- free( p_vout );
- return( NULL );
- }
- p_vout->p_large_font = vout_LoadFont( DATA_PATH "/" VOUT_LARGE_FONT );
- if( p_vout->p_large_font == NULL )
- {
- p_vout->p_large_font = vout_LoadFont( "share/" VOUT_LARGE_FONT );
- }
- if( p_vout->p_large_font == NULL )
- {
- intf_ErrMsg( "vout error: could not load large font" );
- vout_UnloadFont( p_vout->p_default_font );
- p_vout->pf_destroy( p_vout );
- free( p_vout );
- return( NULL );
- }