Make drive exceptions non-static objects that are shared between multiple units.

Also replace the three Dummy functions wth dummy_exception (also common).

Bump the revision.

This reduces the memory footprint of libcdda_interface of about 200 bytes.
This commit is contained in:
flameeyes
2008-06-13 19:26:22 +00:00
parent fb85aa1533
commit 35692e9e83
5 changed files with 20 additions and 80 deletions

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.13 2008/03/20 19:02:38 karl Exp $
# $Id: Makefile.am,v 1.14 2008/06/13 19:26:22 flameeyes Exp $
#
# Copyright (C) 2004, 2005, 2006, 2007, 2008 Rocky Bernstein <rocky@gnu.org>
#
@@ -45,14 +45,14 @@
EXTRA_DIST = libcdio_cdda.sym
libcdio_cdda_la_CURRENT = 0
libcdio_cdda_la_REVISION = 3
libcdio_cdda_la_REVISION = 4
libcdio_cdda_la_AGE = 0
noinst_HEADERS = common_interface.h drive_exceptions.h low_interface.h \
smallft.h utils.h
libcdio_cdda_sources = common_interface.c cddap_interface.c interface.c \
scan_devices.c smallft.c toc.c utils.c
scan_devices.c smallft.c toc.c utils.c drive_exceptions.c
lib_LTLIBRARIES = libcdio_cdda.la

View File

@@ -1,5 +1,5 @@
/*
$Id: cddap_interface.c,v 1.7 2008/04/16 17:00:40 karl Exp $
$Id: cddap_interface.c,v 1.8 2008/06/13 19:26:22 flameeyes Exp $
Copyright (C) 2004, 2005, 2007, 2008 Rocky Bernstein <rocky@gnu.org>
Original interface.c Copyright (C) 1994-1997
@@ -246,12 +246,6 @@ cddap_read (cdrom_drive_t *d, void *p, lsn_t begin, long i_sectors)
}
/* hook */
static int Dummy (cdrom_drive_t *d,int Switch)
{
return(0);
}
static int
verify_read_command(cdrom_drive_t *d)
{
@@ -387,7 +381,7 @@ cddap_init_drive (cdrom_drive_t *d)
}
#endif /*HAVE_LINUX_MAJOR_H*/
d->enable_cdda = Dummy;
d->enable_cdda = dummy_exception;
d->set_speed = cddap_setspeed;
d->read_toc = cddap_readtoc;
d->read_audio = cddap_read;

View File

