Discman
Loading...
Searching...
No Matches
CDDrive::Reader Class Reference

The Reader uses a separate thread to load data into the CDDrive's ring buffer. More...

#include <cd_drive.h>

Collaboration diagram for CDDrive::Reader:

Public Types

enum  Action { Idle , Load , Exit }
 Actions are taken consecutively. Setting an action on the Reader takes effect after its current action. More...
 

Public Member Functions

 Reader (CDDrive &drive)
 Reader constructor.
 
 ~Reader ()
 Reader destructor.
 
void action (const Action action)
 Set the next action for the Reader.
 
Action action ()
 Returns the current Reader action in a thread-safe way.
 
void track (const int track)
 Seeks to the given track on the disc using 1-based indexing.
 
void buffer (const int buffer)
 Sets the index of the buffer in the CDDrive's ring buffer to read samples into.
 
void load ()
 Fills the current buffer with audio samples.
 
void loop ()
 The execution loop performed by the thread.
 

Private Attributes

CDDrive_drive
 The parent CDDrive.
 
Action _action
 The current or next action to be taken by the Reader.
 
int _buffer
 The index of the buffer in the CDDrive's ring buffer to read samples into.
 
cdrom_paranoia_t * _paranoia
 cdio handle to the sample reader.
 
std::mutex _action_lock
 Provides mutually exclusive access to the _action member between the the application thread and the Reader thread.
 
std::thread _thread
 The thread used to run loop().
 

Detailed Description

The Reader uses a separate thread to load data into the CDDrive's ring buffer.

Definition at line 172 of file cd_drive.h.

Member Enumeration Documentation

◆ Action

Actions are taken consecutively. Setting an action on the Reader takes effect after its current action.

Enumerator
Idle 
Load 
Exit 

Definition at line 177 of file cd_drive.h.

Constructor & Destructor Documentation

◆ Reader()

CDDrive::Reader::Reader ( CDDrive & drive)

Reader constructor.

Parameters
[in]driveThe parent CDDrive.

Definition at line 9 of file cd_drive.cc.

◆ ~Reader()

CDDrive::Reader::~Reader ( )

Reader destructor.

Definition at line 19 of file cd_drive.cc.

Member Function Documentation

◆ action() [1/2]

CDDrive::Reader::Action CDDrive::Reader::action ( )

Returns the current Reader action in a thread-safe way.

Returns
The current action.

Definition at line 42 of file cd_drive.cc.

◆ action() [2/2]

void CDDrive::Reader::action ( const Action action)

Set the next action for the Reader.

Parameters
[in]actionThe action to take.

Definition at line 26 of file cd_drive.cc.

◆ buffer()

void CDDrive::Reader::buffer ( const int buffer)

Sets the index of the buffer in the CDDrive's ring buffer to read samples into.

Parameters
[in]bufferThe index of the buffer (0 or 1).

Definition at line 38 of file cd_drive.cc.

◆ load()

void CDDrive::Reader::load ( )

Fills the current buffer with audio samples.

Definition at line 61 of file cd_drive.cc.

◆ loop()

void CDDrive::Reader::loop ( )

The execution loop performed by the thread.

Definition at line 77 of file cd_drive.cc.

◆ track()

void CDDrive::Reader::track ( const int track)

Seeks to the given track on the disc using 1-based indexing.

Parameters
[in]trackThe track to seek to .

Definition at line 32 of file cd_drive.cc.

Member Data Documentation

◆ _action

Action CDDrive::Reader::_action
private

The current or next action to be taken by the Reader.

Definition at line 212 of file cd_drive.h.

◆ _action_lock

std::mutex CDDrive::Reader::_action_lock
private

Provides mutually exclusive access to the _action member between the the application thread and the Reader thread.

Definition at line 220 of file cd_drive.h.

◆ _buffer

int CDDrive::Reader::_buffer
private

The index of the buffer in the CDDrive's ring buffer to read samples into.

Definition at line 214 of file cd_drive.h.

◆ _drive

CDDrive& CDDrive::Reader::_drive
private

The parent CDDrive.

Definition at line 210 of file cd_drive.h.

◆ _paranoia

cdrom_paranoia_t* CDDrive::Reader::_paranoia
private

cdio handle to the sample reader.

Definition at line 216 of file cd_drive.h.

◆ _thread

std::thread CDDrive::Reader::_thread
private

The thread used to run loop().

Definition at line 224 of file cd_drive.h.


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