mirror of
https://github.com/Droid-VM/crosvm.git
synced 2026-11-17 06:58:03 +00:00
crosvm's virtio-snd had no way to reach Android audio, and even with a backend it could not have made a sound: a stream opened by uid 0 is silenced by the platform, and crosvm runs as root here. So the backend has two halves. The device can run somewhere else. `--virtio-snd uid=`/`gid=`/`supp_gids=` forks and execs `crosvm device snd` under that uid over a socketpair, the way --shared-dir and --pmem-ext2 already place theirs. exec is mandatory rather than tidy: binder cannot be inherited across a bare fork, and AAudio is binder. The PDEATHSIG goes on after the setuid, since the kernel clears it when credentials change. Privilege is dropped with setresuid, not setuid -- setuid's saved-uid path under CAP_SETUID updates cred->ucounts but not cred->user, so the process's NPROC charge is never added yet is subtracted on exit; the counter goes negative and every later fork by that uid fails, which on Android means the app the VM belongs to can no longer be launched. A server that has already dropped also stops trying to become whoever a guest fs request names, since it cannot, and the attempt takes the whole operation down with EPERM. Endpoints are named and typed. A card carries a list of PCM devices, each pinned to one AudioDeviceInfo id, each declaring what it is for; the guest is told the real device type rather than a generic one, and each endpoint offers only the formats it can actually open. A float-only device gets no endpoint at all instead of a broken one -- crosvm's wire format list has no FLOAT, so a device that supports nothing else has nothing to advertise. The format axis is otherwise left wide because Windows does not renegotiate a cached one: narrow it after the guest has looked once and the guest never asks again. Underruns can hold the last period instead of playing silence (`underrun=hold`), with WSOLA and LPC variants, and an idle stream releases its endpoint so the platform can route someone else. Playback position is interpolated from what has actually been consumed rather than from a free-running QPC: the two drift, and a WaveRT guest reading the QPC-derived position writes into a buffer the host has not finished with, which is audible as a tear at the seam. One executor bug came out of this and is fixed here rather than around: an `ex.delay(Duration::ZERO)` arms a timerfd with an all-zero itimerspec, which *disarms* it -- the descriptor never becomes readable and the task never wakes. A scheduler pacing against a wall clock reaches zero the moment it falls behind, so on a phone this was a matter of time, and the symptom was audio going silent for good after a few minutes. |
History
|
|
|---|---|---|
| .. | ||
| audio_streams | ||
| balloon_control | ||
| cros_async | ||
| data_model | ||
| io_uring | ||
| sync | ||
| chromeos_warning.md | ||
| README.md | ||
Crosvm General Purpose Libraries
The crates in this folder are general purpose libraries used by other projects in ChromeOS as well.
To make them accessible independendly of crosvm, each of these crates is excluded from the crosvm workspace.