2009-11-28

XBMC over Jack (Revisited)

I updated my ubuntu to karmic (9.10) lately, which works great, though my hacked version of XBMC cannot compile, after some hacks, it compiles fine, though gave me segment fault when starting. So I decided to take some time to install the current version of XBMC and apply my jack patch on it.

This time I decide to use the version in PPA's karmic release instead the svn version (the previous one on svn was not very stable, crash now and then), first add xbmc and nvidia-vdpau repositories (xbmc depends on nvidia-190-libvdpau-dev, though I am still using 185 since the 190 version crash with tv-out, might goes to another post)
sudo add-apt-repository ppa:team-xbmc/ppa
sudo add-apt-repository ppa:nvidia-vdpau/ppa

You still need to add the source part into apt source list, (add-apt-repository can get the key for you, which is convenient, wish it can support an option to add the source part too). Add this line to /etc/apt/sources.list.d/team-xbmc-ppa-karmic.list

deb-src http://ppa.launchpad.net/team-xbmc/ppa/ubuntu karmic main

Then install the needed libraries for building xbmc, and download the source codes.

sudo apt-get build-dep xbmc
apt-get source xbmc
sudo apt-get install libbio2jack0-dev libjack-dev libjack0.100.0-dev libjackasyn-dev


You should have the source codes ready after a while. As a comments in my previews post said, the audio interface was changed a little bit in the new xbmc source, though fortunately it's not a big change, so the previous patch can works just fine after some minor changes. get the patch from this address.
* https://sites.google.com/site/yjpark/downloads (xbmc-9.11~beta1-jack.patch)

patch -p0 < xbmc-9.11~beta1-jack.patch

Then do the normal configure, before make, please add "-ljack" into Makefile, (search the line LIBS=..., add it to the end of the line will be fine), after that make should work.

One important thing to note, to make the audio matching video, you probably should change the delay constant in xbmc/cores/AudioRenderers/JackDirectSound.cpp.

float CJackDirectSound::GetDelay()
{
Update();

return m_timePerPacket * (float)m_packetsSent + 0.4;
}


Just play an correct video file, adjust audio delay to make it sync, then add the value you used into the end of the return line will be ok (ahead means plus)

Note: C++ library for Jack is from Jack_CPP (http://x37v.info/jack_cpp/doc/index.html) (by Alex Norman, with pretty good documetation and examples, thanks again), I included the needed files in the patch, though suggest you to look at the documents on his site for more information.

What's next

Currently this is not working if enabling real time support in jackd, probably will do some research on this part.

Also plan to find a way to deal with the ugly delay part, ideally can calculate the delay, if too hard, probably will retrieve the value from config, then won't need rebuild for it.

And make the library detecting with the proper way, both in code and also in configure process (not a c/cpp programmer, so might need some time), then no manual change needed.

If I can finish all these, then will try to commit the patch to xbmc.

4 comments:

Anonymous said...

hey well can`t await to see whats gooing on with your plugin... i'm realy keen on this because jackd is my standard audioserver but unfortunately I need the Realtimesupport so your driver is not usefull for me at the moment... if you carry on i will probably be one who is going to help you testing your stuff.

greetz Sebastian

Unknown said...

I hope that this makes it into the next release.

I'm currently having trouble getting it to work. When I start xbmc I see that alsa.jack.jackP is connected to the correct output. However, if I try to play any audio the alsa.jack.jackP ports dissapear (using qjackctl not in realtime mode)

YJ Park said...

Actually this works fine on Jackd with realtime active.
Though for some reason my machine crashed with Jackd with realtime randomly after a few hours.
I guess it's not the problem with xbmc or my hack.

Anonymous said...

Try to compile with XBMC-10.1 on Gentoo, but didn't work. I have modified the patch little bit because AudioRendererFactory.cpp has a few other line numbers. The modified patch is accepted, but the compile breaks with this error:
AudioRendererFactory.cpp:137: error: cannot allocate an object of abstract type 'CJackDirectSound'
JackDirectSound.h:38: note: because the following virtual functions are pure within 'CJackDirectSound':

Do you know an advice? Would be great.

greetz Gerion