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
71
72
73
74
75
76
77
78
79
//! Components that abstract over different backends.
use *;
use crate;
/// The web platform isn't able to start
/// the context synchronously without direct user input.
/// That means the diffing code will fill the the processor's
/// buffers without ever getting cleared until the context
/// actually starts.
///
/// This signal helps mitigate that.
///
/// We still let some events through such as sample playback events,
/// but these shouldn't overwhelm the buffers as the pools
/// will simply saturate and eventually reject new queue requests.
///
/// This downside could also be mitigated, but requires more
/// careful attention.
pub ;
/// A [`Resource`] containing the audio context's stream configuration.
///
/// Mutating this resource will cause the audio stream to stop
/// and restart, applying the latest changes.
;
/// When triggered globally, this attempts to automatically
/// restart the audio stream.
///
/// If the current devices are no longer available, this will
/// attempt to select the default input and output.
;
/// Bookkeeping that should be called following stream initialization.
///
/// For example, once a backend has initialized a stream and knows
/// the active sample rate, it can finish startup bookkeeping.
/// ```
/// # use bevy::prelude::*;
/// # use bevy_seedling::context::SampleRate;
/// # use bevy_seedling::platform::initialize_stream;
/// # use std::num::NonZeroU32;
/// fn start_stream(commands: Commands) {
/// let sample_rate = SampleRate::new(NonZeroU32::new(48000).unwrap());
/// initialize_stream(sample_rate, commands);
/// }
/// ```