diff AudioPlayer.cpp @ 390:35a62d1948d4

More sound fixes
author Nomad
date Sat, 23 Feb 2013 08:27:32 +0200
parents d95a91011d57
children 74205b91647b 747933903b1c
line wrap: on
line diff
--- a/AudioPlayer.cpp	Sat Feb 23 04:02:05 2013 +0200
+++ b/AudioPlayer.cpp	Sat Feb 23 08:27:32 2013 +0200
@@ -976,7 +976,6 @@
       auto channel = &pMixerChannels[v62];
       AIL_init_sample(channel->hSample);
       AIL_set_sample_file(channel->hSample, (char *)pSoundList->pSounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1);
-      int s = AIL_sample_status(channel->hSample);
       if (uVolume)
         sample_volume = uVolume;
       AIL_set_sample_volume(channel->hSample, sample_volume);
@@ -1620,13 +1619,19 @@
   {
     auto channel = pMixerChannels + i;
 
-    AIL_end_sample(channel->hSample);
-    _4ABE55(channel);
+    if (AIL_sample_status(channel->hSample) == AIL::Sample::Done)
+    {
+      AIL_end_sample(channel->hSample);
+      _4ABE55(channel);
+    }
   }
 
   for (uint i = 0; i < uMixerChannels; ++i)
   {
     auto channel = pMixerChannels + i;
+    if (channel->source_pid <= 0)
+      continue;
+
     int source_type = channel->source_pid & 7,
         source_id = channel->source_pid >> 3;
     int source_x,
@@ -2220,8 +2225,9 @@
 
   v2 = 0;
   //v3 = this;
-  if ( pSoundList->pSounds )
-  {
+  if (!pSoundList->pSounds)
+    return;
+ 
     v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx];
     if ( v4->eType == SOUND_DESC_SWAP)
     {
@@ -2270,7 +2276,6 @@
         }
       }
     }
-  }
 }