Add interface for setting speed and blocksize. Reinstated it in

cd-paranoia libraries and command.

Some more variable convention regularizations.
This commit is contained in:
rocky
2005-01-18 00:57:19 +00:00
parent 17c55ea59b
commit e5bdc956e9
14 changed files with 211 additions and 73 deletions

View File

@@ -1,5 +1,5 @@
/* -*- c -*-
$Id: device.h,v 1.3 2005/01/09 16:07:46 rocky Exp $
$Id: device.h,v 1.4 2005/01/18 00:57:19 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -106,7 +106,7 @@ extern "C" {
Eject media in CD drive if there is a routine to do so.
@param p_cdio the CD object to be acted upon.
@return 0 if success and 1 for failure, and 2 if no routine.
@return 0 if success and 1 for failure, and -2 if no routine.
If the CD is ejected *p_cdio is freed and p_cdio set to NULL.
*/
int cdio_eject_media (CdIo_t **p_cdio);
@@ -247,6 +247,16 @@ extern "C" {
/* out*/ cdio_hwinfo_t *p_hw_info );
/*!
Get the drive speed.
@return the drive speed if greater than 0. -1 if we had an error. is -2
returned if this is not implemented for the current driver.
@see cdio_set_speed
*/
int cdio_get_speed ( const CdIo_t *p_cdio, int i_speed );
/*! True if AIX driver is available. */
bool cdio_have_aix (void);
@@ -669,11 +679,12 @@ extern "C" {
CdIo_t * cdio_open_am_nrg (const char *psz_source,
const char *psz_access_mode);
/*! Return a string containing the default device name that the
NRG driver would use when none is specified. A scan is made
for NRG disk images in the current directory..
/*! Get a string containing the default device name that the NRG
driver would use when none is specified. A scan is made for NRG
disk images in the current directory.
NULL is returned on error or there is no CD-ROM device.
@return string containing the default device. NULL on error or
there is no CD-ROM device.
*/
char * cdio_get_default_device_nrg(void);
@@ -726,6 +737,24 @@ extern "C" {
*/
bool cdio_is_device(const char *psz_source, driver_id_t driver_id);
/*!
Set the blocksize for subsequent reads.
@return 0 if everything went okay, -1 if we had an error. is -2
returned if this is not implemented for the current driver.
*/
int cdio_set_blocksize ( const CdIo_t *p_cdio, int i_blocksize );
/*!
Set the drive speed.
@return 0 if everything went okay, -1 if we had an error. is -2
returned if this is not implemented for the current driver.
@see cdio_get_speed
*/
int cdio_set_speed ( const CdIo_t *p_cdio, int i_speed );
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@@ -1,5 +1,5 @@
/*
$Id: scsi_mmc.h,v 1.37 2005/01/05 04:16:11 rocky Exp $
$Id: scsi_mmc.h,v 1.38 2005/01/18 00:57:20 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -356,14 +356,16 @@ uint8_t scsi_mmc_get_cmd_len(uint8_t scsi_cmd);
Returns 0 if command completed successfully.
*/
int scsi_mmc_run_cmd( const CdIo *p_cdio, unsigned int i_timeout_ms,
int scsi_mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
const scsi_mmc_cdb_t *p_cdb,
scsi_mmc_direction_t e_direction, unsigned int i_buf,
/*in/out*/ void *p_buf );
/*!
* Eject using SCSI MMC commands. Return 0 if successful.
* Eject using SCSI MMC commands.
@return 0 if successful.
*/
int scsi_mmc_eject_media( const CdIo *p_cdio);
int scsi_mmc_eject_media( const CdIo_t *p_cdio);
/*!
Return the discmode as reported by the SCSI-MMC Read (FULL) TOC
@@ -374,26 +376,31 @@ int scsi_mmc_eject_media( const CdIo *p_cdio);
at http://www.t10.org/ftp/t10/drafts/mmc/mmc-r10a.pdf See
especially tables 72, 73 and 75.
*/
discmode_t scsi_mmc_get_discmode( const CdIo *p_cdio );
discmode_t scsi_mmc_get_discmode( const CdIo_t *p_cdio );
/*!
Return the the kind of drive capabilities of device.
Get drive capabilities for a device.
@return the drive capabilities.
*/
void scsi_mmc_get_drive_cap (const CdIo *p_cdio,
void scsi_mmc_get_drive_cap (const CdIo_t *p_cdio,
/*out*/ cdio_drive_read_cap_t *p_read_cap,
/*out*/ cdio_drive_write_cap_t *p_write_cap,
/*out*/ cdio_drive_misc_cap_t *p_misc_cap);
/*!
Get the DVD type associated with cd object.
@return the DVD discmode.
*/
discmode_t scsi_mmc_get_dvd_struct_physical ( const CdIo *p_cdio,
cdio_dvd_struct_t *s);
/*!
Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
False is returned if we had an error getting the information.
@return true if we were able to get hardware info, false if we had
an error.
*/
bool scsi_mmc_get_hwinfo ( const CdIo_t *p_cdio,
/* out*/ cdio_hwinfo_t *p_hw_info );
@@ -409,24 +416,24 @@ bool scsi_mmc_get_hwinfo ( const CdIo_t *p_cdio,
string when done with it.
*/
char *scsi_mmc_get_mcn ( const CdIo *p_cdio );
char *scsi_mmc_get_mcn ( const CdIo_t *p_cdio );
/*! Packet driver to read mode2 sectors.
Can read only up to 25 blocks.
*/
int scsi_mmc_read_sectors ( const CdIo *p_cdio, void *p_buf, lba_t lba,
int scsi_mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf, lba_t lba,
int sector_type, unsigned int i_blocks);
/*!
Set the block size for subsequest read requests, via a SCSI MMC
MODE_SELECT 6 command.
*/
int scsi_mmc_set_blocksize ( const CdIo *p_cdio, unsigned int i_bsize);
int scsi_mmc_set_blocksize ( const CdIo_t *p_cdio, unsigned int i_bsize);
/*!
Set the block size for subsequest read requests, via a SCSI MMC
MODE_SENSE 6 command.
*/
int scsi_mmc_get_blocksize ( const CdIo *p_cdio );
int scsi_mmc_get_blocksize ( const CdIo_t *p_cdio );
#endif /* __SCSI_MMC_H__ */

View File

@@ -1,5 +1,5 @@
/*
$Id: cooked_interface.c,v 1.11 2005/01/15 16:05:44 rocky Exp $
$Id: cooked_interface.c,v 1.12 2005/01/18 00:57:20 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Original interface.c Copyright (C) 1994-1997
@@ -64,14 +64,9 @@ cooked_readtoc (cdrom_drive_t *d)
/* Set operating speed */
static int
cooked_setspeed(cdrom_drive_t *d, int speed)
cooked_setspeed(cdrom_drive_t *d, int i_speed)
{
#if SET_SPEED_FIXED
if(d->ioctl_fd!=-1)
return ioctl(d->ioctl_fd, CDROM_SELECT_SPEED, speed);
else
#endif
return 0;
return cdio_set_speed(d->p_cdio, i_speed);
}
/* read 'SectorBurst' adjacent sectors of audio sectors

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_generic.c,v 1.5 2005/01/02 22:43:41 rocky Exp $
$Id: _cdio_generic.c,v 1.6 2005/01/18 00:57:20 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -25,7 +25,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.5 2005/01/02 22:43:41 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.6 2005/01/18 00:57:20 rocky Exp $";
#include <stdio.h>
#include <stdlib.h>
@@ -50,13 +50,35 @@ static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.5 2005/01/02 22:43:41 roc
#include "portable.h"
/*!
Eject media -- there's nothing to do here. We always return 2.
Eject media -- there's nothing to do here. We always return -2.
Should we also free resources?
*/
int
cdio_generic_bogus_eject_media (void *user_data) {
cdio_generic_unimplemented_eject_media (void *p_user_data) {
/* Sort of a stub here. Perhaps log a message? */
return 2;
return -2;
}
/*!
Set the blocksize for subsequent reads.
@return -2 since it's not implemented.
*/
int
cdio_generic_unimplemented_set_blocksize (void *p_user_data, int i_blocksize) {
/* Sort of a stub here. Perhaps log a message? */
return -2;
}
/*!
Set the drive speed.
@return -2 since it's not implemented.
*/
int
cdio_generic_unimplemented_set_speed (void *p_user_data, int i_speed) {
/* Sort of a stub here. Perhaps log a message? */
return -2;
}

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_linux.c,v 1.7 2005/01/17 17:20:09 rocky Exp $
$Id: _cdio_linux.c,v 1.8 2005/01/18 00:57:20 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.7 2005/01/17 17:20:09 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.8 2005/01/18 00:57:20 rocky Exp $";
#include <string.h>
@@ -587,8 +587,9 @@ _read_mode2_sectors_mmc (_img_private_t *p_env, void *p_buf, lba_t lba,
return retval;
}
if ((retval = scsi_mmc_set_blocksize (p_env->gen.cdio, CDIO_CD_FRAMESIZE)))
return retval;
/* Restore blocksize. */
retval = scsi_mmc_set_blocksize (p_env->gen.cdio, CDIO_CD_FRAMESIZE);
return retval;
} else
cdb.field[1] = 0; /* sector size mode2 */
@@ -929,7 +930,7 @@ stat_size_linux (void *p_user_data)
_img_private_t *p_env = p_user_data;
struct cdrom_tocentry tocent;
uint32_t size;
uint32_t i_size;
tocent.cdte_track = CDIO_CDROM_LEADOUT_TRACK;
tocent.cdte_format = CDROM_LBA;
@@ -939,9 +940,9 @@ stat_size_linux (void *p_user_data)
exit (EXIT_FAILURE);
}
size = tocent.cdte_addr.lba;
i_size = tocent.cdte_addr.lba;
return size;
return i_size;
}
/*!
@@ -984,6 +985,24 @@ static char checklist2[][40] = {
{"?a hd?"}, {"?0 scd?"}, {"?0 sr?"}, {""}
};
/* Set operating speed */
static int
set_blocksize_linux (void *p_user_data, int i_blocksize)
{
const _img_private_t *p_env = p_user_data;
return scsi_mmc_set_blocksize(p_env->gen.cdio, i_blocksize);
}
/* Set operating speed */
static int
set_speed_linux (void *p_user_data, int i_speed)
{
const _img_private_t *p_env = p_user_data;
if (!p_env) return -1;
return ioctl(p_env->gen.fd, CDROM_SELECT_SPEED, i_speed);
}
#endif /* HAVE_LINUX_CDROM */
/*!
@@ -1158,6 +1177,8 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode)
.read_toc = read_toc_linux,
.run_scsi_mmc_cmd = run_scsi_cmd_linux,
.set_arg = set_arg_linux,
.set_blocksize = set_blocksize_linux,
.set_speed = set_speed_linux,
.stat_size = stat_size_linux
};

View File

@@ -1,5 +1,5 @@
/*
$Id: cdio_private.h,v 1.5 2005/01/17 17:20:09 rocky Exp $
$Id: cdio_private.h,v 1.6 2005/01/18 00:57:20 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -160,6 +160,12 @@ extern "C" {
*/
track_format_t (*get_track_format) (void *p_env, track_t i_track);
/*!
Set the drive speed. -1 is returned if we had an error.
-2 is returned if this is not implemented for the current driver.
*/
int (*p_get_speed) (void *p_env);
/*!
Return true if we have XA data (green, mode2 form1) or
XA data (green, mode2 form2). That is track begins:
@@ -262,6 +268,22 @@ extern "C" {
*/
int (*set_arg) (void *p_env, const char key[], const char value[]);
/*!
Set the blocksize for subsequent reads.
@return 0 if everything went okay, -1 if we had an error. is -2
returned if this is not implemented for the current driver.
*/
int (*set_blocksize) ( void *p_env, int i_blocksize );
/*!
Set the drive speed.
@return 0 if everything went okay, -1 if we had an error. is -2
returned if this is not implemented for the current driver.
*/
int (*set_speed) ( void *p_env, int i_speed );
/*!
Return the size of the CD in logical block address (LBA) units.
*/

View File

@@ -1,5 +1,5 @@
/*
$Id: device.c,v 1.3 2005/01/17 17:20:09 rocky Exp $
$Id: device.c,v 1.4 2005/01/18 00:57:20 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -536,16 +536,16 @@ cdio_get_driver_name (const CdIo_t *p_cdio)
return CdIo_all_drivers[p_cdio->driver_id].name;
}
/*!
Return the driver id.
if CdIo is NULL (we haven't initialized a specific device driver),
then return DRIVER_UNKNOWN.
*/
/*!
Return the driver id.
if CdIo is NULL (we haven't initialized a specific device driver),
then return DRIVER_UNKNOWN.
*/
driver_id_t
cdio_get_driver_id (const CdIo *cdio)
cdio_get_driver_id (const CdIo_t *p_cdio)
{
if (NULL==cdio) return DRIVER_UNKNOWN;
return cdio->driver_id;
if (!p_cdio) return DRIVER_UNKNOWN;
return p_cdio->driver_id;
}
/*!
@@ -691,6 +691,35 @@ cdio_open_am_cd (const char *psz_source, const char *psz_access_mode)
psz_source, psz_access_mode);
}
/*!
Set the blocksize for subsequent reads.
@return 0 if everything went okay, -1 if we had an error. is -2
returned if this is not implemented for the current driver.
*/
int cdio_set_blocksize ( const CdIo_t *p_cdio, int i_blocksize )
{
if (!p_cdio) return -1;
if (p_cdio->op.set_blocksize) return -2;
return p_cdio->op.set_blocksize(p_cdio->env, i_blocksize);
}
/*!
Set the drive speed.
@return 0 if everything went okay, -1 if we had an error. is -2
returned if this is not implemented for the current driver.
@see cdio_get_speed
*/
int
cdio_set_speed (const CdIo_t *p_cdio, int i_speed)
{
if (!p_cdio) return -1;
if (p_cdio->op.set_speed) return -2;
return p_cdio->op.set_speed(p_cdio->env, i_speed);
}
/*
* Local variables:

View File

@@ -1,5 +1,5 @@
/*
$Id: generic.h,v 1.5 2005/01/04 04:33:36 rocky Exp $
$Id: generic.h,v 1.6 2005/01/18 00:57:20 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -64,7 +64,7 @@ extern "C" {
1-3: Joliet level. */
iso9660_pvd_t pvd;
iso9660_svd_t svd;
CdIo *cdio; /**< a way to call general cdio routines. */
CdIo_t *cdio; /**< a way to call general cdio routines. */
cdtext_t cdtext; /**< CD-Text for disc. */
cdtext_t cdtext_track[CDIO_CD_MAX_TRACKS+1]; /**< CD-TEXT for each track*/
track_flags_t track_flags[CDIO_CD_MAX_TRACKS+1];
@@ -74,8 +74,23 @@ extern "C" {
Bogus eject media when there is no ejectable media, e.g. a disk image
We always return 2. Should we also free resources?
*/
int cdio_generic_bogus_eject_media (void *env);
int cdio_generic_unimplemented_eject_media (void *p_env);
/*!
Set the blocksize for subsequent reads.
@return -2 since it's not implemented.
*/
int cdio_generic_unimplemented_set_blocksize (void *p_user_data,
int i_blocksize);
/*!
Set the drive speed.
@return -2 since it's not implemented.
*/
int cdio_generic_unimplemented_set_speed (void *p_user_data, int i_speed);
/*!
Release and free resources associated with cd.
*/

View File

@@ -1,5 +1,5 @@
/*
$Id: cdrdao.c,v 1.6 2005/01/17 17:20:09 rocky Exp $
$Id: cdrdao.c,v 1.7 2005/01/18 00:57:20 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
toc reading routine adapted from cuetools
@@ -25,7 +25,7 @@
(*.cue).
*/
static const char _rcsid[] = "$Id: cdrdao.c,v 1.6 2005/01/17 17:20:09 rocky Exp $";
static const char _rcsid[] = "$Id: cdrdao.c,v 1.7 2005/01/18 00:57:20 rocky Exp $";
#include "image.h"
#include "cdio_assert.h"
@@ -84,10 +84,10 @@ _init_cdrdao (_img_private_t *env)
/* Have to set init before calling _stat_size_cdrdao() or we will
get into infinite recursion calling passing right here.
*/
env->gen.init = true;
env->gen.init = true;
env->gen.i_first_track = 1;
env->psz_mcn = NULL;
env->disc_mode = CDIO_DISC_MODE_NO_INFO;
env->psz_mcn = NULL;
env->disc_mode = CDIO_DISC_MODE_NO_INFO;
cdtext_init (&(env->gen.cdtext));
@@ -1203,6 +1203,8 @@ cdio_open_cdrdao (const char *psz_cue_name)
_funcs.read_mode2_sector = _read_mode2_sector_cdrdao;
_funcs.read_mode2_sectors = _read_mode2_sectors_cdrdao;
_funcs.set_arg = _set_arg_image;
_funcs.set_speed = cdio_generic_unimplemented_set_speed;
_funcs.set_blocksize = cdio_generic_unimplemented_set_blocksize;
_funcs.stat_size = _stat_size_cdrdao;
if (NULL == psz_cue_name) return NULL;

View File

@@ -1,5 +1,5 @@
/*
$Id: image_common.c,v 1.3 2005/01/04 04:33:36 rocky Exp $
$Id: image_common.c,v 1.4 2005/01/18 00:57:20 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -38,18 +38,15 @@
#include <string.h>
#endif
#define free_if_notnull(obj) \
if (NULL != obj) { free(obj); obj=NULL; };
/*!
Eject media -- there's nothing to do here except free resources.
We always return 2.
We always return -2.
*/
int
_eject_media_image(void *user_data)
_eject_media_image(void *p_user_data)
{
_free_image (user_data);
return 2;
_free_image (p_user_data);
return -2;
}
/*!

View File

@@ -1,5 +1,5 @@
/*
$Id: image_common.h,v 1.5 2005/01/12 11:34:52 rocky Exp $
$Id: image_common.h,v 1.6 2005/01/18 00:57:20 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -63,8 +63,8 @@ typedef struct {
#endif
} _img_private_t;
#define free_if_notnull(obj) \
if (NULL != obj) { free(obj); obj=NULL; };
#define free_if_notnull(p_obj) \
if (NULL != p_obj) { free(p_obj); p_obj=NULL; };
/*!
We don't need the image any more. Free all memory associated with

View File

@@ -129,6 +129,8 @@ cdio_read_mode1_sectors
cdio_read_mode2_sector
cdio_read_mode2_sectors
cdio_set_arg
cdio_set_blocksize
cdio_set_speed
cdio_stat_size
cdio_stdio_destroy
cdio_stdio_new

View File

@@ -1,6 +1,6 @@
/* Common SCSI Multimedia Command (MMC) routines.
$Id: scsi_mmc.c,v 1.3 2005/01/09 16:26:51 rocky Exp $
$Id: scsi_mmc.c,v 1.4 2005/01/18 00:57:20 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -323,12 +323,12 @@ scsi_mmc_set_blocksize_private ( const void *p_env,
}
int
scsi_mmc_set_blocksize ( const CdIo_t *p_cdio, unsigned int i_bsize)
scsi_mmc_set_blocksize ( const CdIo_t *p_cdio, unsigned int i_blocksize)
{
if ( ! p_cdio ) return -2;
return
scsi_mmc_set_blocksize_private (p_cdio->env, p_cdio->op.run_scsi_mmc_cmd,
i_bsize);
i_blocksize);
}

View File

@@ -905,12 +905,9 @@ main(int argc,char *argv[])
d->disc_toc[i].dwStartSector+=toc_offset;
}
#ifdef SPEED_FINISHED
if (force_cdrom_speed != -1) {
cdda_speed_set(d,force_cdrom_speed);
}
#endif
if (d->nsectors==1) {
report("WARNING: The autosensed/selected sectors per read value is\n"