Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I am using irrKlang 1.4.0 in a .Net 4.0 C Sharp application for both playing MP3 audio and for accessing the raw PCM audio data of MP3s so that I can detect leading and trailing silence in the audio. I have encountered a strange problem when using the ISoundSource.SampleData property to access the PCM audio data. A System.AccessViolation exception is sometimes thrown when accessing that property. The exception info says: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt.". I was originally thinking that maybe my memory was bad so I ran memtest on my computer for hours with no errors and I eventually decided to buy new memory as a last resort but the error still occurs. Then more recently, I encountered the same exception on four other computers so I am confident that it is not a hardware problem. I tried to identify some sort of pattern to see if for example the exception occurred more frequently with small or large MP3 files or different bitrates but was unable to recognize a pattern. The code snippet below shows how I'm using irrKlang to access the PCM audio data. The bold line is where the exception occurs.
Oh yeah, my OS is Windows 7 Pro 64bit. Any help would be appreciated. Thanks, Brett |
||||
|
I think this only works if the sound is not streaming. (Which you apparently are doing). Also, this will only work as long as the sound source is existing. Are you maybe removing that sound source? Or maybe you are using some other threads and doing something with the sound in there? |
||||
|
Erik, I read at http://www.ambiera.com/forum.php... that the SampleData property could not be accessed when streaming is used. In that link, Niko suggested setting the ForcedStreamingThreshold to -1 so that is why I'm doing that. What makes you think that my code is using streaming? The sound source definitely exists. I'm not removing the sound source or accessing the ISoundEngine / ISoundSource from another thread. This shouldn't matter but I am using a Parallel.ForEach loop and the sample code executes in the body of that loop. Since each item that is being looped on is unique it shouldn't matter if they are done in parallel. I'm currently creating a new ISoundEngine for each loop iteration. Would it be better to have each iteration share one ISoundEngine instance? Thanks, Brett |
||||
|
Ah, I'm not that familiar with Parallel.ForEach, but this sounds like this is doing this in a new thread? irrKlang needs to be calles from the same thread it was created in. I guess this is simply your problem. |
|