@@ -1,5 +1,5 @@
/*
$Id: drive_exceptions.h,v 1.5 2008/04/16 17:00:40 karl Exp $
$Id: drive_exceptions.h,v 1.6 2008/06/13 19:26:23 flameeyes Exp $
Copyright (C) 2004, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 1998 Monty xiphmont@mit.edu
@@ -43,59 +43,16 @@ extern long scsi_read_mmc2(cdrom_drive_t *d, void *,long,long);
#define scsi_read_mmc2 NULL
#endif
int dummy_exception (cdrom_drive_t *d,int Switch);
#if HAVE_LINUX_MAJOR_H
/* list of drives that affect autosensing in ATAPI specific portions of code
(force drives to detect as ATAPI or SCSI, force ATAPI read command */
static exception_t atapi_list[]={
{"SAMSUNG SCR-830 REV 2.09 2.09 ", 1, 0, Dummy,scsi_read_mmc2,0},
{"Memorex CR-622", 1, 0, Dummy, NULL,0},
{"SONY CD-ROM CDU-561", 0, 0, Dummy, NULL,0},
{"Chinon CD-ROM CDS-525", 0, 0, Dummy, NULL,0},
{NULL,0,0,NULL,NULL,0}};
#endif /*HAVE_LINUX_MAJOR_H*/
/* list of drives that affect MMC default settings */
extern const exception_t atapi_list[];
#endif
#ifdef NEED_MMC_LIST
static exception_t mmc_list[]={
{"SAMSUNG SCR-830 REV 2.09 2.09 ", 1, 0, Dummy,scsi_read_mmc2,0},
{"Memorex CR-622", 1, 0, Dummy, NULL,0},
{"SONY CD-ROM CDU-561", 0, 0, Dummy, NULL,0},
{"Chinon CD-ROM CDS-525", 0, 0, Dummy, NULL,0},
{"KENWOOD CD-ROM UCR", -1, 0, NULL,scsi_read_D8, 0},
{NULL,0,0,NULL,NULL,0}};
#endif /*NEED_MMC_LIST*/
/* list of drives that affect SCSI default settings */
extern const exception_t mmc_list[];
#endif
#ifdef NEED_SCSI_LIST
static exception_t scsi_list[]={
{"TOSHIBA", -1,0x82,scsi_enable_cdda,scsi_read_28, 0},
{"IBM", -1,0x82,scsi_enable_cdda,scsi_read_28, 0},
{"DEC", -1,0x82,scsi_enable_cdda,scsi_read_28, 0},
{"IMS", -1, 0,scsi_enable_cdda,scsi_read_28, 1},
{"KODAK", -1, 0,scsi_enable_cdda,scsi_read_28, 1},
{"RICOH", -1, 0,scsi_enable_cdda,scsi_read_28, 1},
{"HP", -1, 0,scsi_enable_cdda,scsi_read_28, 1},
{"PHILIPS", -1, 0,scsi_enable_cdda,scsi_read_28, 1},
{"PLASMON", -1, 0,scsi_enable_cdda,scsi_read_28, 1},
{"GRUNDIG CDR100IPW", -1, 0,scsi_enable_cdda,scsi_read_28, 1},
{"MITSUMI CD-R ", -1, 0,scsi_enable_cdda,scsi_read_28, 1},
{"KENWOOD CD-ROM UCR", -1, 0, NULL,scsi_read_D8, 0},
{"YAMAHA", -1, 0,scsi_enable_cdda, NULL, 0},
{"PLEXTOR", -1, 0, NULL, NULL, 0},
{"SONY", -1, 0, NULL, NULL, 0},
{"NEC", -1, 0, NULL,scsi_read_D4_10,0},
/* the 7501 locks up if hit with the 10 byte version from the
autoprobe first */
{"MATSHITA CD-R CW-7501", -1, 0, NULL,scsi_read_D4_12,-1},
{NULL,0,0,NULL,NULL,0}};
#endif /* NEED_SCSI_LIST*/
extern const exception_t scsi_list[];
#endif

View File

@@ -1,5 +1,5 @@
/*
$Id: scsi_interface.c,v 1.3 2008/04/17 17:39:47 karl Exp $
$Id: scsi_interface.c,v 1.4 2008/06/13 19:26:23 flameeyes Exp $
Copyright (C) 2004, 2008 Rocky Bernstein <rocky@gnu.org>
Original interface.c Copyright (C) 1994-1997
@@ -36,12 +36,6 @@
#include <cdio/scsi_mmc.h>
#include <cdio/bytesex.h>
/* hook */
static int
Dummy (cdrom_drive_t *d,int s){
return(0);
}
#include "drive_exceptions.h"
static void
@@ -1272,7 +1266,7 @@ verify_read_command(cdrom_drive_t *d)
switch(i){
case 0:
d->density=0;
d->enable_cdda=Dummy;
d->enable_cdda=dummy_exception;
es="none ";
if(!densitypossible)i=-2; /* short circuit MMC style commands */
break;
@@ -1510,7 +1504,7 @@ scsi_init_drive(cdrom_drive_t *d){
/* generic Sony type defaults; specialize from here */
d->density = 0x0;
d->enable_cdda = Dummy;
d->enable_cdda = dummy_exception;
d->read_audio = scsi_read_D8;
d->fua=0x0;
if(d->is_atapi)d->lun=0; /* it should already be; just to make sure */

View File

@@ -1,5 +1,5 @@
/*
$Id: test_interface.c,v 1.3 2008/04/16 17:00:40 karl Exp $
$Id: test_interface.c,v 1.4 2008/06/13 19:26:23 flameeyes Exp $
Copyright (C) 2004, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 1998 Monty xiphmont@mit.edu
@@ -215,19 +215,14 @@ test_read(cdrom_drive *d, void *p, long begin, long sectors)
return(sectors);
}
/* hook */
static int Dummy (cdrom_drive *d,int Switch){
return(0);
}
/* set function pointers to use the ioctl routines */
int test_init_drive (cdrom_drive *d){
d->nsectors=13;
d->enable_cdda = Dummy;
d->enable_cdda = dummy_exception;
d->read_audio = test_read;
d->read_toc = test_readtoc;
d->set_speed = Dummy;
d->set_speed = dummy_exception;
d->tracks=d->read_toc(d);
if(d->tracks==-1)
return(d->tracks);