Expand description
Streaming buffer.
§Overview
Streaming buffers are used for long sounds (usually longer than 15 seconds) to reduce memory usage. Some sounds in games are very long - music, ambient sounds, voice, etc. and it is too inefficient to load and decode them directly into memory all at once - it will just take enormous amount of memory that could be used to something more useful.
§Usage
There are almost no difference with generic buffers:
use std::sync::{Mutex, Arc};
use rg3d_sound::buffer::{SoundBufferResource, DataSource};
async fn make_streaming_buffer() -> SoundBufferResource {
let data_source = DataSource::from_file("some_long_sound.ogg").await.unwrap();
SoundBufferResource::new_streaming(data_source).unwrap()
}§Notes
Streaming buffer cannot be shared across multiple source. On attempt to create a source with a streaming buffer that already in use you’ll get error.
Structs§
- Streaming
Buffer - Streaming buffer for long sounds. Does not support random access.