com.tuneology.avm.drive
Class CDDrive

java.lang.Object
  |
  +--com.tuneology.avm.drive.Drive
        |
        +--com.tuneology.avm.drive.CDDrive
Direct Known Subclasses:
CDRDrive

public class CDDrive
extends Drive

An interface to a CD-ROM drive.

Version:
$Id: CDDrive.java,v 1.20 2003/07/10 19:52:12 xnarf Exp $
Author:
Fran Taylor

Field Summary
protected  boolean audio_play
          True if the drive can play audio CDs
static int AUDIO_TRACK
          possible value for TocEntry.typ
static int AUDIO_TRACKS_BIT
          This bit is set if the disc in the drive contains at least one audio track.
protected  boolean BCK
          True if the drive can have valid data on falling edge of clock
protected  java.lang.String bclk
          length of data in BCLKs of the drive.
protected  boolean BUF
          True if the drive can support Buffer-Underrun-Free recording
protected  int buffer_size
          buffer size in KB of the drive.
protected  boolean c2_pointers
          True if the drive can support C2 error pointers
protected  boolean cd_da_accurate
          True if the drive can restart non-streamed digital audio reads accurately
protected  boolean cd_da_supported
          True if the drive can read digital audio blocks
protected  boolean cd_r_read
          True if the drive can read CD-R media
protected  boolean cd_r_write
          True if the drive can write CD-R media
protected  boolean cd_rw_read
          True if the drive can read CD-RW media
protected  boolean cd_rw_write
          True if the drive can write CD-RW media
protected static java.lang.String cdrdaoCmd
           
protected static java.lang.String cdrecordCmd
           
protected  boolean composite
          True if the drive can deliver composite A/V data
protected  int cur_read_speed
          Current read speed in kB/s supported by the drive.
protected  int cur_write_speed
          Current write speed in kB/s supported by the drive.
protected  DiscInfo curInfo
          current disc info - set by native code
static int DATA_TRACK
          possible value for TocEntry.typ
static int DATA_TRACKS_BIT
          This bit is set if the disc in the drive has a data track.
protected  boolean digital_port_1
          True if the drive can support digital output on port 1
protected  boolean digital_port_2
          True if the drive can support digital output on port 2
static int DISC_PRESENT_BIT
          This bit is set if a disc is present in the drive.
protected  boolean disk_present_rep
          True if the drive can support Individual Disc Present feature
static int DRIVE_CLOSED_BIT
          This bit is set if the drive is closed.
static int DRIVE_READY_BIT
          This bit is set if the drive is ready.
protected  boolean dvd_r_read
          True if the drive can read DVD-R media
protected  boolean dvd_r_write
          True if the drive can write DVD-R media
protected  boolean dvd_ram_read
          True if the drive can read DVD-RAM media
protected  boolean dvd_ram_write
          True if the drive can write DVD-RAM media
protected  boolean dvd_rom_read
          True if the drive can read DVD-ROM media
static int ERASABLE_DISC
          This bit is set if the disc in the drive is erasable.
static int EXTRA_FILE
          possible value for TocEntry.typ
static int FS_3DO
          possible value for TocEntry.fs
static int FS_BOOTABLE
           
static int FS_CDTV
           
static int FS_EXT2
          possible value for TocEntry.fs
static int FS_HFS
          possible value for TocEntry.fs
static int FS_HIDDEN_TRACK
           
static int FS_HIGH_SIERRA
          possible value for TocEntry.fs
static int FS_INTERACTIVE
          possible value for TocEntry.fs
static int FS_ISO_9660
          possible value for TocEntry.fs
static int FS_ISO_9660_INTERACTIVE
          possible value for TocEntry.fs
static int FS_ISO_HFS
          possible value for TocEntry.fs
static int FS_JOLIET
           
static int FS_MASK
           
static int FS_MULTISESSION
           
static int FS_NO_DATA
          possible value for TocEntry.fs
