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 PTLIB_PWAVFILEDEV_H
00035 #define PTLIB_PWAVFILEDEV_H
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(
00068 const PString & device,
00069 Directions dir,
00070 unsigned numChannels,
00071 unsigned sampleRate,
00072 unsigned bitsPerSample
00073 );
00074 virtual PString GetName() const;
00075 PBoolean Close();
00076 PBoolean IsOpen() const;
00077 PBoolean Write(const void * buf, PINDEX len);
00078 PBoolean Read(void * buf, PINDEX len);
00079 PBoolean SetFormat(unsigned numChannels,
00080 unsigned sampleRate,
00081 unsigned bitsPerSample);
00082 unsigned GetChannels() const;
00083 unsigned GetSampleRate() const;
00084 unsigned GetSampleSize() const;
00085 PBoolean SetBuffers(PINDEX size, PINDEX count);
00086 PBoolean GetBuffers(PINDEX & size, PINDEX & count);
00087 PBoolean HasPlayCompleted();
00088 PBoolean WaitForPlayCompletion();
00089 PBoolean StartRecording();
00090 PBoolean IsRecordBufferFull();
00091 PBoolean AreAllRecordBuffersFull();
00092 PBoolean WaitForRecordBufferFull();
00093 PBoolean WaitForAllRecordBuffersFull();
00094
00095 protected:
00096 bool ReadSamples(void * data, PINDEX size);
00097
00098 PWAVFile m_WAVFile;
00099 PAdaptiveDelay m_Pacing;
00100 bool m_autoRepeat;
00101 unsigned m_sampleRate;
00102 PINDEX m_bufferSize;
00103 };
00104
00105
00106 #endif // defined(P_WAVFILE)
00107
00108 #endif // PTLIB_PWAVFILEDEV_H
00109
00110
00111