Wednesday, September 23, 2009

GtkBuilder XML to .h file

Here is a little perl script to convert a GtkBuilder .xml file as generated by libglade3 to a .h file. Kind of in the style of gdk-pixbuf-csource.
$var = $ARGV[0];
open IN, "<$var";
$var =~ s/\./_/g;
print "static const char $var\[\] =\n";

while() {
$line = $_;
chomp $line;
$line =~ s/\"/\\\"/g;
if (/<\/interface>/) {
print "\"$line\";\n";
} else {
print "\"$line\"\n";
close IN;

Use it like this GtkBuilder.xml > GtkBuilder.h
And then #include "GtkBuilder.h" and you should have a variable name GtkBuilder_xml that is a string that holds the xml that gtk_builder_add_from_string can use.

Tuesday, September 22, 2009

Using Clutter and Gstreamer for Media Playback

I have been watching the clutter toolkit for sometime and putting together a couple of demo apps at the same time just to see what it can do. So with Fedora 12, there is a new clutter 1.0. Unfortunately none of my old demo apps work, so clutterdesk and couple of other thing would need to be converted to the clutter 1.0 api. So when I feel like it I'll probably get around to do it. But what was most interesting to me in clutter 1.0 was the new ClutterMedia actor. So I installed the components to use it, and it is based on GStreamer (which finally appears to produce pretty decent output for most media items).

So I created a simple playback area and actually had two videos (one ogg and the other quicktime) playing on a single "stage" with about 30ish lines of code. Could just play the media, but it seemed to work quite well.

Next was to see what it would take to get some information about the media. This was actually the difficult part, but luckily I was able to dig thru the totem code and find the information I needed.

Next was to create a gnome-mplayer like gui for it, but since I was playing with new toys, I decided to use GtkBuilder to do it. I used glade3 to create an XML file that gtkbuilder could read. As a side note, having Glade3 produce an include .h file that contained the XML in a const gchar would be a nice improvement, that way you could just include the .h file and go, nothing else to ship.

Had a few issues figuring out how to use it, but after awhile, I got it and produced something that looks like this. (This is the Harry Potter and the Half Blood Prince trailer, that I have stored locally).

Looks a lot like gnome-mplayer and I think I have about 4-6hrs into learning how to do all this. It is quite interesting and the toolkits are quite well thought out. So I'll continue to play with this demo on and off and see what comes out.

If you would like the code, I would be happy to email it to you.

Sunday, September 20, 2009

r600 and Fedora 12 Snapshot 3ish

I had been running the r600 drivers or at least trying to, using the git versions of the kernel (drm-next branch), mesa, libdrm and xf86-video-ati on my Fedora 11 machine. And I understand that when running this type of config that things are probably gonna crash.

So when I used this config with KMS/DRI2 enabled it annoyed, but did not surprise me when it crashed. However, to get a stable system I was able to add radeon.modeset=0 to the kernel command line and things just worked correctly. No crashes, fast XV all that stuff.

So I decided that I should upgrade to F12 for a couple of reasons.
1. The new GTK with client side windows was included and I have a feeling that could cause gnome-mplayer some pain

2. The r600 drivers were built in to everything

So after downloading 2.5GB of files and upgrading using preupgrade I rebooted the machine. The preupgrade process ran, but hard locked the machine a couple of times using everything default while the upgrade was running (I should have known then). I finally on the third try added radeon.modeset=0 to the kernel command line and the preupgrade finished. After that was done I ran yum and got the latest of everything else.

Then more pain started. The machine using the default of everything would boot up and let me login and promptly lock pretty much right as the desktop showed up and sometimes it would even lockup in GDM when the screen was shuffling around and sometimes I would get 10 mins before it would lock up. So back to the radeon.modeset=0 option. However, this disabled all acceleration. Firefox was dead slow and xv didn't work. Unacceptable. Tired playing around with it a bit more and was out of lock, all I got were lockups for my efforts.

Luckily my motherboard has the Intel G35 chip onboard so I have that as a backup video card. So out comes the ATI card and in goes the ADD2 DVI adapter that I use with my display. After that everything is pretty happy and no lockups and etracer has twice the framerate with the Intel card as with the ATI card (this should not be). Now I know this is all early stuff and I do expect the ATI card to work eventually. But to have snapshot 3 of Fedora out and to have these kinda lockups, well that kinda sucks.