Err spRemoveSound (SPSound *sound)
All sounds belonging to an SPPlayer are automatically disposed of when that SPPlayer is disposed of with spDeletePlayer()
. Use this function if you want to remove a sound manually.
For sound file class SPSounds, the file opened by spAddSoundFile()
is closed. The sample item passed into spAddSample()
is left behind after this spRemoveSound()
for the client to clean up.
An SPSound cannot be removed from its owning SPPlayer while it is being read from while the player is running. spIsSoundInUse()
can be used to determine if the sound is being read. If this function is called for an SPSound for which spIsSoundInUse()
returns TRUE, the SPPlayer is stopped by calling spStop()
.
If you remove a Sample Item class SPSound during that window of vulnerability and then delete the data for the Sample Item (e.g. UnloadSample()
), the SoundSpooler is then pointing to freed memory, whose contents may be clobbered by another task at any time. Unfortunately you may not hear bad results if you do this inadvertently because there's no guarantee that freed memory will get trashed (unless you are running a daemon to munge newly freed memory).
So, avoid removing Sample Item class SPSounds while the SPPlayer is playing. Or at least go to measures to insure that the Sample Item class SPSound you are removing is not in the spooler (e.g. it has never been played, or at least not since the last spStop()
).
spAddMarker
(), spAddSoundFile(), spRemoveMarker(), spDeletePlayer(), spIsSoundInUse()