class AudioDevice

Defined at line 37 of file ../../src/media/audio/audio_core/audio_device.h

Public Methods

void ~AudioDevice ()

Defined at line 39 of file ../../src/media/audio/audio_core/audio_device.h

const std::string & name ()

Defined at line 41 of file ../../src/media/audio/audio_core/audio_device.h

void Wakeup ()

Wakeup

Called from outside the mixing ExecutionDomain to cause an AudioDevice's::OnWakeup handler to

run from within the context of the mixing execution domain.

Defined at line 76 of file ../../src/media/audio/audio_core/audio_device.cc

std::optional<Format> format ()

|media::audio::AudioObject|

Defined at line 68 of file ../../src/media/audio/audio_core/audio_device.cc

uint64_t token ()

Defined at line 81 of file ../../src/media/audio/audio_core/audio_device.cc

const DeviceConfig::DeviceProfile & profile ()

Defined at line 33 of file ../../src/media/audio/audio_core/audio_device.cc

void SetGainInfo (const fuchsia::media::AudioGainInfo & info, fuchsia::media::AudioGainValidFlags set_flags)

Accessor set gain. Limits the gain command to what the hardware allows, and

wakes up the device in the event of a meaningful change in gain settings.

Only called by AudioDeviceManager, and only after the device is activated.

Defined at line 86 of file ../../src/media/audio/audio_core/audio_device.cc

void SetSoftwareGainInfo (const fuchsia::media::AudioGainInfo & info)

Like set gain, but updates SW gain only.

Defined at line 102 of file ../../src/media/audio/audio_core/audio_device.cc

fuchsia::media::AudioDeviceInfo GetDeviceInfo ()

Device info used during device enumeration and add-notifications.

Defined at line 292 of file ../../src/media/audio/audio_core/audio_device.cc

fpromise::promise<void, zx_status_t> Startup ()

Gives derived classes a chance to set up hardware, then sets up the machinery needed for

scheduling processing tasks and schedules the first processing callback immediately in order

to get the process running.

Defined at line 212 of file ../../src/media/audio/audio_core/audio_device.cc

fpromise::promise<void> Shutdown ()

Makes certain that the shutdown process has started, synchronizes with processing tasks which

were executing at the time, then finishes the shutdown by unlinking from all renderers and

capturers and cleaning up all resources.

Defined at line 230 of file ../../src/media/audio/audio_core/audio_device.cc

std::shared_ptr<Clock> reference_clock ()

Simple accessor here (not in .h) because of forward-declaration issues with AudioDriver

Defined at line 28 of file ../../src/media/audio/audio_core/audio_device.cc

bool plugged ()

Accessors for the current plug state of the device.

In addition to publishing and unpublishing streams when codecs are attached to or removed from

hot-pluggable buses (such as USB), some codecs have the ability to detect the plugged/unplugged

state of external connectors (such as a 3.5mm audio jack). Drivers can report this state as

well as the time of the last state change. Currently this information is used in the Audio

Service to implement simple routing policies for AudioRenderers and AudioCapturers.

plugged : true when an audio output/input stream is either hardwired, or

believes that it has something connected to its plug.

