179 lines
No EOL
5.5 KiB
C++
179 lines
No EOL
5.5 KiB
C++
|
|
#ifndef __CDROM_INTERFACE__
|
|
#define __CDROM_INTERFACE__
|
|
|
|
#define MAX_ASPI_CDROM 5
|
|
|
|
#include <string.h>
|
|
|
|
#define RAW_SECTOR_SIZE 2352
|
|
#define COOKED_SECTOR_SIZE 2048
|
|
|
|
typedef struct SMSF {
|
|
unsigned char min;
|
|
unsigned char sec;
|
|
unsigned char fr;
|
|
} TMSF;
|
|
|
|
extern int CDROM_GetMountType(char* path);
|
|
|
|
class CDROM_Interface
|
|
{
|
|
public:
|
|
// CDROM_Interface (void);
|
|
virtual ~CDROM_Interface (void) {};
|
|
|
|
virtual bool SetDevice (char* path) = 0;
|
|
|
|
virtual bool GetUPC (unsigned char& attr, char* upc) = 0;
|
|
|
|
virtual bool GetAudioTracks (int& stTrack, int& end, TMSF& leadOut) = 0;
|
|
virtual bool GetAudioTrackInfo (int track, TMSF& start, unsigned char& attr) = 0;
|
|
virtual bool GetAudioSub (unsigned char& attr, unsigned char& track, unsigned char& index, TMSF& relPos, TMSF& absPos) = 0;
|
|
virtual bool GetAudioStatus (bool& playing, bool& pause) = 0;
|
|
virtual bool GetMediaTrayStatus (bool& mediaPresent, bool& mediaChanged, bool& trayOpen) = 0;
|
|
|
|
virtual bool PlayAudioSector (unsigned long start,unsigned long len) = 0;
|
|
virtual bool PauseAudio (bool resume) = 0;
|
|
virtual bool StopAudio (void) = 0;
|
|
|
|
virtual bool ReadSectors (void* buffer, bool raw, unsigned long sector, unsigned long num) = 0;
|
|
|
|
virtual bool LoadUnloadMedia (bool unload) = 0;
|
|
};
|
|
|
|
class CDROM_Interface_Fake : public CDROM_Interface
|
|
{
|
|
public:
|
|
bool SetDevice (char* path) { return true; };
|
|
bool GetUPC (unsigned char& attr, char* upc) { attr = 0; strcpy(upc,"UPC"); return true; };
|
|
bool GetAudioTracks (int& stTrack, int& end, TMSF& leadOut);
|
|
bool GetAudioTrackInfo (int track, TMSF& start, unsigned char& attr);
|
|
bool GetAudioSub (unsigned char& attr, unsigned char& track, unsigned char& index, TMSF& relPos, TMSF& absPos);
|
|
bool GetAudioStatus (bool& playing, bool& pause);
|
|
bool GetMediaTrayStatus (bool& mediaPresent, bool& mediaChanged, bool& trayOpen);
|
|
bool PlayAudioSector (unsigned long start,unsigned long len) { return true; };
|
|
bool PauseAudio (bool resume) { return true; };
|
|
bool StopAudio (void) { return true; };
|
|
bool ReadSectors (void* buffer, bool raw, unsigned long sector, unsigned long num) { return true; };
|
|
bool LoadUnloadMedia (bool unload) { return true; };
|
|
};
|
|
|
|
|
|
#if defined (WIN32) /* Win 32 */
|
|
|
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
|
|
#include <windows.h>
|
|
#include "wnaspi32.h" // Aspi stuff
|
|
|
|
class CDROM_Interface_Aspi : public CDROM_Interface
|
|
{
|
|
public:
|
|
CDROM_Interface_Aspi (void);
|
|
~CDROM_Interface_Aspi (void);
|
|
|
|
bool SetDevice (char* path);
|
|
|
|
bool GetUPC (unsigned char& attr, char* upc);
|
|
|
|
bool GetAudioTracks (int& stTrack, int& end, TMSF& leadOut);
|
|
bool GetAudioTrackInfo (int track, TMSF& start, unsigned char& attr);
|
|
bool GetAudioSub (unsigned char& attr, unsigned char& track, unsigned char& index, TMSF& relPos, TMSF& absPos);
|
|
bool GetAudioStatus (bool& playing, bool& pause);
|
|
bool GetMediaTrayStatus (bool& mediaPresent, bool& mediaChanged, bool& trayOpen);
|
|
|
|
bool PlayAudioSector (unsigned long start,unsigned long len);
|
|
bool PauseAudio (bool resume);
|
|
bool StopAudio (void);
|
|
|
|
bool ReadSectors (void* buffer, bool raw, unsigned long sector, unsigned long num);
|
|
|
|
bool LoadUnloadMedia (bool unload);
|
|
|
|
private:
|
|
DWORD GetTOC (LPTOC toc);
|
|
HANDLE OpenIOCTLFile (char cLetter, BOOL bAsync);
|
|
void GetIOCTLAdapter (HANDLE hF,int * iDA,int * iDT,int * iDL);
|
|
bool ScanRegistryFindKey (HKEY& hKeyBase);
|
|
bool ScanRegistry (HKEY& hKeyBase);
|
|
BYTE GetHostAdapter (void);
|
|
|
|
// ASPI stuff
|
|
BYTE haId;
|
|
BYTE target;
|
|
BYTE lun;
|
|
char letter;
|
|
|
|
// Windows stuff
|
|
HINSTANCE hASPI;
|
|
HANDLE hEvent; // global event
|
|
DWORD (*pGetASPI32SupportInfo) (void); // ptrs to aspi funcs
|
|
DWORD (*pSendASPI32Command) (LPSRB);
|
|
};
|
|
|
|
class CDROM_Interface_Ioctl : public CDROM_Interface
|
|
{
|
|
public:
|
|
CDROM_Interface_Ioctl (void);
|
|
~CDROM_Interface_Ioctl (void);
|
|
|
|
bool SetDevice (char* path);
|
|
|
|
bool GetUPC (unsigned char& attr, char* upc);
|
|
|
|
bool GetAudioTracks (int& stTrack, int& end, TMSF& leadOut);
|
|
bool GetAudioTrackInfo (int track, TMSF& start, unsigned char& attr);
|
|
bool GetAudioSub (unsigned char& attr, unsigned char& track, unsigned char& index, TMSF& relPos, TMSF& absPos);
|
|
bool GetAudioStatus (bool& playing, bool& pause);
|
|
bool GetMediaTrayStatus (bool& mediaPresent, bool& mediaChanged, bool& trayOpen);
|
|
|
|
bool PlayAudioSector (unsigned long start,unsigned long len);
|
|
bool PauseAudio (bool resume);
|
|
bool StopAudio (void);
|
|
|
|
bool ReadSectors (void* buffer, bool raw, unsigned long sector, unsigned long num);
|
|
|
|
bool LoadUnloadMedia (bool unload);
|
|
|
|
private:
|
|
|
|
HANDLE hIOCTL;
|
|
TMSF oldLeadOut;
|
|
};
|
|
|
|
#else /* Linux */
|
|
|
|
class CDROM_Interface_Linux : public CDROM_Interface
|
|
{
|
|
public:
|
|
CDROM_Interface_Linux (void);
|
|
~CDROM_Interface_Linux (void);
|
|
|
|
bool SetDevice (char* path);
|
|
|
|
bool GetUPC (unsigned char& attr, char* upc);
|
|
|
|
bool GetAudioTracks (int& stTrack, int& end, TMSF& leadOut);
|
|
bool GetAudioTrackInfo (int track, TMSF& start, unsigned char& attr);
|
|
bool GetAudioSub (unsigned char& attr, unsigned char& track, unsigned char& index, TMSF& relPos, TMSF& absPos);
|
|
bool GetAudioStatus (bool& playing, bool& pause);
|
|
bool GetMediaTrayStatus (bool& mediaPresent, bool& mediaChanged, bool& trayOpen);
|
|
|
|
bool PlayAudioSector (unsigned long start,unsigned long len);
|
|
bool PauseAudio (bool resume);
|
|
bool StopAudio (void);
|
|
|
|
bool ReadSectors (void* buffer, bool raw, unsigned long sector, unsigned long num);
|
|
|
|
bool LoadUnloadMedia (bool unload);
|
|
|
|
private:
|
|
|
|
int dhandle;
|
|
TMSF oldLeadOut;
|
|
};
|
|
|
|
#endif /* linux */
|
|
|
|
#endif /* __CDROM_INTERFACE__ */ |