static int FS_PHOTO_CD
           
static int FS_ROCKRIDGE
           
static int FS_UFS
          possible value for TocEntry.fs
static int FS_UNKNOWN
          possible value for TocEntry.fs
static int FS_VIDEOCDI
           
static int FS_XA
           
protected  boolean ISRC
          True if the drive can return CD ISRC information
protected  java.lang.String load_type
          the drive's loading mechanism type
protected  boolean lock
          True if the drive can allow media to be locked in the drive via PREVENT/ALLOW command
protected  boolean LSBF
          True if the drive can send digital data LSB-first
protected  int max_read_speed
          Maximum read speed in kB/s supported by the drive.
protected  int max_write_speed
          Maximum write speed in kB/s supported by the drive.
protected  boolean method2
          True if the drive can read fixed-packet CD media using Method 2
protected  boolean mode_2_form_1
          True if the drive can read Mode 2 Form 1 blocks
protected  boolean mode_2_form_2
          True if the drive can read Mode 2 Form 2 blocks
protected  boolean multi_session
          True if the drive can read multi-session CDs
protected  int num_vol_levels
          number of volume control labels supported by the drive.
protected  boolean prevent_jumper
          True if the drive can lock media on power up via prevent jumper
protected  java.lang.String processOutput
           
protected  boolean pw_in_lead_in
          True if the drive can read raw P-W subcode data from lead in
protected  boolean RCK
          True if the drive can set LRCK high for left-channel data
protected  boolean read_bar_code
          True if the drive can read CD bar code
static int RECORDABLE_DISC
          This bit is set if the disc in the drive is recordable.
protected  boolean rw_deint_corr
          True if the drive can return R-W subcode de-interleaved and error-corrected
protected  boolean rw_supported
          True if the drive can R-W subcode information
protected  boolean sep_chan_mute
          True if the drive can support independent mute setting for each channel
protected  boolean sep_chan_vol
          True if the drive can support individual volume control setting for each channel
protected  boolean side_change
          True if the drive can support changing side of disk
protected  boolean sw_slot_sel
          True if the drive can have load-empty-slot-in-changer feature
protected  boolean test_write
          True if the drive can support test writing
protected  boolean UPC
          True if the drive can return CD media catalog number
protected  java.lang.Integer[] writeSpeeds
          list of write speeds
 
Fields inherited from class com.tuneology.avm.drive.Drive
ent, refNum, TYPE_CDR, TYPE_CDROM, TYPE_CDRW, TYPE_DVD, TYPE_DVDR, TYPE_DVDRAM, TYPE_EJECTABLE, TYPE_FIXEDDISC, TYPE_FLOPPY, TYPE_LOADABLE, TYPE_LOOPBACK, TYPE_NETWORK, TYPE_OTHER, TYPE_REMOVABLE
 
Method Summary
 void addChangeListener(PlayerStatusListener st)
           
 java.io.InputStream createImage()
          Reads the contents of the CD
 void doUpdate(PlayerStatus st)
           
 Ripper getAudioRipper()
          Returns the current audio ripping class.
static java.lang.Class[] getAudioRippers()
          Returns an array of potential audio ripper classes.
protected static java.util.ArrayList getCdrdaoCmd()
           
 java.lang.String getCdrdaoDriver()
          Returns the current setting of the cdrdao driver for this drive.
static java.lang.String[] getCdrdaoDrivers()
          Returns a list of all drivers used by cdrdao.
protected static java.util.ArrayList getCdrecordCmd()
           
 Ripper getDataRipper()
          Returns the current data track ripping class.
static java.lang.Class[] getDataRippers()
          Returns an array of potential data ripper classes.
static java.lang.String getDefaultCdrdaoDriver()
          Returns the default cdrdao driver.
