This doesn’t always work though. Sometimes when user switches the sound being played, only a small beginning chunk of the audio file is played, or extreme stuttering happens. My only guess it is some cache and improper garbage collection mistake on my side.
It doesn’t happen always, more like once each 10 times, so testing that will be hard as I have no way to know if no issue with ogg means ogg works fine or I just haven’t encountered the random issue again with that format.
It’s an AAC channel from video files right now.
What I can say is, if it occurs, it stays there. By that I mean if I load another video/audio file, the stuttering is guaranteed to remain. Almost feels like something has to be done like unsync video to audio but it doesn’t happen, or some cache issue.
Well, if that’s the case, the sound won’t be cleared as long as it’s synchronized to a video. You would have to call unsynchronize() on the MovieTexture.
The audio manager does also keep a cache of loaded samples around for a while. You could try to call clearCache() on the audio manager to see if it makes a difference.
I feel like there are some bugs in the audio handling code of Panda.
I tried both suggestions.
So far to code for clearing the previous video file before loading the new one looks like this:
if texture != None:
texture.unsynchronize() # audio (if any) has to be unsyced
loader.unloadTexture(texture)
texture = None
sphere.clearTexture()
TexturePool.releaseAllTextures()
if sound != None:
sound.stop()
loader.unloadSfx(sound)
sound = None
base.sfxManagerList[0].clearCache()
This has given rise to the following issue, which again seems to happen randomly or hard to find any pattern:
I played one video file until the end until it started looping, then switched to the next video file, only first second or so of audio was heard, then nothing, and the same for every video file after that issue first happened. After a while videos started playing just the first second of their audio and looping that.