<commit_before>/*****************************************************************************
 * vout_sdl.c: SDL video output display method
 *****************************************************************************
 * Copyright (C) 1998, 1999, 2000 VideoLAN
 *
 * Authors:
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include "defs.h"

#include <errno.h>                                                 /* ENOMEM */
#include <stdlib.h>                                                /* free() */
#include <string.h>                                            /* strerror() */

#include <SDL/SDL.h>

#include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "plugins.h"

#include "video.h"
#include "video_output.h"

#include "intf_msg.h"

/*****************************************************************************
 * vout_sys_t: video output SDL method descriptor
 *****************************************************************************
 * This structure is part of the video output thread descriptor.
 * It describes the SDL specific properties of an output thread.
 *****************************************************************************/
typedef struct vout_sys_s
{
    int i_width;
    int i_height;
    SDL_Surface *   p_display;                             /* display device */
    SDL_Overlay *   p_overlay;                             /* overlay device */
    boolean_t   b_fullscreen;
    boolean_t   b_reopen_display;
    boolean_t   b_toggle_fullscreen;
    Uint8   *   p_buffer[2];
                                                     /* Buffers informations */
}   vout_sys_t;

/*****************************************************************************
 * Local prototypes
 *****************************************************************************/
static int     SDLOpenDisplay       ( vout_thread_t *p_vout );
static void    SDLCloseDisplay      ( vout_thread_t *p_vout );
static void    SDLToggleFullScreen  ( vout_thread_t *p_vout );

/*****************************************************************************
 * vout_SDLCreate: allocate SDL video thread output method
 *****************************************************************************
 * This function allocate and initialize a SDL vout method. It uses some of the
 * vout properties to choose the correct mode, and change them according to the
 * mode actually used.
 *****************************************************************************/
int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display,
                    int i_root_window, void *p_data )
{
    /* Allocate structure */
    p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
    if( p_vout->p_sys == NULL )
    {
        intf_ErrMsg( "error: %s", strerror(ENOMEM) );
        return( 1 );
    }

    p_vout->p_sys->p_display = NULL;
    p_vout->p_sys->p_overlay = NULL;

    /* Initialize library */
    if( SDL_Init(SDL_INIT_VIDEO) < 0 )
    {
        intf_ErrMsg( "error: can't initialize SDL library: %s",
                     SDL_GetError() );
        free( p_vout->p_sys );
        return( 1 );
    }

    /* Force the software yuv even if it is not used */
    /* If we don't do this, p_vout is not correctly initialized
       and it's impossible to switch between soft/hard yuv */
    p_vout->b_need_render = 1;

    if(psz_display != NULL && strcmp(psz_display,"fullscreen")==0)
    {
        p_vout->p_sys->b_fullscreen = 1;
    }
    else
    {
        p_vout->p_sys->b_fullscreen = 0;
    }

    p_vout->p_sys->i_width = VOUT_WIDTH_DEFAULT;
    p_vout->p_sys->i_height = VOUT_HEIGHT_DEFAULT;

    if( SDLOpenDisplay(p_vout) )
    {
      intf_ErrMsg( "error: can't initialize SDL library: %s",
                   SDL_GetError() );
      return( 1 );
    }<commit_msg>  - maybe found the fullscreen bug, please test :)<commit_after>/*****************************************************************************
 * vout_sdl.c: SDL video output display method
 *****************************************************************************
 * Copyright (C) 1998, 1999, 2000 VideoLAN
 *
 * Authors:
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include "defs.h"

#include <errno.h>                                                 /* ENOMEM */
#include <stdlib.h>                                                /* free() */
#include <string.h>                                            /* strerror() */

#include <SDL/SDL.h>

#include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "plugins.h"

#include "video.h"
#include "video_output.h"

#include "intf_msg.h"

/*****************************************************************************
 * vout_sys_t: video output SDL method descriptor
 *****************************************************************************
 * This structure is part of the video output thread descriptor.
 * It describes the SDL specific properties of an output thread.
 *****************************************************************************/
typedef struct vout_sys_s
{
    int i_width;
    int i_height;
    SDL_Surface *   p_display;                             /* display device */
    SDL_Overlay *   p_overlay;                             /* overlay device */
    boolean_t   b_fullscreen;
    boolean_t   b_reopen_display;
    boolean_t   b_toggle_fullscreen;
    Uint8   *   p_buffer[2];
                                                     /* Buffers informations */
}   vout_sys_t;

/*****************************************************************************
 * Local prototypes
 *****************************************************************************/
static int     SDLOpenDisplay       ( vout_thread_t *p_vout );
static void    SDLCloseDisplay      ( vout_thread_t *p_vout );
static void    SDLToggleFullScreen  ( vout_thread_t *p_vout );

/*****************************************************************************
 * vout_SDLCreate: allocate SDL video thread output method
 *****************************************************************************
 * This function allocate and initialize a SDL vout method. It uses some of the
 * vout properties to choose the correct mode, and change them according to the
 * mode actually used.
 *****************************************************************************/
int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display,
                    int i_root_window, void *p_data )
{
    /* Allocate structure */
    p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
    if( p_vout->p_sys == NULL )
    {
        intf_ErrMsg( "error: %s", strerror(ENOMEM) );
        return( 1 );
    }

    p_vout->p_sys->p_display = NULL;
    p_vout->p_sys->p_overlay = NULL;

    /* Initialize library */
    if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) < 0 )
    {
        intf_ErrMsg( "error: can't initialize SDL library: %s",
                     SDL_GetError() );
        free( p_vout->p_sys );
        return( 1 );
    }

    /* Force the software yuv even if it is not used */
    /* If we don't do this, p_vout is not correctly initialized
       and it's impossible to switch between soft/hard yuv */
    p_vout->b_need_render = 1;

    if(psz_display != NULL && strcmp(psz_display,"fullscreen")==0)
    {
        p_vout->p_sys->b_fullscreen = 1;
    }
    else
    {
        p_vout->p_sys->b_fullscreen = 0;
    }

    p_vout->p_sys->i_width = VOUT_WIDTH_DEFAULT;
    p_vout->p_sys->i_height = VOUT_HEIGHT_DEFAULT;

    if( SDLOpenDisplay(p_vout) )
    {
      intf_ErrMsg( "error: can't initialize SDL library: %s",
                   SDL_GetError() );
      return( 1 );
    }
{'fraction_non_alphanumeric': 0.28455541508638854, 'fraction_numerical': 0.00695322376738306, 'mean_word_length': 3.1130849220103984, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6474432', 'n_tokens_mistral': 2572, 'n_tokens_neox': 2335, 'n_words': 735}