The microphone the target computer sees, with the :microphone function
of the USB gadget (see NanoKVMGo.USB).
play/2 sends it PCM: interleaved samples in the microphone's format, the
channels and sample size the gadget set it up with, at the rate the target
chose. format/1 tells that format, and subscribers hear of it.
The nano_kvm_go_playback port program keeps the microphone's stream
running: between samples the target hears silence, and samples that come
in faster than the target takes them are dropped once more than 200 ms
wait, so the sound never lags. The program runs while there are
subscribers, and from play/2 until :idle_ms without samples.
Messages
Subscribers receive {NanoKVMGo.Microphone, {:format, format}}, a
NanoKVMGo.Audio.format/0, when the program starts, when subscribing to a
running one, and when the target chooses another rate. Samples sent in
the old format until then play at the wrong speed.
Options
:name- the name to register,NanoKVMGo.Microphoneby default:device- the ALSA playback device,"hw:CARD=UAC2Gadget,DEV=0"by default:idle_ms- how long to keep the stream without samples and subscribers, 10 s by default:program- the port program, the library'snano_kvm_go_playbackby default
Summary
Functions
Returns a specification to start this module under a supervisor.
The format of the running stream, nil without one.
Plays samples on the microphone, in its format, any number of frames.
Starts the process. See the module documentation for the options.
Sends the format to the caller until it unsubscribes or exits, and keeps the stream running meanwhile.
Stops sending to the caller.
Types
@type message() :: {NanoKVMGo.Microphone, {:format, NanoKVMGo.Audio.format()}}
A message to subscribers, see the module documentation.
@type option() :: {:name, GenServer.name()} | {:device, String.t()} | {:idle_ms, pos_integer()} | {:program, Path.t()}
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec format(GenServer.server()) :: NanoKVMGo.Audio.format() | nil
The format of the running stream, nil without one.
@spec play(GenServer.server(), binary()) :: :ok
Plays samples on the microphone, in its format, any number of frames.
@spec start_link([option()]) :: GenServer.on_start()
Starts the process. See the module documentation for the options.
@spec subscribe(GenServer.server()) :: :ok
Sends the format to the caller until it unsubscribes or exits, and keeps the stream running meanwhile.
@spec unsubscribe(GenServer.server()) :: :ok
Stops sending to the caller.