RADLib
RADical C++ application framework
RADMedia::AudioInputDevice Class Reference

Convenience input-only audio device. More...

#include <RADMedia.h>

+ Inheritance diagram for RADMedia::AudioInputDevice:
+ Collaboration diagram for RADMedia::AudioInputDevice:

Public Member Functions

 AudioInputDevice (RADCore::EventLoop &loop)
 Creates an input audio device using loop for capture events. More...
 
- Public Member Functions inherited from RADMedia::RADAudioDevice
 RADAudioDevice (RADCore::EventLoop &loop, AudioDeviceDirection direction)
 Creates an input or output audio device using loop for events. More...
 
 ~RADAudioDevice () override
 Closes the device if still open. More...
 
AudioDeviceDirection direction () const
 Returns whether this device captures input or plays output. More...
 
void setDeviceId (std::string deviceId)
 Sets the ALSA device id, usually "default" or an enumerated id. More...
 
const std::string & deviceId () const
 Returns the configured ALSA device id. More...
 
void setFormat (WavFormat format)
 Sets the desired audio format. More...
 
const WavFormatformat () const
 Returns the configured audio format. More...
 
void setFramesPerChunk (size_t frames)
 Sets how many frames are transferred per low-level chunk. More...
 
size_t framesPerChunk () const
 Returns frames transferred per low-level chunk. More...
 
void setTargetLatencyUsec (unsigned int usec)
 Sets the requested ALSA device latency in microseconds before opening. More...
 
unsigned int targetLatencyUsec () const
 Returns the requested ALSA device latency in microseconds. More...
 
void setPeriodFrames (size_t frames)
 Sets the requested ALSA hardware period size in frames. Zero uses framesPerChunk(). More...
 
size_t periodFrames () const
 Returns the requested ALSA hardware period size in frames, or zero for automatic. More...
 
void setBufferFrames (size_t frames)
 Sets the requested ALSA hardware buffer size in frames. Zero uses targetLatencyUsec(). More...
 
size_t bufferFrames () const
 Returns the requested ALSA hardware buffer size in frames, or zero for automatic. More...
 
void setMaxBufferedBytes (size_t bytes)
 Sets the maximum queued input bytes retained for reads. More...
 
size_t maxBufferedBytes () const
 Returns the maximum queued input bytes. More...
 
size_t bytesAvailable () const
 Returns queued readable bytes for input devices. More...
 
bool open (RADCore::OpenMode mode) override
 Opens the device for read or write depending on direction. More...
 
void close () override
 Closes the ALSA handle and worker thread. More...
 
bool isOpen () const override
 Returns true when the ALSA device is open. More...
 
ssize_t readData (void *buffer, size_t maxBytes) override
 Reads captured bytes from the input buffer. More...
 
ssize_t writeData (const void *data, size_t size) override
 Writes bytes to the output device. More...
 
ssize_t writeFrames (const void *data, size_t frames)
 Writes complete frames to the output device. More...
 
size_t delayFrames () const
 Returns ALSA's current playback/capture delay in frames, or zero when unavailable. More...
 
void drain ()
 Drains queued playback frames. More...
 
void drop ()
 Drops queued playback/capture frames. More...
 
- Public Member Functions inherited from RADCore::RADIODevice
virtual ~RADIODevice ()=default
 Destroys the IO device. More...
 
std::vector< uint8_t > read (size_t maxBytes)
 Reads up to maxBytes into a byte vector. More...
 
std::vector< uint8_t > readAll (size_t chunkSize=8192)
 Reads all available data in chunks. More...
 
ssize_t write (const std::vector< uint8_t > &data)
 Writes a byte vector. More...
 
ssize_t write (const std::string &text)
 Writes string bytes. More...
 
- Public Member Functions inherited from RADCore::RADObject
 RADObject ()
 Creates a RADObject bound to the current thread. More...
 
virtual ~RADObject ()
 Disconnects tracked event links and releases lifetime token. More...
 
void registerLink (const ConnectionRecord &record)
 Registers a connection for cleanup when this object is destroyed. More...
 
std::thread::id threadId () const
 Returns the thread id this object is currently associated with. More...
 
EventLoopassociatedEventLoop () const
 Returns the associated event loop, if any. More...
 
ThreadAffinity threadAffinity () const
 Returns both thread id and associated loop atomically. More...
 
std::weak_ptr< void > lifetimeToken () const
 Returns a weak token used to drop queued callbacks after destruction. More...
 
void moveToThread (std::thread::id tId, EventLoop *loop=nullptr)
 Moves the object's affinity to tId and optional loop. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from RADMedia::RADAudioDevice
static bool isFormatSupported (const std::string &deviceId, AudioDeviceDirection direction, const WavFormat &format)
 Returns true when ALSA reports deviceId can use format for direction. More...
 
- Public Attributes inherited from RADMedia::RADAudioDevice
RADCore::Event< void() > started
 Raised when the device starts capture or playback. More...
 
RADCore::Event< void() > stopped
 Raised when the device stops. More...
 
RADCore::Event< void() > underrun
 Raised when playback underruns. More...
 
- Public Attributes inherited from RADCore::RADIODevice
RADCore::Event< void() > readyRead
 Raised when data is available to read. More...
 
RADCore::Event< void(size_t) > bytesWritten
 Raised after bytes are written. More...
 
RADCore::Event< void(std::string) > errorOccurred
 Raised when an IO error occurs. More...
 

Detailed Description

Convenience input-only audio device.

Constructor & Destructor Documentation

◆ AudioInputDevice()

RADMedia::AudioInputDevice::AudioInputDevice ( RADCore::EventLoop loop)
explicit

Creates an input audio device using loop for capture events.


The documentation for this class was generated from the following file: