From 3fc010d765126216d4ff54f79fd531679afb14b4 Mon Sep 17 00:00:00 2001 From: b-ma Date: Sun, 28 Apr 2024 09:41:59 +0200 Subject: [PATCH] return RenderCapacity as owned value --- src/capacity.rs | 1 + src/context/online.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/capacity.rs b/src/capacity.rs index df2ec535..7faadf89 100644 --- a/src/capacity.rs +++ b/src/capacity.rs @@ -65,6 +65,7 @@ impl AudioRenderCapacityEvent { /// Ideally the load value is below 1.0, meaning that it took less time to render the audio than it /// took to play it out. An audio buffer underrun happens when this load value is greater than 1.0: the /// system could not render audio fast enough for real-time. +#[derive(Clone)] pub struct AudioRenderCapacity { context: ConcreteBaseAudioContext, receiver: Receiver, diff --git a/src/context/online.rs b/src/context/online.rs index dc402fd9..97c5ce66 100644 --- a/src/context/online.rs +++ b/src/context/online.rs @@ -268,6 +268,12 @@ impl AudioContext { self.backend_manager.lock().unwrap().sink_id().to_owned() } + /// Returns an [`AudioRenderCapacity`] instance associated with an AudioContext. + #[must_use] + pub fn render_capacity(&self) -> AudioRenderCapacity { + self.render_capacity.clone() + } + /// Update the current audio output device. /// /// The provided `sink_id` string must match a device name `enumerate_devices_sync`. @@ -712,12 +718,6 @@ impl AudioContext { let opts = node::MediaElementAudioSourceOptions { media_element }; node::MediaElementAudioSourceNode::new(self, opts) } - - /// Returns an [`AudioRenderCapacity`] instance associated with an AudioContext. - #[must_use] - pub fn render_capacity(&self) -> &AudioRenderCapacity { - &self.render_capacity - } } #[cfg(test)]