Skip to content

Commit 01f1f49

Browse files
author
Algorithman
committed
Win10 Crash Debug and maybe already fix?
1 parent c3a1789 commit 01f1f49

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

SoundCenSe GTK/SoundCenSeGTK/Output/fmodChannelPool.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using Misc;
5+
using NLog;
56

67
namespace 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
}

0 commit comments

Comments
 (0)