X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Finterface%2Fintf_eject.c;h=ed73af20e95f151ba94b972048d50284111c3ca9;hb=639c2a0e2aeb95d127b219327e2240090a363284;hp=58a45d92f75da4eb87098e8819b43c97e4bf8586;hpb=774372d1f2e4c3d60ce81df4b2dc98e36d3eca55;p=vlc diff --git a/src/interface/intf_eject.c b/src/interface/intf_eject.c index 58a45d92f7..ed73af20e9 100644 --- a/src/interface/intf_eject.c +++ b/src/interface/intf_eject.c @@ -1,13 +1,13 @@ /***************************************************************************** * intf_eject.c: CD/DVD-ROM ejection handling functions ***************************************************************************** - * Copyright (C) 2001, 2002 VideoLAN - * $Id: intf_eject.c,v 1.19 2003/03/21 17:14:56 gbazin Exp $ + * Copyright (C) 2001-2004 the VideoLAN team + * $Id$ * - * Author: Julien Blache for the Linux part - * with code taken from the Linux "eject" command - * Jon Lech Johansen for Darwin - * Gildas Bazin for Win32 + * Authors: Julien Blache for the Linux part + * with code taken from the Linux "eject" command + * Jon Lech Johansen for Darwin + * Gildas Bazin for Win32 * * 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 @@ -24,6 +24,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/ +/** + * \file + * This file contain functions to eject CD and DVD drives + */ + #include #include @@ -85,6 +90,13 @@ static int EjectSCSI ( int i_fd ); * returns 1 on failure * returns -1 if not implemented *****************************************************************************/ +/** + * \brief Ejects the CD /DVD + * \ingroup vlc_interface + * \param p_this the calling vlc_object_t + * \param psz_device the CD/DVD to eject + * \return 0 on success, 1 on failure, -1 if not implemented + */ int __intf_Eject( vlc_object_t *p_this, const char *psz_device ) { int i_ret = VLC_SUCCESS; @@ -98,7 +110,7 @@ int __intf_Eject( vlc_object_t *p_this, const char *psz_device ) * The only way to cleanly unmount the disc under MacOS X * is to use the 'disktool' command line utility. It uses * the non-public Disk Arbitration API, which can not be - * used by Cocoa or Carbon applications. + * used by Cocoa or Carbon applications. */ if( ( psz_disk = (char *)strstr( psz_device, "disk" ) ) != NULL && @@ -153,15 +165,17 @@ int __intf_Eject( vlc_object_t *p_this, const char *psz_device ) i_flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE; - if( !mciSendCommand( 0, MCI_OPEN, i_flags, (unsigned long)&op ) ) + if( !mciSendCommand( 0, MCI_OPEN, i_flags, (unsigned long)&op ) ) { st.dwItem = MCI_STATUS_READY; - /* Eject disc */ - mciSendCommand( op.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0 ); - /* Release access to the device */ - mciSendCommand( op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0 ); + /* Eject disc */ + i_ret = mciSendCommand( op.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0 ); + /* Release access to the device */ + mciSendCommand( op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0 ); } + else i_ret = VLC_EGENERIC; + return i_ret; #else /* WIN32 */ int i_fd; @@ -169,7 +183,7 @@ int __intf_Eject( vlc_object_t *p_this, const char *psz_device ) /* This code could be extended to support CD/DVD-ROM chargers */ i_fd = open( psz_device, O_RDONLY | O_NONBLOCK ); - + if( i_fd == -1 ) { msg_Err( p_this, "could not open device %s", psz_device ); @@ -210,6 +224,13 @@ int __intf_Eject( vlc_object_t *p_this, const char *psz_device ) /***************************************************************************** * Eject using SCSI commands. Return 0 if successful *****************************************************************************/ +/** + * \brief Ejects the CD /DVD using SCSI commands + * \ingroup vlc_interface + * This function is local + * \param i_fd a device nummber + * \return 0 on success, VLC_EGENERIC on failure + */ static int EjectSCSI( int i_fd ) { int i_status; @@ -248,7 +269,7 @@ static int EjectSCSI( int i_fd ) { return VLC_EGENERIC; } - + scsi_cmd.inlen = 0; scsi_cmd.outlen = 0; scsi_cmd.cmd[0] = START_STOP; @@ -262,10 +283,10 @@ static int EjectSCSI( int i_fd ) { return VLC_EGENERIC; } - + /* Force kernel to reread partition table when new disc inserted */ i_status = ioctl( i_fd, BLKRRPART ); - + return i_status; } #endif