The entry sound
The sound service: the device service of the sound device of the machine (virtio-snd, virtio 1.x over PCI). It serves a timed stream to its one client: each record of frames plays at the time that it names .
It has one device and nothing else: the registers of the device, one message interrupt, memory for the queues, the machine with the right Physical only, a copy of the configuration of the device, and the stream ring. The root service found the device, enabled it and set its interrupt (src/library/modus/pci), when the process with the grant Sound_Device started; it stops this service when that process stops.
What it is for. A process plays sound at a time of the system clock, and never sees the device, its queues or its clock.
The commands of the stream ring (src/library/modus/contract/timed_stream): Attach with the sample region, Start, then Play for each record. The completion of a Play comes when the device took the period that holds its last frame. A refusal gives a status and the values of an error record, and no frame of the record plays.
What a reader sees. No window: the line sound: ok, the output stream <n> of <count>, ... on the log when the device is ready, the line sound: the stream started, ... at Start, and one line at the first underrun and at the first hold of a period. A failure writes a line at the level error and stops the service.
What it does not prove. It does not know the delay of the device after it took a period: QEMU reports none. It corrects no drift of the clock of the device; it only holds the periods of a device that takes them faster than their time.
See: The timed stream, and sound through virtio-snd in the repository
sound module with an entry
- Hash
94495d8ec0321d987ece5793b70283d10f8c98fb57b7ce92174c2f944fdc79e2- Size
61440 bytes- Exports
0- Imports
0- Imported by
0- License
- MIT
The sound service: the device service of the sound device of the machine (virtio-snd, virtio 1.x over PCI)
| Fact | Value |
|---|---|
| Kind | Modules with an entry |
| Source | src/modules/system/sound |
| Boot image | yes: in the boot image, 61440 bytes in this build |
| Build settings | none: the defaults of the source |
| Imports | none |
| Imported by | none |
Neighbours
It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.
Exports
| Export | What it does |
|---|---|
entry() | starts the device and then serves the stream ring, until the root service stops it |
entry
entry()
entry starts the device and then serves the stream ring, until the root service stops it.
What it sets up: the machine handle with the right Physical, the stream ring, and the configuration of the device that the root service copied. It finds the virtio registers, resets the device, gives it the control queue and the transmit queue, makes the periods, finds the output stream and sets the one format (start). It then writes sound: ok, the output stream ....
The loop. After each wake:
- 1. It reads the used ring of the transmit queue. Each period that the device took frees its slot, in the order of the periods; each pending record whose last frame was taken gets its completion.
- 2. When the device holds no period and the time is past the end of the frames given, the service was late: an underrun. It moves the anchor, so the next frame plays now.
- 3. It gives a new period for each free slot, unless the frames given end too far ahead of now: it then holds the period until its time.
- 4. While the completion queue has room, it takes the next command through its border:
Attach,StartorPlay; any other word completes at once with its refusal. - 5. It tells the device of the new periods, wakes the client when a completion came, and waits for the interrupt of the device, a new command, or the end of a hold.
The stop: with no ring, a ring larger than the contract, no configuration, no virtio registers, no output stream of the format, a device that does not answer, needs a reset, or uses a period out of order or that was not given, it writes the reason at the level error and stops with Failed. Else it never returns.
- Form
- The entry of the module: one parameter, an address, fixed by the contract.
src/modules/system/sound/main.odin:572
Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).
What the root service gives it
| What | Value | As the root service says |
|---|---|---|
| Grants | The sound device and the ring of its one client (driver_start). | |
| Other terms of its start grant set | none | |
| Budget that it asks for |
| The working memory: the rest of the pages that the root service gave it by its name, once the tool counts its module and its thread. As for the entropy service, the tables of the domain of the device under the IOMMU are paid from it; the periods and their list take PERIOD_PAGES + 1 more, and the map of the sample region of the client its page tables. |
The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).
Play type of the package timed_stream
Play :: struct {...}
One record of frames, as the border read it.
src/library/modus/contract/timed_stream/timed_stream.odin:139
