mirror of
https://github.com/RustAudio/rodio
synced 2025-01-19 06:53:53 +00:00
Fix AGC example compilation
`experimental` flag removes some API, just keep the example minimally functional in that case.
This commit is contained in:
parent
808d51b937
commit
de53b87a06
1 changed files with 17 additions and 9 deletions
|
@ -19,19 +19,27 @@ fn main() {
|
||||||
let agc_source = source.automatic_gain_control(1.0, 4.0, 0.005, 5.0);
|
let agc_source = source.automatic_gain_control(1.0, 4.0, 0.005, 5.0);
|
||||||
|
|
||||||
// Make it so that the source checks if automatic gain control should be
|
// Make it so that the source checks if automatic gain control should be
|
||||||
// enabled or disabled every 5 milliseconds. We must clone `agc_enabled`
|
// enabled or disabled every 5 milliseconds. We must clone `agc_enabled`,
|
||||||
// or we would lose it when we move it into the periodic access.
|
// or we would lose it when we move it into the periodic access.
|
||||||
let agc_enabled = Arc::new(AtomicBool::new(true));
|
let agc_enabled = Arc::new(AtomicBool::new(true));
|
||||||
|
|
||||||
|
#[cfg(not(feature = "experimental"))]
|
||||||
|
{
|
||||||
let agc_enabled_clone = agc_enabled.clone();
|
let agc_enabled_clone = agc_enabled.clone();
|
||||||
let controlled = agc_source.periodic_access(Duration::from_millis(5), move |agc_source| {
|
let controlled = agc_source.periodic_access(Duration::from_millis(5), move |agc_source| {
|
||||||
agc_source.set_enabled(agc_enabled_clone.load(Ordering::Relaxed));
|
agc_source.set_enabled(agc_enabled_clone.load(Ordering::Relaxed));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add the source now equipped with automatic gain control and controlled via
|
// Add the source now equipped with automatic gain control and controlled via
|
||||||
// periodic_access to the sink for playback
|
// periodic_access to the sink for playback.
|
||||||
sink.append(controlled);
|
sink.append(controlled);
|
||||||
|
}
|
||||||
|
#[cfg(feature = "experimental")]
|
||||||
|
{
|
||||||
|
sink.append(agc_source);
|
||||||
|
}
|
||||||
|
|
||||||
// after 5 seconds of playback disable automatic gain control using the
|
// After 5 seconds of playback disable automatic gain control using the
|
||||||
// shared AtomicBool `agc_enabled`. You could do this from another part
|
// shared AtomicBool `agc_enabled`. You could do this from another part
|
||||||
// of the program since `agc_enabled` is of type Arc<AtomicBool> which
|
// of the program since `agc_enabled` is of type Arc<AtomicBool> which
|
||||||
// is freely clone-able and move-able.
|
// is freely clone-able and move-able.
|
||||||
|
|
Loading…
Reference in a new issue