Monday, 23 November 2009

Gstreamer Migration

Just shy of a month ago I became fed up of Phonon's flakey API and decided to dump it for something else. Performance and feature-wise Phonon was OK but thing's in the API didn't actually match up to what was happening in real life. Mainly it's "state" feature was the key reason for me to give it up.
I won't get into details, as it will raise my blood-pressure, but ever since I started using this media-framework I would discover something nasty and create an awful hack to get around it.

Since the end of October I have been trying out Python-Gstreamer in a new git branch. Some periods I doubted my decision because of Python-Gstreamer initially quite terrible documentation. I spent a good period learning the nitty gritty parts of how it uses "elements" to create a "Pipeline" which is a catch-all solution for playing a file.
Despite getting this low-level method to work it was not gap-less. When a track moves tot he next in a playlist automatically, a noticeable gap was present.

This brings me on to Gstreamer's playbin2. If you look at that link you will notice that there is no Python. That's because there is no Python documentation for this useful feature of Gstreamer. Playbin2 is a high-level solution to playing a file. You can put in elements if you want but I wanted it just for it's gap-less playback.
As I had no Python examples a Google search resulted in this find. It took a while to figure out what was relevant to Gstreamer and Quod-libet but eventually I got the gist of it. If it looks messy, that is OK. It looked the same to me. In my opinion they seem to be doing a lot of unnecessary things such as destroying+re-creating their playbin2 object when loading a new file. I know how this sounds but I think it looks very hacked together. Maybe time will prove them right and me to be wrong.

By taking what I needed from quod-libet's backend I ended up with an almost working solution. On rare occasions gap-less playback was possible. After a frustrating and fruitless few days I made a new thread at Gentoo Forums as last resort. Thankfully a superstar by the name of didumos provided a possible reason to the error, investigated it, and provided a patch. All that and he/she doesn't _do_ Python.

Since then I have done a touch of bug-fixing and now believe the end is near for the migration. I have a feeling a few bugs are present in my use of gstreamer and defintely know it's not optimal. In addition PyLint always crashes when checking it's "Pythonness" of the backend which isn't helpful.

After this a few new minor features expect ver0.3 out soon.

No comments:

Post a Comment