libASPL
Loading...
Searching...
No Matches
aspl::Plugin Class Reference

Plugin object. More...

#include <aspl/Plugin.hpp>

Inheritance diagram for aspl::Plugin:
aspl::Object

Public Member Functions

 Plugin (std::shared_ptr< const Context > context, const PluginParameters &params={})
 Construct plugin.
 
Getters and setters
virtual std::string GetManufacturer () const
 Get plugin manufacturer. Human readable name of the maker of the plug-in. Can be localized. By default returns PluginParameters::Manufacturer.
 
virtual std::string GetResourceBundlePath () const
 Get resource bundle path. By default returns PluginParameters::ResourceBundlePath.
 
virtual std::vector< AudioObjectID > GetDeviceIDs () const
 Get devices. Returns the list of owned devices. Default implementation returns all owned objects of kAudioDeviceClassID class.
 
virtual AudioObjectID GetDeviceIDByUID (const std::string &uid) const
 Get device with given UID. Returns nullptr if there is no such device.
 
Devices
UInt32 GetDeviceCount () const
 Get number of devices added.
 
std::shared_ptr< DeviceGetDeviceByIndex (UInt32 idx) const
 Get device with given zero-based index. Returns nullptr if there are less than idx+1 devices.
 
std::shared_ptr< DeviceGetDeviceByID (AudioObjectID deviceID) const
 Get device with given object ID. Returns nullptr if there is no such device.
 
bool HasDevice (std::shared_ptr< Device > device) const
 Check if device is already added.
 
void AddDevice (std::shared_ptr< Device > device)
 Add device to the plugin. Adds device to the owned object list.
 
void RemoveDevice (std::shared_ptr< Device > device)
 Remove device from the plugin. Removes device from the owned object list.
 
Property dispatch
AudioClassID GetClass () const override
 Get class ID.
 
AudioClassID GetBaseClass () const override
 Get base class ID.
 
bool IsInstance (AudioClassID classID) const override
 Check if this object is instance of given base class.
 
Boolean HasProperty (AudioObjectID objectID, pid_t clientPID, const AudioObjectPropertyAddress *address) const override
 Check whether given property is present.
 
OSStatus IsPropertySettable (AudioObjectID objectID, pid_t clientPID, const AudioObjectPropertyAddress *address, Boolean *outIsSettable) const override
 Check whether given property can be changed.
 
OSStatus GetPropertyDataSize (AudioObjectID objectID, pid_t clientPID, const AudioObjectPropertyAddress *address, UInt32 qualifierDataSize, const void *qualifierData, UInt32 *outDataSize) const override
 Get size of property value in bytes.
 
OSStatus GetPropertyData (AudioObjectID objectID, pid_t clientPID, const AudioObjectPropertyAddress *address, UInt32 qualifierDataSize, const void *qualifierData, UInt32 inDataSize, UInt32 *outDataSize, void *outData) const override
 Get property value.
 
OSStatus SetPropertyData (AudioObjectID objectID, pid_t clientPID, const AudioObjectPropertyAddress *address, UInt32 qualifierDataSize, const void *qualifierData, UInt32 inDataSize, const void *inData) override
 Change property value.
 
- Public Member Functions inherited from aspl::Object
 Object (std::shared_ptr< const Context > context, const char *className="Object", AudioObjectID objectID=kAudioObjectUnknown)
 Construct object. Class name is used for logging. It should be the name of the derived class. If objectID is kAudioObjectUnknown (zero), allocates new object ID. Otherwise uses given object ID.
 
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
std::shared_ptr< const ContextGetContext () const
 Get object context.
 
AudioObjectID GetID () const
 Get object ID. Returns objectID selected at construction time.
 
AudioObjectID GetOwnerID () const
 Get object owner. If the object has an owner, returns its ID. Otherwise, returns kAudioObjectUnknown (zero).
 
bool HasOwner () const
 Check if the object is part of the hierarchy. Returns true if GetOwnerID() is not equal to kAudioObjectUnknown.
 