protected  java.util.ArrayList getDevCdrecordCmd()
           
 java.lang.String getDevice()
          Returns the device name.
 DiscInfo getDiscInfo()
          Returns the current state of the drive and full information about a CD, if present.
 int getDriveReadSpeed()
          Returns the maximum read speed of the drive.
 java.lang.String getGenericDev()
          for linux only
 MountPoint[] getMountPoints()
          Returns the mount points.
 AudioPlayer getPlayer(java.lang.String volumeControl)
           
static java.lang.String getRipperDescription(java.lang.Class cl)
          returns a short string describing the ripper.
static java.lang.String getVersions()
          Returns a string containing the versions of the burners and rippers used.
 boolean isLoaded()
          Returns true if the tray is closed.
protected  void readCapabilities()
          This fails on OSX if there is an Audio CD inserted and mounted.
 void removeChangeListener(PlayerStatusListener st)
           
 java.io.InputStream ripTrack(int track, int startIndex, int len, int bufsiz, RipStatus stat)
          Rips an audio track as a WAV file, or a data track as raw data, and returns a stream to it.
 void setAudioRipper(java.lang.Class cl)
          Sets the audio ripper class to be used by this drive.
static void setCdrdaoCmd(java.lang.String str)
           
 void setCdrdaoDriver(java.lang.String str)
          Set the driver used by cdrdao with this drive.
static void setCdrecordCmd(java.lang.String str)
           
 void setDataRipper(java.lang.Class cl)
          Sets the data ripper class to be used by this drive.
 void setPlayer(AudioPlayer pl)
           
 void startUpdate()
          Start the background thread that keeps the audio status updated.
 void stopUpdate()
          Stop the audio status update thread.
static void touch()
           
 
Methods inherited from class com.tuneology.avm.drive.Drive
findDriveByDevice, findDriveByScsiId, findMountPointByDevice, getDefaultCDROM, getDisktoolCmd, getDrive, getDriveList, getDriveType, getDriveType, getEntry, getHdiutilCmd, getManufacturer, getModel, getMountPoint, getNameMax, getScsiId, getScsiId, getVersion, isCDR, isCdrom, setDiscFreeCmd, setDisktoolCmd, setFstabPath, setHdiutilCmd, setMountCmd, setUmountCmd
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cd_r_read

protected boolean cd_r_read
True if the drive can read CD-R media

cd_r_write

protected boolean cd_r_write
True if the drive can write CD-R media

cd_rw_read

protected boolean cd_rw_read
True if the drive can read CD-RW media

cd_rw_write

protected boolean cd_rw_write
True if the drive can write CD-RW media

dvd_r_read

protected boolean dvd_r_read
True if the drive can read DVD-R media

dvd_r_write

protected boolean dvd_r_write
True if the drive can write DVD-R media

dvd_rom_read

protected boolean dvd_rom_read
True if the drive can read DVD-ROM media

dvd_ram_read

protected boolean dvd_ram_read
True if the drive can read DVD-RAM media

dvd_ram_write

protected boolean dvd_ram_write
True if the drive can write DVD-RAM media

test_write

protected boolean test_write
True if the drive can support test writing

mode_2_form_1

protected boolean mode_2_form_1
True if the drive can read Mode 2 Form 1 blocks

mode_2_form_2

protected boolean mode_2_form_2
True if the drive can read Mode 2 Form 2 blocks

cd_da_supported

protected boolean cd_da_supported
True if the drive can read digital audio blocks

cd_da_accurate

protected boolean cd_da_accurate
True if the drive can restart non-streamed digital audio reads accurately

BUF

protected boolean BUF
True if the drive can support Buffer-Underrun-Free recording

multi_session

protected boolean multi_session
True if the drive can read multi-session CDs

method2

protected boolean method2
True if the drive can read fixed-packet CD media using Method 2

read_bar_code

protected boolean read_bar_code
True if the drive can read CD bar code

rw_supported

protected boolean rw_supported
True if the drive can R-W subcode information

