示例#1
0
 private void freeResources()
 {
     lock (lockObject) {
         if (stopNow)                 // If explicitly stopped, freeResources has already been called.
         {
             return;
         }
         stopNow   = true;
         fileNames = null;
         SecondarySoundBuffer s = null;
         foreach (SecondarySoundBuffer buffer in soundBuffers)
         {
             s = buffer;
             DSound.unloadSound(ref s);
         }
     }
 }
示例#2
0
 //Will be called by ogg player thread when a file is done playing.
 //This event sets the play flag to false.
 //Only then can the program assume the file is done playing,
 //since this flag is unset last and it means
 //all resources have been cleaned up and nothing is lost.
 public void stopEventHandler()
 {
     stoppedSignal.WaitOne();
     if (!stopNow)
     {
         if (playPointer < fileNames.Length - 1)
         {
             SecondarySoundBuffer s = soundBuffers[playPointer];
             DSound.unloadSound(ref s);
             playPointer++;
             play(loop);
         }
         if (!loop)                 // If the file is explicitly stopped, the stopOgg method will call free resources so we don't have to do it here; instead, this is the case when the file is done playing naturally, so stopOgg might never be called.
         {
             freeResources();
         }
     }
 }