std::vector< AudioObjectID > GetOwnedObjectIDs (AudioObjectPropertyScope scope=kAudioObjectPropertyScopeGlobal, AudioClassID classID=0) const
 Get owned objects. Returns the list of objects to which this object is the owner.
 
void AddOwnedObject (std::shared_ptr< Object > object, AudioObjectPropertyScope scope=kAudioObjectPropertyScopeGlobal)
 Add object to the list of owned objects. Also invokes SetOwner() on the added object.
 
void RemoveOwnedObject (AudioObjectID objectID)
 Remove object to the list of owned objects. Also invokes SetOwner() on the removed object.
 
void NotifyPropertyChanged (AudioObjectPropertySelector selector, AudioObjectPropertyScope scope=kAudioObjectPropertyScopeGlobal, AudioObjectPropertyElement element=kAudioObjectPropertyElementMain) const
 Notify HAL that a property was changed. This is automatically called by all setters.
 
void NotifyPropertiesChanged (std::vector< AudioObjectPropertySelector > selectors, AudioObjectPropertyScope scope=kAudioObjectPropertyScopeGlobal, AudioObjectPropertyElement element=kAudioObjectPropertyElementMain) const
 Notify HAL that some properties were changed. This is automatically called by all setters.
 
virtual std::vector< AudioServerPlugInCustomPropertyInfo > GetCustomProperties () const
 Get info about registered custom properties. Returns list of properties added using RegisterCustomProperty().
 
template<typename ObjectType , typename ValueType >
void RegisterCustomProperty (AudioObjectPropertySelector selector, ObjectType &object, GetterMethod< ObjectType, ValueType > getter, SetterMethod< ObjectType, ValueType > setter=nullptr)
 Register custom property with getter and optional setter.
 
template<typename GetterFunc >
void RegisterCustomProperty (AudioObjectPropertySelector selector, GetterFunc getter)
 Register custom property with getter and optional setter.
 
void RegisterCustomProperty (AudioObjectPropertySelector selector, std::function< CFStringRef()> getter, std::function< void(CFStringRef)> setter)
 Register custom property with getter and optional setter.
 
void RegisterCustomProperty (AudioObjectPropertySelector selector, std::function< CFPropertyListRef()> getter, std::function< void(CFPropertyListRef)> setter)
 Register custom property with getter and optional setter.
 

Additional Inherited Members

- Public Types inherited from aspl::Object
template<typename ObjectType , typename ValueType >
using GetterMethod = ValueType (ObjectType::*)() const
 Pointer to custom property getter method. Used in RegisterCustomProperty().
 
template<typename ObjectType , typename ValueType >
using SetterMethod = void (ObjectType::*)(ValueType)
 Pointer to custom property setter method. Used in RegisterCustomProperty().
 

Detailed Description

Plugin object.

Plugin is the root of the Object tree. All other objects are owned by it, either directly or indirectly.

Plugin, unlike other objects, has the constant well-known identifier (kAudioObjectPlugInObject). HAL uses it to recursively discover all other objects in the hierarchy.

Typically, plugin owns one or more devices, and each device owns one or more streams and zero or multiple controls. Plugin itself is owned by Driver, but the latter is not an Object, but rather something like an entry point to the object tree.

Definition at line 48 of file Plugin.hpp.

Constructor & Destructor Documentation

◆ Plugin()

aspl::Plugin::Plugin ( std::shared_ptr< const Context > context,
const PluginParameters & params = {} )
explicit

Construct plugin.

Member Function Documentation

◆ AddDevice()

void aspl::Plugin::AddDevice ( std::shared_ptr< Device > device)

Add device to the plugin. Adds device to the owned object list.

◆ GetBaseClass()

AudioClassID aspl::Plugin::GetBaseClass ( ) const
overridevirtual

Get base class ID.

Reimplemented from aspl::Object.

◆ GetClass()

AudioClassID aspl::Plugin::GetClass ( ) const
overridevirtual

Get class ID.

Reimplemented from aspl::Object.

◆ GetDeviceByID()

