I want to use the original function ov_open_callbacks to getting a streamed Ogg loader in my OpenAL module.
Here is the test case:
Returns me an "Unhandled Memory Exception Error"
But wat is wrong? OggFile or is there no way for Callbacks?
cu olli
Here is the test case:
SuperStrict Framework Pub.OggVorbis Import BRL.FileSystem Const NOTOPEN : Int = 0 Const PARTOPEN : Int = 1 Const OPENED : Int = 2 Const STREAMSET : Int = 3 Const INITSET : Int = 4 Const SEEK_SET : Int = 0 Const SEEK_CUR : Int = 1 Const SEEK_END : Int = 2 Type ov_callbacks Field read_func : Byte Ptr Field seek_func : Byte Ptr Field close_func : Byte Ptr Field tell_func : Byte Ptr End Type Extern Function ov_clear:Int(vf:Byte Ptr) Function ov_open_callbacks:Int(datasource:Byte Ptr, vf:Byte Ptr, .. initial:Byte Ptr, ibytes:Long, callbacks:Byte Ptr) End Extern Global Stream : TStream, .. Callbacks : ov_callbacks, .. OggFile : Byte Ptr Stream = ReadStream("Test.ogg") If Not Stream Then Throw("Unable to open ogg file") Callbacks = New ov_callbacks Callbacks.read_func = VorbisRead Callbacks.seek_func = VorbisSeek Callbacks.close_func = VorbisClose Callbacks.tell_func = VorbisTell OggFile = MemAlloc(1024*1024) If Not ov_open_callbacks(Stream, OggFile, Null, 0, Callbacks) = 0 Then .. Throw("Unable to open ogg file") Function VorbisRead:Int(Buffer:Byte Ptr, ByteSize:Int, Count:Int, Stream:TStream) DebugLog "read: " + ByteSize + " | " + Count Return Stream.Read(Buffer, ByteSize*Count)/ByteSize End Function Function VorbisSeek:Int(Stream:TStream, Offset:Long, Origin:Int) Local Success:Int DebugLog "seek: " + Offset + " | " + Origin Success = -1 Select Origin Case SEEK_SET Success = Stream.Seek(Offset) Case SEEK_CUR Success = Stream.Seek(Stream.Pos() + Offset) Case SEEK_END Success = Stream.Seek(Stream.Size() + Offset) End Select If Success = -1 Then Return -1 Return 0 End Function Function VorbisClose:Int(Stream:TStream) DebugLog "close" Stream.Close() End Function Function VorbisTell:Long(Stream:TStream) DebugLog "tell" Return Stream.Pos() End Function
Returns me an "Unhandled Memory Exception Error"
But wat is wrong? OggFile or is there no way for Callbacks?
cu olli