# `TuningFork.Listener`
[🔗](https://github.com/jaman/tuning_fork/blob/v0.1.11/tuning_fork_speaker/lib/tuning_fork/listener.ex#L1)

Plays raw signed 16-bit little-endian PCM arriving on a TCP port through this machine's
speaker, one connection after another — the far end of `TuningFork.Sink.Tcp` over an
ssh tunnel.

    {:ok, listener} = TuningFork.Listener.start_link(port: 5000)

Each connection opens the sink afresh and closes it when the connection ends; the next
connection is accepted then. Audio that has arrived faster than it can play — a burst
while the device was opening, a stall on the link — is dropped down to `:max_lag_ms`,
so what is heard stays that close to what was sent.

## Options

  * `:port` — the TCP port to listen on; `0` picks a free one and `port/1` tells
    which. Required
  * `:ip` — the interface to listen on. Default `{127, 0, 0, 1}`, this machine only
  * `:rate`, `:channels` — the PCM format. Default `44_100` and `2`
  * `:sink` — the `TuningFork.Sink` to play through, as `module` or `{module, opts}`.
    Default `TuningFork.Sink.Speaker`
  * `:max_lag_ms` — the most audio kept waiting to play. Default `100`
  * `:name` — a registered name. Default: none

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `port`

```elixir
@spec port(GenServer.server()) :: :inet.port_number()
```

The port being listened on.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Start listening.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
