The audio of the HDMI/DisplayPort input, or of the USB speaker.
The LT7911EXC passes the source's audio on as I2S. This process captures it
while there are subscribers, in the nano_kvm_go_audio port program, as
interleaved PCM: signed 16-bit little-endian from the HDMI input, and from
the USB speaker in the format the USB gadget set it up with, at the rate
the target chose.
Options
:name- the name to register,NanoKVMGo.Audioby default:source-:hdmi, the HDMI/DisplayPort input (the default), or:usb, what the target plays to the NanoKVM's USB speaker (the:speakerfunction of the USB gadget, seeNanoKVMGo.USB); run one process per source:device- the ALSA capture device, by default the source's:"hw:CARD=LT7911EXC,DEV=0"or"hw:CARD=UAC2Gadget,DEV=0":rate- the sample rate to expect at first, 48000 by default, the rate most computers send at:channels- the channels to capture where the device has them, 2 by default; the USB speaker has the channels it was set up with:period_ms- the audio in each message, 1 to 1000 ms, 20 ms by default:video_device- for the:hdmisource, the video capture device whose driver reports the input's sample rate, by default the board's, found each time the capture starts;nilto measure the rate instead:program- the port program, the library'snano_kvm_go_audioby default
Messages
Subscribers receive, with the :source of the process, so that one
subscriber can take both sources apart:
{NanoKVMGo.Audio, {:format, source, format}}, such as%{rate: 48000, channels: 2, sample_format: :s16_le}, when the capture starts, when subscribing to a running one, and when the source switches to another rate. The bridge passes the source's rate on and reports it to the video capture driver, which the port program follows. Where the driver does not report it, the program measures the rate the samples arrive at and snaps it to a standard one (44.1 kHz, 48 kHz, ...) within a few seconds. The USB speaker reports the rate the target chooses.{NanoKVMGo.Audio, {:pcm, source, data}},:period_msof samples each
No samples come while the source sends no audio. A subscriber with more than a second of audio waiting misses the next until it catches up; one on another node gets them all, as its messages waiting cannot be counted.
Summary
Types
A message to subscribers, see the module documentation.
Interleaved signed samples, as ALSA names them: S16_LE, S24_3LE...
Functions
A child specification, with the :name as its id: one process per
source can run in the same supervisor.
The format of the running capture, nil without one.
Starts the process. See the module documentation for the options.
Sends the audio to the caller until it unsubscribes or exits.
Stops sending to the caller.
Types
@type format() :: %{ rate: pos_integer(), channels: pos_integer(), sample_format: sample_format() }
A message to subscribers, see the module documentation.
@type option() :: {:name, GenServer.name()} | {:source, source()} | {:device, String.t()} | {:rate, pos_integer()} | {:channels, pos_integer()} | {:period_ms, 1..1000} | {:video_device, Path.t() | nil} | {:program, Path.t()}
@type sample_format() :: :s16_le | :s24_3le | :s24_le | :s32_le
Interleaved signed samples, as ALSA names them: S16_LE, S24_3LE...
@type source() :: :hdmi | :usb
Functions
@spec child_spec([option()]) :: Supervisor.child_spec()
A child specification, with the :name as its id: one process per
source can run in the same supervisor.
@spec format(GenServer.server()) :: format() | nil
The format of the running capture, nil without one.
@spec start_link([option()]) :: GenServer.on_start()
Starts the process. See the module documentation for the options.
@spec subscribe(GenServer.server()) :: :ok
Sends the audio to the caller until it unsubscribes or exits.
@spec unsubscribe(GenServer.server()) :: :ok
Stops sending to the caller.