lib/driver/device.c: bug in close routine looping.

lib/*: Modify close routine for Win32 ioctl.
src/cdda-player: add option for close cd tray and minor things
This commit is contained in:
rocky
2005-03-08 03:11:19 +00:00
parent db3b2fa938
commit 7ae764d9b8
6 changed files with 80 additions and 38 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: win32.c,v 1.25 2005/03/07 00:55:31 rocky Exp $
$Id: win32.c,v 1.26 2005/03/08 03:11:19 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -26,7 +26,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: win32.c,v 1.25 2005/03/07 00:55:31 rocky Exp $";
static const char _rcsid[] = "$Id: win32.c,v 1.26 2005/03/08 03:11:19 rocky Exp $";
#include <cdio/cdio.h>
#include <cdio/sector.h>
@@ -173,16 +173,6 @@ audio_stop_win32 ( void *p_user_data)
}
}
static driver_return_code_t
close_tray_win32 ( void *p_user_data)
{
if ( WIN_NT ) {
return close_tray_win32ioctl (p_user_data);
} else {
return DRIVER_OP_UNSUPPORTED; /* not yet, but soon I hope */
}
}
/* General ioctl() CD-ROM command function */
static bool
_cdio_mciSendCommand(int id, UINT msg, DWORD flags, void *arg)
@@ -552,6 +542,16 @@ read_toc_win32 (void *p_user_data)
return ret;
}
driver_return_code_t
close_tray_win32 ( const char *psz_win32_drive)
{
if ( WIN_NT ) {
return close_tray_win32ioctl (psz_win32_drive);
} else {
return DRIVER_OP_UNSUPPORTED; /* not yet, but soon I hope */
}
}
/*!
Eject media. Return 1 if successful, 0 otherwise.
*/
@@ -856,7 +856,6 @@ cdio_open_am_win32 (const char *psz_orig_source, const char *psz_access_mode)
_funcs.audio_resume = audio_resume_win32;
_funcs.audio_set_volume = audio_set_volume_win32;
_funcs.audio_stop = audio_stop_win32;
_funcs.close_tray = close_tray_win32;
_funcs.eject_media = eject_media_win32;
_funcs.free = free_win32;
_funcs.get_arg = get_arg_win32;

View File

@@ -1,5 +1,5 @@
/*
$Id: win32.h,v 1.7 2005/03/07 00:55:31 rocky Exp $
$Id: win32.h,v 1.8 2005/03/08 03:11:19 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -120,7 +120,7 @@ audio_set_volume_win32ioctl ( void *p_user_data,
@param p_user_data the CD object to be acted upon.
*/
driver_return_code_t close_tray_win32ioctl (void *p_user_data);
driver_return_code_t close_tray_win32ioctl (const char *psz_win32_drive);
/*!
Reads an audio device using the DeviceIoControl method into data

View File

@@ -1,5 +1,5 @@
/*
$Id: win32_ioctl.c,v 1.20 2005/03/07 00:55:31 rocky Exp $
$Id: win32_ioctl.c,v 1.21 2005/03/08 03:11:19 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -26,7 +26,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.20 2005/03/07 00:55:31 rocky Exp $";
static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.21 2005/03/08 03:11:19 rocky Exp $";
#ifdef HAVE_WIN32_CDROM
@@ -360,15 +360,39 @@ audio_stop_win32ioctl (void *p_user_data)
*/
driver_return_code_t
close_tray_win32ioctl (void *p_user_data)
close_tray_win32ioctl (const char *psz_win32_drive)
{
const _img_private_t *p_env = p_user_data;
#ifdef WIN32
DWORD dw_bytes_returned;
DWORD dw_access_flags;
bool b_success =
DeviceIoControl(p_env->h_device_handle, IOCTL_STORAGE_LOAD_MEDIA2,
NULL, (DWORD) 0, NULL, 0, &dw_bytes_returned, NULL);
OSVERSIONINFO ov;
HANDLE h_device_handle;
bool b_success;
memset(&ov,0,sizeof(OSVERSIONINFO));
ov.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(&ov);
if((ov.dwPlatformId==VER_PLATFORM_WIN32_NT) &&
(ov.dwMajorVersion>4))
dw_access_flags = GENERIC_READ|GENERIC_WRITE; /* add gen write on W2k/XP */
else dw_access_flags = GENERIC_READ;
h_device_handle = CreateFile( psz_win32_drive,
dw_access_flags,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL );
b_success =
DeviceIoControl(h_device_handle, IOCTL_STORAGE_LOAD_MEDIA,
NULL, (DWORD) 0, NULL, 0, &dw_bytes_returned, NULL);
CloseHandle(h_device_handle);
if ( ! b_success ) {
char *psz_msg = NULL;
long int i_err = GetLastError();
@@ -381,6 +405,9 @@ close_tray_win32ioctl (void *p_user_data)
return DRIVER_OP_ERROR;
}
return DRIVER_OP_SUCCESS;
#else
return DRIVER_OP_UNSUPPORTED;
#endif
}
/*!