File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed
SoundCenSe GTK/SoundCenSeGTK/Output Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change 22using System . Collections . Generic ;
33using System . Linq ;
44using Misc ;
5+ using NLog ;
56
67namespace SoundCenSeGTK
78{
@@ -10,6 +11,7 @@ public class FmodChannelPool
1011 #region Fields and Constants
1112
1213 private static FmodChannelPool instance ;
14+ public static readonly Logger logger = LogManager . GetCurrentClassLogger ( ) ;
1315
1416 private readonly Dictionary < KeyValuePair < int , string > , fmodChannelSound > channels =
1517 new Dictionary < KeyValuePair < int , string > , fmodChannelSound > ( ) ;
@@ -94,13 +96,33 @@ public void UnregisterChannel(fmodChannelSound channel)
9496
9597 public bool IsSoundPlaying ( string filename )
9698 {
97- foreach ( var sf in channels . Values )
99+ List < fmodChannelSound > channelsounds = null ;
100+ lock ( channels )
101+ {
102+ channelsounds = channels . Values . ToList ( ) ;
103+ }
104+ foreach ( var sf in channelsounds )
98105 {
99- if ( sf . SoundSoundFile . SoundFile . Filename == filename )
106+ if ( sf . SoundSoundFile != null )
107+ {
108+ if ( sf . SoundSoundFile . SoundFile != null )
109+ {
110+ if ( sf . SoundSoundFile . SoundFile . Filename == filename )
111+ {
112+ return true ;
113+ }
114+ }
115+ else
116+ {
117+ logger . Log ( LogLevel . Fatal , "sf.SoundSoundFile.SoundFile is NULL while looking for " + filename ) ;
118+ }
119+ }
120+ else
100121 {
101- return true ;
122+ logger . Log ( LogLevel . Fatal , "sf.SoundSoundFile is NULL while looking for " + filename ) ;
102123 }
103124 }
125+
104126 return false ;
105127 }
106128 }
You can’t perform that action at this time.
0 commit comments