openbsd-ports/devel/ptlib/files/sound_sndio.h
ajacoutot 540c1f4f5f Import ptlib-2.6.5
PTLib is a moderately large C++ class library that originated many years
ago as a method to produce applications that run on both Microsoft
Windows and Unix X-Windows systems. It also was to have a Macintosh port
as well, but this never eventuated. In those days it was called the
PWLib the Portable Windows Library.

Since then, the availability of multi-platform GUI toolkits such as KDE
and wxWindows, and the development of the OpenH323 and OPAL projects as
primary user of the library, has emphasised the focus on networking, I/O
portability, multi-threading and protocol portability. Mostly, the
library is used to create high performance and highly portable
network-centric applications. So all the GUI abstractions ahave been
dropped and it was renamed the Portable Tools Library that you see
today.
2010-03-23 21:10:17 +00:00

67 lines
2.1 KiB
C++

#include <ptlib.h>
#include <ptlib/sound.h>
#include <ptlib/socket.h>
#include <sndio.h>
class PSoundChannelSNDIO: public PSoundChannel
{
public:
PSoundChannelSNDIO();
void Construct();
PSoundChannelSNDIO(const PString &device,
PSoundChannel::Directions dir,
unsigned numChannels,
unsigned sampleRate,
unsigned bitsPerSample);
~PSoundChannelSNDIO();
static PStringArray GetDeviceNames(PSoundChannel::Directions = Player);
static PString GetDefaultDevice(PSoundChannel::Directions);
PBoolean Open(const PString & _device,
Directions _dir,
unsigned _numChannels,
unsigned _sampleRate,
unsigned _bitsPerSample);
PBoolean Setup();
PBoolean Close();
PBoolean IsOpen() const;
PBoolean Write(const void * buf, PINDEX len);
PBoolean Read(void * buf, PINDEX len);
PBoolean SetFormat(unsigned numChannels,
unsigned sampleRate,
unsigned bitsPerSample);
unsigned GetChannels() const;
unsigned GetSampleRate() const;
unsigned GetSampleSize() const;
PBoolean SetBuffers(PINDEX size, PINDEX count);
PBoolean GetBuffers(PINDEX & size, PINDEX & count);
PBoolean PlaySound(const PSound & sound, PBoolean wait);
PBoolean PlayFile(const PFilePath & filename, PBoolean wait);
PBoolean HasPlayCompleted();
PBoolean WaitForPlayCompletion();
PBoolean RecordSound(PSound & sound);
PBoolean RecordFile(const PFilePath & filename);
PBoolean StartRecording();
PBoolean IsRecordBufferFull();
PBoolean AreAllRecordBuffersFull();
PBoolean WaitForRecordBufferFull();
PBoolean WaitForAllRecordBuffersFull();
PBoolean Abort();
PBoolean SetVolume(unsigned newVal);
PBoolean GetVolume(unsigned &devVol);
protected:
struct sio_hdl *hdl;
struct sio_par par;
unsigned mNumChannels;
unsigned mSampleRate;
unsigned mBitsPerSample;
unsigned mFragCount;
unsigned mFragSize;
unsigned mBytesPerFrame;
Directions mDirection;
PString mDevice;
PBoolean isInitialised;
};