class RawCD

Class for a raw CDROM device.

Inheritance:

RawCD


Public Fields

float volstep

Public Methods

void CloseTray(void)
int CurrentItemIndex(void)
int CurrentItemLength(void)
int CurrentItemTime(void)
void DecVol(void)
void Eject(void)
CdStatus getStatus(void)
void IncVol(void)
void InitDev( char *devname )
void InitDev(void)
int ItemLength(int idx)
void lrqpSet(int idx)
void PauseResume(void)
void PlayItem(int itemno, bool reposition=false)
void PlayItemBlock(int itemno, int t0, int t_f=-1, bool reposition=true)
RawCD( void )
RawCD( char *devname )
void Stop(void)
int ToC_Entry(int idx)
int ToC_Length(void)
void TrayControl( bool close_ioctl=false, bool trayless=false )
void UpdateStatus(void)
float Volume(void)

Documentation

This is the RawCD object. It defines an API for cdrom-device access.

The API is toolkit- and platform- independent. Any platform-specific code will be in the *.C sources for each platform, which should include this file.

The API uses standard Unix file operations, and requires a filename for the CDROM device.

Private Members

There are numerous private member flags, variables, and methods. All [well, most] of the private methods are inlined.

The private members are all specific to this implementation of a raw CD device. If you decide to create your own implementation, it makes more sense to just keep this header file, but rewrite all of the code in the *.C file. This is also what you should do if you need to port this class to systems other than Linux or to Linux SCSI drives.

  
  ----------------------------------------------------------
  ----------------------------------------------------------
  

float volstep
The step by which to increase or decrease the CDROM drive volume. Initialized to 0.1. [The volume ranges from 0 to 1.]

RawCD( void )
Class Constructor.

RawCD( char *devname )
Overloaded Class Constructor. Difference: After initializing the variables, it calls InitDev(devname). devname is the filename of the CDROM device.

void InitDev( char *devname )
Overloaded version. Sets an internal pointer to devname, and closes the CDROM device if it's currently open. It then calls InitDev(void) to re-initialize the device using the new device filename.

void TrayControl( bool close_ioctl=false, bool trayless=false )
Sets how a RawCD object controls the CDROM tray. Use close_ioctl=true if you can close the CDROM tray via an ioctl call. Use trayless=true if the CDROM has no retractable tray.

float Volume(void)
You should call UpdateStatus() before calling this method.

Returns:
The current volume of the CDROM device.

int ToC_Entry(int idx)
Returns the position on the CD of the idx-th track, in units of frames.

idx=0 refers to the first item.

void lrqpSet(int idx)
Sets the lrqp-counter to idx. idx=0 refers to the first item.

The lrqp-counter is used by PlayItem() for synchronization purposes.

See Also:
PlayItem

int ItemLength(int idx)
Returns the length, in units of frames, of the idx-th track.

idx=0 refers to the first item.

CdStatus getStatus(void)
You should call UpdateStatus() before calling this method.

Returns:
A CdStatus enum containing the current status of the device.

int CurrentItemIndex(void)
You should call UpdateStatus() before calling this method.

Returns:
The index of the current track playing. A value of 0 refers to the first item.

int CurrentItemLength(void)
You should call UpdateStatus() before calling this method.

Returns:
The length, in frames, of the current item playing.

int CurrentItemTime(void)
You should call UpdateStatus() before calling this method.

Returns:
The time elapsed, relative to the current item playing.

int ToC_Length(void)
Returns:
The number of playable tracks on the CD [excludes the leadout track and the nonexistent null-track].

void InitDev(void)
Uses the device filename [set by its overloaded version or by the constructor] to open the CDROM device, then loads the ToC, and lastly calls UpdateStatus().

void IncVol(void)
Increments the volume by a step.

void DecVol(void)
Decrements the volume by a step.

void Stop(void)
Stops play, updating the device status and setting internal flags. Only does something if the drive is closed and has a disc.

void PauseResume(void)
Toggles the pause state of the cdrom. Only does something if the drive is playing.

void PlayItemBlock(int itemno, int t0, int t_f=-1, bool reposition=true)
Play track itemno between two blocks of time, starting at t0 and ending at t_f. t0 and t_f are relative to the start of the specified track. itemno=0 corresponds to the first playable track.

If t_f<=t0, PlayItemBlock returns an error. If t_f is 0, negative, or beyond the end of the CD, PlayItemBlock simply plays to the end of the disc.

The flag reposition is used to control what PlayItemBlock does if the drive is already playing. If reposition=true, the drive stops and restarts at the new location. Otherwise, PlayItemBlock does nothing.

void PlayItem(int itemno, bool reposition=false)
Play track itemno. itemno=0 corresponds to the first playable track.

The flag reposition is used to control what PlayItem does if the drive is already playing. If reposition=true, the drive stops and restarts at the new location. Otherwise, PlayItem does nothing.

This is where the lrpq-index comes in. It specifies the index of the last specifically-requested play item, and is set by both PlayItem and PlayItemBlock. If:

  1. reposition=true
  2. the requested track is the one immediately following the last one requested [i.e. itemno=lrqp+1].
  3. the current play position is +/-1 second of the beginning of itemno
...then PlayItem just updates some counters and returns, allowing the drive to keep playing. If the last two conditions aren't met, then the drive stops an restarts.

The idea behind this elaborate scheme is to keep play smooth. As long as your CDROM drive keeps playing through, in sequence, once it's started playing, this scheme will work.

void UpdateStatus(void)
Update the status flags and counter variables. Does nothing if the tray is ejected or empty.

void Eject(void)
Ejects the CD.

void CloseTray(void)
Closes the tray by one of two methods, depending on how the routine is compiled. It can use the CDROMCLOSETRAY ioctl, or it can simply close and reopen the CDROM device. It always calls InitDev(void) after everything else.


This class has no child classes.

alphabetic index hierarchy of classes


Copyright 1997 by John Weiss [John.Weiss@colorado.edu] "generated by doc++"?! More like mangled ...

generated by doc++