rw_deint_corr

protected boolean rw_deint_corr
True if the drive can return R-W subcode de-interleaved and error-corrected

pw_in_lead_in

protected boolean pw_in_lead_in
True if the drive can read raw P-W subcode data from lead in

UPC

protected boolean UPC
True if the drive can return CD media catalog number

ISRC

protected boolean ISRC
True if the drive can return CD ISRC information

c2_pointers

protected boolean c2_pointers
True if the drive can support C2 error pointers

composite

protected boolean composite
True if the drive can deliver composite A/V data

audio_play

protected boolean audio_play
True if the drive can play audio CDs

sep_chan_vol

protected boolean sep_chan_vol
True if the drive can support individual volume control setting for each channel

sep_chan_mute

protected boolean sep_chan_mute
True if the drive can support independent mute setting for each channel

digital_port_1

protected boolean digital_port_1
True if the drive can support digital output on port 1

digital_port_2

protected boolean digital_port_2
True if the drive can support digital output on port 2

LSBF

protected boolean LSBF
True if the drive can send digital data LSB-first

RCK

protected boolean RCK
True if the drive can set LRCK high for left-channel data

BCK

protected boolean BCK
True if the drive can have valid data on falling edge of clock

prevent_jumper

protected boolean prevent_jumper
True if the drive can lock media on power up via prevent jumper

lock

protected boolean lock
True if the drive can allow media to be locked in the drive via PREVENT/ALLOW command

side_change

protected boolean side_change
True if the drive can support changing side of disk

sw_slot_sel

protected boolean sw_slot_sel
True if the drive can have load-empty-slot-in-changer feature

disk_present_rep

protected boolean disk_present_rep
True if the drive can support Individual Disc Present feature

num_vol_levels

protected int num_vol_levels
number of volume control labels supported by the drive.

max_read_speed

protected int max_read_speed
Maximum read speed in kB/s supported by the drive.

cur_read_speed

protected int cur_read_speed
Current read speed in kB/s supported by the drive.

max_write_speed

protected int max_write_speed
Maximum write speed in kB/s supported by the drive.

cur_write_speed

protected int cur_write_speed
Current write speed in kB/s supported by the drive.

buffer_size

protected int buffer_size
buffer size in KB of the drive.

bclk

protected java.lang.String bclk
length of data in BCLKs of the drive.

load_type

protected java.lang.String load_type
the drive's loading mechanism type

writeSpeeds

protected java.lang.Integer[] writeSpeeds
list of write speeds

curInfo

protected DiscInfo curInfo
current disc info - set by native code

processOutput

protected java.lang.String processOutput

cdrecordCmd

protected static java.lang.String cdrecordCmd

cdrdaoCmd

protected static java.lang.String cdrdaoCmd

DRIVE_CLOSED_BIT

public static final int DRIVE_CLOSED_BIT
This bit is set if the drive is closed.

DRIVE_READY_BIT

public static final int DRIVE_READY_BIT
This bit is set if the drive is ready.

DISC_PRESENT_BIT

public static final int DISC_PRESENT_BIT
This bit is set if a disc is present in the drive.

RECORDABLE_DISC

public static final int RECORDABLE_DISC
This bit is set if the disc in the drive is recordable.

ERASABLE_DISC

public static final int ERASABLE_DISC
This bit is set if the disc in the drive is erasable.

AUDIO_TRACKS_BIT

public static final int AUDIO_TRACKS_BIT
This bit is set if the disc in the drive contains at least one audio track.

DATA_TRACKS_BIT

public static final int DATA_TRACKS_BIT
This bit is set if the disc in the drive has a data track.

DATA_TRACK

public static final int DATA_TRACK
possible value for TocEntry.typ

AUDIO_TRACK

public static final int AUDIO_TRACK
possible value for TocEntry.typ

EXTRA_FILE

public static final int EXTRA_FILE
possible value for TocEntry.typ