plug_time : The time (per zx::clock::get_monotonic() at which the plugged/unplugged state of

this output or input last changed.

routable : False when a device's OutputPipeline is being updated in AudioDeviceManager. This

protects a device from being plugged or unplugged while undergoing the

PipelineConfig update, as well as ensures only one PipelineConfig update is applied

at a time.

Defined at line 68 of file ../../src/media/audio/audio_core/audio_device.h

zx::time plug_time ()

Defined at line 69 of file ../../src/media/audio/audio_core/audio_device.h

bool routable ()

Defined at line 70 of file ../../src/media/audio/audio_core/audio_device.h

AudioDriver * driver ()

Defined at line 71 of file ../../src/media/audio/audio_core/audio_device.h

bool activated ()

Defined at line 73 of file ../../src/media/audio/audio_core/audio_device.h

const DeviceConfig & config ()

Defined at line 76 of file ../../src/media/audio/audio_core/audio_device.h

void set_config (const DeviceConfig & config)

`set_config()` strictly updates the |config_| variable returned from `config()`; it does not

rebuild the OutputPipeline. To restart the OutputPipeline with an updated configuration, see

`UpdateDeviceProfile()`.

Defined at line 82 of file ../../src/media/audio/audio_core/audio_device.h

zx::duration presentation_delay ()

Presentation delay for this device.

Defined at line 87 of file ../../src/media/audio/audio_core/audio_device.h

fpromise::promise<void, fuchsia::media::audio::UpdateEffectError> UpdateEffect (const std::string & instance_name, const std::string & config)

Sets the configuration of all effects with the given instance name.

Defined at line 90 of file ../../src/media/audio/audio_core/audio_device.h

fpromise::promise<void, zx_status_t> UpdateDeviceProfile (const DeviceConfig::OutputDeviceProfile::Parameters & params)

AudioObjects with Type::Output must override this; this version should never be called.

UpdateDeviceProfile differs from `set_config()` in two ways:

1. It explicitly updates the OutputPipeline with a new OutputDeviceProfile configuration,

restarting the new OutputPipeline with the updated configuration.

2. It provides a convenient way to update the configuration outside of the mixer thread.

Defined at line 101 of file ../../src/media/audio/audio_core/audio_device.h

zx_status_t EnableAudible ()

Device-level power management

Enable/disable this device in the audible or ultrasonic range. Used for power conservation.

Because there is no significant power savings in disabling input devices, these methods return

ZX_ERR_WRONG_TYPE if device is Input or Throttle output. DriverOutput overrides these methods.

Defined at line 140 of file ../../src/media/audio/audio_core/audio_device.h

zx_status_t EnableUltrasonic ()

Defined at line 141 of file ../../src/media/audio/audio_core/audio_device.h

zx_status_t StartCountdownToDisableAudible (zx::duration dur)

Defined at line 142 of file ../../src/media/audio/audio_core/audio_device.h

zx_status_t StartCountdownToDisableUltrasonic (zx::duration dur)

Defined at line 143 of file ../../src/media/audio/audio_core/audio_device.h

Protected Methods

void AudioDevice (Type type, std::string name, DeviceConfig config, ThreadingModel * threading_model, DeviceRegistry * registry, LinkMatrix * link_matrix, std::shared_ptr<AudioCoreClockFactory> clock_factory, std::unique_ptr<AudioDriver> driver)

Defined at line 48 of file ../../src/media/audio/audio_core/audio_device.cc

zx_status_t Init ()

Init

Called during startup on the mixer thread. Derived classes should begin the

process of driver initialization at this point. Return ZX_OK if things have

started and we are waiting for driver init.

Defined at line 143 of file ../../src/media/audio/audio_core/audio_device.cc

void Cleanup ()

Cleanup

Called at shutdown on the mixer thread to allow derived classes to clean

up any allocated resources. All other audio objects have been

disconnected/unlinked. No locks are being held.

Defined at line 164 of file ../../src/media/audio/audio_core/audio_device.cc

void ApplyGainLimits (fuchsia::media::AudioGainInfo * in_out_info, fuchsia::media::AudioGainValidFlags set_flags)

ApplyGainLimits

Modify the contents of a user request to change the gain state to reflect

the actual gain that we are going to end up setting. This may differ from

the requested gain due to hardware limitations or general policy.

void OnWakeup ()

OnWakeup

Called in response to someone from outside the domain poking the

mix_wakeup_ WakeupEvent. At a minimum, the framework will call this once

at startup to get the output running.

void ActivateSelf ()

ActivateSelf

Send a message to the audio device manager to let it know that we are ready

to be added to the set of active devices.

Defined at line 175 of file ../../src/media/audio/audio_core/audio_device.cc

void ShutdownSelf ()

ShutdownSelf

Kick off the process of shutting ourselves down. Note: after this method is

called, no new callbacks may be scheduled. When the main message loop gets

our shutdown request, it completes the process by unlinking us from our

AudioRenderers/AudioCapturers and calling our Cleanup.

Defined at line 200 of file ../../src/media/audio/audio_core/audio_device.cc

bool is_shutting_down ()

Check the shutting down flag. We are in the process of shutting down when

we have become deactivated at the dispatcher framework level.

Defined at line 212 of file ../../src/media/audio/audio_core/audio_device.h

void OnDriverInfoFetched ()

///////////////////////////////////////////////////////////////////////////

AudioDriver hooks.

Hooks used by encapsulated AudioDriver instances to notify AudioDevices

about internal state machine changes.

Defined at line 220 of file ../../src/media/audio/audio_core/audio_device.h

void OnDriverConfigComplete ()

Defined at line 222 of file ../../src/media/audio/audio_core/audio_device.h

void OnDriverStartComplete ()

Defined at line 224 of file ../../src/media/audio/audio_core/audio_device.h

void OnDriverStopComplete ()

Defined at line 226 of file ../../src/media/audio/audio_core/audio_device.h

void OnDriverPlugStateChange (bool plugged, zx::time plug_time)

Defined at line 228 of file ../../src/media/audio/audio_core/audio_device.h

bool UpdatePlugState (bool plugged, zx::time plug_time)

UpdatePlugState

Called by the audio device manager on the main message loop when it is

notified of a plug state change for a device. Used to update the internal

bookkeeping about the current plugged/unplugged state. This method may also

be used by derived classes during Init to set an initial plug state.

Returns true if the plug state has changed, or false otherwise.

Defined at line 249 of file ../../src/media/audio/audio_core/audio_device.cc

void UpdateRoutableState (bool routable)

UpdateRoutableState

Called by the audio device manager on the main message loop when the device is

undergoing an update to its OutputPipeline. Used to update the internal

bookkeeping about the current routable/unroutable state.

Defined at line 265 of file ../../src/media/audio/audio_core/audio_device.cc

const std::shared_ptr<ReadableRingBuffer> & driver_readable_ring_buffer ()

AudioDriver accessors.

Defined at line 276 of file ../../src/media/audio/audio_core/audio_device.cc

const std::shared_ptr<WritableRingBuffer> & driver_writable_ring_buffer ()

Defined at line 280 of file ../../src/media/audio/audio_core/audio_device.cc

void SetPresentationDelay (zx::duration delay)

Update the presentation delay for this device (defaults to zero).

Defined at line 283 of file ../../src/media/audio/audio_core/audio_device.h

const TimelineFunction & driver_ref_time_to_frac_presentation_frame ()

Accessors for some of the useful timeline functions computed by the driver

after streaming starts.

Maps from a presentation/capture time on the reference clock to fractional

frame number in the stream. The presentation/capture time refers to the

time that the sound either exits the speaker or enters the microphone.

Defined at line 284 of file ../../src/media/audio/audio_core/audio_device.cc

const TimelineFunction & driver_ref_time_to_frac_safe_read_or_write_frame ()

Maps from a time on the reference clock to the safe read/write frame number in the stream. The

safe read/write pointer is the point in the stream which is driver_transfer_bytes away from the

interconnect entry/exit point in the stream. This is the point at which an input stream is

guaranteed to have moved its captured data from hardware into RAM, or the point at which an

output stream may have started transmitting data from RAM into hardware. When consuming or

producing audio from an input or output stream, users must always stay ahead of this point.

Defined at line 288 of file ../../src/media/audio/audio_core/audio_device.cc

void OnLinkAdded ()

AudioObject override.

Defined at line 136 of file ../../src/media/audio/audio_core/audio_device.cc

ExecutionDomain & mix_domain ()

Defined at line 288 of file ../../src/media/audio/audio_core/audio_device.h

ThreadingModel & threading_model ()

Defined at line 289 of file ../../src/media/audio/audio_core/audio_device.h

std::shared_ptr<AudioCoreClockFactory> clock_factory ()

Defined at line 290 of file ../../src/media/audio/audio_core/audio_device.h

DeviceRegistry & device_registry ()

Defined at line 291 of file ../../src/media/audio/audio_core/audio_device.h

const fbl::RefPtr<AudioDeviceSettings> & device_settings ()

Defined at line 292 of file ../../src/media/audio/audio_core/audio_device.h

Friends

class PendingInitListTraits
class AudioDriver
class AudioDeviceManager