Nugget
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Friends | List of all members
psyqo::CDRomDevice Class Referencefinal

A specialization of the CDRom interface. More...

#include <psyqo/cdrom-device.hh>

Inheritance diagram for psyqo::CDRomDevice:
Inheritance graph
[legend]
Collaboration diagram for psyqo::CDRomDevice:
Collaboration graph
[legend]

Classes

class  Action
 The action base class for the internal state machine. More...
 
struct  GetPlaybackLocationAwaiter
 
struct  GetTOCSizeAwaiter
 
struct  MuteAwaiter
 
struct  PlaybackLocation
 
struct  ReadTOCAwaiter
 
struct  ResetAwaiter
 
struct  UnmuteAwaiter
 

Public Types

typedef eastl::fixed_vector< uint8_t, 16, false > Response
 

Public Member Functions

virtual ~CDRomDevice ()
 
void prepare ()
 Prepares the CDRom subsystem.
 
void reset (eastl::function< void(bool)> &&callback)
 Resets the CDRom controller.
 
TaskQueue::Task scheduleReset ()
 
bool resetBlocking (GPU &)
 
ResetAwaiter reset ()
 
void readSectors (uint32_t sector, uint32_t count, void *buffer, eastl::function< void(bool)> &&callback) override
 Reads sectors from the CDRom.
 
bool readSectorsBlocking (uint32_t sector, uint32_t count, void *buffer, GPU &)
 
void getTOCSize (unsigned *size, eastl::function< void(bool)> &&callback)
 Gets the size of the Table of Contents from the CDRom. Note that while the blocking variant is available because it is a fairly short operation with the CDRom controller, it can still block the system for roughly 2ms, which is a long time in the context of a 33MHz CPU.
 
TaskQueue::Task scheduleGetTOCSize (unsigned *size)
 
unsigned getTOCSizeBlocking (GPU &)
 
GetTOCSizeAwaiter getTOCSize ()
 
void readTOC (MSF *toc, unsigned size, eastl::function< void(bool)> &&callback)
 Reads the Table of Contents from the CDRom.
 
TaskQueue::Task scheduleReadTOC (MSF *toc, unsigned size)
 
bool readTOCBlocking (MSF *toc, unsigned size, GPU &)
 
ReadTOCAwaiter readTOC (MSF *toc, unsigned size)
 
void mute (eastl::function< void(bool)> &&callback)
 Mutes the CD audio for both CDDA and CDXA.
 
TaskQueue::Task scheduleMute ()
 
void muteBlocking (GPU &)
 
MuteAwaiter mute ()
 
void unmute (eastl::function< void(bool)> &&callback)
 Unmutes the CD audio for both CDDA and CDXA.
 
TaskQueue::Task scheduleUnmute ()
 
void unmuteBlocking (GPU &)
 
UnmuteAwaiter unmute ()
 
void playCDDATrack (MSF start, eastl::function< void(bool)> &&callback)
 Begins playing CDDA audio from a given starting point.
 
void playCDDATrack (unsigned track, eastl::function< void(bool)> &&callback)
 
void playCDDADisc (MSF start, eastl::function< void(bool)> &&callback)
 
void playCDDADisc (unsigned track, eastl::function< void(bool)> &&callback)
 
void resumeCDDA (eastl::function< void(bool)> &&callback)
 
void pauseCDDA ()
 Pauses CDDA playback.
 
void stopCDDA ()
 Stops CDDA playback.
 
void getPlaybackLocation (PlaybackLocation *location, eastl::function< void(PlaybackLocation *)> &&callback)
 Get the Playback location of the CDDA audio.
 
void getPlaybackLocation (eastl::function< void(PlaybackLocation *)> &&callback)
 
TaskQueue::Task scheduleGetPlaybackLocation (PlaybackLocation *location)
 
GetPlaybackLocationAwaiter getPlaybackLocation ()
 