FS_NO_DATA

public static final int FS_NO_DATA
possible value for TocEntry.fs

FS_HIGH_SIERRA

public static final int FS_HIGH_SIERRA
possible value for TocEntry.fs

FS_ISO_9660

public static final int FS_ISO_9660
possible value for TocEntry.fs

FS_INTERACTIVE

public static final int FS_INTERACTIVE
possible value for TocEntry.fs

FS_HFS

public static final int FS_HFS
possible value for TocEntry.fs

FS_UFS

public static final int FS_UFS
possible value for TocEntry.fs

FS_EXT2

public static final int FS_EXT2
possible value for TocEntry.fs

FS_ISO_HFS

public static final int FS_ISO_HFS
possible value for TocEntry.fs

FS_ISO_9660_INTERACTIVE

public static final int FS_ISO_9660_INTERACTIVE
possible value for TocEntry.fs

FS_3DO

public static final int FS_3DO
possible value for TocEntry.fs

FS_UNKNOWN

public static final int FS_UNKNOWN
possible value for TocEntry.fs

FS_MASK

public static final int FS_MASK

FS_XA

public static final int FS_XA

FS_MULTISESSION

public static final int FS_MULTISESSION

FS_PHOTO_CD

public static final int FS_PHOTO_CD

FS_HIDDEN_TRACK

public static final int FS_HIDDEN_TRACK

FS_CDTV

public static final int FS_CDTV

FS_BOOTABLE

public static final int FS_BOOTABLE

FS_VIDEOCDI

public static final int FS_VIDEOCDI

FS_ROCKRIDGE

public static final int FS_ROCKRIDGE

FS_JOLIET

public static final int FS_JOLIET
Method Detail

createImage

public java.io.InputStream createImage()
                                throws java.io.IOException
Reads the contents of the CD

ripTrack

public java.io.InputStream ripTrack(int track,
                                    int startIndex,
                                    int len,
                                    int bufsiz,
                                    RipStatus stat)
                             throws java.lang.Exception
Rips an audio track as a WAV file, or a data track as raw data, and returns a stream to it.
Parameters:
track - the track to rip
startIndex - where to start within the track; 0 is the beginning.
len - the number of sectors to read (-1 means until the end of the track).
bufsiz - the buffer size to use (0 or less means use the default).
stat - the status indicator
Returns:
a stream with the wav file data (for audio tracks) or the raw data (for data tracks), or null if the specified values are not valid for the current cd in the drive.
Throws:
java.lang.Exception -  

getMountPoints

public MountPoint[] getMountPoints()
Returns the mount points. We override this method because on OSX the mount point of a CD depends on its volume label or the audio CD session's title, and it creates a separate mount point for each session found on the disc, so CD-Extra discs show up as two mount points, one for the audio tracks and one for the data track. Rather civilized, no?
Overrides:
getMountPoints in class Drive
Returns:
the mount points.

getDevice

public java.lang.String getDevice()
Returns the device name. We have to override this method because on OSX we only know what the BSD device is when there is a disc in the drive.
Overrides:
getDevice in class Drive
Returns:
the device name

getDiscInfo

public DiscInfo getDiscInfo()
                     throws java.lang.Exception
Returns the current state of the drive and full information about a CD, if present.
Returns:
the info for the disc in the drive.
Throws:
java.lang.Exception -  

getDriveReadSpeed

public int getDriveReadSpeed()
Returns the maximum read speed of the drive.
Returns:
read speed.

isLoaded

public boolean isLoaded()
                 throws java.io.IOException
Returns true if the tray is closed.
Returns:
true if the tray is loaded.
Throws:
java.io.IOException -  

getDataRippers

public static java.lang.Class[] getDataRippers()
Returns an array of potential data ripper classes.
Returns:
an arrsay of ripper classes.

getAudioRippers

