The intention of the Virtual Audio Device is to provide a flexibly-configurable audio device on all Fuchsia systems (even in the absence of audio hardware) for end-to-end testing of the audio subsystem.
The Virtual Audio Device and its drivers are provided by virtual_audio_driver.so and are only included in Fuchsia as part of the “media/tests” component group.
This driver is the legacy version of the virtual-audio driver. It only supports the creation of legacy virtual audio the creation of legacy virtual audio Codec, Dai, and StreamConfig devices. The non-legacy virtual-audio driver supports the creation of virtual audio Composite
When virtual_audio_driver.so is installed (as part of the Audio Development Support assembly input bundle), the VirtualAudioBus driver attaches to the /dev/test device node, automatically adding a device for controlling virtual audio devices. This device node is exposed at /dev/sys/platform/virtual-audio-legacy/virtual-audio-legacy and is backed by a controller driver, implemented by a singleton of the VirtualAudioControlImpl class. Virtual audio devices are created by interacting with this virtual audio controller, via FIDL (more on the FIDL connection and interfafces below).
The controller can be instructed to create a device configuration, and to create a virtual audio device using this configuration. For example, when instructed to add a virtual StreamConfig instance, it creates a VirtualAudioStreamIn or VirtualAudioStreamOut object, which inherits significant functionality from parent class SimpleAudioStream - this parent class is located in Zircon and is used by other audio drivers as well. VirtualAudioStream methods provide very basic support for gain, position notification, and supported formats.
TRACE and DEBUG levels of logging are disabled by default. To enable them, use an ‘fx set’ command
like the following:
fx set x64 --args=dev_bootfs_labels=[\"//src/media/audio/drivers/virtual-audio-legacy:kernel_logging\"]
The driver implements the virtualaudio.Device FIDL interfaces.
The virtualaudio.Control interface is used for top-level activation of virtual audio devices and to fetch the default configuration of each DeviceType (which the client can customize before activating that device instance).
This FIDL interface is used to interact with virtual audio device instances that have been added.
The virtualaudio.Configuration, used when previously adding the device, specifies the following properties:
The virtualaudio.Device interface (another subset of Input and Output) contains methods to make the following dynamic changes:
Once virtual audio input and output devices are created, they can interact with the audio subsystem, including accepting/completing packets and transitioning into/out of playback mode. This functionality is in large part provided by the SimpleAudioStream library.
These features may eventually be added to the virtualaudio driver/service:
Data received by a virtual audio output driver could be sent to:
Data transmitted from a virtual audio input driver could originate from:
Dynamic gain changes (originating externally, e.g. from AVRCP or HID)
Devices with more than 15 supported ranges
Static configuration of the following:
On-the-fly (post-device-creation) configurability of the following:
The validation that AudioCore performs on audio drivers can be validated by a badly-behaved synthetic driver. We should add “bad actor” modes for the virtual driver, to verify our resiliency to common driver errors in which they “fail to honor the driver contract”. These may include failing to provide the notifications promised, etc.
To exercise error handling and other resiliency in audio_core, test clients should be able to specify that a driver emit malformed versions of the following messages (including error result, for those marked with +):
Malformed patterns may include:
audio_cmd_t enum as message.hdr.cmd)AUDIO_INVALID_TRANSACTION_ID as val of message.hdr.transaction_id