ppy / osu-framework

A game framework written with osu! in mind.
MIT License
1.67k stars 419 forks source link

Fix SampleChannelBass reporting wrong state #6401

Open hwsmm opened 1 month ago

hwsmm commented 1 month ago

This PR fixes SampleChannelBass reporting wrong state.

Do not merge this yet. What should we do for looping samples? Stop no longer makes IsAlive false, but looping sample will be a zombie because it doesn't end. Should we make SampleChannels not resumable?

smoogipoo commented 1 week ago

Should we make SampleChannels not resumable?

How about we add a bool ManualFree { get; set; } to the interface? Opposite of BASS' auto-free because interfaces can't have default values (we really should be doing sample.GetChannel(new ChannelProperties { ... }) or similar, but...).

And then, every other case should auto-free when playback ends or Stop() is called.

I believe everywhere in osu! we operate under the assumption that channels are auto-freeing by default as I believe that's effectively how they work in BASS when they're HCHANNELs, so this could be considered a regression from when mixers were added (and they were made into HSTREAMs).

hwsmm commented 4 days ago

I think adding ManualFree flag is unnecessary as it's only relevant when Looping is true. Adding a comment about this may be helpful?

When Looping is false, SampleChannel is automatically disposed once playback ends, but when Looping is true, you're responsible for disposing this channel manually, as the framework can't detect its end.

smoogipoo commented 1 day ago

So what happens when the channel is played, manually stopped, and the ISample is just left to live (as we never dispose samples in game)? It sounds like in this case samples would never be disposed, no?

hwsmm commented 1 day ago

That's right. I'll live until it gets disposed somehow.

I think there is a misunderstanding about ManualFree. Do you want channels to be unable to resume playback once it is stopped when ManualFree is false?

I first assumed that you don't want such behavior, but I guess I misread your comment.

I'm okay with that if that's what you mean.