[Mono-devel-list] Interop with Xine

Simon Ask Ulsnes simon at ulsnes.dk
Thu Dec 9 19:19:33 EST 2004


Hi!
I'm developing yet another music player app for Linux. It's a bit like 
Muine, but more minimalistic and l33t... :-)
The whole idea, and the reason I bothered making another audio player, 
is the concept of a "cut-the-crap" GUI without *anything* but a 
playlist, a search box and a search bar.
I'm planning on using the Xine engine (xinelib), because 1) it's a very 
easy API and 2) I don't have to do format recognition or have anything 
to do with I/O except for file names.

The binding library for xinelib is written in C++ (because I find it 
easier and more comprehensible than C - practically it makes no 
difference except I use cout instead of printf... I should probably 
rewrite it in C when I get around to it). Now, I have a small testing 
app for testing new functions I implement in the library (so that I'll 
know when the library part works properly).

The library includes an initialization function that intializes (duh...) 
the Xine engine and creates the necessary objects and streams and so on. 
It goes something like this:

engine = new XineEngine;    // a struct for holding the objects, nothing 
special - engine is static in the .cpp file of the library
engine->ao_driver = "auto";  // select audio output driver automatically
engine->xine = xine_new(); // create the xine object
xine_init(engine->xine);       // internal initialization of the xine 
object - xine_init is an API function
(... do some audio port opening and stream creating ...)

The thing is: My testing app runs initialization and creation and 
destruction of all objects just fine. But when I do *exactly* the same 
thing, same order, same parameters, from C# via Interop, I get this:

--- OUTPUT START ---
Initializing Engine (xine µ player)...
setting ao_driver...auto
creating xine object...
setting configfile...
loading config...
init'ing xine...

Unhandled Exception: System.NullReferenceException: Object reference not 
set to an instance of an object
in (unmanaged) (wrapper managed-to-native) Oiga.Xine:Init (string)
in <0x00004> (wrapper managed-to-native) Oiga.Xine:Init (string)
in <0x00017> Oiga.Xine:.ctor (string)
in <0x0005c> Oiga.MainApp:.ctor ()
in <0x0001b> Oiga.MainApp:Main (string[])

Segmentation Fault
--- OUTPUT END ---


What's that all about? No objects are being marshalled at all, since the 
Xine engine and the XineEngine struct containing the pointers only 
exists as a static object within unmanaged space. Any suggestions?

Oh, and one thing more: I took a peek in the Muine source, and as far as 
I could tell they do it exactly the same way as I do! Tell me if you 
need the source to say anything useful, I'll have to go to bed now.

Yours,
Simon Ask Ulsnes



More information about the Mono-devel-list mailing list