25 May '13 - 06:33 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: problem with BASS_StreamCreateFileUser  (Read 976 times)
newhero911
Posts: 7


« on: 19 May '09 - 09:12 »
Reply with quoteQuote

hi,
I'm now developing a software that playing flac and mp3 file over the internet. My software have an option that allow user can convert flac to mp3 and play that mp3. So I decide to use BASS_StreamCreateFileUser like this:
Quote
public static void Play(object state)
        {
            //resetEvent.WaitOne();
            BASS_FILEPROCS fileProcs = new BASS_FILEPROCS(null, null, new FILEREADPROC(FileReadProc), null);
            int stream = Bass.BASS_StreamCreateFileUser(BASSStreamSystem.STREAMFILE_BUFFERPUSH,
                BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN, fileProcs, IntPtr.Zero);

            Uri url = new Uri(state.ToString());
            playback = new Playback();
            playback.Play(stream);

            ...
}
but I get an error: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." when I try to call BASS_StreamCreateFileUser.
I don't understand  Huh. Could anyone help me about this?
Thank a lot.
Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #1 on: 20 May '09 - 15:03 »
Reply with quoteQuote

I don't use .Net myself, but from what I've seen, I guess that could be a "garbage collector" issue. You can find a section on that in the BASS.Net documentation.
Logged
radio42
Posts: 4012


« Reply #2 on: 20 May '09 - 15:16 »
Reply with quoteQuote

This is the same issue you already had with the encoder: see here http://www.un4seen.com/forum/?topic=9852.msg68623#msg68623

So again: please study the chapter about Interop and Callbacks in the BASS.NET help!

BASS_FILEPROCS fileProcs = new BASS_FILEPROCS(null, null, new FILEREADPROC(FileReadProc), null);
This is your problem - NEVER create callback delegates locally in a stack variable - as they will be collected by the GC once you leave the method!
ALWAYS create callback delegates on the heap by declaring them as local variables!
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines