Skip to content

Commit

Permalink
return RenderCapacity as owned value
Browse files Browse the repository at this point in the history
  • Loading branch information
b-ma committed Apr 28, 2024
1 parent cc7a6c1 commit 3fc010d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/capacity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AudioRenderCapacityLoad>,
Expand Down
12 changes: 6 additions & 6 deletions src/context/online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit 3fc010d

Please sign in to comment.