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:
@@ -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>
|
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#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/cdio.h>
|
||||||
#include <cdio/sector.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 */
|
/* General ioctl() CD-ROM command function */
|
||||||
static bool
|
static bool
|
||||||
_cdio_mciSendCommand(int id, UINT msg, DWORD flags, void *arg)
|
_cdio_mciSendCommand(int id, UINT msg, DWORD flags, void *arg)
|
||||||
@@ -552,6 +542,16 @@ read_toc_win32 (void *p_user_data)
|
|||||||
return ret;
|
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.
|
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_resume = audio_resume_win32;
|
||||||
_funcs.audio_set_volume = audio_set_volume_win32;
|
_funcs.audio_set_volume = audio_set_volume_win32;
|
||||||
_funcs.audio_stop = audio_stop_win32;
|
_funcs.audio_stop = audio_stop_win32;
|
||||||
_funcs.close_tray = close_tray_win32;
|
|
||||||
_funcs.eject_media = eject_media_win32;
|
_funcs.eject_media = eject_media_win32;
|
||||||
_funcs.free = free_win32;
|
_funcs.free = free_win32;
|
||||||
_funcs.get_arg = get_arg_win32;
|
_funcs.get_arg = get_arg_win32;
|
||||||
|
|||||||
@@ -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>
|
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.
|
@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
|
Reads an audio device using the DeviceIoControl method into data
|
||||||
|
|||||||
@@ -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>
|
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#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
|
#ifdef HAVE_WIN32_CDROM
|
||||||
|
|
||||||
@@ -360,15 +360,39 @@ audio_stop_win32ioctl (void *p_user_data)
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
driver_return_code_t
|
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_bytes_returned;
|
||||||
|
DWORD dw_access_flags;
|
||||||
|
|
||||||
bool b_success =
|
OSVERSIONINFO ov;
|
||||||
DeviceIoControl(p_env->h_device_handle, IOCTL_STORAGE_LOAD_MEDIA2,
|
HANDLE h_device_handle;
|
||||||
NULL, (DWORD) 0, NULL, 0, &dw_bytes_returned, NULL);
|
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 ) {
|
if ( ! b_success ) {
|
||||||
char *psz_msg = NULL;
|
char *psz_msg = NULL;
|
||||||
long int i_err = GetLastError();
|
long int i_err = GetLastError();
|
||||||
@@ -381,6 +405,9 @@ close_tray_win32ioctl (void *p_user_data)
|
|||||||
return DRIVER_OP_ERROR;
|
return DRIVER_OP_ERROR;
|
||||||
}
|
}
|
||||||
return DRIVER_OP_SUCCESS;
|
return DRIVER_OP_SUCCESS;
|
||||||
|
#else
|
||||||
|
return DRIVER_OP_UNSUPPORTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdio_private.h,v 1.23 2005/03/07 07:23:52 rocky Exp $
|
$Id: cdio_private.h,v 1.24 2005/03/08 03:11:19 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -474,6 +474,7 @@ extern "C" {
|
|||||||
unsigned int *i_drives);
|
unsigned int *i_drives);
|
||||||
|
|
||||||
driver_return_code_t close_tray_linux (const char *psz_device);
|
driver_return_code_t close_tray_linux (const char *psz_device);
|
||||||
|
driver_return_code_t close_tray_win32 (const char *psz_win32_drive);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: device.c,v 1.15 2005/03/07 07:23:52 rocky Exp $
|
$Id: device.c,v 1.16 2005/03/08 03:11:19 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = {
|
|||||||
&cdio_get_default_device_win32,
|
&cdio_get_default_device_win32,
|
||||||
&cdio_is_device_win32,
|
&cdio_is_device_win32,
|
||||||
&cdio_get_devices_win32,
|
&cdio_get_devices_win32,
|
||||||
NULL
|
&close_tray_win32
|
||||||
},
|
},
|
||||||
|
|
||||||
{DRIVER_CDRDAO,
|
{DRIVER_CDRDAO,
|
||||||
@@ -312,7 +312,7 @@ cdio_close_tray (const char *psz_device, /*in/out*/ driver_id_t
|
|||||||
*p_driver_id = CDIO_MIN_DEVICE_DRIVER;
|
*p_driver_id = CDIO_MIN_DEVICE_DRIVER;
|
||||||
|
|
||||||
/* Scan for driver */
|
/* Scan for driver */
|
||||||
for ( ; *p_driver_id<=CDIO_MAX_DRIVER; *p_driver_id++) {
|
for ( ; *p_driver_id<=CDIO_MAX_DRIVER; (*p_driver_id)++) {
|
||||||
if ( (*CdIo_all_drivers[*p_driver_id].have_driver)() &&
|
if ( (*CdIo_all_drivers[*p_driver_id].have_driver)() &&
|
||||||
*CdIo_all_drivers[*p_driver_id].close_tray ) {
|
*CdIo_all_drivers[*p_driver_id].close_tray ) {
|
||||||
return (*CdIo_all_drivers[*p_driver_id].close_tray)(psz_device);
|
return (*CdIo_all_drivers[*p_driver_id].close_tray)(psz_device);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdda-player.c,v 1.1 2005/03/07 12:55:12 rocky Exp $
|
$Id: cdda-player.c,v 1.2 2005/03/08 03:11:19 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -103,12 +103,15 @@ bool b_db = false; /* we have a database at all */
|
|||||||
bool b_record = false; /* we have a record for
|
bool b_record = false; /* we have a record for
|
||||||
the inserted CD */
|
the inserted CD */
|
||||||
|
|
||||||
#define PLAY_CD 1
|
typedef enum {
|
||||||
#define PLAY_TRACK 2
|
PLAY_CD=1,
|
||||||
#define STOP_PLAYING 3
|
PLAY_TRACK=2,
|
||||||
#define EJECT_CD 4
|
STOP_PLAYING=3,
|
||||||
#define LIST_TRACKS 5
|
EJECT_CD=4,
|
||||||
#define PS_LIST_TRACKS 6
|
CLOSE_CD=5,
|
||||||
|
LIST_TRACKS=6,
|
||||||
|
PS_LIST_TRACKS=7
|
||||||
|
} cd_operation_t;
|
||||||
|
|
||||||
char *psz_device=NULL;
|
char *psz_device=NULL;
|
||||||
char *psz_program;
|
char *psz_program;
|
||||||
@@ -299,7 +302,7 @@ cd_eject(CdIo_t *p_cdio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cd_close(CdIo_t *p_cdio)
|
cd_close(const char *psz_device)
|
||||||
{
|
{
|
||||||
if (!b_cd) {
|
if (!b_cd) {
|
||||||
action("close...");
|
action("close...");
|
||||||
@@ -388,7 +391,7 @@ play_track(track_t i_start_track, track_t i_end_track)
|
|||||||
char line[80];
|
char line[80];
|
||||||
|
|
||||||
if (!b_cd) {
|
if (!b_cd) {
|
||||||
cd_close(p_cdio);
|
cd_close(psz_device);
|
||||||
read_toc(p_cdio);
|
read_toc(p_cdio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1050,7 +1053,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* parse options */
|
/* parse options */
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
if (-1 == (c = getopt(argc, argv, "xdhkvcpset:la")))
|
if (-1 == (c = getopt(argc, argv, "xdhkvcCpset:la")))
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'v':
|
case 'v':
|
||||||
@@ -1085,6 +1088,10 @@ main(int argc, char *argv[])
|
|||||||
interactive = 0;
|
interactive = 0;
|
||||||
todo = LIST_TRACKS;
|
todo = LIST_TRACKS;
|
||||||
break;
|
break;
|
||||||
|
case 'C':
|
||||||
|
interactive = 0;
|
||||||
|
todo = CLOSE_CD;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
interactive = 0;
|
interactive = 0;
|
||||||
todo = PS_LIST_TRACKS;
|
todo = PS_LIST_TRACKS;
|
||||||
@@ -1134,6 +1141,14 @@ main(int argc, char *argv[])
|
|||||||
if (b_verbose)
|
if (b_verbose)
|
||||||
fprintf(stderr,"open %s... ", psz_device);
|
fprintf(stderr,"open %s... ", psz_device);
|
||||||
|
|
||||||
|
if (!interactive) {
|
||||||
|
b_sig = true;
|
||||||
|
nostop=1;
|
||||||
|
if (!b_cd && todo != EJECT_CD) {
|
||||||
|
cd_close(psz_device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p_cdio = cdio_open (psz_device, driver_id);
|
p_cdio = cdio_open (psz_device, driver_id);
|
||||||
|
|
||||||
if (!p_cdio) {
|
if (!p_cdio) {
|
||||||
@@ -1157,7 +1172,7 @@ main(int argc, char *argv[])
|
|||||||
nostop=1;
|
nostop=1;
|
||||||
read_toc(p_cdio);
|
read_toc(p_cdio);
|
||||||
if (!b_cd && todo != EJECT_CD) {
|
if (!b_cd && todo != EJECT_CD) {
|
||||||
cd_close(p_cdio);
|
cd_close(psz_device);
|
||||||
read_toc(p_cdio);
|
read_toc(p_cdio);
|
||||||
}
|
}
|
||||||
if (b_cd || todo == EJECT_CD) {
|
if (b_cd || todo == EJECT_CD) {
|
||||||
@@ -1225,7 +1240,7 @@ main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
case 'c':
|
case 'c':
|
||||||
cd_close(p_cdio);
|
cd_close(psz_device);
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
case 'P':
|
case 'P':
|
||||||
|
|||||||
Reference in New Issue
Block a user