void setVolume (uint8_t leftToLeft, uint8_t rightToLeft, uint8_t leftToRight, uint8_t rightToRight)
 Set the Volume of the CDDA audio.
 
bool isIdle () const
 Checks if the CDROM device is in idle state.
 
- Public Member Functions inherited from psyqo::CDRom
virtual ~CDRom ()
 
TaskQueue::Task scheduleReadSectors (uint32_t sector, uint32_t count, void *buffer)
 Schedule a read operation.
 
TaskQueue::Task scheduleReadRequest (ReadRequest *request)
 Schedule a read operation.
 
ReadSectorsAwaiter readSectorsForCoroutine (uint32_t sector, uint32_t count, void *buffer)
 Wrapper around the readSectors method for coroutines.
 

Friends

class ActionBase
 

Detailed Description

A specialization of the CDRom interface.

This class is a specialization of the CDRom interface, which provides a way to read from the physical CDRom drive of the console. All of the methods in this class are asynchronous, and will call the provided callback when the operation is complete. The class also provides a blocking variant for some of the methods, which can be used to perform the operation synchronously. Note that the blocking variants are only provided for methods that are expected to complete quickly, and should not be used in performance-critical code, as they can still block the system for several milliseconds. The callbacks will be called from the main thread, and have a boolean parameter that indicates whether the operation was successful. Last but not least, the class provides a coroutine-friendly API, which allows the use of the co_await keyword to suspend the coroutine until the operation is complete.

Member Typedef Documentation

◆ Response

typedef eastl::fixed_vector<uint8_t, 16, false> psyqo::CDRomDevice::Response

Constructor & Destructor Documentation

◆ ~CDRomDevice()

psyqo::CDRomDevice::~CDRomDevice ( )
virtual

Member Function Documentation

◆ getPlaybackLocation() [1/3]

GetPlaybackLocationAwaiter psyqo::CDRomDevice::getPlaybackLocation ( )
inline

◆ getPlaybackLocation() [2/3]

void psyqo::CDRomDevice::getPlaybackLocation ( eastl::function< void(PlaybackLocation *)> &&  callback)

◆ getPlaybackLocation() [3/3]

void psyqo::CDRomDevice::getPlaybackLocation ( PlaybackLocation location,
eastl::function< void(PlaybackLocation *)> &&  callback 
)

Get the Playback location of the CDDA audio.

This method will request the current playback location of the CDDA audio. The callback will be called with a pointer to a PlaybackLocation structure, which will contain the relative and absolute MSF values, the current track number, and the current index. The callback will be called with a null pointer if the location could not be retrieved.

Parameters
locationIf provided, the location will be stored here.
callbackThe callback to call when the location is retrieved.

◆ getTOCSize() [1/2]

GetTOCSizeAwaiter psyqo::CDRomDevice::getTOCSize ( )
inline

◆ getTOCSize() [2/2]

void psyqo::CDRomDevice::getTOCSize ( unsigned *  size,
eastl::function< void(bool)> &&  callback 
)

Gets the size of the Table of Contents from the CDRom. Note that while the blocking variant is available because it is a fairly short operation with the CDRom controller, it can still block the system for roughly 2ms, which is a long time in the context of a 33MHz CPU.

Parameters
sizeThe pointer to store the size of the TOC.
callbackThe callback to call when the size is retrieved.

◆ getTOCSizeBlocking()

unsigned psyqo::CDRomDevice::getTOCSizeBlocking ( GPU gpu)

◆ isIdle()

bool psyqo::CDRomDevice::isIdle ( ) const
inline

Checks if the CDROM device is in idle state.

◆ mute() [1/2]

MuteAwaiter psyqo::CDRomDevice::mute ( )
inline

◆ mute() [2/2]

void psyqo::CDRomDevice::mute ( eastl::function< void(bool)> &&  callback)

Mutes the CD audio for both CDDA and CDXA.

Parameters
callbackThe callback to call when the mute operation is complete.

