@@ -10,10 +10,7 @@ use reaper_medium::ControlSurface;
10
10
use rxrust:: prelude:: * ;
11
11
use slog:: debug;
12
12
use smallvec:: SmallVec ;
13
- use std:: cell:: RefCell ;
14
- use std:: collections:: hash_map:: Entry ;
15
13
use std:: collections:: { HashMap , HashSet } ;
16
- use std:: time:: { Duration , Instant } ;
17
14
18
15
const NORMAL_TASK_BULK_SIZE : usize = 32 ;
19
16
const FEEDBACK_TASK_BULK_SIZE : usize = 32 ;
@@ -28,7 +25,6 @@ pub struct MainProcessor {
28
25
mappings : HashMap < MappingId , MainProcessorMapping > ,
29
26
feedback_buffer : FeedbackBuffer ,
30
27
feedback_subscriptions : FeedbackSubscriptions ,
31
- ephemeral_source_cache : EphemeralSourceCache ,
32
28
self_feedback_sender : crossbeam_channel:: Sender < FeedbackMainTask > ,
33
29
normal_task_receiver : crossbeam_channel:: Receiver < NormalMainTask > ,
34
30
feedback_task_receiver : crossbeam_channel:: Receiver < FeedbackMainTask > ,
@@ -57,7 +53,6 @@ impl ControlSurface for MainProcessor {
57
53
Reaper :: get( ) . logger( ) ,
58
54
"Main processor: Updating all mappings..."
59
55
) ;
60
- self . ephemeral_source_cache . clear ( ) ;
61
56
let mut unused_sources = self . currently_feedback_enabled_sources ( ) ;
62
57
// Put into hash map in order to quickly look up mappings by ID
63
58
self . mappings = mappings
@@ -97,7 +92,6 @@ impl ControlSurface for MainProcessor {
97
92
"Main processor: Updating mapping {:?}..." ,
98
93
mapping. id( )
99
94
) ;
100
- self . ephemeral_source_cache . clear ( ) ;
101
95
// (Re)subscribe to or unsubscribe from feedback
102
96
match mapping. target ( ) {
103
97
Some ( target) if mapping. feedback_is_enabled ( ) => {
@@ -169,11 +163,7 @@ impl ControlSurface for MainProcessor {
169
163
// selected") and the real-time processor doesn't yet know about it, there
170
164
// might be a short amount of time where we still receive control
171
165
// statements. We filter them here.
172
- if m. control_is_enabled ( ) {
173
- // TODO-high Only add if prevent immediate feedback enabled
174
- self . ephemeral_source_cache . add ( m. source ( ) . clone ( ) ) ;
175
- m. control ( value) ;
176
- }
166
+ m. control_if_enabled ( value) ;
177
167
} ;
178
168
}
179
169
}
@@ -196,11 +186,6 @@ impl ControlSurface for MainProcessor {
196
186
if let Some ( mapping_ids) = self . feedback_buffer . poll ( ) {
197
187
let source_values = mapping_ids. iter ( ) . filter_map ( |mapping_id| {
198
188
let mapping = self . mappings . get ( mapping_id) ?;
199
- if mapping. feedback_is_enabled ( )
200
- && self . ephemeral_source_cache . contains ( mapping. source ( ) )
201
- {
202
- return None ;
203
- }
204
189
mapping. feedback_if_enabled ( )
205
190
} ) ;
206
191
self . send_feedback ( source_values) ;
@@ -226,7 +211,6 @@ impl MainProcessor {
226
211
feedback_buffer : Default :: default ( ) ,
227
212
feedback_subscriptions : Default :: default ( ) ,
228
213
session,
229
- ephemeral_source_cache : Default :: default ( ) ,
230
214
}
231
215
}
232
216
@@ -379,43 +363,3 @@ impl Drop for MainProcessor {
379
363
debug ! ( Reaper :: get( ) . logger( ) , "Dropping main processor..." ) ;
380
364
}
381
365
}
382
-
383
- const EPHEMERAL_SOURCE_CACHE_LIFESPAN : Duration = Duration :: from_millis ( 20 ) ;
384
-
385
- /// Allows to add sources and keeps them just for a few milliseconds.
386
- #[ derive( Debug , Default ) ]
387
- struct EphemeralSourceCache {
388
- entries : RefCell < HashMap < MidiSource , Instant > > ,
389
- }
390
-
391
- impl EphemeralSourceCache {
392
- /// Adds the given source
393
- pub fn add ( & mut self , source : MidiSource ) {
394
- self . entries . borrow_mut ( ) . insert ( source, Instant :: now ( ) ) ;
395
- }
396
-
397
- /// Checks if the given source is in this cache and not yet expired.
398
- ///
399
- /// Also removes the cache entry if expired.
400
- pub fn contains ( & self , source : & MidiSource ) -> bool {
401
- use Entry :: * ;
402
- let expired = {
403
- if let Some ( source) = self . entries . borrow ( ) . get ( source) {
404
- source. elapsed ( ) > EPHEMERAL_SOURCE_CACHE_LIFESPAN
405
- } else {
406
- return false ;
407
- }
408
- } ;
409
- if expired {
410
- self . entries . borrow_mut ( ) . remove ( source) ;
411
- false
412
- } else {
413
- true
414
- }
415
- }
416
-
417
- /// Clears the cache
418
- fn clear ( & mut self ) {
419
- self . entries . borrow_mut ( ) . clear ( ) ;
420
- }
421
- }
0 commit comments