pub struct StreamingSource { /* private fields */ }
Expand description
A source that plays a queue of owned buffers.
Implementations§
Source§impl StreamingSource
impl StreamingSource
Sourcepub fn buffers_queued(&self) -> ALint
pub fn buffers_queued(&self) -> ALint
alGetSourcei(AL_BUFFERS_QUEUED)
Sourcepub fn buffers_processed(&self) -> ALint
pub fn buffers_processed(&self) -> ALint
alGetSourcei(AL_BUFFERS_PROCESSED)
Examples found in repository?
examples/sine.rs (line 73)
7fn main() {
8 let alto = if let Ok(alto) = Alto::load_default() {
9 alto
10 } else {
11 println!("No OpenAL implementation present!");
12 return;
13 };
14
15 println!("Using output: {:?}", alto.default_output().unwrap());
16 let dev = alto.open(None).unwrap();
17 let ctx = dev.new_context(None).unwrap();
18
19 let mut slot = if dev.is_extension_present(alto::ext::Alc::Efx) {
20 println!("Using EFX reverb");
21 if let Ok(slot) = (|| -> AltoResult<_> {
22 let mut slot = ctx.new_aux_effect_slot()?;
23 let mut reverb: efx::EaxReverbEffect = ctx.new_effect()?;
24 reverb.set_preset(&efx::REVERB_PRESET_GENERIC)?;
25 slot.set_effect(&reverb)?;
26 Ok(slot)
27 })() {
28 Some(slot)
29 } else {
30 println!("Broken router detected; disabling EFX");
31 None
32 }
33 } else {
34 println!("EFX not present");
35 None
36 };
37
38 {
39 let buf = ctx.new_buffer(SinWave::new(44_000 / 440, 0.25).render().take(44_000 / 440).collect::<Vec<_>>(), 44_000).unwrap();
40 let buf = Arc::new(buf);
41
42 let mut src = ctx.new_static_source().unwrap();
43 src.set_buffer(buf).unwrap();
44 src.set_looping(true);
45 if let Some(ref mut slot) = slot {
46 src.set_aux_send(0, slot).unwrap();
47 }
48
49 println!("Playing static 440hz sine wave...");
50 src.play();
51
52 std::thread::sleep(std::time::Duration::new(2, 0));
53 }
54
55 std::thread::sleep(std::time::Duration::new(1, 0));
56
57 {
58 let mut wave = SinWave::new(44_000 / 220, 0.25);
59
60 let mut src = ctx.new_streaming_source().unwrap();
61 if let Some(ref mut slot) = slot {
62 src.set_aux_send(0, slot).unwrap();
63 }
64 for _ in 0 .. 5 {
65 let buf = ctx.new_buffer(wave.render().take(44_000 / 10).collect::<Vec<_>>(), 44_000).unwrap();
66 src.queue_buffer(buf).unwrap();
67 }
68
69 println!("Playing streaming 220hz sine wave...");
70 src.play();
71
72 for _ in 0 .. 15 {
73 while src.buffers_processed() == 0 { }
74
75 let mut buf = src.unqueue_buffer().unwrap();
76 buf.set_data(wave.render().take(44_000 / 10).collect::<Vec<_>>(), 44_000).unwrap();
77 src.queue_buffer(buf).unwrap();
78 }
79
80 while src.buffers_processed() < 5 { }
81 }
82
83 std::thread::sleep(std::time::Duration::new(1, 0));
84}
Sourcepub fn queue_buffer(&mut self, buf: Buffer) -> AltoResult<()>
pub fn queue_buffer(&mut self, buf: Buffer) -> AltoResult<()>
alSourceQueueBuffers()
Examples found in repository?
examples/sine.rs (line 66)
7fn main() {
8 let alto = if let Ok(alto) = Alto::load_default() {
9 alto
10 } else {
11 println!("No OpenAL implementation present!");
12 return;
13 };
14
15 println!("Using output: {:?}", alto.default_output().unwrap());
16 let dev = alto.open(None).unwrap();
17 let ctx = dev.new_context(None).unwrap();
18
19 let mut slot = if dev.is_extension_present(alto::ext::Alc::Efx) {
20 println!("Using EFX reverb");
21 if let Ok(slot) = (|| -> AltoResult<_> {
22 let mut slot = ctx.new_aux_effect_slot()?;
23 let mut reverb: efx::EaxReverbEffect = ctx.new_effect()?;
24 reverb.set_preset(&efx::REVERB_PRESET_GENERIC)?;
25 slot.set_effect(&reverb)?;
26 Ok(slot)
27 })() {
28 Some(slot)
29 } else {
30 println!("Broken router detected; disabling EFX");
31 None
32 }
33 } else {
34 println!("EFX not present");
35 None
36 };
37
38 {
39 let buf = ctx.new_buffer(SinWave::new(44_000 / 440, 0.25).render().take(44_000 / 440).collect::<Vec<_>>(), 44_000).unwrap();
40 let buf = Arc::new(buf);
41
42 let mut src = ctx.new_static_source().unwrap();
43 src.set_buffer(buf).unwrap();
44 src.set_looping(true);
45 if let Some(ref mut slot) = slot {
46 src.set_aux_send(0, slot).unwrap();
47 }
48
49 println!("Playing static 440hz sine wave...");
50 src.play();
51
52 std::thread::sleep(std::time::Duration::new(2, 0));
53 }
54
55 std::thread::sleep(std::time::Duration::new(1, 0));
56
57 {
58 let mut wave = SinWave::new(44_000 / 220, 0.25);
59
60 let mut src = ctx.new_streaming_source().unwrap();
61 if let Some(ref mut slot) = slot {
62 src.set_aux_send(0, slot).unwrap();
63 }
64 for _ in 0 .. 5 {
65 let buf = ctx.new_buffer(wave.render().take(44_000 / 10).collect::<Vec<_>>(), 44_000).unwrap();
66 src.queue_buffer(buf).unwrap();
67 }
68
69 println!("Playing streaming 220hz sine wave...");
70 src.play();
71
72 for _ in 0 .. 15 {
73 while src.buffers_processed() == 0 { }
74
75 let mut buf = src.unqueue_buffer().unwrap();
76 buf.set_data(wave.render().take(44_000 / 10).collect::<Vec<_>>(), 44_000).unwrap();
77 src.queue_buffer(buf).unwrap();
78 }
79
80 while src.buffers_processed() < 5 { }
81 }
82
83 std::thread::sleep(std::time::Duration::new(1, 0));
84}
Sourcepub fn unqueue_buffer(&mut self) -> AltoResult<Buffer>
pub fn unqueue_buffer(&mut self) -> AltoResult<Buffer>
alSourceUnqueueBuffers()
Examples found in repository?
examples/sine.rs (line 75)
7fn main() {
8 let alto = if let Ok(alto) = Alto::load_default() {
9 alto
10 } else {
11 println!("No OpenAL implementation present!");
12 return;
13 };
14
15 println!("Using output: {:?}", alto.default_output().unwrap());
16 let dev = alto.open(None).unwrap();
17 let ctx = dev.new_context(None).unwrap();
18
19 let mut slot = if dev.is_extension_present(alto::ext::Alc::Efx) {
20 println!("Using EFX reverb");
21 if let Ok(slot) = (|| -> AltoResult<_> {
22 let mut slot = ctx.new_aux_effect_slot()?;
23 let mut reverb: efx::EaxReverbEffect = ctx.new_effect()?;
24 reverb.set_preset(&efx::REVERB_PRESET_GENERIC)?;
25 slot.set_effect(&reverb)?;
26 Ok(slot)
27 })() {
28 Some(slot)
29 } else {
30 println!("Broken router detected; disabling EFX");
31 None
32 }
33 } else {
34 println!("EFX not present");
35 None
36 };
37
38 {
39 let buf = ctx.new_buffer(SinWave::new(44_000 / 440, 0.25).render().take(44_000 / 440).collect::<Vec<_>>(), 44_000).unwrap();
40 let buf = Arc::new(buf);
41
42 let mut src = ctx.new_static_source().unwrap();
43 src.set_buffer(buf).unwrap();
44 src.set_looping(true);
45 if let Some(ref mut slot) = slot {
46 src.set_aux_send(0, slot).unwrap();
47 }
48
49 println!("Playing static 440hz sine wave...");
50 src.play();
51
52 std::thread::sleep(std::time::Duration::new(2, 0));
53 }
54
55 std::thread::sleep(std::time::Duration::new(1, 0));
56
57 {
58 let mut wave = SinWave::new(44_000 / 220, 0.25);
59
60 let mut src = ctx.new_streaming_source().unwrap();
61 if let Some(ref mut slot) = slot {
62 src.set_aux_send(0, slot).unwrap();
63 }
64 for _ in 0 .. 5 {
65 let buf = ctx.new_buffer(wave.render().take(44_000 / 10).collect::<Vec<_>>(), 44_000).unwrap();
66 src.queue_buffer(buf).unwrap();
67 }
68
69 println!("Playing streaming 220hz sine wave...");
70 src.play();
71
72 for _ in 0 .. 15 {
73 while src.buffers_processed() == 0 { }
74
75 let mut buf = src.unqueue_buffer().unwrap();
76 buf.set_data(wave.render().take(44_000 / 10).collect::<Vec<_>>(), 44_000).unwrap();
77 src.queue_buffer(buf).unwrap();
78 }
79
80 while src.buffers_processed() < 5 { }
81 }
82
83 std::thread::sleep(std::time::Duration::new(1, 0));
84}
Trait Implementations§
Source§impl PartialEq for StreamingSource
impl PartialEq for StreamingSource
Source§impl Source for StreamingSource
impl Source for StreamingSource
Source§fn state(&self) -> SourceState
fn state(&self) -> SourceState
alGetSourcei(AL_SOURCE_STATE)
Source§fn set_relative(&mut self, value: bool)
fn set_relative(&mut self, value: bool)
alSourcei(AL_SOURCE_RELATIVE)
Source§fn set_min_gain(&mut self, value: f32) -> AltoResult<()>
fn set_min_gain(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_MIN_GAIN)
Source§fn set_max_gain(&mut self, value: f32) -> AltoResult<()>
fn set_max_gain(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_MAX_GAIN)
Source§fn reference_distance(&self) -> f32
fn reference_distance(&self) -> f32
alGetSourcef(AL_REFERENCE_DISTANCE)
Source§fn set_reference_distance(&mut self, value: f32) -> AltoResult<()>
fn set_reference_distance(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_REFERENCE_DISTANCE)
Source§fn rolloff_factor(&self) -> f32
fn rolloff_factor(&self) -> f32
alGetSourcef(AL_ROLLOFF_FACTOR)
Source§fn set_rolloff_factor(&mut self, value: f32) -> AltoResult<()>
fn set_rolloff_factor(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_ROLLOFF_FACTOR)
Source§fn max_distance(&self) -> f32
fn max_distance(&self) -> f32
alGetSourcef(AL_MAX_DISTANCE)
Source§fn set_max_distance(&mut self, value: f32) -> AltoResult<()>
fn set_max_distance(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_MAX_DISTANCE)
Source§fn set_position<V: Into<[f32; 3]>>(&mut self, value: V) -> AltoResult<()>
fn set_position<V: Into<[f32; 3]>>(&mut self, value: V) -> AltoResult<()>
alSourcefv(AL_POSITION)
Source§fn set_velocity<V: Into<[f32; 3]>>(&mut self, value: V) -> AltoResult<()>
fn set_velocity<V: Into<[f32; 3]>>(&mut self, value: V) -> AltoResult<()>
alSourcefv(AL_VELOCITY)
Source§fn set_direction<V: Into<[f32; 3]>>(&mut self, value: V) -> AltoResult<()>
fn set_direction<V: Into<[f32; 3]>>(&mut self, value: V) -> AltoResult<()>
alSourcefv(AL_DIRECTION)
Source§fn cone_inner_angle(&self) -> f32
fn cone_inner_angle(&self) -> f32
alGetSourcef(AL_CONE_INNER_ANGLE)
Source§fn set_cone_inner_angle(&mut self, value: f32) -> AltoResult<()>
fn set_cone_inner_angle(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_CONE_INNER_ANGLE)
Source§fn cone_outer_angle(&self) -> f32
fn cone_outer_angle(&self) -> f32
alGetSourcef(AL_CONE_OUTER_ANGLE)
Source§fn set_cone_outer_angle(&mut self, value: f32) -> AltoResult<()>
fn set_cone_outer_angle(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_CONE_OUTER_ANGLE)
Source§fn cone_outer_gain(&self) -> f32
fn cone_outer_gain(&self) -> f32
alGetSourcef(AL_CONE_OUTER_GAIN)
Source§fn set_cone_outer_gain(&mut self, value: f32) -> AltoResult<()>
fn set_cone_outer_gain(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_CONE_OUTER_GAIN)
Source§fn sec_offset(&self) -> f32
fn sec_offset(&self) -> f32
alGetSourcef(AL_SEC_OFFSET)
Source§fn set_sec_offset(&mut self, value: f32) -> AltoResult<()>
fn set_sec_offset(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_SEC_OFFSET)
Source§fn sample_offset(&self) -> ALint
fn sample_offset(&self) -> ALint
alGetSourcei(AL_SAMPLE_OFFSET)
Source§fn set_sample_offset(&mut self, value: ALint) -> AltoResult<()>
fn set_sample_offset(&mut self, value: ALint) -> AltoResult<()>
alSourcei(AL_SAMPLE_OFFSET)
Source§fn byte_offset(&self) -> ALint
fn byte_offset(&self) -> ALint
alGetSourcei(AL_BYTE_OFFSET)
Source§fn set_byte_offset(&mut self, value: ALint) -> AltoResult<()>
fn set_byte_offset(&mut self, value: ALint) -> AltoResult<()>
alSourcei(AL_BYTE_OFFSET)
Source§fn soft_sec_offset_latency(&self) -> AltoResult<(f64, f64)>
fn soft_sec_offset_latency(&self) -> AltoResult<(f64, f64)>
alGetSourcedvSOFT(AL_SEC_OFFSET_LATENCY_SOFT)
Requires AL_SOFT_source_latency
Source§fn soft_sample_frac_offset_latency(&self) -> AltoResult<(i32, i32, i64)>
fn soft_sample_frac_offset_latency(&self) -> AltoResult<(i32, i32, i64)>
alGetSourcei16vSOFT(AL_SAMPLE_OFFSET_LATENCY_SOFT)
Requires AL_SOFT_source_latency
Source§fn soft_sec_length(&self) -> AltoResult<f32>
fn soft_sec_length(&self) -> AltoResult<f32>
alGetSourcef(AL_SEC_LENGTH_SOFT)
Requires AL_SOFT_source_length
Source§fn soft_sample_length(&self) -> AltoResult<ALint>
fn soft_sample_length(&self) -> AltoResult<ALint>
alGetSourcei(AL_SAMPLE_LENGTH_SOFT)
Requires AL_SOFT_source_length
Source§fn soft_byte_length(&self) -> AltoResult<ALint>
fn soft_byte_length(&self) -> AltoResult<ALint>
alGetSourcei(AL_BYTE_LENGTH_SOFT)
Requires AL_SOFT_source_length
Source§fn soft_direct_channels(&self) -> bool
fn soft_direct_channels(&self) -> bool
alGetSourcei(AL_DIRECT_CHANNELS_SOFT)
Requires AL_SOFT_direct_channels
Source§fn set_soft_direct_channels(&mut self, value: bool) -> AltoResult<()>
fn set_soft_direct_channels(&mut self, value: bool) -> AltoResult<()>
alSourcei(AL_DIRECT_CHANNELS_SOFT)
Requires AL_SOFT_direct_channels
Source§fn distance_model(&self) -> DistanceModel
fn distance_model(&self) -> DistanceModel
alGetSourcei(AL_DISTANCE_MODEL)
Requires AL_EXT_source_distance_model
Source§fn set_distance_model(&mut self, value: DistanceModel) -> AltoResult<()>
fn set_distance_model(&mut self, value: DistanceModel) -> AltoResult<()>
alSourcei(AL_DISTANCE_MODEL)
Requires AL_EXT_source_distance_model
Source§fn soft_spatialization(&self) -> SoftSourceSpatialization
fn soft_spatialization(&self) -> SoftSourceSpatialization
alGetSourcei(AL_SOURCE_SPATIALIZATION_SOFT)
Requires AL_SOFT_source_spatialization
Source§fn set_soft_spatialization(
&mut self,
value: SoftSourceSpatialization,
) -> AltoResult<()>
fn set_soft_spatialization( &mut self, value: SoftSourceSpatialization, ) -> AltoResult<()>
alSourcei(AL_SOURCE_SPATIALIZATION_SOFT)
Requires AL_SOFT_source_spatialization
Source§fn soft_resampler(&self) -> AltoResult<ALint>
fn soft_resampler(&self) -> AltoResult<ALint>
alGetSourcei(AL_SOURCE_RESAMPLER_SOFT)
Requires AL_SOFT_source_resampler
Source§fn set_soft_resampler(&mut self, value: ALint) -> AltoResult<()>
fn set_soft_resampler(&mut self, value: ALint) -> AltoResult<()>
alSourcei(AL_SOURCE_RESAMPLER_SOFT)
Requires AL_SOFT_source_resampler
Source§fn stereo_angles<V: From<[f32; 2]>>(&self) -> AltoResult<V>
fn stereo_angles<V: From<[f32; 2]>>(&self) -> AltoResult<V>
alGetSourcefv(AL_STEREO_ANGLES)
Requires AL_EXT_STEREO_ANGLES
Source§fn set_stereo_angles<V: Into<[f32; 2]>>(&mut self, value: V) -> AltoResult<()>
fn set_stereo_angles<V: Into<[f32; 2]>>(&mut self, value: V) -> AltoResult<()>
alSourcefv(AL_STEREO_ANGLES)
Requires AL_EXT_STEREO_ANGLES
Source§fn set_radius(&self, value: f32) -> AltoResult<()>
fn set_radius(&self, value: f32) -> AltoResult<()>
alSourcef(AL_SOURCE_RADIUS)
Requires AL_EXT_SOURCE_RADIUS
Source§fn set_direct_filter<F: Filter>(&mut self, value: &F) -> AltoResult<()>
fn set_direct_filter<F: Filter>(&mut self, value: &F) -> AltoResult<()>
alSourcei(AL_DIRECT_FILTER)
Requires ALC_EXT_EFX
Source§fn clear_direct_filter(&mut self)
fn clear_direct_filter(&mut self)
alSourcei(AL_DIRECT_FILTER)
Requires ALC_EXT_EFX
Source§fn set_aux_send(
&mut self,
send: ALint,
slot: &mut AuxEffectSlot,
) -> AltoResult<()>
fn set_aux_send( &mut self, send: ALint, slot: &mut AuxEffectSlot, ) -> AltoResult<()>
alSourceiv(AL_AUXILIARY_SEND_FILTER)
Requires ALC_EXT_EFX
Source§fn set_aux_send_filter<F: Filter>(
&mut self,
send: ALint,
slot: &mut AuxEffectSlot,
filter: &F,
) -> AltoResult<()>
fn set_aux_send_filter<F: Filter>( &mut self, send: ALint, slot: &mut AuxEffectSlot, filter: &F, ) -> AltoResult<()>
alSourceiv(AL_AUXILIARY_SEND_FILTER)
Requires ALC_EXT_EFX
Source§fn clear_aux_send(&mut self, send: ALint)
fn clear_aux_send(&mut self, send: ALint)
alSourceiv(AL_AUXILIARY_SEND_FILTER)
Requires ALC_EXT_EFX
Source§fn air_absorption_factor(&self) -> f32
fn air_absorption_factor(&self) -> f32
alGetSourcef(AL_AIR_ABSORPTION_FACTOR)
Requires ALC_EXT_EFX
Source§fn set_air_absorption_factor(&mut self, value: f32) -> AltoResult<()>
fn set_air_absorption_factor(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_AIR_ABSORPTION_FACTOR)
Requires ALC_EXT_EFX
Source§fn room_rolloff_factor(&self) -> f32
fn room_rolloff_factor(&self) -> f32
alGetSourcef(AL_ROOM_ROLLOFF_FACTOR)
Requires ALC_EXT_EFX
Source§fn set_room_rolloff_factor(&mut self, value: f32) -> AltoResult<()>
fn set_room_rolloff_factor(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_ROOM_ROLLOFF_FACTOR)
Requires ALC_EXT_EFX
Source§fn cone_outer_gainhf(&self) -> f32
fn cone_outer_gainhf(&self) -> f32
alGetSourcef(AL_CONE_OUTER_GAINHF)
Requires ALC_EXT_EFX
Source§fn set_cone_outer_gainhf(&mut self, value: f32) -> AltoResult<()>
fn set_cone_outer_gainhf(&mut self, value: f32) -> AltoResult<()>
alSourcef(AL_CONE_OUTER_GAINHF)
Requires ALC_EXT_EFX
Source§fn direct_filter_gainhf_auto(&self) -> bool
fn direct_filter_gainhf_auto(&self) -> bool
alGetSourcei(AL_DIRECT_FILTER_GAINHF_AUTO)
Requires ALC_EXT_EFX
Source§fn set_direct_filter_gainhf_auto(&mut self, value: bool) -> AltoResult<()>
fn set_direct_filter_gainhf_auto(&mut self, value: bool) -> AltoResult<()>
alSourcei(AL_DIRECT_FILTER_GAINHF_AUTO)
Requires ALC_EXT_EFX
impl Eq for StreamingSource
Auto Trait Implementations§
impl Freeze for StreamingSource
impl !RefUnwindSafe for StreamingSource
impl Send for StreamingSource
impl Sync for StreamingSource
impl Unpin for StreamingSource
impl !UnwindSafe for StreamingSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more