run(
dev,mx,opts) ->task/fn
Run the audio writer task on the LEV event loop
Spawns a task into the running lev.run. The task waits until the device
takes a period, fills one from the mixer, and writes it. With no voices
playing it writes silence, so the stream never runs dry. A device with a
wait method, the pulse one, is waited on through it; any other is
waited on writable through dev:fd().
| opts field | default | description |
|---|---|---|
timeout | 0.1 | seconds between checks of cancel |
cancel | nil | a lev.cancel_token; the task ends when it fires |
name | "sound_writer" | task name |
spawn | true | false returns the task body as a function, for the caller to run |
stats | nil | a table the task counts in: periods played, underruns recovered |
The task never resets stats; the caller owns it. An underrun loses the
period that met it. The task prepares the stream again and fills the next
period fresh. So periods counts what played and underruns what did
not. The task ends on a device error other than an underrun or a full
ring.