1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! How deep the host is asked to keep the ring ahead of the USB output.
//!
//! A deep ring absorbs an upstream stall (slow storage, a network source,
//! scheduling) that a shallow one would let through as a dropout. It also delays
//! everything that is applied to the audio *as it is written*: software gain, and
//! whatever processing the host itself does before `write`, is heard only after
//! the audio already queued, which is the ring's fill. A change to audio that is
//! already in the ring is impossible, so the depth is a trade.
//!
//! Bit-perfect passthrough has no live processing to delay, so it keeps the deep
//! ring. While software gain is applied the recommended depth is the shallow
//! `processing_buffer_target_ms`.
//!
//! The depth is re-evaluated on every `writable_bytes()` call, because the mode
//! can change during playback. Nothing is flushed when it does: a ring that is
//! now deeper than its target is simply not refilled until the output has drained
//! it below the target, and one that is shallower than its target is filled on.
//! Either way the audio is continuous. This module is the decision, kept apart
//! from libusb so it can be tested on the host. Sizes are ring samples (frames
//! times channels).
/// The two depths the host is asked to keep the ring at.
pub
/// Whether anything the listener can change live is applied to the audio as it
/// is written.
///
/// Raw DSD and DoP are never processed (software gain is refused for them), so a
/// bitstream is never live. For PCM it is live when the software gain is anything
/// but exactly 1.0, which the output thread then multiplies in.
pub
/// Whether the shallow depth applies: software gain is applied to PCM, or the
/// host says it processes the audio itself before writing it (EQ, DSP,
/// crossfade). A bitstream is never live whatever the host says.
pub
/// Whether the host should write more into a ring holding `buffered_samples`
/// while it is kept at `target_samples`.
pub