AudioCodecs_Stream.hxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __AUDIOCODECS_STREAM__
00023 #define __AUDIOCODECS_STREAM__
00024
00025 #include "DataTypes.hxx"
00026 #include "DataTypes.hxx"
00027 #include <vector>
00028
00029 namespace CLAM
00030 {
00031
00032 class AudioFile;
00033
00034 namespace AudioCodecs
00035 {
00043 class Stream
00044 {
00045 public:
00046 Stream();
00047 virtual ~Stream();
00049 virtual void PrepareReading() = 0;
00051 virtual void PrepareWriting() = 0;
00053 virtual void Dispose() = 0;
00056 virtual void SeekTo(unsigned long framePosition) {}
00058 virtual unsigned long GetFramePosition() const {return mFramePosition;}
00059 protected:
00061 virtual void DiskToMemoryTransfer() = 0;
00063 virtual void MemoryToDiskTransfer() = 0;
00064
00065 public:
00067 bool ReadData( int channel, TData* buffer, unsigned nFrames );
00069 bool ReadData( TData** buffers, unsigned nFrames );
00071 bool ReadData( int* channels, int nchannels,
00072 TData** buffers, unsigned nFrames );
00073
00075 void WriteData( int channel, const TData* buffer, unsigned nFrames );
00077 void WriteData( TData** const buffers, unsigned nFrames );
00079 void WriteData( int* channels, int nchannels,
00080 TData** const buffers, unsigned nFrames );
00081
00082 protected:
00083 void SetChannels( unsigned nChannels );
00084
00085 protected:
00086 unsigned mChannels;
00087 std::vector<TData> mInterleavedData;
00088 bool mEOFReached;
00089 unsigned mFramesLastRead;
00090 unsigned long mFramePosition;
00091
00092 private:
00093 void AdjustInterleavedBuffer( unsigned nFrames );
00094 };
00095 }
00096
00097 }
00098
00099 #endif // AudioCodecs_Stream.hxx
00100