Sunday, August 13, 2006

Bugs, bugs and ... bugs!

During the last days I did not much progress on implementing new functionality.
My new schedule is to...
1) fix the backend to make ByteStream work
2) allow each branch of GraphHandler to have more sinks connected
3) port fub's gui config app to dbus
4) make kcm work (this involves frontend work as well)

The reason for my slow process have been bugs.
First I had to figure out that the Phonon ByteStream/MediaObject frontend states had problems... the KIO object setup was done only in setUrl()... Matthias fixed it in a minute.
Then I found corner cases where NMM/Phonon/KIO cooperation becomes difficolt: that is when the kio object finishes sending data before phonon-nmm has finished its initialization (happens when the media file is really short). Also this involved both backend and frontend changes.
Then the other day I updated dbus from CVS and... bang!!!! Someone on 8/8/06 has introducd a really nice in configure in. It took an entire afternoon to make dbus work again (I'm not an autotools expert, I had to learn-try-fail-learn_more-...
Then I found a nice bad bug in NMM MPEGDecodeNode. track_size is not initialized and track_duration is computed from it. If you play a live stream (for example an mp3 file streamed from Phonon::Bytestream) track_duration can't be told... a random value was inserted into the CEvent. After fixing it I found that if track_duration is 0 progress events are not emitted; I can't see the reason for this: you can have progress even if you don't know where you are inside the file.
I see from vlagrind output that there are some other uninitialized variblas on which a control statement depends on... but I was not able to fix those jet.

Those were just the things I was able to fix!
I still have some bugs. The big problem working on phonon-nmm is that you have to work on bleeding edge code (kdelibs, KIO, Phonon, NMM -should be the more stable here-, Qt4, dbus) and you have to do a lto of tricks to make them work. I have spend almost a week in the beginning writing a script to set up all the environment vars and daemons (I was inspired by a script sent to me by Matthias).
The hardest problem is that Qt4/KDE4 code confuses debuggers and memory checkers like gdb and valgrind! So you have to fill the code with debug statements and recompile and... well, when you type make in the Qt, NMM, or kdelibs source trees... you'll heat your CPU for quite a lot of time! That is way icecream (icecc) comes in the story: this tool allows you to easily cluster your machines into a renderfarm. It is one of the pieces of code in the world, it saves so many compile time! But... a tiny little bug in the kubuntu package I had made me mad... so I had compile the latest svn version, find another little bug ,report it to the icecream main developer (coolo on #kde4-devel) and wait (minutes really) for the fix.
Back to phonon-nmm my favourite bug is... UNKOWN! Maybe it is more than one bug.
The symptoms are random. Sometimes kdeinit can't unload phonon-nmm because of NMM not releasing the soundcard device. Sometimes in ByteStreamNode I push_back into a list 23 Buffers* and then I iterate on 23 elements... Ah, that is ok, I know... buth the size of the first element is the sum of the others :-)
I'm working on this bug right now. I hope to resolve this, but ATM I really don't know how to understand where it comes from.

I must be crazy anyway. Because...

I'm having fun!!!!!!