How to free music handle with B+?

BlitzPlus Forums/BlitzPlus Programming/How to free music handle with B+?

Grisu(Posted 2003) [#1]
I assign a backgroundmusic with:

musicchn=PlayMusic(MusicDir$+musicfiles(song_no))

When I need to change music I stop it and free up the memory used:

StopChannel musicchn
FreeSound musicchn

This works perfect with B3D 1.83, but with B+ the program crashes and I get the message "Invalide sound handle".

As there is nothing like "Freemusic" what can I do to make it work in B+ 1.35?

Notes:
- No, I can't use Loadsound as some formats are not supported!
- No, I can't just play new music files as the arising memory leak will crash the pc!

*looks helpless and waits for the enlightment*


soja(Posted 2003) [#2]
Are you sure PlayMusic does not stream the music from the device, therefore the only memory that is really allocated for it is the handle (which means you don't need to "free" anything)?

Remember that FreeSound is designated as a counterpart to LoadSound, not PlayMusic.

This makes sense to me, anyway. If you want to verify it, load up a memory usage watcher and see what happens when you do use the different commands.


Grisu(Posted 2003) [#3]
Ok, thanks soja. I just leave out the freesound command.

BTW: Does B+ load up the vid mem dynamically, it seemed so to me as the memory usage was not that constant as under B3D 1.83...


soja(Posted 2003) [#4]
I couldn't tell you off the top of my head... though I wouldn't be surprised, since the recent engine was written from scratch.


Grisu(Posted 2003) [#5]
The Power of Blitz...
I would think so cause the same code compiled with b3d has a more static memory consumption.

Anyway, I took out all freesounds and it works now! :)


Hotcakes(Posted 2003) [#6]
Yes, B+ has three ways of storing and managing gfx. As for the LoadMusic thing, obviously if you're using midis or modules their memory consumption would be quite large if you've loaded a few of them... So this is still a valid issue. I just assumed they would be cleared from mem when StopMusic is called.