mirror of
https://github.com/RustAudio/rodio
synced 2024-11-10 06:04:16 +00:00
Remove exclusive borrow requirement in Sink, SpatialSink (#203)
The inner Mutex does not require this.
This commit is contained in:
parent
6fd5288cc7
commit
4bb832ba30
5 changed files with 10 additions and 7 deletions
|
@ -1,3 +1,6 @@
|
|||
# Unreleased
|
||||
- Remove exclusive `&mut` borrow requirements in `Sink` & `SpatialSink` setters.
|
||||
|
||||
# Version 0.8.1 (2018-09-18)
|
||||
|
||||
- Update `lewton` dependency to 0.9
|
||||
|
|
|
@ -8,7 +8,7 @@ fn main() {
|
|||
let device = rodio::default_output_device().unwrap();
|
||||
|
||||
let file = std::fs::File::open("examples/beep.wav").unwrap();
|
||||
let mut beep1 = rodio::play_once(&device, BufReader::new(file)).unwrap();
|
||||
let beep1 = rodio::play_once(&device, BufReader::new(file)).unwrap();
|
||||
beep1.set_volume(0.2);
|
||||
println!("Started beep1");
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::time::Duration;
|
|||
|
||||
fn main() {
|
||||
let device = rodio::default_output_device().unwrap();
|
||||
let mut sink = rodio::SpatialSink::new(
|
||||
let sink = rodio::SpatialSink::new(
|
||||
&device,
|
||||
[-10.0, 0.0, 0.0],
|
||||
[1.0, 0.0, 0.0],
|
||||
|
|
|
@ -96,7 +96,7 @@ impl Sink {
|
|||
/// The value `1.0` is the "normal" volume (unfiltered input). Any value other than `1.0` will
|
||||
/// multiply each sample by this value.
|
||||
#[inline]
|
||||
pub fn set_volume(&mut self, value: f32) {
|
||||
pub fn set_volume(&self, value: f32) {
|
||||
*self.controls.volume.lock().unwrap() = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,17 +36,17 @@ impl SpatialSink {
|
|||
}
|
||||
|
||||
/// Sets the position of the sound emitter in 3 dimensional space.
|
||||
pub fn set_emitter_position(&mut self, pos: [f32; 3]) {
|
||||
pub fn set_emitter_position(&self, pos: [f32; 3]) {
|
||||
self.positions.lock().unwrap().emitter_position = pos;
|
||||
}
|
||||
|
||||
/// Sets the position of the left ear in 3 dimensional space.
|
||||
pub fn set_left_ear_position(&mut self, pos: [f32; 3]) {
|
||||
pub fn set_left_ear_position(&self, pos: [f32; 3]) {
|
||||
self.positions.lock().unwrap().left_ear = pos;
|
||||
}
|
||||
|
||||
/// Sets the position of the right ear in 3 dimensional space.
|
||||
pub fn set_right_ear_position(&mut self, pos: [f32; 3]) {
|
||||
pub fn set_right_ear_position(&self, pos: [f32; 3]) {
|
||||
self.positions.lock().unwrap().right_ear = pos;
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ impl SpatialSink {
|
|||
/// The value `1.0` is the "normal" volume (unfiltered input). Any value other than 1.0 will
|
||||
/// multiply each sample by this value.
|
||||
#[inline]
|
||||
pub fn set_volume(&mut self, value: f32) {
|
||||
pub fn set_volume(&self, value: f32) {
|
||||
self.sink.set_volume(value);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue