Tuesday, August 26, 2008

Kaffeine for KDE4

The author of the KDE4 port for Kaffeine asked me to do some testing on the ATSC scanning support (they don't use ATSC in Europe). While it took me a couple of weeks to find the cycles, I finally got KDE4 and the dev environment setup, I built the new version of Kaffeine from source, and what do I find?

My entire ATSC PSIP and scanning implementation from Kaffeine 0.8.7 got scrapped and rewritten from scratch.

Now, I'm a big fan of refactoring, and I recognize that there were a couple of code reuse issues because I wasn't familiarized with the DVB code in Kaffeine. But scrap the entire implementation?

Worse, I took a look at the actual code, and it doesn't excite me. The parser extracts data from arbitrary offsets, it extracts the bare minimum of information required to "work", and apparently the notion of constants is nowhere to be found.

I love little gems like this:

length = (((at(30) & 0x3) << 8) | at(31)) + 32;

Or this:

bool isHidden() const
{
return ((at(26) & 0x10) != 0);
}


Do you know what "26" is? Or why it's being anded with 0x10?

The parser in 0.8.7 at least made a point to document to death where the stuff came from. The parsing was annotated with comments like "// See ATSC A/65C Sec 6.3.1 Table 6.7" so you knew exactly where to look in the spec.

I guess it's a bit hard not to take it personally since I invested a good bit of time in it. Also the new version is obviously a work in progress and perhaps it's premature to judge.

What to do now? I guess I can take the new implementation and improve the quality until it is closer to the 0.8.7 code. I can simply do nothing (it does "work" after all), although I'm going to be pretty screwed if I ever want to add functionality like the program guide support.

Also, I don't want to do any more work on the KDE3 version of Kaffeine if it's all going to be scrapped and rewritten anyway.

The upside is if I want to contribute, it's a target rich environment. The sound doesn't work. It doesn't tune right most of the time. It crashes on exit.