std::shared_ptr< Device > aspl::Plugin::GetDeviceByID ( AudioObjectID deviceID) const

Get device with given object ID. Returns nullptr if there is no such device.

◆ GetDeviceByIndex()

std::shared_ptr< Device > aspl::Plugin::GetDeviceByIndex ( UInt32 idx) const

Get device with given zero-based index. Returns nullptr if there are less than idx+1 devices.

◆ GetDeviceCount()

UInt32 aspl::Plugin::GetDeviceCount ( ) const

Get number of devices added.

◆ GetDeviceIDByUID()

virtual AudioObjectID aspl::Plugin::GetDeviceIDByUID ( const std::string & uid) const
virtual

Get device with given UID. Returns nullptr if there is no such device.

Note
Backs kAudioPlugInPropertyTranslateUIDToDevice property.

◆ GetDeviceIDs()

virtual std::vector< AudioObjectID > aspl::Plugin::GetDeviceIDs ( ) const
virtual

Get devices. Returns the list of owned devices. Default implementation returns all owned objects of kAudioDeviceClassID class.

Note
Backs kAudioPlugInPropertyDeviceList property.

◆ GetManufacturer()

virtual std::string aspl::Plugin::GetManufacturer ( ) const
virtual

Get plugin manufacturer. Human readable name of the maker of the plug-in. Can be localized. By default returns PluginParameters::Manufacturer.

Note
Backs kAudioObjectPropertyManufacturer property.

◆ GetPropertyData()

OSStatus aspl::Plugin::GetPropertyData ( AudioObjectID objectID,
pid_t clientPID,
const AudioObjectPropertyAddress * address,
UInt32 qualifierDataSize,
const void * qualifierData,
UInt32 inDataSize,
UInt32 * outDataSize,
void * outData ) const
overridevirtual

Get property value.

Reimplemented from aspl::Object.

◆ GetPropertyDataSize()

OSStatus aspl::Plugin::GetPropertyDataSize ( AudioObjectID objectID,
pid_t clientPID,
const AudioObjectPropertyAddress * address,
UInt32 qualifierDataSize,
const void * qualifierData,
UInt32 * outDataSize ) const
overridevirtual

Get size of property value in bytes.

Reimplemented from aspl::Object.

◆ GetResourceBundlePath()

virtual std::string aspl::Plugin::GetResourceBundlePath ( ) const
virtual

Get resource bundle path. By default returns PluginParameters::ResourceBundlePath.

Remarks
Relative to the path of the plug-in bundle. Empty string means use plug-in bundle itself.
Note
Backs kAudioPlugInPropertyResourceBundle property.

◆ HasDevice()

bool aspl::Plugin::HasDevice ( std::shared_ptr< Device > device) const

Check if device is already added.

◆ HasProperty()

Boolean aspl::Plugin::HasProperty ( AudioObjectID objectID,
pid_t clientPID,
const AudioObjectPropertyAddress * address ) const
overridevirtual

Check whether given property is present.

Reimplemented from aspl::Object.

◆ IsInstance()

bool aspl::Plugin::IsInstance ( AudioClassID classID) const
overridevirtual

Check if this object is instance of given base class.

Reimplemented from aspl::Object.

◆ IsPropertySettable()

OSStatus aspl::Plugin::IsPropertySettable ( AudioObjectID objectID,
pid_t clientPID,
const AudioObjectPropertyAddress * address,
Boolean * outIsSettable ) const
overridevirtual

Check whether given property can be changed.

Reimplemented from aspl::Object.

◆ RemoveDevice()

void aspl::Plugin::RemoveDevice ( std::shared_ptr< Device > device)

Remove device from the plugin. Removes device from the owned object list.

◆ SetPropertyData()

OSStatus aspl::Plugin::SetPropertyData ( AudioObjectID objectID,
pid_t clientPID,
const AudioObjectPropertyAddress * address,
UInt32 qualifierDataSize,
const void * qualifierData,
UInt32 inDataSize,
const void * inData )
overridevirtual

Change property value.

Reimplemented from aspl::Object.


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