feliwir / feliwir/SharpAudio

Null Reference Exception Playing SoundStream

Open
#22 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
194
Forks
20
PR merge metrics
No merged PRs in 30d

Description

```
private bool doEmitSound(PlaySFX req, GameState state, Instant instant)
{
if (!allowSFX)
return true;
state.Messages.EmitMsg(new ConsoleInput($"Playing {req.Resource}"));
if (!soundboard.ContainsKey(req.Resource))
soundboard.Add(req.Resource, new SoundStream(AssetManager.FindFileStream(req.Resource), sfxEngine));
soundboard[req.Resource].Volume = (currentVolume * req.Volume);//Should be at most 1*1.
soundboard[req.Resource].Play();
return true;
}
```

This code plays the sound as expected the first time, but fails with a null reference exception when the volume property is modified or the play method is called. the second time regardless of being a new SoundStream or an existing SoundStream.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.