diff --git a/SilentPatchSA/AudioHardwareSA.h b/SilentPatchSA/AudioHardwareSA.h index bb0c1bd..c0a0979 100644 --- a/SilentPatchSA/AudioHardwareSA.h +++ b/SilentPatchSA/AudioHardwareSA.h @@ -22,7 +22,7 @@ enum eDecoderType }; // 1.0/Steam structure -class NOVMT CAEDataStreamOld : public IStream +class NOVMT CAEDataStreamOld final : public IStream { private: HANDLE hHandle; @@ -57,9 +57,9 @@ public: } } - inline DWORD GetID() + inline DWORD GetID() const { return dwID; } - inline HANDLE GetFile() + inline HANDLE GetFile() const { return hHandle; } virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject); @@ -87,7 +87,7 @@ public: // Custom methods DWORD Seek(LONG nToSeek, DWORD nPoint); DWORD FillBuffer(void* pBuf, DWORD nLen); - DWORD GetCurrentPosition() + DWORD GetCurrentPosition() const { LARGE_INTEGER filePointer; filePointer.QuadPart = 0; @@ -97,7 +97,7 @@ public: }; // 1.01 structure -class NOVMT CAEDataStreamNew : public IStream +class NOVMT CAEDataStreamNew final : public IStream { private: void* pUselessMalloc; @@ -134,9 +134,9 @@ public: } } - inline DWORD GetID() + inline DWORD GetID() const { return dwID; } - inline HANDLE GetFile() + inline HANDLE GetFile() const { return hHandle; } virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject); @@ -164,7 +164,7 @@ public: // Custom methods DWORD Seek(LONG nToSeek, DWORD nPoint); DWORD FillBuffer(void* pBuf, DWORD nLen); - DWORD GetCurrentPosition() + DWORD GetCurrentPosition() const { LARGE_INTEGER filePointer; filePointer.QuadPart = 0; @@ -201,20 +201,20 @@ public: return reinterpret_cast(this)->FillBuffer(pBuf, nLen); return reinterpret_cast(this)->FillBuffer(pBuf, nLen); } - unsigned int GetCurrentPosition() + unsigned int GetCurrentPosition() const { if ( m_bUseNewStruct ) - return reinterpret_cast(this)->GetCurrentPosition(); - return reinterpret_cast(this)->GetCurrentPosition(); } + return reinterpret_cast(this)->GetCurrentPosition(); + return reinterpret_cast(this)->GetCurrentPosition(); } - inline DWORD GetID() + inline DWORD GetID() const { if ( m_bUseNewStruct ) - return reinterpret_cast(this)->GetID(); - return reinterpret_cast(this)->GetID(); } + return reinterpret_cast(this)->GetID(); + return reinterpret_cast(this)->GetID(); } - inline HANDLE GetFile() + inline HANDLE GetFile() const { if ( m_bUseNewStruct ) - return reinterpret_cast(this)->GetFile(); - return reinterpret_cast(this)->GetFile(); } + return reinterpret_cast(this)->GetFile(); + return reinterpret_cast(this)->GetFile(); } }; @@ -233,18 +233,20 @@ public: inline CAEDataStream* GetStream() { return pStream; } + inline const CAEDataStream* GetStream() const + { return pStream; } virtual bool Initialise()=0; virtual uint32_t FillBuffer(void* pBuf,uint32_t nLen)=0; - virtual uint32_t GetStreamLengthMs()=0; - virtual uint32_t GetStreamPlayTimeMs()=0; + virtual uint32_t GetStreamLengthMs() const =0; + virtual uint32_t GetStreamPlayTimeMs() const =0; virtual void SetCursor(uint32_t nTime)=0; - virtual uint32_t GetSampleRate()=0; + virtual uint32_t GetSampleRate() const =0; virtual ~CAEStreamingDecoder(); - virtual uint32_t GetStreamID()=0; + virtual uint32_t GetStreamID() const =0; }; static_assert(sizeof(CAEDataStreamOld) == 0x28, "Wrong size: CAEDataStreamOld"); diff --git a/SilentPatchSA/FLACDecoderSA.h b/SilentPatchSA/FLACDecoderSA.h index 9cb4fac..8e20868 100644 --- a/SilentPatchSA/FLACDecoderSA.h +++ b/SilentPatchSA/FLACDecoderSA.h @@ -2,7 +2,7 @@ #include "AudioHardwareSA.h" -class CAEFLACDecoder : public CAEStreamingDecoder +class CAEFLACDecoder final : public CAEStreamingDecoder { private: FLAC__StreamDecoder* m_FLACdecoder = nullptr; @@ -31,14 +31,14 @@ public: virtual ~CAEFLACDecoder() override; virtual bool Initialise() override; virtual uint32_t FillBuffer(void* pBuf, uint32_t nLen) override; - virtual uint32_t GetStreamLengthMs() override + virtual uint32_t GetStreamLengthMs() const override { return uint32_t((m_streamMeta->data.stream_info.total_samples * 1000) / m_streamMeta->data.stream_info.sample_rate); } - virtual uint32_t GetStreamPlayTimeMs() override + virtual uint32_t GetStreamPlayTimeMs() const override { return uint32_t((m_currentSample * 1000) / m_streamMeta->data.stream_info.sample_rate); } virtual void SetCursor(uint32_t nTime) override { FLAC__stream_decoder_seek_absolute(m_FLACdecoder, (uint64_t(nTime) * m_streamMeta->data.stream_info.sample_rate) / 1000); } - virtual uint32_t GetSampleRate() override + virtual uint32_t GetSampleRate() const override { return m_streamMeta->data.stream_info.sample_rate; } - virtual uint32_t GetStreamID() override + virtual uint32_t GetStreamID() const override { return GetStream()->GetID(); } }; \ No newline at end of file diff --git a/SilentPatchSA/WaveDecoderSA.h b/SilentPatchSA/WaveDecoderSA.h index a70fcf1..01f4515 100644 --- a/SilentPatchSA/WaveDecoderSA.h +++ b/SilentPatchSA/WaveDecoderSA.h @@ -2,7 +2,7 @@ #include "AudioHardwareSA.h" -class CAEWaveDecoder : public CAEStreamingDecoder +class CAEWaveDecoder final : public CAEStreamingDecoder { private: uint32_t m_dataSize; @@ -33,9 +33,9 @@ public: virtual bool Initialise() override; virtual uint32_t FillBuffer(void* pBuf, uint32_t nLen) override; - virtual uint32_t GetStreamLengthMs() override + virtual uint32_t GetStreamLengthMs() const override { return (static_cast(m_dataSize) * 1000) / m_formatChunk.blockAlign; } - virtual uint32_t GetStreamPlayTimeMs() override + virtual uint32_t GetStreamPlayTimeMs() const override { return (static_cast(GetStream()->GetCurrentPosition() - m_offsetToData) * 1000) / m_formatChunk.blockAlign; } virtual void SetCursor(uint32_t nTime) override @@ -44,10 +44,10 @@ public: GetStream()->Seek( m_offsetToData + (static_cast(sampleNum) * m_formatChunk.blockAlign), FILE_BEGIN ); } - virtual uint32_t GetSampleRate() override + virtual uint32_t GetSampleRate() const override { return m_formatChunk.sampleRate; } - virtual uint32_t GetStreamID() override + virtual uint32_t GetStreamID() const override { return GetStream()->GetID(); } private: