File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -193,22 +193,28 @@ impl ConcreteBaseAudioContext {
193
193
} ;
194
194
195
195
( listener_params, destination_channel_config)
196
- } ; // nodes will drop now, so base.inner has no copies anymore
196
+ } ; // Nodes will drop now, so base.inner has no copies anymore
197
197
198
198
let mut base = base;
199
199
let inner_mut = Arc :: get_mut ( & mut base. inner ) . unwrap ( ) ;
200
200
inner_mut. listener_params = Some ( listener_params) ;
201
201
inner_mut. destination_channel_config = destination_channel_config;
202
202
203
- // validate if the hardcoded node IDs line up
203
+ // Validate if the hardcoded node IDs line up
204
204
debug_assert_eq ! (
205
205
base. inner. node_id_inc. load( Ordering :: Relaxed ) ,
206
206
LISTENER_PARAM_IDS . end,
207
207
) ;
208
208
209
- // (?) only for online context
209
+ // For an online AudioContext, pre-create the HRTF-database for panner nodes
210
+ if !offline {
211
+ crate :: node:: load_hrtf_processor ( sample_rate as u32 ) ;
212
+ }
213
+
214
+ // Boot the event loop thread that handles the events spawned by the render thread
215
+ // (we don't do this for offline rendering because it makes little sense, the graph cannot
216
+ // be mutated once rendering has started anyway)
210
217
if let Some ( event_channel) = event_recv {
211
- // init event loop
212
218
event_loop. run ( event_channel) ;
213
219
}
214
220
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ use super::{
20
20
/// The included data contains the impulse responses at 44100 Hertz, so it needs to be resampled
21
21
/// for other values (which can easily take 100s of milliseconds). Therefore cache the result (per
22
22
/// sample rate) in a global variable and clone it every time a new panner is created.
23
- fn load_hrtf_processor ( sample_rate : u32 ) -> ( HrtfProcessor , usize ) {
23
+ pub ( crate ) fn load_hrtf_processor ( sample_rate : u32 ) -> ( HrtfProcessor , usize ) {
24
24
static INSTANCE : OnceLock < Mutex < HashMap < u32 , ( HrtfProcessor , usize ) > > > = OnceLock :: new ( ) ;
25
25
let cache = INSTANCE . get_or_init ( || Mutex :: new ( HashMap :: new ( ) ) ) ;
26
26
let mut guard = cache. lock ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments