13 #include <semaphore.h> 15 #include <sys/types.h> 16 #include <sys/soundcard.h> 17 #include <alsa/asoundlib.h> 18 #include <alsa/pcm_plugin.h> 24 #include "utl/UtlVoidPtr.h" 80 static int getDeviceNames(UtlContainer& deviceNames,
bool capture);
141 OsStatus
initDeviceFinal(
unsigned samplesPerSec,
unsigned samplerPerFrame);
145 OsStatus
setSampleRate(
unsigned samplesPerSec,
unsigned samplerPerFrame);
148 OsStatus
doInput(
char* buffer,
int size);
150 OsStatus
doOutput(
const char* buffer,
int size);
182 int alsaSetupWarning(
const char* devname,
int err,
bool cap,
const char* pLogString);
OsStatus doInput(char *buffer, int size)
Perform input operation of ALSA device.
OsStatus detachReader()
Disable input device.
UtlBoolean isDevCapMmap()
Definition: MpAlsa.h:212
UtlBoolean isDevCapDuplex()
Definition: MpAlsa.h:207
void noMoreNeeded()
Deinitialization and freeing sequences.
UtlBoolean alsaSetTrigger(bool turnOn)
static void * soundCardIoWrapper(void *arg)
Thread subroutine.
int readBufSize
Definition: MpAlsa.h:167
UtlBoolean isDeviceValid()
Inquire if the device is valid.
Definition: MpAlsa.h:187
Container for device specific input ALSA driver.
Definition: MpodAlsa.h:41
OsStatus doInputRs(MpAudioSample *buffer, unsigned size)
Perform input operation of ALSA device with siutable resampler.
OsStatus doOutput(const char *buffer, int size)
Perform output operation of ALSA device.
OsStatus initDeviceFinal(unsigned samplesPerSec, unsigned samplerPerFrame)
Final initializations for ALSA device.
volatile UtlBoolean mStReader
Input device is enabled.
Definition: MpAlsa.h:123
int writeBufSize
Definition: MpAlsa.h:166
UtlBoolean isNotUsed()
Inquire if ALSA device is free, i.e. neither input nor output is connected.
Definition: MpAlsa.h:222
OsStatus setInputDevice(MpidAlsa *pIDD)
Connect MpidAlsa class driver.
sem_t mSleepSem
Control IO thread sleeping.
Definition: MpAlsa.h:135
OsStatus detachWriter()
Disable output device.
Wrapper for ALSA device that use file descriptor to communicate.
Definition: MpAlsa.h:32
int alsaSetupPcmDevice(const char *devname, bool capture, unsigned &suggestedRate)
OsStatus attachWriter()
Enable output device.
UtlBoolean isDevCapBatch()
Definition: MpAlsa.h:202
int16_t MpAudioSample
Definition: MpTypes.h:44
unsigned mUsedSamplesPerFrame
Used frame size for IO.
Definition: MpAlsa.h:129
volatile UtlBoolean mStWriter
Output device is enabled.
Definition: MpAlsa.h:124
int mDeviceCap
Device capabilities.
Definition: MpAlsa.h:121
snd_pcm_t * pPcmIn
Definition: MpAlsa.h:165
OsStatus setSampleRate(unsigned samplesPerSec, unsigned samplerPerFrame)
Because ALSA device works in duplex mode we must ensure that input and output driver use one sample r...
OsStatus freeOutputDevice()
Disconnect Output driver.
MpAudioSample * mResamplerBuffer
Buffer for conversions.
Definition: MpAlsa.h:131
UtlBoolean isReaderAttached()
Inquire if the input device is connected.
Definition: MpAlsa.h:192
unsigned mUsedSamplesPerSec
Used samples rate either for IO.
Definition: MpAlsa.h:128
snd_pcm_t * pPcmOut
Definition: MpAlsa.h:164
int alsaSetupWarning(const char *devname, int err, bool cap, const char *pLogString)
void soundIoThread()
Thread subroutine.
UtlBoolean isDevCapTrigger()
Definition: MpAlsa.h:217
OsStatus doOutputRs(const MpAudioSample *buffer, unsigned size)
Perform output operation of ALSA device with siutable resampler.
MpidAlsa * mReader
Input driver.
Definition: MpAlsa.h:118
UtlBoolean mStereoOps
Use stereo output.
Definition: MpAlsa.h:132
OsStatus freeInputDevice()
Disconnect Input driver.
static int getDeviceNames(UtlContainer &deviceNames, bool capture)
get list of available input or output Alsa device names
OsStatus initDevice(const char *devname, int samplesPerSecond)
Pre initializations for ALSA device.
void threadIoStatusChanged()
pthread_t mIoThread
Internal IO thread.
Definition: MpAlsa.h:134
UtlBoolean mbWriteCap
Device is able to capture audio.
Definition: MpAlsa.h:116
volatile UtlBoolean mStShutdown
Thread exit flag.
Definition: MpAlsa.h:125
UtlBoolean mbReadCap
Device is able to play audio.
Definition: MpAlsa.h:115
OsStatus setOutputDevice(MpodAlsa *pODD)
Connect MpodAlsa class driver.
Container for device specific input ALSA driver.
Definition: MpidAlsa.h:36
UtlBoolean isWriterAttached()
Inquire if the output device is connected.
Definition: MpAlsa.h:197
MpodAlsa * mWriter
Output driver.
Definition: MpAlsa.h:119
volatile UtlBoolean mModeChanged
IO settings has changed.
Definition: MpAlsa.h:126
OsStatus attachReader()
Enable input device.
sem_t mSignalSem
Use for parameters synchronization.
Definition: MpAlsa.h:136