Windows fixes. Read TOC via MMC only when media is not DVD.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: aspi32.c,v 1.5 2005/02/05 13:13:31 rocky Exp $
|
||||
$Id: aspi32.c,v 1.6 2005/02/06 17:36:17 rocky Exp $
|
||||
|
||||
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: aspi32.c,v 1.5 2005/02/05 13:13:31 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: aspi32.c,v 1.6 2005/02/06 17:36:17 rocky Exp $";
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
#include <cdio/sector.h>
|
||||
@@ -191,7 +191,7 @@ get_discmode_aspi (_img_private_t *p_env)
|
||||
|
||||
dvd.physical.type = CDIO_DVD_STRUCT_PHYSICAL;
|
||||
dvd.physical.layer_num = 0;
|
||||
if (0 == mmc_get_dvd_struct_physical_private (p_env, &run_scsi_cmd_aspi,
|
||||
if (0 == mmc_get_dvd_struct_physical_private (p_env, &run_mmc_cmd_aspi,
|
||||
&dvd)) {
|
||||
switch(dvd.physical.layer[0].book_type) {
|
||||
case CDIO_DVD_BOOK_DVD_ROM: return CDIO_DISC_MODE_DVD_ROM;
|
||||
@@ -487,10 +487,10 @@ init_aspi (_img_private_t *env)
|
||||
We return 0 if command completed successfully.
|
||||
*/
|
||||
int
|
||||
run_scsi_cmd_aspi( void *p_user_data, unsigned int i_timeout_ms,
|
||||
unsigned int i_cdb, const scsi_mmc_cdb_t * p_cdb,
|
||||
scsi_mmc_direction_t e_direction,
|
||||
unsigned int i_buf, /*in/out*/ void *p_buf )
|
||||
run_mmc_cmd_aspi( void *p_user_data, unsigned int i_timeout_ms,
|
||||
unsigned int i_cdb, const scsi_mmc_cdb_t * p_cdb,
|
||||
scsi_mmc_direction_t e_direction,
|
||||
unsigned int i_buf, /*in/out*/ void *p_buf )
|
||||
{
|
||||
const _img_private_t *p_env = p_user_data;
|
||||
HANDLE hEvent;
|
||||
@@ -601,9 +601,9 @@ read_sectors_aspi (_img_private_t *p_env, void *data, lsn_t lsn,
|
||||
i_buf = CDIO_CD_FRAMESIZE_RAW;
|
||||
}
|
||||
|
||||
return run_scsi_cmd_aspi(p_env, OP_TIMEOUT_MS,
|
||||
scsi_mmc_get_cmd_len(cdb.field[0]),
|
||||
&cdb, SCSI_MMC_DATA_READ, i_buf*nblocks, data);
|
||||
return run_mmc_cmd_aspi(p_env, OP_TIMEOUT_MS,
|
||||
scsi_mmc_get_cmd_len(cdb.field[0]),
|
||||
&cdb, SCSI_MMC_DATA_READ, i_buf*nblocks, data);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -668,10 +668,10 @@ read_toc_aspi (_img_private_t *p_env)
|
||||
|
||||
CDIO_MMC_SET_READ_LENGTH16(cdb.field, sizeof(tocheader));
|
||||
|
||||
i_status = run_scsi_cmd_aspi (p_env, OP_TIMEOUT_MS,
|
||||
scsi_mmc_get_cmd_len(cdb.field[0]),
|
||||
&cdb, SCSI_MMC_DATA_READ,
|
||||
sizeof(tocheader), &tocheader);
|
||||
i_status = run_mmc_cmd_aspi (p_env, OP_TIMEOUT_MS,
|
||||
scsi_mmc_get_cmd_len(cdb.field[0]),
|
||||
&cdb, SCSI_MMC_DATA_READ,
|
||||
sizeof(tocheader), &tocheader);
|
||||
|
||||
if (0 != i_status) return false;
|
||||
|
||||
@@ -694,10 +694,10 @@ read_toc_aspi (_img_private_t *p_env)
|
||||
|
||||
CDIO_MMC_SET_READ_LENGTH16(cdb.field, i_toclength);
|
||||
|
||||
i_status = run_scsi_cmd_aspi (p_env, OP_TIMEOUT_MS,
|
||||
scsi_mmc_get_cmd_len(cdb.field[0]),
|
||||
&cdb, SCSI_MMC_DATA_READ,
|
||||
i_toclength, p_fulltoc);
|
||||
i_status = run_mmc_cmd_aspi (p_env, OP_TIMEOUT_MS,
|
||||
scsi_mmc_get_cmd_len(cdb.field[0]),
|
||||
&cdb, SCSI_MMC_DATA_READ,
|
||||
i_toclength, p_fulltoc);
|
||||
if( 0 != i_status ) {
|
||||
p_env->gen.i_tracks = 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Win32 aspi specific */
|
||||
/*
|
||||
$Id: aspi32.h,v 1.2 2005/01/27 11:08:55 rocky Exp $
|
||||
$Id: aspi32.h,v 1.3 2005/02/06 17:36:17 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -240,10 +240,10 @@ bool read_toc_aspi (_img_private_t *env);
|
||||
|
||||
Return 0 if command completed successfully.
|
||||
*/
|
||||
int run_scsi_cmd_aspi( void *p_user_data,
|
||||
unsigned int i_timeout,
|
||||
unsigned int i_cdb,
|
||||
const scsi_mmc_cdb_t * p_cdb,
|
||||
scsi_mmc_direction_t e_direction,
|
||||
unsigned int i_buf, /*in/out*/ void *p_buf );
|
||||
int run_mmc_cmd_aspi( void *p_user_data,
|
||||
unsigned int i_timeout,
|
||||
unsigned int i_cdb,
|
||||
const scsi_mmc_cdb_t * p_cdb,
|
||||
scsi_mmc_direction_t e_direction,
|
||||
unsigned int i_buf, /*in/out*/ void *p_buf );
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: win32.c,v 1.15 2005/02/03 07:35:15 rocky Exp $
|
||||
$Id: win32.c,v 1.16 2005/02/06 17:36:17 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.15 2005/02/03 07:35:15 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: win32.c,v 1.16 2005/02/06 17:36:17 rocky Exp $";
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
#include <cdio/sector.h>
|
||||
@@ -166,19 +166,19 @@ is_cdrom_win32(const char drive_letter) {
|
||||
Return 0 if command completed successfully.
|
||||
*/
|
||||
static int
|
||||
run_scsi_cmd_win32( void *p_user_data, unsigned int i_timeout_ms,
|
||||
unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb,
|
||||
scsi_mmc_direction_t e_direction,
|
||||
unsigned int i_buf, /*in/out*/ void *p_buf )
|
||||
run_mmc_cmd_win32( void *p_user_data, unsigned int i_timeout_ms,
|
||||
unsigned int i_cdb, const scsi_mmc_cdb_t *p_cdb,
|
||||
scsi_mmc_direction_t e_direction,
|
||||
unsigned int i_buf, /*in/out*/ void *p_buf )
|
||||
{
|
||||
_img_private_t *p_env = p_user_data;
|
||||
|
||||
if (p_env->hASPI) {
|
||||
return run_scsi_cmd_aspi( p_env, i_timeout_ms, i_cdb, p_cdb,
|
||||
e_direction, i_buf, p_buf );
|
||||
return run_mmc_cmd_aspi( p_env, i_timeout_ms, i_cdb, p_cdb,
|
||||
e_direction, i_buf, p_buf );
|
||||
} else {
|
||||
return run_scsi_cmd_win32ioctl( p_env, i_timeout_ms, i_cdb, p_cdb,
|
||||
e_direction, i_buf, p_buf );
|
||||
return run_mmc_cmd_win32ioctl( p_env, i_timeout_ms, i_cdb, p_cdb,
|
||||
e_direction, i_buf, p_buf );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -746,6 +746,7 @@ cdio_open_am_win32 (const char *psz_orig_source, const char *psz_access_mode)
|
||||
_funcs.get_drive_cap = get_drive_cap_mmc;
|
||||
_funcs.get_first_track_num = get_first_track_num_generic;
|
||||
_funcs.get_hwinfo = NULL;
|
||||
_funcs.get_media_changed = get_media_changed_mmc;
|
||||
_funcs.get_mcn = _cdio_get_mcn;
|
||||
_funcs.get_num_tracks = get_num_tracks_generic;
|
||||
_funcs.get_track_channels = get_track_channels_generic,
|
||||
@@ -763,7 +764,7 @@ cdio_open_am_win32 (const char *psz_orig_source, const char *psz_access_mode)
|
||||
_funcs.read_mode2_sector = _cdio_read_mode2_sector;
|
||||
_funcs.read_mode2_sectors = _cdio_read_mode2_sectors;
|
||||
_funcs.read_toc = &read_toc_win32;
|
||||
_funcs.run_scsi_mmc_cmd = &run_scsi_cmd_win32;
|
||||
_funcs.run_mmc_cmd = &run_mmc_cmd_win32;
|
||||
_funcs.set_arg = set_arg_win32;
|
||||
_funcs.set_blocksize = set_blocksize_mmc;
|
||||
_funcs.set_speed = set_speed_mmc;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: win32.h,v 1.3 2005/02/04 03:57:45 rocky Exp $
|
||||
$Id: win32.h,v 1.4 2005/02/06 17:36:17 rocky Exp $
|
||||
|
||||
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -99,12 +99,12 @@ const char *is_cdrom_win32ioctl (const char drive_letter);
|
||||
|
||||
Return 0 if command completed successfully.
|
||||
*/
|
||||
int run_scsi_cmd_win32ioctl( void *p_user_data,
|
||||
unsigned int i_timeout,
|
||||
unsigned int i_cdb,
|
||||
const scsi_mmc_cdb_t * p_cdb,
|
||||
scsi_mmc_direction_t e_direction,
|
||||
unsigned int i_buf, /*in/out*/ void *p_buf );
|
||||
int run_mmc_cmd_win32ioctl( void *p_user_data,
|
||||
unsigned int i_timeout,
|
||||
unsigned int i_cdb,
|
||||
const scsi_mmc_cdb_t * p_cdb,
|
||||
scsi_mmc_direction_t e_direction,
|
||||
unsigned int i_buf, /*in/out*/ void *p_buf );
|
||||
|
||||
/*!
|
||||
Initialize internal structures for CD device.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: win32_ioctl.c,v 1.11 2005/02/06 11:13:37 rocky Exp $
|
||||
$Id: win32_ioctl.c,v 1.12 2005/02/06 17:36:17 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.11 2005/02/06 11:13:37 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.12 2005/02/06 17:36:17 rocky Exp $";
|
||||
|
||||
#ifdef HAVE_WIN32_CDROM
|
||||
|
||||
@@ -233,10 +233,9 @@ run_mmc_cmd_win32ioctl( void *p_user_data,
|
||||
/*!
|
||||
Get disc type associated with cd object.
|
||||
*/
|
||||
discmode_t
|
||||
get_discmode_win32ioctl (_img_private_t *p_env)
|
||||
static discmode_t
|
||||
dvd_discmode_win32ioctl (_img_private_t *p_env)
|
||||
{
|
||||
track_t i_track;
|
||||
discmode_t discmode=CDIO_DISC_MODE_NO_INFO;
|
||||
|
||||
/* See if this is a DVD. */
|
||||
@@ -257,12 +256,28 @@ get_discmode_win32ioctl (_img_private_t *p_env)
|
||||
default: return CDIO_DISC_MODE_DVD_OTHER;
|
||||
}
|
||||
}
|
||||
return discmode;
|
||||
}
|
||||
|
||||
if (!p_env->gen.toc_init)
|
||||
read_toc_win32ioctl (p_env);
|
||||
|
||||
if (!p_env->gen.toc_init)
|
||||
return CDIO_DISC_MODE_NO_INFO;
|
||||
/*!
|
||||
Get disc type associated with cd object.
|
||||
*/
|
||||
discmode_t
|
||||
get_discmode_win32ioctl (_img_private_t *p_env)
|
||||
{
|
||||
track_t i_track;
|
||||
discmode_t discmode;
|
||||
|
||||
if (!p_env) return CDIO_DISC_MODE_ERROR;
|
||||
|
||||
discmode = dvd_discmode_win32ioctl(p_env);
|
||||
|
||||
if (CDIO_DISC_MODE_NO_INFO != discmode) return discmode;
|
||||
|
||||
if (!p_env->gen.toc_init) read_toc_win32ioctl (p_env);
|
||||
|
||||
if (!p_env->gen.toc_init) return CDIO_DISC_MODE_ERROR;
|
||||
|
||||
for (i_track = p_env->gen.i_first_track;
|
||||
i_track < p_env->gen.i_first_track + p_env->gen.i_tracks ;
|
||||
@@ -661,10 +676,24 @@ read_toc_win32ioctl (_img_private_t *p_env)
|
||||
CDROM_TOC cdrom_toc;
|
||||
DWORD dwBytesReturned;
|
||||
unsigned int i, j;
|
||||
|
||||
bool b_fulltoc_first; /* Do we do fulltoc or DeviceIoControl
|
||||
first? */
|
||||
if ( ! p_env ) return false;
|
||||
|
||||
if ( read_fulltoc_win32mmc(p_env) ) return true;
|
||||
/*
|
||||
The MMC5 spec says:
|
||||
For media other than CD, information may be fabricated in order
|
||||
^^^ ^^
|
||||
to emulate a CD structure for teh specific media.
|
||||
|
||||
There is no requirement though that it *has* to and some DVD
|
||||
drives like one by Thompson for XBOX don't support a
|
||||
IOCTL_CDROM_READ_TOC for DVD's. So if we have a DVD we will not
|
||||
prefer getting the TOC via MMC.
|
||||
*/
|
||||
b_fulltoc_first = (CDIO_DISC_MODE_NO_INFO == dvd_discmode_win32ioctl(p_env));
|
||||
|
||||
if ( b_fulltoc_first && read_fulltoc_win32mmc(p_env) ) return true;
|
||||
|
||||
/* SCSI-MMC READ_TOC (FULTOC) read failed. Try reading TOC via
|
||||
DeviceIoControl instead */
|
||||
@@ -674,12 +703,17 @@ read_toc_win32ioctl (_img_private_t *p_env)
|
||||
&dwBytesReturned, NULL ) == 0 ) {
|
||||
char *psz_msg = NULL;
|
||||
long int i_err = GetLastError();
|
||||
cdio_log_level_t loglevel = b_fulltoc_first
|
||||
? CDIO_LOG_WARN : CDIO_LOG_DEBUG;
|
||||
|
||||
FORMAT_ERROR(i_err, psz_msg);
|
||||
if (psz_msg) {
|
||||
cdio_warn("could not read TOC (%ld): %s", i_err, psz_msg);
|
||||
cdio_log(loglevel, "could not read TOC (%ld): %s", i_err, psz_msg);
|
||||
LocalFree(psz_msg);
|
||||
} else
|
||||
cdio_warn("could not read TOC (%ld)", i_err);
|
||||
cdio_log(loglevel, "could not read TOC (%ld)", i_err);
|
||||
|
||||
if ( !b_fulltoc_first && read_fulltoc_win32mmc(p_env) ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user