Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
AccessViolationException

bjt32185
Registered User
Quote
2012-10-13 17:09:26

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.

string songPath = "someSong.mp3";
using (ISoundEngine engine = new ISoundEngine())
{
using (ISoundSource soundSource = engine.AddSoundSourceFromFile(songPath, StreamMode.NoStreaming, false))
{
soundSource.ForcedStreamingThreshold = -1;

if (soundSource.SampleData != null)
{
...
}
}
}

Oh yeah, my OS is Windows 7 Pro 64bit.

Any help would be appreciated.

Thanks,
Brett


erik
Registered User
Quote
2012-10-14 21:52:22

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?


bjt32185
Registered User
Quote
2013-01-01 15:48:15

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


erik
Registered User
Quote
2013-01-02 10:30:32

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.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Intern?tional" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact