Cannot delete/move a sound file after loading

Hello,
I am having trouble with deleting a sound file after loading it to my Panda3D application through the loader.loadSfx. Since Panda3D is streaming the sound, the os cannot delete the file. I have read some forums and find a solution by preloading the sound, so no streaming. However, I am afraid that this solution will take up too much RAM when I start using many sounds.

Is there any way to load/get the sound from the AudioManager by streaming but while deleting/removing the sound file, stop the stream?

The code I started with:

sound = loader.loadSfx(soundFilepath)

The solution with pre-load:

sound = self.audioObj = base.sfxManagerList[0].getSound(soundfilepath, 0, AudioManager.SMSample)

Thank you in advance,
Zeina

In principle, if you delete all references to a sound object, it is supposed to be released by the sound manager and the file should be closed.

So, in practice, this means you must stop the sound, and assign all Python variables that stored the sound object to None or some other value.

David

I see. By any chance, do you know where these references are being hold?

I have tried these two codes below, however the file is still being hold by Panda. I am checking the locks on the sound file by a program called Unlocker and eclipse debugger. Before these lines, Panda has no control/lock over the sound file.

Code 1:

self.audioObj = loader.loadSfx(soundFilepath)
self.audioObj = None

Code 2:

self.audioObj = loader.loadSfx(soundFilepath)
del self.audioObj
self.audioObj = None

Zeina

use self.audioObj.Play() to play the sound and if you don’t need the sound any more use self.audioObj.Stop().

thanks

Yedhu

Hmm, are using FMod or OpenAL as your sound interface? Try switching to the other one. Does it give the same behavior?

After casually looking through the code in Panda, I don’t see where Panda could be holding a file open beyond the Python lifetime of the sound object, so right now I’m mystified.

David