![]() |
HulaLoop
Simple cross-platform audio loopback and recording.
|
Abstract class that defines the required components for OS specfic audio classes. More...
#include <OSAudio.h>


Public Member Functions | |
| virtual | ~OSAudio ()=0 |
| Virtual implementation of Destructor. | |
| void | setBufferSize (uint32_t size) |
| Set the desired capture buffer size. More... | |
| void | addBuffer (HulaRingBuffer *rb) |
| Add an initialized buffer to the list of buffers that receive audio data. More... | |
| void | removeBuffer (HulaRingBuffer *rb) |
| Remove a buffer from the list of buffers that receive audio data. More... | |
| void | copyToBuffers (const void *data, uint32_t bytes) |
| Write to each of the buffers contained in rbs. | |
| virtual std::vector< Device * > | getDevices (DeviceType type)=0 |
| Receive the list of available record, playback and/or loopback audio devices connected to the OS and return them as Device instances. More... | |
| virtual void | capture ()=0 |
| Execution loop for loopback capture. | |
| virtual bool | checkDeviceParams (Device *device)=0 |
| Verify the bit rate of set rate with the hardware device compatibility. | |
| virtual bool | setActiveInputDevice (Device *device) |
| Set the selected input device and restart capture threads with new device. More... | |
| virtual bool | setActiveOutputDevice (Device *device) |
| Set the selected output device and restart capture threads with new device. More... | |
Static Public Member Functions | |
| static void | backgroundCapture (OSAudio *_this) |
| Static function to allow starting a thread with an instance's capture method. More... | |
Protected Member Functions | |
| OSAudio () | |
| Constructor is protected since this class is abstract. | |
Protected Attributes | |
| Device * | activeInputDevice |
| The selected input device. | |
| Device * | activeOutputDevice |
| The selected output device. | |
| std::vector< HulaRingBuffer * > | rbs |
| List of all added ring buffers. More... | |
| std::vector< std::thread > | inThreads |
| Thread for input device activities. | |
| std::vector< std::thread > | outThreads |
| Thread for output device activities. | |
| std::atomic< bool > | endCapture |
| Flag to syncronize the capture thread for an instance. More... | |
| uint32_t | captureBufferSize |
| I don't really know what this is for right now but I'm going to add this comment so that Doxygen will quit complaining. More... | |
Abstract class that defines the required components for OS specfic audio classes.
| void OSAudio::addBuffer | ( | HulaRingBuffer * | rb | ) |
Add an initialized buffer to the list of buffers that receive audio data.
If already present, the ring buffer will not be duplicated.
| rb | HulaLoop ring buffer to add to the list. |
|
static |
Static function to allow starting a thread with an instance's capture method.
This will block, so it should be called in a new thread.
Calling this directly outside of this class is dangerous. Any thread not in the inThreads vector cannot be guarenteed a valid endCapture signal since it won't be joined after a device switch or 0 buffer state. Sync flags might be reset before the independent thread sees them.
| _this | Instance of OSAudio subclass which capture should be called on. |
|
pure virtual |
Receive the list of available record, playback and/or loopback audio devices connected to the OS and return them as Device instances.
| type | DeviceType that is combination from the DeviceType enum |
Implemented in hula::WindowsAudio, hula::LinuxAudio, and hula::OSXAudio.
| void OSAudio::removeBuffer | ( | HulaRingBuffer * | rb | ) |
Remove a buffer from the list of buffers that receive audio data.
The removed buffer is not deleted and must be deleted by the user.
This enables pausing retrieval when audio is not needed and re-adding the same buffer when audio data is again needed.
| rb | HulaLoop ring buffer to remove from the list. |
|
virtual |
Set the selected input device and restart capture threads with new device.
| device | Instance of Device that corresponds to the desired system device |
Reimplemented in hula::LinuxAudio.
|
virtual |
Set the selected output device and restart capture threads with new device.
| device | Instance of Device that corresponds to the desired system device |
| void OSAudio::setBufferSize | ( | uint32_t | size | ) |
Set the desired capture buffer size.
| size | Integer value representing the desired buffer size |
|
protected |
I don't really know what this is for right now but I'm going to add this comment so that Doxygen will quit complaining.
Peace. Love. Happiness. Doxygen :)
|
protected |
Flag to syncronize the capture thread for an instance.
This is used to break the capture loop when switching devices or when 0 buffers are present.
Should never be set directly. Only by setActiveXXXDevice().
|
protected |
List of all added ring buffers.
Data received from the operating system is copied into each of these buffers.
1.8.13