◆ muteBlocking()

void psyqo::CDRomDevice::muteBlocking ( GPU )

◆ pauseCDDA()

void psyqo::CDRomDevice::pauseCDDA ( )

Pauses CDDA playback.

This method will request a pause of the CDDA playback. The callback which was provided to the playCDDA method will be called with true when the playback is paused successfully. This method can only be called when the CDDA playback is in progress, as indicated by a first successful call of the playCDDA callback, and will fail if not. Pausing the playback will not stop the CDRom drive motor, which means that another playCDDA call start playing faster than if the motor was stopped.

◆ playCDDADisc() [1/2]

void psyqo::CDRomDevice::playCDDADisc ( MSF  start,
eastl::function< void(bool)> &&  callback 
)

◆ playCDDADisc() [2/2]

void psyqo::CDRomDevice::playCDDADisc ( unsigned  track,
eastl::function< void(bool)> &&  callback 
)

◆ playCDDATrack() [1/2]

void psyqo::CDRomDevice::playCDDATrack ( MSF  start,
eastl::function< void(bool)> &&  callback 
)

Begins playing CDDA audio from a given starting point.

This method will begin playing CDDA audio from a given starting point. The starting point is either a track number or an MSF value. Unlike other APIs here, upon success, the callback will be called twice: once when the playback actually started, and once when the playback is complete or paused, which can be after the end of the track, at the end of the disc if the last track is reached, or if the playback is paused or stopped using the pauseCDDA or stopCDDA methods. The first callback will be called with true if the playback started successfully, and false if it failed. In the case of failure, the second callback will not be called. The Track variant will stop playback at the end of the track, while the Disc variant will stop playback at the end of the disc. The resume method can be used to resume playback after a pause. Its callback argument will function similarly to the callback argument of the playCDDA methods.

Parameters
startThe starting point for playback.
stopAtEndOfTrackIf true, playback will stop at the end of the track.
callbackThe callback to call when playback is complete.

◆ playCDDATrack() [2/2]

void psyqo::CDRomDevice::playCDDATrack ( unsigned  track,
eastl::function< void(bool)> &&  callback 
)

◆ prepare()

void psyqo::CDRomDevice::prepare ( )

Prepares the CDRom subsystem.

This method prepares the kernel and the system for the CDRom subsystem. It should be called once from the application's prepare method.

◆ readSectors()

void psyqo::CDRomDevice::readSectors ( uint32_t  sector,
uint32_t  count,
void buffer,
eastl::function< void(bool)> &&  callback 
)
overridevirtual

Reads sectors from the CDRom.

This method will read a number of sectors from the CDRom drive. The sectors will be read into the provided buffer. Note that only one read operation can be active at a time, and that the ISO9660Parser class will call this method to read the filesystem structure, so care must be taken to ensure no other read operation is active when the parser is used.

Parameters
sectorThe sector to start reading from.
countThe number of sectors to read.
bufferThe buffer to read the sectors into.
callbackThe callback to call when the read is complete.

Implements psyqo::CDRom.

◆ readSectorsBlocking()

bool psyqo::CDRomDevice::readSectorsBlocking ( uint32_t  sector,
uint32_t  count,
void buffer,
GPU gpu 
)

◆ readTOC() [1/2]

ReadTOCAwaiter psyqo::CDRomDevice::readTOC ( MSF toc,
unsigned  size 
)
inline

◆ readTOC() [2/2]

void psyqo::CDRomDevice::readTOC ( MSF toc,
unsigned  size,
eastl::function< void(bool)> &&  callback 
)

Reads the Table of Contents from the CDRom.

This method will read the Table of Contents from the CDRom drive. The TOC will be read into the provided buffer. Note that a CD-Rom can have up to 99 tracks, and the TOC will be read into the provided buffer starting at index 1 for the first track. Any tracks that are not present on the CD will not have their MSF structure filled in, so the application should ensure that the buffer is initialized to zero before calling this method. The blocking variant may take a total of 200ms to complete, depending on the number of tracks on the CD.

Parameters
tocThe buffer to read the TOC into.
sizeThe size of the buffer. Should be 100 to hold all possible tracks.
callbackThe callback to call when the read is complete.

◆ readTOCBlocking()

bool psyqo::CDRomDevice::readTOCBlocking ( MSF toc,
unsigned  size,
GPU gpu 
)

◆ reset() [1/2]

ResetAwaiter psyqo::CDRomDevice::reset ( )
inline

◆ reset() [2/2]

void psyqo::CDRomDevice::reset ( eastl::function< void(bool)> &&  callback)

Resets the CDRom controller.

This method will reset the CDRom controller. It technically does not need to be called, but it is a good idea to call it when the application starts, in order to ensure that the controller is in a known state.

◆ resetBlocking()

bool psyqo::CDRomDevice::resetBlocking ( GPU gpu)

◆ resumeCDDA()

void psyqo::CDRomDevice::resumeCDDA ( eastl::function< void(bool)> &&  callback)

◆ scheduleGetPlaybackLocation()

psyqo::TaskQueue::Task psyqo::CDRomDevice::scheduleGetPlaybackLocation ( PlaybackLocation location)

◆ scheduleGetTOCSize()

psyqo::TaskQueue::Task psyqo::CDRomDevice::scheduleGetTOCSize ( unsigned *  size)

◆ scheduleMute()

psyqo::TaskQueue::Task psyqo::CDRomDevice::scheduleMute ( )

◆ scheduleReadTOC()

psyqo::TaskQueue::Task psyqo::CDRomDevice::scheduleReadTOC ( MSF toc,
unsigned  size 
)

◆ scheduleReset()

psyqo::TaskQueue::Task psyqo::CDRomDevice::scheduleReset ( )

◆ scheduleUnmute()

psyqo::TaskQueue::Task psyqo::CDRomDevice::scheduleUnmute ( )

◆ setVolume()

void psyqo::CDRomDevice::setVolume ( uint8_t  leftToLeft,
uint8_t  rightToLeft,
uint8_t  leftToRight,
uint8_t  rightToRight 
)

Set the Volume of the CDDA audio.

This method will set the volume of the CDDA audio. The volume is set using four values, which represent the volume of the left channel to the left speaker, the right channel to the left speaker, the left channel to the right speaker, and the right channel to the right speaker. The given output value should be in the range of 0 to 128, where 0 is silence and 128 is full volume. The values for a given output speaker will be added together, so clipping can occur if the sum of the values is greater than 128. The method can be used at any time, unlike the mute/unmute methods, which can only be used when the drive is idle. The normal volume setting is 0x80, 0x00, 0x00, 0x80.

Parameters
leftToLeftThe volume of the left channel to the left speaker.
rightToLeftThe volume of the right channel to the left speaker.
leftToRightThe volume of the left channel to the right speaker.
rightToRightThe volume of the right channel to the right speaker.

◆ stopCDDA()

void psyqo::CDRomDevice::stopCDDA ( )

Stops CDDA playback.

This method will request a stop of the CDDA playback. It functions similarly to the pauseCDDA method, but will stop the CDRom drive motor, which means that another playCDDA call will take longer to start playing than if the motor was not stopped.

◆ unmute() [1/2]

UnmuteAwaiter psyqo::CDRomDevice::unmute ( )
inline

◆ unmute() [2/2]

void psyqo::CDRomDevice::unmute ( eastl::function< void(bool)> &&  callback)

Unmutes the CD audio for both CDDA and CDXA.

Parameters
callbackThe callback to call when the unmute operation is complete.

◆ unmuteBlocking()

void psyqo::CDRomDevice::unmuteBlocking ( GPU )

Friends And Related Symbol Documentation

◆ ActionBase

friend class ActionBase
friend

The documentation for this class was generated from the following files: