Changeset d7b4b27b2c049e4f9197ff7206a8a06b6db36d40
- Timestamp:
- 09/01/02 11:22:37
(7 years ago)
- Author:
- Sam Hocevar <sam@videolan.org>
- git-committer:
- Sam Hocevar <sam@videolan.org> 1010571757 +0000
- git-parent:
[c7b1c474c6a8687a0645553beb0e5c6f868d8c5c]
- git-author:
- Sam Hocevar <sam@videolan.org> 1010571757 +0000
- Message:
- ./src/interface/intf_eject.c: BSD/OS port by Steven M. Schultz.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rc7b1c47 |
rd7b4b27 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2001, 2002 VideoLAN |
|---|
| 5 | | * $Id: intf_eject.c,v 1.1 2002/01/09 02:01:14 sam Exp $ |
|---|
| | 5 | * $Id: intf_eject.c,v 1.2 2002/01/09 10:22:37 sam Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Author: Julien Blache <jb@technologeek.org> for the Linux part |
|---|
| … | … | |
| 30 | 30 | #include <videolan/vlc.h> |
|---|
| 31 | 31 | |
|---|
| | 32 | #ifdef HAVE_DVD_H |
|---|
| | 33 | # include <dvd.h> |
|---|
| | 34 | #endif |
|---|
| | 35 | |
|---|
| 32 | 36 | #ifdef SYS_LINUX |
|---|
| 33 | | |
|---|
| 34 | | /* This code could be extended to support CD/DVD-ROM chargers */ |
|---|
| 35 | 37 | # include <linux/version.h> |
|---|
| 36 | 38 | /* handy macro found in 2.1 kernels, but not in older ones */ |
|---|
| … | … | |
| 54 | 56 | # include <scsi/sg.h> |
|---|
| 55 | 57 | # include <scsi/scsi_ioctl.h> |
|---|
| | 58 | #endif |
|---|
| | 59 | |
|---|
| | 60 | /***************************************************************************** |
|---|
| | 61 | * Local prototypes |
|---|
| | 62 | *****************************************************************************/ |
|---|
| | 63 | #ifdef SYS_LINUX |
|---|
| | 64 | static int EjectSCSI ( int i_fd ); |
|---|
| | 65 | #endif |
|---|
| | 66 | |
|---|
| | 67 | /***************************************************************************** |
|---|
| | 68 | * intf_Eject: eject the CDRom |
|---|
| | 69 | ***************************************************************************** |
|---|
| | 70 | * returns 0 on success |
|---|
| | 71 | * returns 1 on failure |
|---|
| | 72 | * returns -1 if not implemented |
|---|
| | 73 | *****************************************************************************/ |
|---|
| | 74 | int intf_Eject( const char *psz_device ) |
|---|
| | 75 | { |
|---|
| | 76 | int i_ret; |
|---|
| | 77 | |
|---|
| | 78 | /* This code could be extended to support CD/DVD-ROM chargers */ |
|---|
| | 79 | int i_fd = 0; |
|---|
| | 80 | |
|---|
| | 81 | i_fd = open( psz_device, O_RDONLY | O_NONBLOCK ); |
|---|
| | 82 | |
|---|
| | 83 | if( i_fd == -1 ) |
|---|
| | 84 | { |
|---|
| | 85 | intf_ErrMsg( "intf error: couldn't open device %s", psz_device ); |
|---|
| | 86 | return 1; |
|---|
| | 87 | } |
|---|
| | 88 | |
|---|
| | 89 | #ifdef SYS_LINUX |
|---|
| | 90 | /* Try a simple ATAPI eject */ |
|---|
| | 91 | i_ret = ioctl( i_fd, CDROMEJECT, 0 ); |
|---|
| | 92 | |
|---|
| | 93 | if( i_ret != 0 ) |
|---|
| | 94 | { |
|---|
| | 95 | i_ret = EjectSCSI( i_fd ); |
|---|
| | 96 | } |
|---|
| | 97 | |
|---|
| | 98 | if( i_ret != 0 ) |
|---|
| | 99 | { |
|---|
| | 100 | intf_ErrMsg( "intf error: couldn't eject %s", psz_device ); |
|---|
| | 101 | } |
|---|
| | 102 | |
|---|
| | 103 | #elif defined (HAVE_DVD_H) |
|---|
| | 104 | i_ret = ioctl( i_fd, CDROMEJECT, 0 ); |
|---|
| | 105 | |
|---|
| | 106 | #else |
|---|
| | 107 | intf_ErrMsg( "intf error: CD-Rom ejection unsupported on this platform" ); |
|---|
| | 108 | i_ret = -1; |
|---|
| 56 | 109 | |
|---|
| 57 | 110 | #endif |
|---|
| | 111 | close( i_fd ); |
|---|
| 58 | 112 | |
|---|
| 59 | | static int EjectCdrom( int i_fd ); |
|---|
| 60 | | static int EjectScsi ( int i_fd ); |
|---|
| 61 | | |
|---|
| 62 | | /* |
|---|
| 63 | | * Eject using CDROMEJECT ioctl. Return 0 if successful |
|---|
| 64 | | */ |
|---|
| 65 | | static int EjectCdrom( int i_fd ) |
|---|
| 66 | | { |
|---|
| 67 | | int i_status; |
|---|
| 68 | | |
|---|
| 69 | | i_status = ioctl( i_fd, CDROMEJECT ); |
|---|
| 70 | | |
|---|
| 71 | | return i_status; |
|---|
| | 113 | return i_ret; |
|---|
| 72 | 114 | } |
|---|
| 73 | 115 | |
|---|
| | 116 | /* The following functions are local */ |
|---|
| 74 | 117 | |
|---|
| 75 | | /* |
|---|
| | 118 | #ifdef SYS_LINUX |
|---|
| | 119 | /***************************************************************************** |
|---|
| 76 | 120 | * Eject using SCSI commands. Return 0 if successful |
|---|
| 77 | | */ |
|---|
| 78 | | static int EjectScsi( int i_fd ) |
|---|
| | 121 | *****************************************************************************/ |
|---|
| | 122 | static int EjectSCSI( int i_fd ) |
|---|
| 79 | 123 | { |
|---|
| 80 | 124 | int i_status; |
|---|
| … | … | |
| 134 | 178 | return i_status; |
|---|
| 135 | 179 | } |
|---|
| | 180 | #endif |
|---|
| 136 | 181 | |
|---|
| 137 | | /* |
|---|
| 138 | | * returns 0 on success |
|---|
| 139 | | * returns 1 on failure |
|---|
| 140 | | * returns -1 if not implemented |
|---|
| 141 | | * |
|---|
| 142 | | * Modify eject_disc() prototype as needed for portability |
|---|
| 143 | | */ |
|---|
| 144 | | |
|---|
| 145 | | int intf_Eject( const char *psz_device ) |
|---|
| 146 | | { |
|---|
| 147 | | int i_ret; |
|---|
| 148 | | |
|---|
| 149 | | #ifdef SYS_LINUX |
|---|
| 150 | | int i_fd = 0; |
|---|
| 151 | | |
|---|
| 152 | | i_fd = open( psz_device, O_RDONLY | O_NONBLOCK ); |
|---|
| 153 | | |
|---|
| 154 | | if( i_fd == -1 ) |
|---|
| 155 | | { |
|---|
| 156 | | intf_ErrMsg( "intf error: couldn't open device %s", psz_device ); |
|---|
| 157 | | return 1; |
|---|
| 158 | | } |
|---|
| 159 | | |
|---|
| 160 | | if( EjectCdrom(i_fd) == 0 ) |
|---|
| 161 | | { |
|---|
| 162 | | i_ret = 0; |
|---|
| 163 | | } |
|---|
| 164 | | else if( EjectScsi(i_fd) == 0 ) |
|---|
| 165 | | { |
|---|
| 166 | | i_ret = 0; |
|---|
| 167 | | } |
|---|
| 168 | | else |
|---|
| 169 | | { |
|---|
| 170 | | intf_ErrMsg( "intf error: couldn't eject %s", psz_device ); |
|---|
| 171 | | i_ret = 1; |
|---|
| 172 | | } |
|---|
| 173 | | |
|---|
| 174 | | close( i_fd ); |
|---|
| 175 | | |
|---|
| 176 | | #else |
|---|
| 177 | | i_ret = -1; |
|---|
| 178 | | |
|---|
| 179 | | #endif |
|---|
| 180 | | return i_ret; |
|---|
| 181 | | } |
|---|
| 182 | | |
|---|
| r1e053ea |
rd7b4b27 |
|
| 5 | 5 | ***************************************************************************** |
|---|
| 6 | 6 | * Copyright (C) 1998-2001 VideoLAN |
|---|
| 7 | | * $Id: main.c,v 1.143 2002/01/07 02:12:30 sam Exp $ |
|---|
| | 7 | * $Id: main.c,v 1.144 2002/01/09 10:22:37 sam Exp $ |
|---|
| 8 | 8 | * |
|---|
| 9 | 9 | * Authors: Vincent Seguin <seguin@via.ecp.fr> |
|---|
| … | … | |
| 1309 | 1309 | i_capabilities |= CPU_CAPABILITY_SSE; |
|---|
| 1310 | 1310 | } |
|---|
| 1311 | | else |
|---|
| 1312 | | { |
|---|
| 1313 | | fprintf( stderr, "warning: your OS doesn't have support for " |
|---|
| 1314 | | "SSE instructions, some optimizations\n" |
|---|
| 1315 | | "will be disabled" |
|---|
| 1316 | | # ifdef SYS_LINUX |
|---|
| 1317 | | " (you will need Linux kernel 2.4.x or later)" |
|---|
| 1318 | | # endif |
|---|
| 1319 | | "\n" ); |
|---|
| 1320 | | } |
|---|
| 1321 | 1311 | # endif |
|---|
| 1322 | 1312 | } |
|---|