From ed2939b205acd00dc13e15e9407b7d543bd2912f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 21 Aug 2004 07:01:54 +0000 Subject: [PATCH] IsStreamingFromDisk --- stepmania/src/RageSound.cpp | 8 +++++++- stepmania/src/RageSound.h | 2 ++ stepmania/src/RageSoundReader.h | 1 + stepmania/src/RageSoundReader_FileReader.h | 1 + stepmania/src/RageSoundReader_Preload.h | 1 + stepmania/src/RageSoundReader_Resample_Fast.h | 1 + stepmania/src/RageSoundReader_Resample_Good.h | 1 + 7 files changed, 14 insertions(+), 1 deletion(-) diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index 827809a46d..edb0fd4ab6 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -156,8 +156,9 @@ public: int SetPosition_Accurate(int ms) { return 0; } int SetPosition_Fast(int ms) { return 0; } int Read(char *buf, unsigned len) { return 0; } - int GetSampleRate() const { return 44100; } SoundReader *Copy() const { return new RageSoundReader_Silence; } + int GetSampleRate() const { return 44100; } + bool IsStreamingFromDisk() const { return false; } }; @@ -790,6 +791,11 @@ int RageSound::GetSampleRate() const return Sample->GetSampleRate(); } +bool RageSound::IsStreamingFromDisk() const +{ + ASSERT( Sample ); + return Sample->IsStreamingFromDisk(); +} bool RageSound::SetPositionFrames( int frames ) { diff --git a/stepmania/src/RageSound.h b/stepmania/src/RageSound.h index cf37f9c4a2..5aeff53a0e 100644 --- a/stepmania/src/RageSound.h +++ b/stepmania/src/RageSound.h @@ -22,6 +22,7 @@ public: virtual float GetVolume() const = 0; virtual int GetID() const = 0; virtual CString GetLoadedFilePath() const = 0; + virtual bool IsStreamingFromDisk() const = 0; }; /* These are parameters to play a sound. These are normally changed before playing begins, @@ -104,6 +105,7 @@ public: float GetLengthSeconds(); float GetPositionSeconds( bool *approximate=NULL, RageTimer *Timestamp=NULL ) const; int GetSampleRate() const; + bool IsStreamingFromDisk() const; bool SetPositionSeconds( float fSeconds ); CString GetLoadedFilePath() const { return m_sFilePath; } bool IsPlaying() const { return playing; } diff --git a/stepmania/src/RageSoundReader.h b/stepmania/src/RageSoundReader.h index 0562698f69..374204f595 100644 --- a/stepmania/src/RageSoundReader.h +++ b/stepmania/src/RageSoundReader.h @@ -22,6 +22,7 @@ public: virtual SoundReader *Copy() const = 0; virtual int GetSampleRate() const = 0; virtual unsigned GetNumChannels() const { return 2; } /* 1 or 2 */ + virtual bool IsStreamingFromDisk() const = 0; bool Error() const { return !error.empty(); } string GetError() const { return error; } diff --git a/stepmania/src/RageSoundReader_FileReader.h b/stepmania/src/RageSoundReader_FileReader.h index e8b3038baf..461e37f79f 100644 --- a/stepmania/src/RageSoundReader_FileReader.h +++ b/stepmania/src/RageSoundReader_FileReader.h @@ -23,6 +23,7 @@ public: OPEN_FATAL_ERROR=2, }; virtual OpenResult Open(CString filename) = 0; + virtual bool IsStreamingFromDisk() const { return true; } static SoundReader *OpenFile( CString filename, CString &error ); private: diff --git a/stepmania/src/RageSoundReader_Preload.h b/stepmania/src/RageSoundReader_Preload.h index 1e69b60607..fce998e294 100644 --- a/stepmania/src/RageSoundReader_Preload.h +++ b/stepmania/src/RageSoundReader_Preload.h @@ -46,6 +46,7 @@ public: int Read(char *buf, unsigned len); int GetSampleRate() const { return samplerate; } unsigned GetNumChannels() const { return channels; } + bool IsStreamingFromDisk() const { return false; } SoundReader *Copy() const; ~SoundReader_Preload() { } diff --git a/stepmania/src/RageSoundReader_Resample_Fast.h b/stepmania/src/RageSoundReader_Resample_Fast.h index a92a24aa97..8ff4d32323 100644 --- a/stepmania/src/RageSoundReader_Resample_Fast.h +++ b/stepmania/src/RageSoundReader_Resample_Fast.h @@ -33,6 +33,7 @@ public: int GetSampleRate() const { return samplerate; } unsigned GetNumChannels() const { return source->GetNumChannels(); } + bool IsStreamingFromDisk() const { return source->IsStreamingFromDisk(); } }; #endif diff --git a/stepmania/src/RageSoundReader_Resample_Good.h b/stepmania/src/RageSoundReader_Resample_Good.h index e40d8f769f..0207bc7025 100644 --- a/stepmania/src/RageSoundReader_Resample_Good.h +++ b/stepmania/src/RageSoundReader_Resample_Good.h @@ -25,6 +25,7 @@ public: int GetSampleRate() const { return samplerate; } unsigned GetNumChannels() const { return source->GetNumChannels(); } + bool IsStreamingFromDisk() const { return source->IsStreamingFromDisk(); } enum { BUFSIZE = 4096 };