class Device
Defined at line 40 of file ../../src/media/audio/services/device_registry/device.h
This class represents a driver and audio device, once it is detected.
Public Methods
bool has_error ()
Simple accessors
This is the const subset available to device observers.
Defined at line 206 of file ../../src/media/audio/services/device_registry/device.h
bool is_operational ()
Defined at line 207 of file ../../src/media/audio/services/device_registry/device.h
fuchsia_audio_device::DeviceType device_type ()
Defined at line 208 of file ../../src/media/audio/services/device_registry/device.h
bool is_codec ()
Defined at line 209 of file ../../src/media/audio/services/device_registry/device.h
bool is_composite ()
Defined at line 210 of file ../../src/media/audio/services/device_registry/device.h
TokenId token_id ()
Assigned by this service, guaranteed unique for this boot session, but not across reboots.
Defined at line 215 of file ../../src/media/audio/services/device_registry/device.h
const std::optional<fuchsia_audio_device::Info> & info ()
`info` is only populated once the device is initialized.
Defined at line 217 of file ../../src/media/audio/services/device_registry/device.h
const std::vector<fuchsia_audio_device::ElementDaiFormatSet> & dai_format_sets ()
Defined at line 220 of file ../../src/media/audio/services/device_registry/device.h
const std::vector<fuchsia_audio_device::ElementRingBufferFormatSet> & ring_buffer_format_sets ()
Defined at line 223 of file ../../src/media/audio/services/device_registry/device.h
const std::vector<fuchsia_audio_device::ElementPacketStreamFormatSet> & packet_stream_format_sets ()
Defined at line 228 of file ../../src/media/audio/services/device_registry/device.h
fuchsia_audio::Format ring_buffer_format (ElementId element_id)
TODO(https://fxbug.dev/42069015): Consider using media_audio::Format internally.
Defined at line 234 of file ../../src/media/audio/services/device_registry/device.h
std::optional<int16_t> valid_bits_per_sample (ElementId element_id)
Defined at line 241 of file ../../src/media/audio/services/device_registry/device.h
std::optional<bool> supports_set_active_channels (ElementId element_id)
Defined at line 249 of file ../../src/media/audio/services/device_registry/device.h
bool dai_format_is_set ()
Defined at line 255 of file ../../src/media/audio/services/device_registry/device.h
const fuchsia_hardware_audio::CodecFormatInfo & codec_format_info (ElementId element_id)
Defined at line 256 of file ../../src/media/audio/services/device_registry/device.h
bool codec_is_started ()
Defined at line 259 of file ../../src/media/audio/services/device_registry/device.h
bool has_codec_properties ()
Defined at line 261 of file ../../src/media/audio/services/device_registry/device.h
bool has_composite_properties ()
Defined at line 262 of file ../../src/media/audio/services/device_registry/device.h
bool has_health_state ()
Defined at line 263 of file ../../src/media/audio/services/device_registry/device.h
bool dai_format_sets_retrieved ()
Defined at line 264 of file ../../src/media/audio/services/device_registry/device.h
bool ring_buffer_format_sets_retrieved ()
Defined at line 265 of file ../../src/media/audio/services/device_registry/device.h
bool packet_stream_format_sets_retrieved ()
Defined at line 266 of file ../../src/media/audio/services/device_registry/device.h
const std::unordered_set<ElementId> & dai_ids ()
Defined at line 267 of file ../../src/media/audio/services/device_registry/device.h
const std::unordered_set<ElementId> & ring_buffer_ids ()
Defined at line 268 of file ../../src/media/audio/services/device_registry/device.h
const std::unordered_set<ElementId> & packet_stream_ids ()
Defined at line 269 of file ../../src/media/audio/services/device_registry/device.h
const std::unordered_set<TopologyId> & topology_ids ()
Defined at line 270 of file ../../src/media/audio/services/device_registry/device.h
const std::unordered_set<ElementId> & element_ids ()
Defined at line 271 of file ../../src/media/audio/services/device_registry/device.h
bool has_plug_state ()
Defined at line 273 of file ../../src/media/audio/services/device_registry/device.h
bool checked_for_signalprocessing ()
Defined at line 274 of file ../../src/media/audio/services/device_registry/device.h
bool supports_signalprocessing ()
Defined at line 275 of file ../../src/media/audio/services/device_registry/device.h
std::shared_ptr<DeviceInspectInstance> inspect ()
Defined at line 278 of file ../../src/media/audio/services/device_registry/device.h
uint64_t count ()
Static object counts, for debugging purposes.
Defined at line 281 of file ../../src/media/audio/services/device_registry/device.h
uint64_t initialized_count ()
Defined at line 282 of file ../../src/media/audio/services/device_registry/device.h
uint64_t unhealthy_count ()
Defined at line 283 of file ../../src/media/audio/services/device_registry/device.h
std::shared_ptr<Device> Create (std::weak_ptr<DevicePresenceWatcher>presence_watcher,async_dispatcher_t *dispatcher,std::string_viewname,fuchsia_audio_device::DeviceTypedevice_type,fuchsia_audio_device::DriverClientdriver_client,const std::string &added_by)
static
Defined at line 285 of file ../../src/media/audio/services/device_registry/device.cc
void ~Device ()
Defined at line 348 of file ../../src/media/audio/services/device_registry/device.cc
void Initialize ()
Defined at line 831 of file ../../src/media/audio/services/device_registry/device.cc
bool AddObserver (const std::shared_ptr<ObserverNotify> & observer_to_add)
Defined at line 580 of file ../../src/media/audio/services/device_registry/device.cc
bool SetControl (std::shared_ptr<ControlNotify> control_notify)
Returns true if the specified entity successfully asserts control of this device.
Defined at line 518 of file ../../src/media/audio/services/device_registry/device.cc
void DropRingBuffer (ElementId element_id)
Whether client- or device-originated, reset any state associated with an active RingBuffer.
Defined at line 660 of file ../../src/media/audio/services/device_registry/device.cc
void DropPacketStream (ElementId element_id)
Defined at line 726 of file ../../src/media/audio/services/device_registry/device.cc
std::optional<fuchsia_hardware_audio::Format2> SupportedRingBufferDriverFormatForClientFormat (ElementId element_id, const fuchsia_audio::Format & client_format)
Determine the full fuchsia_hardware_audio::Format needed for ConnectRingBufferFidl.
This method expects that the required fields are present.
Defined at line 1937 of file ../../src/media/audio/services/device_registry/device.cc
std::optional<fuchsia_hardware_audio::Format2> SupportedPacketStreamDriverFormatForClientFormat (ElementId element_id, const fuchsia_audio_device::PacketStreamFormat & client_format)
Determine the full fuchsia_hardware_audio::Format needed for ConnectPacketStreamFidl.
This method expects that the required fields are present.
Defined at line 1986 of file ../../src/media/audio/services/device_registry/device.cc
std::optional<fuchsia_hardware_audio::PcmFormat> MatchPcmFormatSet (const std::vector<fuchsia_hardware_audio::SupportedFormats2> & supported_formats, const fuchsia_hardware_audio::PcmFormat & format_template)
Matches a client's PCM format requirements against a driver's supported PCM formats.
Returns the best matching PcmFormat (with optimal valid_bits_per_sample) if found.
Defined at line 2042 of file ../../src/media/audio/services/device_registry/device.cc
std::optional<fuchsia_hardware_audio::Encoding> MatchEncodingSet (const std::vector<fuchsia_hardware_audio::SupportedFormats2> & supported_formats, const fuchsia_hardware_audio::Encoding & client_encoding)
Checks if a driver's supported encodings match a client's requested encoding.
Returns the matched Encoding if found.
Defined at line 2083 of file ../../src/media/audio/services/device_registry/device.cc
void SetDaiFormat (ElementId element_id, const fuchsia_hardware_audio::DaiFormat & dai_formats)
This method guarantees that ControlNotify's DaiFormatIsChanged or DaiFormatIsNotChanged will
eventually be called, either immediately or asynchronously when driver SetDaiFormat concludes.
Defined at line 2159 of file ../../src/media/audio/services/device_registry/device.cc
bool Reset ()
If true is returned, then we guarantee to call ControlNotify::DeviceIsReset (and CodecIsStopped
if the Start/Stop state is changed, and DaiFormatIsChanged if the DaiFormat is changed).
If false is returned, then no change occurs and these notifications will not be called.
Defined at line 2340 of file ../../src/media/audio/services/device_registry/device.cc
bool CodecStart ()
If true is returned, then we guarantee to call CodecIsStarted/CodecIsNotStarted on ControlNotify.
If false is returned, then this notification will not be called.
Defined at line 2446 of file ../../src/media/audio/services/device_registry/device.cc
bool CodecStop ()
If true is returned, then we guarantee to call CodecIsStopped or CodecIsNotStopped on
ControlNotify. If false is returned, then this notification will not be called.
Defined at line 2501 of file ../../src/media/audio/services/device_registry/device.cc
zx_status_t SetTopology (TopologyId topology_id)
If the method does not return ZX_OK, then the driver was not called.
Defined at line 1483 of file ../../src/media/audio/services/device_registry/device.cc
zx_status_t SetElementState (ElementId element_id, const fuchsia_hardware_audio_signalprocessing::SettableElementState & element_state)
If the method does not return ZX_OK, then the driver was not called.
Defined at line 1379 of file ../../src/media/audio/services/device_registry/device.cc
bool CreateRingBuffer (ElementIdelement_id,const fuchsia_hardware_audio::Format2 &format,uint32_trequested_ring_buffer_bytes,fit::callback<void (fit::result<fuchsia_audio_device::ControlCreateRingBufferError, Device::RingBufferInfo>)>create_ring_buffer_callback)
Expects the caller to have already checked if the RingBuffer has already been created,
or if a Create request is already pending, and to have validated the format arguments.
This method guarantees to call create_ring_buffer_callback (immediately or asynchronously).
For certain unrecoverable errors, OnError is called as well.
Defined at line 2558 of file ../../src/media/audio/services/device_registry/device.cc
bool CreatePacketStream (ElementIdelement_id,const fuchsia_hardware_audio::Format2 &format,fit::callback<void (fit::result<fuchsia_audio_device::ControlCreatePacketStreamError, Device::PacketStreamInfo>)>create_packet_stream_callback)
Expects the caller to have already checked if the PacketStream has already been created,
or if a Create request is already pending, and to have validated the format arguments.
This method guarantees to call create_packet_stream_callback (immediately or asynchronously).
For certain unrecoverable errors, OnError is called as well.
Defined at line 2646 of file ../../src/media/audio/services/device_registry/device.cc
bool SetActiveChannels (ElementIdelement_id,uint64_tchannel_bitmask,fit::callback<void (zx::result<zx::time>)>set_active_channels_callback)
Change the channels that are currently active (powered-up).
Defined at line 3280 of file ../../src/media/audio/services/device_registry/device.cc
void StartRingBuffer (ElementId element_id, fit::callback<void (zx::result<zx::time>)> start_callback)
Expects the caller to have already created the RingBuffer, and checked if it has already
started or if a Start request is already pending.
Defined at line 3379 of file ../../src/media/audio/services/device_registry/device.cc
void StopRingBuffer (ElementId element_id, fit::callback<void (zx_status_t)> stop_callback)
Expects the caller to have already created the RingBuffer, and checked if it is already
stopped or if a Stop request is already pending.
Defined at line 3435 of file ../../src/media/audio/services/device_registry/device.cc
void StartPacketStream (ElementId element_id, fit::callback<void (zx::result<>)> start_callback)
Expects the caller to have already created the PacketStream, and checked if it has already
started or if a Start request is already pending.
Defined at line 3491 of file ../../src/media/audio/services/device_registry/device.cc
void StopPacketStream (ElementId element_id, fit::callback<void (zx_status_t)> stop_callback)
Expects the caller to have already created the PacketStream, and checked if it is already
stopped or if a Stop request is already pending.
Defined at line 3572 of file ../../src/media/audio/services/device_registry/device.cc
void SetPacketStreamBuffers (ElementIdelement_id,fuchsia_audio_device::PacketStreamSetupVmoInfosetup_vmo_info,fit::callback<void (fit::result<fuchsia_audio_device::PacketStreamSetBufferError, fuchsia_audio_device::PacketStreamBuffers>)>set_buffers_callback)
Expects the caller to have already created the PacketStream, checked if it is already
configured (or started), and validated the input `setup_vmo_info` arguments.
Defined at line 3643 of file ../../src/media/audio/services/device_registry/device.cc
zx::result<zx::clock> GetReadOnlyClock ()
Create a duplicate handle to our clock with limited rights. We can transfer it to a client who
can only read and duplicate. Specifically, they cannot change this clock's rate or offset.
Defined at line 1919 of file ../../src/media/audio/services/device_registry/device.cc
void SetSignalProcessingSupported (bool is_supported)
Called during initialization, when we know definitively whether the driver supports the protocol.
It might also be called later, if there is an error related to the signalprocessing protocol.
If this is the first time this is called, then call `OnInitializationResponse` to unblock the
signalprocessing-related aspect of the "wait for multiple responses" state machine.
Defined at line 358 of file ../../src/media/audio/services/device_registry/device.cc
Records
Friends
std::ostream & Device (std::ostream & out, PacketStreamState packet_stream_state)
std::ostream & Device (std::ostream & out, RingBufferState ring_buffer_state)
std::ostream & Device (std::ostream & out, State device_state)
class AudioDeviceRegistryServerTestBase
class CompositeTest
class CodecTest
class DeviceTest
class DeviceTestBase