@@ -165,9 +165,8 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
165165 dd->printf (" Speech: %s " , (isOn (AudioAffect_Speech) ? " Yes" : " No" ));
166166 dd->printf (" Music: %s\n " , (isOn (AudioAffect_Music) ? " Yes" : " No" ));
167167 dd->printf (" Channels Available: " );
168- dd->printf (" %d Sounds " , m_sound->getAvailableSamples ());
169-
170- dd->printf (" %d(%d) 3D Sounds\n " , m_sound->getAvailable3DSamples (), m_available3DSamples.size () );
168+ dd->printf (" %u Sounds " , getNumAvailable2DSamples ());
169+ dd->printf (" %u 3D Sounds\n " , getNumAvailable3DSamples ());
171170 dd->printf (" Volume: " );
172171 dd->printf (" Sound: %d " , REAL_TO_INT (m_soundVolume * 100 .0f ));
173172 dd->printf (" 3DSound: %d " , REAL_TO_INT (m_sound3DVolume * 100 .0f ));
@@ -196,8 +195,8 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
196195 fprintf ( fp, " Speech: %s " , (isOn (AudioAffect_Speech) ? " Yes" : " No" ) );
197196 fprintf ( fp, " Music: %s\n " , (isOn (AudioAffect_Music) ? " Yes" : " No" ) );
198197 fprintf ( fp, " Channels Available: " );
199- fprintf ( fp, " %d Sounds " , m_sound-> getAvailableSamples () );
200- fprintf ( fp, " %d 3D Sounds\n " , m_sound-> getAvailable3DSamples () );
198+ fprintf ( fp, " %u Sounds " , getNumAvailable2DSamples () );
199+ fprintf ( fp, " %u 3D Sounds\n " , getNumAvailable3DSamples () );
201200 fprintf ( fp, " Volume: " );
202201 fprintf ( fp, " Sound: %d " , REAL_TO_INT (m_soundVolume * 100 .0f ) );
203202 fprintf ( fp, " 3DSound: %d " , REAL_TO_INT (m_sound3DVolume * 100 .0f ) );
@@ -715,7 +714,7 @@ void MilesAudioManager::playAudioEvent( AudioRequest* req )
715714 H3DSAMPLE sample3D;
716715 if ( !handleToKill || foundSoundToReplace )
717716 {
718- sample3D = getFirst3DSample ( event );
717+ sample3D = getAvailable3DSample ( event );
719718 if ( !sample3D )
720719 {
721720 // If we don't have an available sample, kill the lowest priority assuming we have one that is lower
@@ -724,7 +723,7 @@ void MilesAudioManager::playAudioEvent( AudioRequest* req )
724723 // in which case we need to attempt to find another sound to kill.
725724 if ( killLowestPrioritySoundImmediately ( event ) )
726725 {
727- sample3D = getFirst3DSample ( event );
726+ sample3D = getAvailable3DSample ( event );
728727 }
729728 }
730729 }
@@ -740,7 +739,6 @@ void MilesAudioManager::playAudioEvent( AudioRequest* req )
740739
741740 if (sample3D) {
742741 audio->m_file = playSample3D (event, sample3D);
743- m_sound->notifyOf3DSampleStart ();
744742 }
745743
746744 if ( !audio->m_file )
@@ -781,7 +779,7 @@ void MilesAudioManager::playAudioEvent( AudioRequest* req )
781779 HSAMPLE sample;
782780 if ( !handleToKill || foundSoundToReplace )
783781 {
784- sample = getFirst2DSample (event);
782+ sample = getAvailable2DSample (event);
785783 if ( !sample )
786784 {
787785 // If we don't have an available sample, kill the lowest priority assuming we have one that is lower
@@ -790,7 +788,7 @@ void MilesAudioManager::playAudioEvent( AudioRequest* req )
790788 // in which case we need to attempt to find another sound to kill.
791789 if ( killLowestPrioritySoundImmediately ( event ) )
792790 {
793- sample = getFirst2DSample ( event );
791+ sample = getAvailable2DSample ( event );
794792 }
795793 }
796794 }
@@ -807,7 +805,6 @@ void MilesAudioManager::playAudioEvent( AudioRequest* req )
807805
808806 if (sample) {
809807 audio->m_file = playSample (event, sample);
810- m_sound->notifyOf2DSampleStart ();
811808 }
812809
813810 if (!audio->m_file ) {
@@ -1042,17 +1039,6 @@ void MilesAudioManager::stopPlayingAudio( PlayingAudio *release )
10421039 if (prevStatus != PS_Stopping) {
10431040 return ;
10441041 }
1045- if (release->m_audioEventRTS ->getAudioEventInfo ()->m_soundType == AT_SoundEffect) {
1046- if (release->m_type == PAT_Sample) {
1047- if (release->m_sample ) {
1048- m_sound->notifyOf2DSampleCompletion ();
1049- }
1050- } else {
1051- if (release->m_3DSample ) {
1052- m_sound->notifyOf3DSampleCompletion ();
1053- }
1054- }
1055- }
10561042 releaseMilesHandles (release);
10571043}
10581044
@@ -1175,48 +1161,47 @@ void MilesAudioManager::freeAllMilesHandles()
11751161 stopAllAudioImmediately ();
11761162
11771163 // Walks through the available 2-D and 3-D handles and releases them
1178- std::list<HSAMPLE >::iterator it;
1179- for ( it = m_availableSamples.begin (); it != m_availableSamples.end (); ) {
1180- HSAMPLE sample = *it;
1181- AIL_release_sample_handle (sample);
1182- it = m_availableSamples.erase (it);
1164+ std::vector<HSAMPLE >::iterator it;
1165+ for ( it = m_availableSamples.begin (); it != m_availableSamples.end (); ++it ) {
1166+ AIL_release_sample_handle (*it);
11831167 }
1168+
1169+ m_availableSamples.clear ();
11841170 m_num2DSamples = 0 ;
11851171
1186- std::list<H3DSAMPLE >::iterator it3D;
1187- for ( it3D = m_available3DSamples.begin (); it3D != m_available3DSamples.end (); ) {
1188- H3DSAMPLE sample3D = *it3D;
1189- AIL_release_3D_sample_handle (sample3D);
1190- it3D = m_available3DSamples.erase (it3D);
1172+ std::vector<H3DSAMPLE >::iterator it3D;
1173+ for ( it3D = m_available3DSamples.begin (); it3D != m_available3DSamples.end (); ++it3D ) {
1174+ AIL_release_3D_sample_handle (*it3D);
11911175 }
1176+
1177+ m_available3DSamples.clear ();
11921178 m_num3DSamples = 0 ;
11931179 m_numStreams = 0 ;
11941180}
11951181
11961182// -------------------------------------------------------------------------------------------------
1197- HSAMPLE MilesAudioManager::getFirst2DSample ( AudioEventRTS *event )
1183+ HSAMPLE MilesAudioManager::getAvailable2DSample ( AudioEventRTS *event )
11981184{
1199- if (m_availableSamples. begin () != m_availableSamples.end ()) {
1200- HSAMPLE retSample = * m_availableSamples.begin ();
1201- m_availableSamples.erase (m_availableSamples. begin () );
1202- return ( retSample) ;
1185+ if (! m_availableSamples.empty ()) {
1186+ HSAMPLE retSample = m_availableSamples.back ();
1187+ m_availableSamples.pop_back ( );
1188+ return retSample;
12031189 }
12041190
1205- // Find the first sample of lower priority than my augmented priority that is interruptable and take its handle
1206-
1191+ // Find the first sample of lower priority than my augmented priority that is interruptible and take its handle
12071192 return nullptr ;
12081193}
12091194
12101195// -------------------------------------------------------------------------------------------------
1211- H3DSAMPLE MilesAudioManager::getFirst3DSample ( AudioEventRTS *event )
1196+ H3DSAMPLE MilesAudioManager::getAvailable3DSample ( AudioEventRTS *event )
12121197{
1213- if (m_available3DSamples. begin () != m_available3DSamples.end ()) {
1214- H3DSAMPLE retSample = * m_available3DSamples.begin ();
1215- m_available3DSamples.erase (m_available3DSamples. begin () );
1216- return ( retSample) ;
1198+ if (! m_available3DSamples.empty ()) {
1199+ H3DSAMPLE retSample = m_available3DSamples.back ();
1200+ m_available3DSamples.pop_back ( );
1201+ return retSample;
12171202 }
12181203
1219- // Find the first sample of lower priority than my augmented priority that is interruptable and take its handle
1204+ // Find the first sample of lower priority than my augmented priority that is interruptible and take its handle
12201205 return nullptr ;
12211206}
12221207
@@ -1755,6 +1740,18 @@ UnsignedInt MilesAudioManager::getNumStreams() const
17551740 return m_numStreams;
17561741}
17571742
1743+ // -------------------------------------------------------------------------------------------------
1744+ UnsignedInt MilesAudioManager::getNumAvailable2DSamples () const
1745+ {
1746+ return (UnsignedInt)m_availableSamples.size ();
1747+ }
1748+
1749+ // -------------------------------------------------------------------------------------------------
1750+ UnsignedInt MilesAudioManager::getNumAvailable3DSamples () const
1751+ {
1752+ return (UnsignedInt)m_available3DSamples.size ();
1753+ }
1754+
17581755// -------------------------------------------------------------------------------------------------
17591756Bool MilesAudioManager::doesViolateLimit ( AudioEventRTS *event ) const
17601757{
@@ -2769,6 +2766,9 @@ void MilesAudioManager::initSamplePools()
27692766 return ;
27702767 }
27712768
2769+ m_availableSamples.reserve (getAudioSettings ()->m_sampleCount2D );
2770+ m_available3DSamples.reserve (getAudioSettings ()->m_sampleCount3D );
2771+
27722772 int i = 0 ;
27732773 for (i = 0 ; i < getAudioSettings ()->m_sampleCount2D ; ++i) {
27742774 HSAMPLE sample = AIL_allocate_sample_handle (m_digitalHandle);
@@ -2825,7 +2825,7 @@ void *MilesAudioManager::getHandleForBink()
28252825 PlayingAudio *aud = allocatePlayingAudio ();
28262826 aud->m_audioEventRTS = NEW AudioEventRTS (" BinkHandle" ); // poolify
28272827 getInfoForAudioEvent (aud->m_audioEventRTS );
2828- aud->m_sample = getFirst2DSample (aud->m_audioEventRTS );
2828+ aud->m_sample = getAvailable2DSample (aud->m_audioEventRTS );
28292829 aud->m_type = PAT_Sample;
28302830
28312831 if (!aud->m_sample ) {
0 commit comments