00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef _PWAVFILEDEV
00035 #define _PWAVFILEDEV
00036
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040
00041 #include <ptlib.h>
00042
00043 #include <ptlib/sound.h>
00044 #include <ptclib/pwavfile.h>
00045 #include <ptclib/delaychan.h>
00046
00047 #if defined(P_WAVFILE)
00048
00049
00051
00052
00053
00054
00055 class PSoundChannel_WAVFile : public PSoundChannel
00056 {
00057 PCLASSINFO(PSoundChannel_WAVFile, PSoundChannel);
00058 public:
00059 PSoundChannel_WAVFile();
00060 PSoundChannel_WAVFile(const PString &device,
00061 PSoundChannel::Directions dir,
00062 unsigned numChannels,
00063 unsigned sampleRate,
00064 unsigned bitsPerSample);
00065 ~PSoundChannel_WAVFile();
00066 static PStringArray GetDeviceNames(PSoundChannel::Directions = Player);
00067 PBoolean Open(const PString & _device,
00068 Directions _dir,
00069 unsigned _numChannels,
00070 unsigned _sampleRate,
00071 unsigned _bitsPerSample);
00072 virtual PString GetName() const;
00073 PBoolean Close();
00074 PBoolean IsOpen() const;
00075 PBoolean Write(const void * buf, PINDEX len);
00076 PBoolean Read(void * buf, PINDEX len);
00077 PBoolean SetFormat(unsigned numChannels,
00078 unsigned sampleRate,
00079 unsigned bitsPerSample);
00080 unsigned GetChannels() const;
00081 unsigned GetSampleRate() const;
00082 unsigned GetSampleSize() const;
00083 PBoolean SetBuffers(PINDEX size, PINDEX count);
00084 PBoolean GetBuffers(PINDEX & size, PINDEX & count);
00085 PBoolean HasPlayCompleted();
00086 PBoolean WaitForPlayCompletion();
00087 PBoolean StartRecording();
00088 PBoolean IsRecordBufferFull();
00089 PBoolean AreAllRecordBuffersFull();
00090 PBoolean WaitForRecordBufferFull();
00091 PBoolean WaitForAllRecordBuffersFull();
00092
00093 protected:
00094 bool ReadSamples(void * data, PINDEX size);
00095
00096 PWAVFile m_WAVFile;
00097 PAdaptiveDelay m_Pacing;
00098 bool m_autoRepeat;
00099 unsigned m_sampleRate;
00100 PINDEX m_bufferSize;
00101 };
00102
00103
00104 #endif // defined(P_WAVFILE)
00105
00106 #endif // _PWAVFILEDEV
00107