3 #define ALSA_PCM_NEW_HW_PARAMS_API 1
4 #include <alsa/asoundlib.h>
6 class PAudioDelay
: public PObject
8 PCLASSINFO(PAudioDelay
, PObject
);
22 #define MIN_HEADROOM 30
23 #define MAX_HEADROOM 60
25 class SoundHandleEntry
: public PObject
{
27 PCLASSINFO(SoundHandleEntry
, PObject
)
37 unsigned bitsPerSample
;
38 unsigned fragmentValue
;
42 #define LOOPBACK_BUFFER_SIZE 5000
43 #define BYTESINBUF ((startptr<endptr)?(endptr-startptr):(LOOPBACK_BUFFER_SIZE+endptr-startptr))
45 class PSoundChannelALSA
: public PSoundChannel
50 PSoundChannelALSA(const PString
&device
,
51 PSoundChannel::Directions dir
,
54 unsigned bitsPerSample
);
56 static PStringArray
GetDeviceNames(PSoundChannel::Directions
);
57 static PString
GetDefaultDevice(PSoundChannel::Directions
);
58 BOOL
Open(const PString
& _device
,
60 unsigned _numChannels
,
62 unsigned _bitsPerSample
);
65 BOOL
Write(const void * buf
, PINDEX len
);
66 BOOL
Read(void * buf
, PINDEX len
);
67 BOOL
SetFormat(unsigned numChannels
,
69 unsigned bitsPerSample
);
70 unsigned GetChannels() const;
71 unsigned GetSampleRate() const;
72 unsigned GetSampleSize() const;
73 BOOL
SetBuffers(PINDEX size
, PINDEX count
);
74 BOOL
GetBuffers(PINDEX
& size
, PINDEX
& count
);
75 BOOL
PlaySound(const PSound
& sound
, BOOL wait
);
76 BOOL
PlayFile(const PFilePath
& filename
, BOOL wait
);
77 BOOL
HasPlayCompleted();
78 BOOL
WaitForPlayCompletion();
79 BOOL
RecordSound(PSound
& sound
);
80 BOOL
RecordFile(const PFilePath
& filename
);
81 BOOL
StartRecording();
82 BOOL
IsRecordBufferFull();
83 BOOL
AreAllRecordBuffersFull();
84 BOOL
WaitForRecordBufferFull();
85 BOOL
WaitForAllRecordBuffersFull();
87 BOOL
SetVolume (unsigned);
88 BOOL
GetVolume (unsigned &);
93 BOOL
Volume (BOOL
, unsigned, unsigned &);
94 PSoundChannel::Directions direction
;
96 unsigned mNumChannels
;
98 unsigned mBitsPerSample
;
101 snd_pcm_t
*os_handle
; /* Handle, different from the PChannel handle */
103 int frame_bytes
; /* Number of bytes in a frame */
104 snd_pcm_uframes_t period_size
;
105 unsigned int periods
;