Search This Blog

Monday, April 28, 2014

NFS And XBMC Gotham on Windows - replacement libnfs.dll

Ok, so there was a bit of a saga with libnfs and Windows leading up to the release of XBMC Gotham.  Major issues with libnfs meant that your entire library could get dropped by XBMC when running 'clean library' due to, basically, stale sockets.

You can read about it in painful detail in that thread, but suffice it to say eventually XBMC developer Memphiz and I found a fix.

It's really a two part fix - one part XBMC code, fixed in Gotham beta 4 and on, and one part a fix in libnfs itself.  The libnfs fix does not seem essential, and has not actually made it in to XBMC Gotham.

In theory, errors might just occasionally occur with XBMC (resulting in files being dropped from your library), when using specifically Windows and NFS, and to that end here is a replacement libnfs.dll that I personally recommend you but in your

C:\WHERE_YOU_PUT_IT\Gotham\XBMC\system

..folder.

Replacement libnfs.dll for XBMC Gotham on Windows


Sunday, February 23, 2014

XBMC, Windows, Boblight, and the Woodenshark USB Lightpack

For along time I've seen groovy videos of ambilight systems making people's TV's dance with colour.  You can see a video of the results of all that follows here: http://lightpack.tv/


(and maybe buy your own lightpack!).

The idea is that it's
  • Cool
  • Gives an illusion of your TV being bigger
  • Increases the apparent contrast of the actual screen
  • Reduces eye fatigue as a whole
Well, that's the theory but it's that first point that's the main thing!

Never seen it - there are plenty of youtube videos etc (search for ambilight which is the original Phillips branded system).

Most open source implementations of this futz around with arduinos or Raspberry Pis to control the lights,  and you can buy LED strinps and wire them up to pins etc.  Sounds like a lot of hassle to me, and a waste of machine - why bother with a Pi/arduino as a controller, it's just another device needing power etc, and it should be trivially easy to get a PC to control one of these things.

Then, Woodenshark did a successful Kickstarter project to bring an easy solution to this problem and the result is here: http://lightpack.tv/ - a USB based LED light strip system.  So, I ordered one (about AU $100).  One lightpack works well for TVs up to 50" but you can get more than one and run them together.

Now, the general idea is to drive this thing with some software called Prismatik - latest releases here: https://github.com/Atarity/Lightpack/releases

But - this software does not work so well, and especially with XBMC.  It's got a lot of bugs - you need to disable Aero to get even vaguely decent performance (which you should probably have turned off anyway - who needs aero on an XBMC box?) - but it also doesn't detect what aspect ratio XBMC is playing in etc.  Basically I tried this out and even after a fair amount of config. work it was still slow and not doing what I wanted.

Now, the standard way of controlling these lightpacks in xbmc environments is via the boblight addon.  This little python addon takes care of all the XBMC stuff - detects what you are playing (movie, tvshow, music video etc) - works out the aspect ratio, and then grabs the right colour numbers from the screen to send them out to the lightpack (via a program called boblightd) which in turn triggers the LEDs to light up all at 60 frames a second.

So the XBMC addon talks to a little controller program - boblightd, a daemon (server) that listens to a port, and accepts control signals to send on to the lightpack LEDs.  Like most of these things, it's developed under Linux/unix.  It's not so easy/obvious how to get it going with Windows, but it is possible.  So normally you would still have boblightd running on some sort of micro-controller I guess, but again I wanted to avoid the extra machine.

So - I knew lightpack support had been added to boblightd, but I could not find a working Windows version.  The main xbmc/windows/boblight thread (here) - has a note from uncleted that said:
I switched the Lightpack driver to WinUSB using Zadig and commented out the libusb_detach_kernel_driver call from lightpack device code. It works for me now without crashing. Not sure if WinUSB is really required so I'll have a bit more of a play to find out.

So this is what we're going to do to get it working.

Here's what uncleted worked out and I did in case anyone wants to repeat:
  1. Install cygwin including development, opengl, usb
  2. SVN the boblightd source from:

    svn checkout http://boblight.googlecode.com/svn/trunk/ boblight-read-only
  3. Comment out the offending code block which makes it crash (it's not needed on Windows/Darwin): - lines 100 to 103 of devicelightpack.cpp:

            if ((error=libusb_detach_kernel_driver(devhandle, LIGHTPACK_INTERFACE)) != LIBUSB_SUCCESS) {
              LogError("%s: error detaching interface %i, error:%i %s", m_name.c_str(), LIGHTPACK_INTERFACE, error, UsbErrorName(error));
              return false;
            }

  4. Configure it:

    ./configure --without-portaudio --without-opengl --without-x11
  5. And then make; make install
     
  6. Grab the resulting binary boblightd.exe from \cygwin\usr\local\bin
 But, I have done this for you.  You also need a conf file for your lightpack. I've included a basic one for a sinlge lightpack mounted to a TV using the Andromeda pattern.

All of this you can grab here. - has the boblightd.exe, the conf file, and a few required cygwin dlls.

Unzip all of these into a folder on your htpc called:

c:\boblightd\

Now, one more necessary step - you must change the lightpack's USB driver to a more unix style friendly.  This will mean it no longer works with prismatik (presumably you can restore the older driver if you need this, but don't worry - if you're just using this thing with XBMC, change the driver and away you go).

To do this just download Zadig.  Run this (say yes when it wants to elevate to admin) - and tell it to show you all devices (in the menus) - then choose lightpack and tell it to replace the driver with the latest (included) WinUSB.  Done - not even a reboot (you should hear the device beeps as this happens, and you should now have a device in Device Manager -> Universal Serial Bus *Devices* -> Lightpack.

You'll want to run boblightd at startup before XBMC starts:

c:\boblightd\boblightd.exe -c c:\boblightd\boblight.conf -f

Finally, install and configure the xbmc boblight service addon - you don't need to change any ports/addresses since you're running it locally on the standard port. I set it all to 'fast' mode initially so it reacts quickly.

IMPORTANT NOTE : THIS BOBLIGHTD DOES NOT SEEM TO WORK CONSISTENTLY IF YOU PLUG THE LIGHTPACK INTO SOME USB3 PORTS (well, for me anyway) - use USB 2!!

If you're having issues, run boblightd as above from the command line (without the -f) ... and see what it says.

I have created an issue for boblightd here and presumably they will fix this up:
http://code.google.com/p/boblight/issues/detail?id=79

So to sum up, to get it going (one lightpack) - you need to:
  1. Grab the pre-compiled files
  2. Unzip all to c:\boblightd
  3.  Replace the lightpack USB driver using Zadig to WinUSB
  4. Run boblightd at startup as above
  5. Plug your lightpack into a USB2 port
  6. Install and configure the XBMC boblight service addon
...that's it!