I’ve been evaluating FMOD for use with some C# applications and I’m getting into some unstable situations which are rather concerning. I’ve been able to reduce my code to that which follows. The code as well as a binary are available at http://www.communikey.us/fmod/. I have run the binary on 3 machines (Windows XP, .NET 2.0 sp 1) and it fails every time. You will notice there are comments in the code that say things like ‘comment this and it works’, ‘uncomment this and it works’. Give it a try. Some of these are not what you would expect from a stable platform. Additionally, I have tested this on version 4.6.9 as well as 4.7.13 with the same failed results. The code at the URL provided was compiled with 4.6.9. Please let me know if I am doing something wrong, or overlooking something. I have spent quite some time with this code, changing it, comparing it to the examples, rewriting it and reducing it to what it is now so that it fails in a non-intermittent fashion.

The Error:

[code:ffu1nc3k]Attempted to read or write protected memory. This is often an indication that ot
her memory is corrupt.
at FMOD.System.FMOD_System_Update(IntPtr system)
at FMOD.System.update() in C:\rick\dev\fmod_test_csharp\ChannelCallbackFailur
e\ChannelCallbackFailure\fmod.cs:line 1622
at ChannelCallbackFailure.Player.Init() in C:\rick\dev\fmod_test_csharp\Chann
elCallbackFailure\ChannelCallbackFailure\Player.cs:line 59[/code:ffu1nc3k]

The code:

[code:ffu1nc3k]
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

I usually get an error like this when I’m doing something multi-threaded and start crossing threads with fmod or try to use fmod in a thread I didn’t create the system object in (which has always been the UI thread, which may or may not apply).

As you can see here, I’ve included the Main. As such, I should mention that this is the entire program right here; no UI, no timer, single threaded, no events, etc.; just a simple stripped down console program to explore this exception.

[code:3ap2tdwe]Attempted to read or write protected memory. This is often an indication that other memory is corrupt. [/code:3ap2tdwe]

error message sometimes when I try to read tags from a file and on very rare occasions when I try to reload a MP3 file that I unloaded previously. Rebooting the computer usually stops the error from reoccurring, but it’s still slightly worrying.

FMOD does it’s own internal channel memory management, so it’s not needed. Regardless, the logic you are using does not make sense. you are testing then setting the channel to null inside code belonging to the channel.