garrysmod-issues
garrysmod-issues copied to clipboard
IGModAudioChannel Stop() also deletes object
As of #278 Stop() simply kills the entire channel, this however should be up to __GC() to do.
the BASS instance can be destroyed but shouldn't affect the lua instance, since this behavior makes playing streams more complicated. (As you'd need to check for IsValid more often and then re-create the instance after each Stop() call)
If you use Pause() on a stream it'll just de-sync and will be behind for as long as it's paused, this is undesired behavior most of the time.
Solutions:
- Handle Stop() differently, keeping the lua instance until actually destroyed trough __GC(), so that Play recreates the BASS instance and plays again... (recommended)
- Make Pause() watch out for streams and give a hint to Play() to re-fetch the stream before playing again (as optional arument to keep both worlds happy)
- Restore Stop()'s old behavior and add a Kill() / Destroy() function to take over the new behavior (not recommended as this messes with people expecting above behavior from Stop() by now)
It is kind off intended. I wrote the developers about using __GC() properly before, but they don't like it much. They use Stop() as a replacement for it. They want you to be able to do this: sound.PlayURL("http://inter.net/somesound.mp3") without having to care about the callback or its channel object.
Hi. In order to avoid compatibility problems with older addons, the third solution is of course the best one.
The new Stop()
behavior can be bound in Lua as IGModAudioChannel:Remove()
, that is a good idea.
To substitude the old behavior, I suggest that IGModAudioChannel:Stop()
should do IGModAudioChannel:Pause()
then IGModAudioChannel:SetTime( 0 )
. It even works well for block-streamed sounds, so I think it should be safe.
Bump #2977 Added warning to wiki.
It's been two years, any hope for a fix? CSoundPatch is even buggier than the newer IGModAudioChannel so this is all we have for decent audio playback.
Seems Stop() also causes the IsValid() function to become nil?
https://github.com/thegrb93/StarfallEx/pull/1252