scsi_mmc.c: get CD-Text length before reading CD-Text. win32.c: make
sure we can't set ASPI when XBOX. Other small changes for XBOX compatibility.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: win32.c,v 1.48 2004/10/31 05:33:08 rocky Exp $
|
$Id: win32.c,v 1.49 2004/10/31 17:18:08 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003, 2004 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.48 2004/10/31 05:33:08 rocky Exp $";
|
static const char _rcsid[] = "$Id: win32.c,v 1.49 2004/10/31 17:18:08 rocky Exp $";
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
@@ -41,25 +41,56 @@ static const char _rcsid[] = "$Id: win32.c,v 1.48 2004/10/31 05:33:08 rocky Exp
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_ERRNO_H
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_FCNTL_H
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_STAT_H
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#endif
|
||||||
#include "aspi32.h"
|
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (MSVC) || defined (_XBOX)
|
||||||
|
#undef IN
|
||||||
|
#else
|
||||||
|
#include "aspi32.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _XBOX
|
||||||
|
#include "stdint.h"
|
||||||
|
#include <xtl.h>
|
||||||
|
#define WIN_NT 1
|
||||||
|
#else
|
||||||
#define WIN_NT ( GetVersion() < 0x80000000 )
|
#define WIN_NT ( GetVersion() < 0x80000000 )
|
||||||
|
#endif
|
||||||
|
|
||||||
/* 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)
|
||||||
{
|
{
|
||||||
|
#ifdef _XBOX
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
MCIERROR mci_error;
|
MCIERROR mci_error;
|
||||||
|
|
||||||
mci_error = mciSendCommand(id, msg, flags, (DWORD)arg);
|
mci_error = mciSendCommand(id, msg, flags, (DWORD)arg);
|
||||||
@@ -70,6 +101,7 @@ _cdio_mciSendCommand(int id, UINT msg, DWORD flags, void *arg)
|
|||||||
cdio_warn("mciSendCommand() error: %s", error);
|
cdio_warn("mciSendCommand() error: %s", error);
|
||||||
}
|
}
|
||||||
return(mci_error == 0);
|
return(mci_error == 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static access_mode_t
|
static access_mode_t
|
||||||
@@ -83,10 +115,16 @@ str_to_access_mode_win32(const char *psz_access_mode)
|
|||||||
if (!strcmp(psz_access_mode, "ioctl"))
|
if (!strcmp(psz_access_mode, "ioctl"))
|
||||||
return _AM_IOCTL;
|
return _AM_IOCTL;
|
||||||
else if (!strcmp(psz_access_mode, "ASPI"))
|
else if (!strcmp(psz_access_mode, "ASPI"))
|
||||||
|
#ifdef _XBOX
|
||||||
return _AM_ASPI;
|
return _AM_ASPI;
|
||||||
|
#else
|
||||||
|
cdio_warn ("XBOX doesn't support % access: %s. Default %s used instead.",
|
||||||
|
psz_access_mode, psz_default_access_mode);
|
||||||
|
return default_access_mode;
|
||||||
|
#endif
|
||||||
else {
|
else {
|
||||||
cdio_warn ("unknown access type: %s. Default used.",
|
cdio_warn ("unknown access type: %s. Default % used instead.",
|
||||||
psz_access_mode);
|
psz_access_mode, psz_default_access_mode);
|
||||||
return default_access_mode;
|
return default_access_mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -402,7 +440,9 @@ read_toc_win32 (void *p_user_data)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_cdio_eject_media (void *user_data) {
|
_cdio_eject_media (void *user_data) {
|
||||||
|
#ifdef _XBOX
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
_img_private_t *env = user_data;
|
_img_private_t *env = user_data;
|
||||||
|
|
||||||
|
|
||||||
@@ -432,6 +472,7 @@ _cdio_eject_media (void *user_data) {
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -696,6 +737,7 @@ cdio_open_am_win32 (const char *psz_orig_source, const char *psz_access_mode)
|
|||||||
_funcs.get_discmode = get_discmode_win32;
|
_funcs.get_discmode = get_discmode_win32;
|
||||||
_funcs.get_drive_cap = scsi_mmc_get_drive_cap_generic;
|
_funcs.get_drive_cap = scsi_mmc_get_drive_cap_generic;
|
||||||
_funcs.get_first_track_num= get_first_track_num_generic;
|
_funcs.get_first_track_num= get_first_track_num_generic;
|
||||||
|
_funcs.get_hwinfo = NULL;
|
||||||
_funcs.get_mcn = _cdio_get_mcn;
|
_funcs.get_mcn = _cdio_get_mcn;
|
||||||
_funcs.get_num_tracks = get_num_tracks_generic;
|
_funcs.get_num_tracks = get_num_tracks_generic;
|
||||||
_funcs.get_track_format = _cdio_get_track_format;
|
_funcs.get_track_format = _cdio_get_track_format;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Common SCSI Multimedia Command (MMC) routines.
|
/* Common SCSI Multimedia Command (MMC) routines.
|
||||||
|
|
||||||
$Id: scsi_mmc.c,v 1.29 2004/10/30 21:53:15 rocky Exp $
|
$Id: scsi_mmc.c,v 1.30 2004/10/31 17:18:08 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -519,7 +519,7 @@ scsi_mmc_get_mcn_generic (const void *p_user_data)
|
|||||||
/*
|
/*
|
||||||
Read cdtext information for a CdIo object .
|
Read cdtext information for a CdIo object .
|
||||||
|
|
||||||
return true on success, false on error or CD-TEXT information does
|
return true on success, false on error or CD-Text information does
|
||||||
not exist.
|
not exist.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
@@ -532,7 +532,7 @@ scsi_mmc_init_cdtext_private ( void *p_user_data,
|
|||||||
generic_img_private_t *p_env = p_user_data;
|
generic_img_private_t *p_env = p_user_data;
|
||||||
scsi_mmc_cdb_t cdb = {{0, }};
|
scsi_mmc_cdb_t cdb = {{0, }};
|
||||||
unsigned char wdata[5000] = { 0, };
|
unsigned char wdata[5000] = { 0, };
|
||||||
int i_status;
|
int i_status, i_errno;
|
||||||
|
|
||||||
if ( ! p_env || ! run_scsi_mmc_cmd || p_env->b_cdtext_error )
|
if ( ! p_env || ! run_scsi_mmc_cmd || p_env->b_cdtext_error )
|
||||||
return false;
|
return false;
|
||||||
@@ -544,21 +544,43 @@ scsi_mmc_init_cdtext_private ( void *p_user_data,
|
|||||||
/* Format */
|
/* Format */
|
||||||
cdb.field[2] = CDIO_MMC_READTOC_FMT_CDTEXT;
|
cdb.field[2] = CDIO_MMC_READTOC_FMT_CDTEXT;
|
||||||
|
|
||||||
CDIO_MMC_SET_READ_LENGTH16(cdb.field, sizeof(wdata));
|
/* Setup to read header, to get length of data */
|
||||||
|
CDIO_MMC_SET_READ_LENGTH16(cdb.field, 4);
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
/* We may need to give CD-TEXT a little more time to complete. */
|
/* Set read timeout 3 minues. */
|
||||||
i_status = run_scsi_mmc_cmd (p_env, 1000*60*3,
|
#define READ_TIMEOUT 3*60*1000
|
||||||
|
|
||||||
|
/* We may need to give CD-Text a little more time to complete. */
|
||||||
|
/* First off, just try and read the size */
|
||||||
|
i_status = run_scsi_mmc_cmd (p_env, READ_TIMEOUT,
|
||||||
scsi_mmc_get_cmd_len(cdb.field[0]),
|
scsi_mmc_get_cmd_len(cdb.field[0]),
|
||||||
&cdb, SCSI_MMC_DATA_READ,
|
&cdb, SCSI_MMC_DATA_READ,
|
||||||
sizeof(wdata), &wdata);
|
4, &wdata);
|
||||||
|
|
||||||
if (i_status != 0) {
|
if (i_status != 0) {
|
||||||
cdio_info ("CD-TEXT reading failed: %s\n", strerror(errno));
|
cdio_info ("CD-Text read failed for header: %s\n", strerror(errno));
|
||||||
|
i_errno = errno;
|
||||||
p_env->b_cdtext_error = true;
|
p_env->b_cdtext_error = true;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
/* Now read the CD-Text data */
|
||||||
|
int i_cdtext = CDIO_MMC_GET_LEN16(wdata);
|
||||||
|
|
||||||
|
if (i_cdtext > sizeof(wdata)) i_cdtext = sizeof(wdata);
|
||||||
|
|
||||||
|
CDIO_MMC_SET_READ_LENGTH16(cdb.field, i_cdtext);
|
||||||
|
i_status = run_scsi_mmc_cmd (p_env, READ_TIMEOUT,
|
||||||
|
scsi_mmc_get_cmd_len(cdb.field[0]),
|
||||||
|
&cdb, SCSI_MMC_DATA_READ,
|
||||||
|
i_cdtext, &wdata);
|
||||||
|
if (i_status != 0) {
|
||||||
|
cdio_info ("CD-Text read for text failed: %s\n", strerror(errno));
|
||||||
|
i_errno = errno;
|
||||||
|
p_env->b_cdtext_error = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
p_env->b_cdtext_init = true;
|
p_env->b_cdtext_init = true;
|
||||||
return cdtext_data_init(p_env, p_env->i_first_track, wdata,
|
return cdtext_data_init(p_env, p_env->i_first_track, wdata,
|
||||||
set_cdtext_field_fn);
|
set_cdtext_field_fn);
|
||||||
|
|||||||
Reference in New Issue
Block a user