Pesquisa personalizada

2014/04/08

paslibvlc VLC Library interface - PasLibVlcUnit.pas - my 1/2 cents

I'm working using the library paslibvlc - a pascal interface for VideoLAN libvlc/libvlccore DLL. I'm happy to find it. It's better than libvlc.pas from Lazarus/FPC, is mature, works fine and it works on Lazarus and Delphi.

While implementing a class to handle VLM broadcast, I did three changes to paslibvlc:
1) I found that PasLibVlcUnit.pas missed libvlc_vlm_set_enabled - it isn't being (dynamically) bound to the DLL  function. So I added it to be initialized also:

  if not libvlc_dll_get_proc_addr(@libvlc_vlm_set_enabled,
    'libvlc_vlm_set_enabled') then exit;
2) Also, I changed that unit to clear all pointers/variables as needed.
3) Not really related to that good library, but the problem was very hard to understand and easy to fix, it a hardware float point exception (to be honest, the problem raises in MMX, but as MMX also uses registers from the float point coprocessor, the context is shared also) that VLM throws while playing some Windows Media Format. The fix is too easy, just set the float point mask before add each media to VLM - I did it before calling libvlc_vlm_add_broadcast.
The bug always happens after add a second stream. Anyway I have to handle several of them, including from unknown sources, without raising fatal exceptions to the application. So it is important to mitigate any exception before it can be propagated.
To fix it, just run the following statement before add the stream to the VLM:
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,exOverflow, exUnderflow, exPrecision]);

The changed PasLibVlcUnit.pas unit can be downloaded here if you think it will be useful.

I implemented a class to handle VLM broadcasting, but my code is too far from that one clean and good code from PasLibVlcUnit. Said it, I can agree that it is working as expected (well, fine...). If anybody want it, just ask me. I implemented it because I didn't find any implementation to the VLM functions, like, eg.: libvlc_vlm_xxxxx

My thanks to Robert Jêdrzejczyk  for bring us its library and maintaining it.