From d7b4b27b2c049e4f9197ff7206a8a06b6db36d40 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 9 Jan 2002 10:22:37 +0000 Subject: [PATCH] * ./src/interface/intf_eject.c: BSD/OS port by Steven M. Schultz. --- src/interface/intf_eject.c | 125 ++++++++++++++++++------------------- src/interface/main.c | 12 +--- 2 files changed, 63 insertions(+), 74 deletions(-) diff --git a/src/interface/intf_eject.c b/src/interface/intf_eject.c index 8111436b4a..ff3edae191 100644 --- a/src/interface/intf_eject.c +++ b/src/interface/intf_eject.c @@ -2,7 +2,7 @@ * intf_eject.c: CD/DVD-ROM ejection handling functions ***************************************************************************** * Copyright (C) 2001, 2002 VideoLAN - * $Id: intf_eject.c,v 1.1 2002/01/09 02:01:14 sam Exp $ + * $Id: intf_eject.c,v 1.2 2002/01/09 10:22:37 sam Exp $ * * Author: Julien Blache for the Linux part * with code taken from the Linux "eject" command @@ -29,9 +29,11 @@ #include -#ifdef SYS_LINUX +#ifdef HAVE_DVD_H +# include +#endif -/* This code could be extended to support CD/DVD-ROM chargers */ +#ifdef SYS_LINUX # include /* handy macro found in 2.1 kernels, but not in older ones */ # ifndef KERNEL_VERSION @@ -53,29 +55,71 @@ # include # include # include - #endif -static int EjectCdrom( int i_fd ); -static int EjectScsi ( int i_fd ); +/***************************************************************************** + * Local prototypes + *****************************************************************************/ +#ifdef SYS_LINUX +static int EjectSCSI ( int i_fd ); +#endif -/* - * Eject using CDROMEJECT ioctl. Return 0 if successful - */ -static int EjectCdrom( int i_fd ) +/***************************************************************************** + * intf_Eject: eject the CDRom + ***************************************************************************** + * returns 0 on success + * returns 1 on failure + * returns -1 if not implemented + *****************************************************************************/ +int intf_Eject( const char *psz_device ) { - int i_status; - - i_status = ioctl( i_fd, CDROMEJECT ); - - return i_status; + int i_ret; + + /* This code could be extended to support CD/DVD-ROM chargers */ + int i_fd = 0; + + i_fd = open( psz_device, O_RDONLY | O_NONBLOCK ); + + if( i_fd == -1 ) + { + intf_ErrMsg( "intf error: couldn't open device %s", psz_device ); + return 1; + } + +#ifdef SYS_LINUX + /* Try a simple ATAPI eject */ + i_ret = ioctl( i_fd, CDROMEJECT, 0 ); + + if( i_ret != 0 ) + { + i_ret = EjectSCSI( i_fd ); + } + + if( i_ret != 0 ) + { + intf_ErrMsg( "intf error: couldn't eject %s", psz_device ); + } + +#elif defined (HAVE_DVD_H) + i_ret = ioctl( i_fd, CDROMEJECT, 0 ); + +#else + intf_ErrMsg( "intf error: CD-Rom ejection unsupported on this platform" ); + i_ret = -1; + +#endif + close( i_fd ); + + return i_ret; } +/* The following functions are local */ -/* +#ifdef SYS_LINUX +/***************************************************************************** * Eject using SCSI commands. Return 0 if successful - */ -static int EjectScsi( int i_fd ) + *****************************************************************************/ +static int EjectSCSI( int i_fd ) { int i_status; @@ -133,50 +177,5 @@ static int EjectScsi( int i_fd ) return i_status; } - -/* - * returns 0 on success - * returns 1 on failure - * returns -1 if not implemented - * - * Modify eject_disc() prototype as needed for portability - */ - -int intf_Eject( const char *psz_device ) -{ - int i_ret; - -#ifdef SYS_LINUX - int i_fd = 0; - - i_fd = open( psz_device, O_RDONLY | O_NONBLOCK ); - - if( i_fd == -1 ) - { - intf_ErrMsg( "intf error: couldn't open device %s", psz_device ); - return 1; - } - - if( EjectCdrom(i_fd) == 0 ) - { - i_ret = 0; - } - else if( EjectScsi(i_fd) == 0 ) - { - i_ret = 0; - } - else - { - intf_ErrMsg( "intf error: couldn't eject %s", psz_device ); - i_ret = 1; - } - - close( i_fd ); - -#else - i_ret = -1; - #endif - return i_ret; -} diff --git a/src/interface/main.c b/src/interface/main.c index 8e2d4791e1..93b871dd8c 100644 --- a/src/interface/main.c +++ b/src/interface/main.c @@ -4,7 +4,7 @@ * and spawn threads. ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: main.c,v 1.143 2002/01/07 02:12:30 sam Exp $ + * $Id: main.c,v 1.144 2002/01/09 10:22:37 sam Exp $ * * Authors: Vincent Seguin * Samuel Hocevar @@ -1308,16 +1308,6 @@ static u32 CPUCapabilities( void ) { i_capabilities |= CPU_CAPABILITY_SSE; } - else - { - fprintf( stderr, "warning: your OS doesn't have support for " - "SSE instructions, some optimizations\n" - "will be disabled" -# ifdef SYS_LINUX - " (you will need Linux kernel 2.4.x or later)" -# endif - "\n" ); - } # endif } -- 2.39.2