class SimpleAudioStream
Defined at line 67 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
The SimpleAudioStream server (thread compatible) implements fidl::WireServer
<Device
> and
fidl::WireServer
<RingBuffer
>.
All this is serialized in the single threaded SimpleAudioStream's dispatcher().
Protected Members
Vector supported_formats_
GainState cur_gain_state_
audio_stream_unique_id unique_id_
char[64] mfr_name_
char[64] prod_name_
char[32] device_name_
int32_t clock_domain_
uint32_t frame_size_
uint32_t driver_transfer_bytes_
uint64_t external_delay_nsec_
audio_pd_notify_flags_t pd_flags_
Public Methods
void Shutdown ()
User facing shutdown method. Implementers with shutdown requirements
should overload ShutdownHook.
Defined at line 45 of file ../../src/media/audio/lib/simple-audio-stream/simple-audio-stream.cc
template <typename T, typename... ConstructorSignature>
fbl::RefPtr<T> Create (ConstructorSignature &&... args)
Create
A general method which handles the construction/initialization of
SimpleAudioStream implementation. Given an implementation called
'MyStream', invocation should look something like..
auto stream = SimpleAudioStream::Create
<MyStream
>(arg1, arg2, ...);
Note: Implementers are encouraged to keep their constructor/destructor
protected/private. In order to do so, however, they will need to make
sure to 'friend class SimpleAudioStream', and to 'friend class fbl::RefPtr
<T
>'
Defined at line 84 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
void SimpleAudioStream (const SimpleAudioStream & )
Defined at line 103 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
void SimpleAudioStream (SimpleAudioStream && )
Defined at line 103 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
SimpleAudioStream & operator= (const SimpleAudioStream & )
Defined at line 103 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
SimpleAudioStream & operator= (SimpleAudioStream && )
Defined at line 103 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
bool is_input ()
Public properties.
Defined at line 106 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
inspect::Inspector & inspect ()
Public for unit testing.
Defined at line 109 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
void DdkUnbind (ddk::UnbindTxn txn)
DDK device implementation
Defined at line 192 of file ../../src/media/audio/lib/simple-audio-stream/simple-audio-stream.cc
void DdkRelease ()
Defined at line 202 of file ../../src/media/audio/lib/simple-audio-stream/simple-audio-stream.cc
void DdkSuspend (ddk::SuspendTxn txn)
Defined at line 207 of file ../../src/media/audio/lib/simple-audio-stream/simple-audio-stream.cc
Protected Methods
void SimpleAudioStream (zx_device_t * parent, bool is_input)
Defined at line 25 of file ../../src/media/audio/lib/simple-audio-stream/simple-audio-stream.cc
zx_status_t Init ()
Init - General hook
Called once during device creation, before the execution domain has been
created and before any device node has been published.
During Init, devices *must*
1) Populate the supported_formats_ vector with at least one valid format
range. The flag ASF_RANGE_FLAG_FPS_CONTINUOUS is not supported (unless
min_frames_per_second and max_frames_per_second are equal since in that
case the flag is irrelevant).
2) Report the stream's gain control capabilities and current gain control
state in the cur_gain_state_ member.
3) Supply a valid, null-terminated, device node name in the device_name_
member.
4) Supply a persistent unique ID in the unique_id_ member.
5) Call SetInitialPlugState to declare its plug detection capabilities
and initial plug state, if the device is not exclusively hardwired.
During Init, devices *should*
1) Supply a valid null-terminated UTF-8 encoded manufacturer name in the
mfr_name_ member.
2) Supply a valid null-terminated UTF-8 encoded product name in the
prod_name_ member.
zx_status_t ChangeFormat (const audio_proto::StreamSetFmtReq & req)
Stream interface methods
ChangeFormat - Stream interface method
All drivers must implement ChangeFormat. When called, the following
guarantees are provided.
1) Any existing ring buffer channel has been deactivated and the ring
buffer (if it had existed previously) is in the stopped state.
2) The format request has been validated against the supported_formats_
list supplied by the implementation.
3) The frame_size_ for the requested format has been computed.
Drivers should take appropriate steps to prepare hardware for the
requested format change. Depending on driver requirements, this may
involve configuring hardware and starting clocks, or may simply involve
deferring such operations until later.
Upon success, drivers *must* have filled out the driver_transfer_bytes_ and
external_delay_nsec fields with appropriate values.
zx_status_t ChangeActiveChannels (uint64_t mask, zx_time_t * set_time_out)
Changes which channels are considered active.
Drivers can turn off hardware based on the channels that are active.
zx_status_t GetBuffer (const audio_proto::RingBufGetBufferReq & req, uint32_t * out_num_rb_frames, zx::vmo * out_buffer)
GetBuffer - RingBuffer interface method
Called after a successful format change in order to establish the shared
ring buffer. GetBuffer will never be called while the ring buffer is in
the started state.
Upon success, drivers should return a valid VMO with appropriate
permissions (READ | MAP | TRANSFER for inputs, WRITE as well for outputs)
as well as reporting the total number of usable frames in the ring.
void SetInitialPlugState (audio_pd_notify_flags_t initial_state)
Called by a child subclass during Init, to establish the properties of this plug.
Caller must include only flags defined for audio_stream_cmd_plug_detect_resp_t.
Defined at line 124 of file ../../src/media/audio/lib/simple-audio-stream/simple-audio-stream.cc
void ~SimpleAudioStream ()
Defined at line 125 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
zx_status_t SetPlugState (bool plugged)
Called by a child subclass when a dynamic plug state change occurs.
Special behavior if this isn't actually a change, or if we should not be able to unplug.
Defined at line 135 of file ../../src/media/audio/lib/simple-audio-stream/simple-audio-stream.cc
void RingBufferShutdown ()
RingBufferShutdown - General hook
Called any time the client ring buffer channel is closed, and only after
the ring buffer is in the stopped state. Implementations may release
their VMO and perform additional hardware shutdown tasks as needed here.
Defined at line 161 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
void ShutdownHook ()
ShutdownHook - general hook
Called during final shutdown, after the execution domain has been
shutdown. All execution domain event sources have been deactivated and
any callbacks have been completed. Implementations should finish
completely shutting down all hardware and prepare for destruction.
Defined at line 169 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
zx_status_t SetGain (const audio_proto::SetGainReq & req)
SetGain - Stream interface method
Drivers which support gain control may overload this method in order to
receive a callback when a validated set gain request has been received by
a client. After processing the request, drivers *must* update the
cur_gain_state_ member to indicate the current gain state. This is what
will be reported to users who request a callback from SetGain, as well as
what will be reported for GetGain operations.
Defined at line 204 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
zx_status_t Start (uint64_t * out_start_time)
Start - RingBuffer interface method
Start the ring buffer. Will only be called after both a format and a
buffer have been established, and only when the ring buffer is in the
stopped state.
Drivers *must* report the time at which the first frame will be clocked
out on the CLOCK_MONOTONIC timeline, not including any external delay.
TODO(johngro): Adapt this when we support alternate HW clock domains.
zx_status_t Stop ()
Stop - RingBuffer interface method
Stop the ring buffer. Will only be called after both a format and a
buffer have been established, and only when the ring buffer is in the
started state.
zx_status_t NotifyPosition (const audio_proto::RingBufPositionNotify & notif)
NotifyPosition - RingBuffer interface event
Send a position notification to the client over the ring buffer channel,
if available. May be called from any thread. May return
ZX_ERR_BAD_STATE if the ring buffer channel is currently closed, or if
the active client has not requested that any position notifications be
provided. Implementations may use this as a signal to stop notification
production until the point in time at which GetBuffer is called again.
Defined at line 174 of file ../../src/media/audio/lib/simple-audio-stream/simple-audio-stream.cc
uint32_t LoadNotificationsPerRing ()
Callable any time after SetFormat while the RingBuffer channel is active,
but only valid after GetBuffer is called. Can be called from any context.
Defined at line 281 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
async_dispatcher_t * dispatcher ()
Defined at line 283 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
const Token & domain_token ()
Defined at line 285 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
void SetTurnOnDelay (int64_t turn_on_delay)
Defined at line 287 of file ../../src/media/audio/lib/simple-audio-stream/include/lib/simple-audio-stream/simple-audio-stream.h
Records
Friends
class RefPtr