win32_specific.c 3.19 KB
Newer Older
Sam Hocevar's avatar
 
Sam Hocevar committed
1 2 3 4
/*****************************************************************************
 * win32_specific.c: Win32 specific features 
 *****************************************************************************
 * Copyright (C) 2001 VideoLAN
Gildas Bazin's avatar
 
Gildas Bazin committed
5
 * $Id: win32_specific.c,v 1.13 2002/07/29 19:05:47 gbazin Exp $
Sam Hocevar's avatar
 
Sam Hocevar committed
6 7
 *
 * Authors: Samuel Hocevar <sam@zoy.org>
Gildas Bazin's avatar
 
Gildas Bazin 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.
 *****************************************************************************/
Gildas Bazin's avatar
 
Gildas Bazin 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

/*****************************************************************************
Gildas Bazin's avatar
 
Gildas Bazin committed
34
 * system_Init: initialize winsock and misc other things.
Sam Hocevar's avatar
 
Sam Hocevar committed
35
 *****************************************************************************/
Gildas Bazin's avatar
 
Gildas Bazin 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
{
    WSADATA Data;
    int i_err;
Gildas Bazin's avatar
 
Gildas Bazin committed
40 41 42
    HINSTANCE hInstLib;

    /* dynamically get the address of SignalObjectAndWait */
Gildas Bazin's avatar
 
Gildas Bazin committed
43 44 45 46 47 48 49 50 51 52
    if( (GetVersion() < 0x80000000) )
    {
        /* We are running on NT/2K/XP, we can use SignalObjectAndWait */
        hInstLib = LoadLibrary( "kernel32" );
        if( hInstLib)
            p_this->p_vlc->SignalObjectAndWait =
                (SIGNALOBJECTANDWAIT)GetProcAddress( hInstLib,
                                                     "SignalObjectAndWait" );
    }
    else p_this->p_vlc->SignalObjectAndWait = NULL;
Sam Hocevar's avatar
 
Sam Hocevar committed
53 54 55 56 57 58

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

    if( i_err )
    {
59
        fprintf( stderr, "error: can't initiate WinSocks, error %i\n", i_err );
Sam Hocevar's avatar
 
Sam Hocevar committed
60
    }
61 62

    _fmode = _O_BINARY;  /* sets the default file-translation mode */
Sam Hocevar's avatar
 
Sam Hocevar committed
63 64
}

Gildas Bazin's avatar
 
Gildas Bazin committed
65 66 67
/*****************************************************************************
 * system_Configure: check for system specific configuration options.
 *****************************************************************************/
Gildas Bazin's avatar
 
Gildas Bazin committed
68
void system_Configure( vlc_t *p_this )
Gildas Bazin's avatar
 
Gildas Bazin committed
69
{
Gildas Bazin's avatar
 
Gildas Bazin committed
70 71
    p_this->p_vlc->b_fast_mutex = config_GetInt( p_this, "fast-mutex" );
    p_this->p_vlc->i_win9x_cv = config_GetInt( p_this, "win9x-cv-method" );
Gildas Bazin's avatar
 
Gildas Bazin committed
72 73
}

Sam Hocevar's avatar
 
Sam Hocevar committed
74 75 76
/*****************************************************************************
 * system_End: terminate winsock.
 *****************************************************************************/
Gildas Bazin's avatar
 
Gildas Bazin committed
77
void system_End( vlc_t *p_this )
Sam Hocevar's avatar
 
Sam Hocevar committed
78 79 80
{
    WSACleanup();
}