win32_specific.c 3.13 KB
Newer Older
Sam Hocevar's avatar
 
Sam Hocevar committed
1 2 3 4
/*****************************************************************************
 * win32_specific.c: Win32 specific features 
 *****************************************************************************
 * Copyright (C) 2001 VideoLAN
gbazin's avatar
 
gbazin committed
5
 * $Id: win32_specific.c,v 1.17 2002/11/07 19:31:08 gbazin Exp $
Sam Hocevar's avatar
 
Sam Hocevar committed
6 7
 *
 * Authors: Samuel Hocevar <sam@zoy.org>
gbazin's avatar
 
gbazin committed
8
 *          Gildas Bazin <gbazin@netcourrier.com>
Sam Hocevar's avatar
 
Sam Hocevar committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * 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.
 *****************************************************************************/
gbazin's avatar
 
gbazin committed
24
#include <errno.h>                                                 /* ENOMEM */
Sam Hocevar's avatar
 
Sam Hocevar committed
25 26
#include <string.h>                                              /* strdup() */
#include <stdlib.h>                                                /* free() */
27
#include <fcntl.h>
Sam Hocevar's avatar
 
Sam Hocevar committed
28 29 30

#include <winsock2.h>

31
#include <vlc/vlc.h>
Sam Hocevar's avatar
 
Sam Hocevar committed
32 33

/*****************************************************************************
gbazin's avatar
 
gbazin committed
34
 * system_Init: initialize winsock and misc other things.
Sam Hocevar's avatar
 
Sam Hocevar committed
35
 *****************************************************************************/
gbazin's avatar
 
gbazin committed
36
void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
Sam Hocevar's avatar
 
Sam Hocevar committed
37 38 39 40 41 42 43 44 45
{
    WSADATA Data;
    int i_err;

    /* WinSock Library Init. */
    i_err = WSAStartup( MAKEWORD( 1, 1 ), &Data );

    if( i_err )
    {
46
        fprintf( stderr, "error: can't initiate WinSocks, error %i\n", i_err );
Sam Hocevar's avatar
 
Sam Hocevar committed
47
    }
48

49 50
    /* Set the default file-translation mode */
    _fmode = _O_BINARY;
Sam Hocevar's avatar
 
Sam Hocevar committed
51 52
}

gbazin's avatar
 
gbazin committed
53 54 55
/*****************************************************************************
 * system_Configure: check for system specific configuration options.
 *****************************************************************************/
gbazin's avatar
 
gbazin committed
56
void system_Configure( vlc_t *p_this )
gbazin's avatar
 
gbazin committed
57
{
gbazin's avatar
 
gbazin committed
58 59
    p_this->p_libvlc->b_fast_mutex = config_GetInt( p_this, "fast-mutex" );
    p_this->p_libvlc->i_win9x_cv = config_GetInt( p_this, "win9x-cv-method" );
gbazin's avatar
 
gbazin committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73

    /* Raise default priority of the current process */
#ifndef ABOVE_NORMAL_PRIORITY_CLASS
#   define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
#endif
    if( !SetPriorityClass( GetCurrentProcess(),
			   ABOVE_NORMAL_PRIORITY_CLASS ) )
    {
        if( !SetPriorityClass( GetCurrentProcess(),
			       HIGH_PRIORITY_CLASS ) )
	    msg_Dbg( p_this, "can't raise process priority" );
	else
	    msg_Dbg( p_this, "raised process priority" );
    }
gbazin's avatar
 
gbazin committed
74 75
}

Sam Hocevar's avatar
 
Sam Hocevar committed
76 77 78
/*****************************************************************************
 * system_End: terminate winsock.
 *****************************************************************************/
gbazin's avatar
 
gbazin committed
79
void system_End( vlc_t *p_this )
Sam Hocevar's avatar
 
Sam Hocevar committed
80 81 82
{
    WSACleanup();
}