Jump to content
  • Advertisement
Sign in to follow this  
Grain

DynamicSoundEffectInstance.BufferNeeded event not firing

This topic is 654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I start create my Speaker and feed it data it seems to only play the first buffer. The method that feeds in buffers first checks needbuffers flag and just returns and does nothing if it's false. My setneedbuffers event handler is never called (I set a break point in it) and needbuffers flag never gets set back to true.

 

If I pause execution and check the state of DynSoundInst it's still set to "playing". DynamicSoundEffectInstance is suposed to stop playback if its starved of data, but that's not the case here.

    public class Speaker_XNA : Speaker
    {
        DynamicSoundEffectInstance DynSoundInst;
        bool needbuffers = true;
        short bitspersample;

        public Speaker_XNA(short BitsPerSample, short Channels, int SamplesPerSecond)
        {
            FrameworkDispatcher.Update();
            DynSoundInst = new DynamicSoundEffectInstance(SamplesPerSecond, (AudioChannels)Channels);
            bitspersample = BitsPerSample;
            DynSoundInst.BufferNeeded += setneedbuffers;

        }
        private void setneedbuffers(object sender, EventArgs e)
        {
            needbuffers = true;
        }
...
}

Share this post


Link to post
Share on other sites
Advertisement

I have ran into the same problem with MonoGame recently: the BufferNeeded event is not firing. I took a look at the current MG sourcecode but unfortunately I haven't been able to track down the cause yet.

The only thing I found related to your question was an issue related to FNA:

 

https://github.com/flibitijibibo/FNA-MGHistory/issues/320

 

According to this DynamicSoundEffenctInstance never changes its state back to SoundState.Stopped unless Stop() is called. 

If it runs out of data, it will be still playing if it is fed with buffers again, however I wasn't able to do it without the BufferNeeded event. The PendingBufferCount property could be used but I would prefer to avoid polling it continuously.

 

Have you found the casue? Anyone else has any ideas?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!