public static java.lang.Class[] getAudioRippers()
Returns an array of potential audio ripper classes.
Returns:
array of audio rippers.

getRipperDescription

public static java.lang.String getRipperDescription(java.lang.Class cl)
returns a short string describing the ripper.
Parameters:
the - ripper class
Returns:
string describing the ripper

setDataRipper

public void setDataRipper(java.lang.Class cl)
                   throws java.lang.NoSuchMethodException,
                          java.lang.InstantiationException,
                          java.lang.IllegalAccessException,
                          java.lang.reflect.InvocationTargetException
Sets the data ripper class to be used by this drive.
Parameters:
cl -  
Throws:
java.lang.NoSuchMethodException -  
java.lang.InstantiationException -  
java.lang.IllegalAccessException -  
java.lang.reflect.InvocationTargetException -  

getDataRipper

public Ripper getDataRipper()
Returns the current data track ripping class.
Returns:
the current data ripper.

getPlayer

public AudioPlayer getPlayer(java.lang.String volumeControl)
                      throws java.lang.Exception
Throws:
java.lang.Exception -  

setPlayer

public void setPlayer(AudioPlayer pl)

setAudioRipper

public void setAudioRipper(java.lang.Class cl)
                    throws java.lang.NoSuchMethodException,
                           java.lang.InstantiationException,
                           java.lang.IllegalAccessException,
                           java.lang.reflect.InvocationTargetException
Sets the audio ripper class to be used by this drive.
Parameters:
cl -  
Throws:
java.lang.NoSuchMethodException -  
java.lang.InstantiationException -  
java.lang.IllegalAccessException -  
java.lang.reflect.InvocationTargetException -  

getAudioRipper

public Ripper getAudioRipper()
Returns the current audio ripping class.
Returns:
the current audio ripper.

getVersions

public static java.lang.String getVersions()
Returns a string containing the versions of the burners and rippers used.
Returns:
the version numbers of the programs used.

getDevCdrecordCmd

protected java.util.ArrayList getDevCdrecordCmd()

getCdrecordCmd

protected static java.util.ArrayList getCdrecordCmd()

getCdrdaoCmd

protected static java.util.ArrayList getCdrdaoCmd()

setCdrecordCmd

public static void setCdrecordCmd(java.lang.String str)
                           throws java.lang.Exception
Parameters:
str -  

setCdrdaoCmd

public static void setCdrdaoCmd(java.lang.String str)
                         throws java.lang.Exception
Parameters:
str -  

setCdrdaoDriver

public void setCdrdaoDriver(java.lang.String str)
Set the driver used by cdrdao with this drive.
Parameters:
str -  

getCdrdaoDriver

public java.lang.String getCdrdaoDriver()
Returns the current setting of the cdrdao driver for this drive.
Returns:
the current cdrdao driver.

getCdrdaoDrivers

public static java.lang.String[] getCdrdaoDrivers()
Returns a list of all drivers used by cdrdao.
Returns:
an array of strings containing the driver names.

getDefaultCdrdaoDriver

public static java.lang.String getDefaultCdrdaoDriver()
Returns the default cdrdao driver.
Returns:
the name of the default cdrdao driver.

addChangeListener

public void addChangeListener(PlayerStatusListener st)
Parameters:
st -  

removeChangeListener

public void removeChangeListener(PlayerStatusListener st)
Parameters:
st -  

readCapabilities

protected void readCapabilities()
                         throws java.lang.Exception
This fails on OSX if there is an Audio CD inserted and mounted. We might need to keep trying.

doUpdate

public void doUpdate(PlayerStatus st)
              throws java.lang.Exception
Parameters:
st -  
Throws:
java.lang.Exception -  

startUpdate

public void startUpdate()
Start the background thread that keeps the audio status updated.

stopUpdate

public void stopUpdate()
Stop the audio status update thread.

getGenericDev

public java.lang.String getGenericDev()
for linux only

touch

public static void touch()