FyroxEngine/Fyrox · warning
error while setting decoder position
Error message
error while setting decoder position
What it means
For streaming sound buffers, set_playback_time seeks the underlying decoder to the requested time. If the decoder cannot seek (time_seek returns Err), the position is not applied and a warning is logged; playback position tracking still continues from the clamped value.
Solutions
- Prefer loading the buffer as non-streaming (immutable) if seeking is required
- Check the audio file is valid and its decoder supports seek
- Clamp requested playback time within [0, duration] before building the source
- Downgrade severity expectations: playback continues from current decoder position
Example fix
// before let src = GenericSourceBuilder::new(buffer).with_play_time(desired_time).build()?; // after let time = desired_time.clamp(Duration::ZERO, buffer.duration()); let src = GenericSourceBuilder::new(buffer).with_play_time(time).build()?; // and consider non-streaming buffer if seek is essential
Defensive patterns
Strategy: validation
Validate before calling
let t = requested.clamp(Duration::ZERO, buffer.duration()); // prefer non-streaming buffer when seek support matters let buffer = SoundBuffer::from_file(path)?; // vs raw streaming
Type guard
fn seekable(b: &SoundBuffer) -> bool { !matches!(b, SoundBuffer::Streaming(_)) } Prevention
- Use non-streaming buffers when random access/seek is required
- Clamp playback time to [0, duration] before set_playback_time
- Verify audio files decode correctly with a standalone decoder
When it happens
Trigger: Calling GenericSourceBuilder::build with a play time, or set_playback_time, on a streaming buffer whose decoder does not support seeking to that offset (or seek fails for format reasons).
Common situations: Streaming compressed audio (OGG/MP3) with decoders lacking full seek support; requesting a time beyond/near the buffer duration in edge cases; malformed audio files.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10).
Data as JSON: /api/errors/a79446859f2f7a60.
Report an issue: GitHub.
Appendix: source
Thrown at fyrox-sound/src/source.rs:474
if let Some(buffer) = buffer.state().data() {
return Duration::from_secs_f64(self.playback_pos / (buffer.sample_rate() as f64));
}
}
Duration::from_secs(0)
}
/// Sets playback duration.
pub fn set_playback_time(&mut self, time: Duration) {
if let Some(buffer) = self.buffer.as_ref() {
if let Some(buffer) = buffer.state().data() {
if let SoundBuffer::Streaming(ref mut streaming) = *buffer {
// Make sure decoder is at right position.
if streaming
.time_seek(time.clamp(Duration::from_secs(0), streaming.duration()))
.is_err()
{
Log::warn("error while setting decoder position");
}
}
// Set absolute position first.
self.playback_pos = (time.as_secs_f64() * buffer.sample_rate as f64)
.clamp(0.0, buffer.duration().as_secs_f64());
// Then adjust buffer read position.
self.buf_read_pos = match *buffer {
SoundBuffer::Streaming(ref mut streaming) => {
// Make sure to load correct data into buffer from decoder.
streaming.read_next_block();
// Streaming sources has different buffer read position because
// buffer contains only small portion of data.
self.playback_pos % (StreamingBuffer::STREAM_SAMPLE_COUNT as f64)
}
SoundBuffer::Generic(_) => self.playback_pos,
};
assert!(
self.buf_read_pos * (buffer.channel_count() as f64)View on GitHub (pinned to 76c91aad8e)