diff --git a/src/dos/cdrom.h b/src/dos/cdrom.h index 1edcb6b5..e67c1251 100644 --- a/src/dos/cdrom.h +++ b/src/dos/cdrom.h @@ -20,12 +20,13 @@ #ifndef __CDROM_INTERFACE__ #define __CDROM_INTERFACE__ -#include -#include -#include -#include +#include #include +#include #include +#include +#include + #include #include @@ -120,6 +121,7 @@ private: protected: TrackFile(Bit16u _chunkSize) : chunkSize(_chunkSize) {} public: + virtual ~TrackFile() = default; virtual bool read(Bit8u *buffer, int seek, int count) = 0; virtual bool seek(Bit32u offset) = 0; virtual Bit32u decode(Bit16s *buffer, Bit32u desired_track_frames) = 0; @@ -127,12 +129,18 @@ private: virtual Bit32u getRate() = 0; virtual Bit8u getChannels() = 0; virtual int getLength() = 0; - virtual ~TrackFile() {} const Bit16u chunkSize; }; + class BinaryFile : public TrackFile { public: BinaryFile (const char *filename, bool &error); + ~BinaryFile (); + + BinaryFile () = delete; + BinaryFile (const BinaryFile&) = delete; // prevent copying + BinaryFile& operator= (const BinaryFile&) = delete; // prevent assignment + bool read(Bit8u *buffer, int seek, int count); bool seek(Bit32u offset); Bit32u decode(Bit16s *buffer, Bit32u desired_track_frames); @@ -140,15 +148,19 @@ private: Bit32u getRate() { return 44100; } Bit8u getChannels() { return 2; } int getLength(); - ~BinaryFile(); private: std::ifstream *file; - BinaryFile(); }; class AudioFile : public TrackFile { public: AudioFile (const char *filename, bool &error); + ~AudioFile (); + + AudioFile () = delete; + AudioFile (const AudioFile&) = delete; // prevent copying + AudioFile& operator= (const AudioFile&) = delete; // prevent assignment + bool read(Bit8u *buffer, int seek, int count) { (void)buffer; // unused but part of the API (void)seek; // ... @@ -160,10 +172,8 @@ private: Bit32u getRate(); Bit8u getChannels(); int getLength(); - ~AudioFile(); private: Sound_Sample *sample; - AudioFile(); }; public: diff --git a/src/dos/dos_mscdex.cpp b/src/dos/dos_mscdex.cpp index c29e42d6..56f4ea11 100644 --- a/src/dos/dos_mscdex.cpp +++ b/src/dos/dos_mscdex.cpp @@ -60,9 +60,9 @@ static Bitu MSCDEX_Strategy_Handler(void); static Bitu MSCDEX_Interrupt_Handler(void); static MountType MSCDEX_GetMountType(const char *path); -class DOS_DeviceHeader:public MemStruct { +class DOS_DeviceHeader : public MemStruct { public: - DOS_DeviceHeader(PhysPt ptr) { pt = ptr; }; + DOS_DeviceHeader(PhysPt ptr) { pt = ptr; } void SetNextDeviceHeader (RealPt ptr) { sSave(sDeviceHeader,nextDeviceHeader,ptr); }; RealPt GetNextDeviceHeader (void) { return sGet(sDeviceHeader,nextDeviceHeader); }; @@ -78,7 +78,7 @@ public: #ifdef _MSC_VER #pragma pack(1) #endif - struct sDeviceHeader{ + struct sDeviceHeader { RealPt nextDeviceHeader; Bit16u devAttributes; Bit16u strategy; @@ -87,7 +87,7 @@ public: Bit16u wReserved; Bit8u driveLetter; Bit8u numSubUnits; - } GCC_ATTRIBUTE(packed) TDeviceHeader; + } GCC_ATTRIBUTE(packed); #ifdef _MSC_VER #pragma pack() #endif @@ -95,11 +95,14 @@ public: class CMscdex { public: - CMscdex (void); - ~CMscdex (void); + CMscdex (); + ~CMscdex (); + + CMscdex (const CMscdex&) = delete; // prevent copying + CMscdex& operator= (const CMscdex&) = delete; // prevent assignment Bit16u GetVersion (void) { return (MSCDEX_VERSION_HIGH<<8)+MSCDEX_VERSION_LOW; }; - Bit16u GetNumDrives (void) { return numDrives; }; + Bit16u GetNumDrives (void) const { return numDrives; } Bit16u GetFirstDrive (void) { return dinfo[0].drive; }; Bit8u GetSubUnit (Bit16u _drive); bool GetUPC (Bit8u subUnit, Bit8u& attr, char* upc); @@ -158,32 +161,33 @@ private: TCtrl audioCtrl; // audio channel control } TDriveInfo; - Bit16u defaultBufSeg; - TDriveInfo dinfo[MSCDEX_MAX_DRIVES]; - CDROM_Interface* cdrom[MSCDEX_MAX_DRIVES]; + Bit16u defaultBufSeg; + TDriveInfo dinfo[MSCDEX_MAX_DRIVES]; + CDROM_Interface * cdrom[MSCDEX_MAX_DRIVES]; public: - Bit16u rootDriverHeaderSeg; + Bit16u rootDriverHeaderSeg; - bool ChannelControl (Bit8u subUnit, TCtrl ctrl); - bool GetChannelControl (Bit8u subUnit, TCtrl& ctrl); + bool ChannelControl(Bit8u subUnit, TCtrl ctrl); + bool GetChannelControl(Bit8u subUnit, TCtrl &ctrl); }; -CMscdex::CMscdex(void) { - numDrives = 0; - rootDriverHeaderSeg = 0; - defaultBufSeg = 0; - - memset(dinfo,0,sizeof(dinfo)); - for (Bit32u i=0; i