From 5ff97b8b452bcb88d3f89f1fa8ed78e3f5df8795 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 31 Oct 2004 17:18:08 +0000 Subject: [PATCH] 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. --- lib/MSWindows/win32.c | 56 +++++++++++++++++++++++++++++++++++++------ lib/scsi_mmc.c | 38 ++++++++++++++++++++++------- 2 files changed, 79 insertions(+), 15 deletions(-) diff --git a/lib/MSWindows/win32.c b/lib/MSWindows/win32.c index 16c529d9..54f15585 100644 --- a/lib/MSWindows/win32.c +++ b/lib/MSWindows/win32.c @@ -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 @@ -26,7 +26,7 @@ # include "config.h" #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 #include @@ -41,25 +41,56 @@ static const char _rcsid[] = "$Id: win32.c,v 1.48 2004/10/31 05:33:08 rocky Exp #include #include + +#ifdef HAVE_STDLIB_H #include +#endif + +#ifdef HAVE_ERRNO_H #include +#endif + +#ifdef HAVE_UNISTD_H #include +#endif + +#ifdef HAVE_FCNTL_H #include +#endif #include #include #include "win32.h" +#ifdef HAVE_SYS_STAT_H #include -#include -#include "aspi32.h" +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#if defined (MSVC) || defined (_XBOX) +#undef IN +#else +#include "aspi32.h" +#endif + +#ifdef _XBOX +#include "stdint.h" +#include +#define WIN_NT 1 +#else #define WIN_NT ( GetVersion() < 0x80000000 ) +#endif /* General ioctl() CD-ROM command function */ static bool _cdio_mciSendCommand(int id, UINT msg, DWORD flags, void *arg) { +#ifdef _XBOX + return false; +#else MCIERROR mci_error; 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); } return(mci_error == 0); +#endif } static access_mode_t @@ -83,10 +115,16 @@ str_to_access_mode_win32(const char *psz_access_mode) if (!strcmp(psz_access_mode, "ioctl")) return _AM_IOCTL; else if (!strcmp(psz_access_mode, "ASPI")) +#ifdef _XBOX 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 { - cdio_warn ("unknown access type: %s. Default used.", - psz_access_mode); + cdio_warn ("unknown access type: %s. Default % used instead.", + psz_access_mode, psz_default_access_mode); return default_access_mode; } } @@ -402,7 +440,9 @@ read_toc_win32 (void *p_user_data) */ static int _cdio_eject_media (void *user_data) { - +#ifdef _XBOX + return -1; +#else _img_private_t *env = user_data; @@ -432,6 +472,7 @@ _cdio_eject_media (void *user_data) { ret = 0; 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_drive_cap = scsi_mmc_get_drive_cap_generic; _funcs.get_first_track_num= get_first_track_num_generic; + _funcs.get_hwinfo = NULL; _funcs.get_mcn = _cdio_get_mcn; _funcs.get_num_tracks = get_num_tracks_generic; _funcs.get_track_format = _cdio_get_track_format; diff --git a/lib/scsi_mmc.c b/lib/scsi_mmc.c index aeafcae5..eaced795 100644 --- a/lib/scsi_mmc.c +++ b/lib/scsi_mmc.c @@ -1,6 +1,6 @@ /* 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 @@ -519,7 +519,7 @@ scsi_mmc_get_mcn_generic (const void *p_user_data) /* 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. */ bool @@ -532,7 +532,7 @@ scsi_mmc_init_cdtext_private ( void *p_user_data, generic_img_private_t *p_env = p_user_data; scsi_mmc_cdb_t cdb = {{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 ) return false; @@ -544,21 +544,43 @@ scsi_mmc_init_cdtext_private ( void *p_user_data, /* Format */ 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; - /* We may need to give CD-TEXT a little more time to complete. */ - i_status = run_scsi_mmc_cmd (p_env, 1000*60*3, +/* Set read timeout 3 minues. */ +#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]), &cdb, SCSI_MMC_DATA_READ, - sizeof(wdata), &wdata); + 4, &wdata); 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; return false; } 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; return cdtext_data_init(p_env, p_env->i_first_track, wdata, set_cdtext_field_fn);