Monday, November 22, 2010

Making Audio Meter pretty with Cairo

With GTK 3 coming out in a few months, one of the tasks for gnome-mplayer has been to replace the drawing code with cairo, rather than gdk drawing primitives. This gives us several cool features including better gradient support.

Here is a screen shot of the current code.


Side note.. one of these days gnome-screen shot should be fixed to grab compiz window decorations.

Friday, November 12, 2010

Getting the default volume from PulseAudio in C

I have been screwing around with trying to find out how to get the default volume from PulseAudio for the longest time. I finally got it working in a GTK application by reading the pavucontrol applications code. Since this was such a pain for me to find, I thought I would share it.

In your configure.in make sure you have these lines

PKG_CHECK_MODULES(PULSE, [libpulse libpulse-mainloop-glib])
AC_SUBST(PULSE_CFLAGS)
AC_SUBST(PULSE_LIBS)


Then make sure in your Makefile.am you have $(PULSE_CFLAGS) in the INCLUDES and $(PULSE_LIBS) in appname_LDADD. These may vary in your setup, but that should work for automake projects.

The code...

#include "gtk/gtk.h"
#include "pulse/pulseaudio.h"
#include "pulse/glib-mainloop.h"

void pa_sink_info_callback(pa_context *context, const pa_sink_info *i, int eol, gpointer data)
{
    if (i != NULL) {
        //printf("channels = %i\n", i->volume.channels);
        //printf("raw volume = %i\n", pa_cvolume_avg(&(i->volume)));
        //printf("linear volume = %f\n", pa_sw_volume_to_linear(pa_cvolume_avg(&(i->volume))));
        printf("percent volume = %f\n", (gdouble)pa_cvolume_avg(&(i->volume)) / (gdouble)PA_VOLUME_NORM);
    }
}
   

void pa_server_info_callback(pa_context *context, const pa_server_info *i, void *userdata)
{
    //printf("server info\n");
    printf("default sink name = %s\n",i->default_sink_name);
    pa_context_get_sink_info_by_name(context,i->default_sink_name, pa_sink_info_callback, NULL);
}

void context_state_callback(pa_context *context, void *userdata)
{
    //printf("context state callback\n");
   
    switch (pa_context_get_state(context)) {
        case PA_CONTEXT_READY: {
            pa_context_get_server_info(context,pa_server_info_callback,NULL);
        }

        default:
            return;
    }

}

int main(int argc, char *argv[]) {
   
    gtk_init(&argc,&argv);
    pa_glib_mainloop *loop = pa_glib_mainloop_new(g_main_context_default());
    pa_context *context = pa_context_new(pa_glib_mainloop_get_api(loop),"test");                             
    pa_context_connect(context, NULL, 0 , NULL);
    pa_context_set_state_callback(context, context_state_callback, NULL);
   
    gtk_main();
    return 1;
}

Thursday, November 11, 2010

Gnome Mplayer 1.0 is out and whats next

Well now that gnome-mplayer 1.0 is out.. where to from here. I have a couple of ideas that I am working on and basically just lack for time to get them all done.

1. Conversion of gnome-mplayer to gtk3
2. Which means redoing the audio meter widget in Cairo
3. I also am converting the main mplayer control to a GTK Widget in libgmtk
4. Probably spawning libgmlib and libgmtk into their own SVN projects

Why do all this, I'm hoping that by making it a widget it will solve some of the weird GTK positioning side effects that I have to work around. So far I have a basic version of the widget working and it seems decent. I have a test harness working where I can use the media player widget and the tracker widget and have them working with each other.






So that is what I am working on...

Monday, October 25, 2010

More testing on r600g

A few weeks ago I posted about some testing I did with the r600 Gallium (r600g) drivers in Mesa 7.9 on my Radeon HD3650 (rv635) card. Well, I've been keeping up with the testing and all I can say is that it keeps getting better. Today, upgraded some more components (xorg) and did some more testing, with the power settings on high. Lowering the cards power setting to 'med' can drop the FPS by 20-30%.

Current packages installed
kernel 2.6.36
libdrm 2.4.22
mesa git
xf86-video-ati git
xserver 1.9

With this setup my desktop (gnome 2.30 with compiz 0.8.6) things seem pretty smooth. Scrolling seems better in Firefox and other things seem correct. I still have some problems with fullscreen video tearing in flash (10.2.161) videos. But mplayer and totem seem to run fine. Clutter apps still don't work quite right on my machine even though I have upgraded clutter to 1.4. But I think I am down level on some of the requirements.

Testing results
nexuiz-glx, normal settings, 1024x768 windowed, 30fps (about the same)
vdrift, 1024x768 windowed, 30-60fps (this is a big improvement)
openarena, 1024x768, windowed, 50-60fps (no change)
etracer, 1024x768, 25-30fps

What is funny is just having the blogger editing screen open seems to drop the FPS of games by about 30%. So the editor code at blogger needs some help.

Wednesday, October 13, 2010

Nautilus script to create mp3s from video files

Do you ever download a video off youtube and think "gee I wish I had an mp3 of that". Well here is a script for nautilus (the gnome file manager in linux) to help you create that mp3.

Create the file in $HOME/.gnome2/nautilus-scripts

I named it "Convert to MP3" and set the execute flags on the script (chmod a+x $HOME/.gnome2/nautilus-scripts/Convert\ to\ MP3)

#!/bin/bash

in_file="$1"
out_file=`echo "$in_file" | sed 's/\.\w*$/\.mp3/'`

ffmpeg -i "$in_file" -f mp3 -ab 128000 "$out_file"


This script requires ffmpeg to be installed for it to work. Once you install this script you should see a new menu item on the context menu of the files named Scripts if it was not already there, and then you should see your "Convert to MP3" option.


Select any video file, choose the "Convert to MP3" option and after a few seconds (depending on the size of the file) an mp3 file will be created with the same name as the original file. 
Hope you found this useful.

Tuesday, October 05, 2010

Radeon Power Management in Linux

In addition to my desktop computer that has a Radeon 3650 video card in it, I have an Lenovo T400 laptop that has and Intel and an ATI video card in it. I have been using the Intel card primarily as it gives good battery life and the fan in the machine does not run much. With the Linux 2.6.35 kernel being out that supports Radeon power management I thought I would give it a try.

Fedora 13, my OS of choice, currently only has kernel 2.6.34 available. So I went to koji and grabbed the latest kernel source package. I made sure I had the dependencies for building the kernel installed, by running yum-builddep kernel. I then took the kernel source package I had and rebuilt it using rpmbuild --rebuild [kernel src rpm]. This process took awhile, but eventually I got a set of kernel packages. I then changed to the ~/rpmbuild/RPMS/x86_64 directory and ran yum --nogpgcheck upgrade kernel*. Once that was installed I rebooted into the new kernel. I then followed the wiki to enable dynpm. I actually placed the options in my /etc/rc.local file so they were applied on every reboot. The system seemed to work ok, but had a little flashing every now and then do the video clocks changing, so I upgraded the xorg-x11-drv-ati rpm using the same process as I did for the kernel and rebooted again. So far the ATI card seems to be working fine, I still have a few flashes every now and then and the battery life is not as good as when using the Intel card. But the 3d performance is much better.

I have not upgraded Mesa on this machine yet, so it is still using Mesa 7.8.

Friday, October 01, 2010

Mesa's r600g Driver Test Drive

There has been alot of talk about the Mesa driver in Linux. One of the new things that has been talked about as the savior of 3d graphics on Linux is the Gallium technology. This technology is supposed to make writing drivers easier and to allow for much more functionality in the Linux 3d stack.

While I am not a gallium expert, I know enough to build the driver and test it out. So I started with my stock Fedora 13 setup (64bit, Q6600, 8GB RAM). I followed the wiki and installed the Kernel, libdrm, mesa and the ATI driver all from git. It took a little while, but it was reasonable to get going. It really helped that I had built many of these components before when the r600c driver originally came out, so I knew the process.

So after installing all the components I booted my machine and plymouth came up, but GDM was a black screen. So I disabled rhgb on the kernel boot line and rebooted. This time I got a working GDM. I fixed the plymouth problem by running /usr/libexec/plymouth/plymouth-update-initrd.

I logged into my normal desktop and compiz was running fine. I verified that I was indeed running gallium, by using glxinfo.

glxinfo | grep OpenGL
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on RV635
OpenGL version string: 2.1 Mesa 7.10-devel
OpenGL shading language version string: 1.20

I then did a few tests with the r600g to see how things were working. glxgears seems to work as did many of the other demos (tunnel, tunnel2, geartrain, dinoshade, etc). All the demos were running right around 60fps, which is the refresh rate of my monitor, so far so good.

I ran IOQuake 3 in a window on my desktop (1024x768 I believe) and averaged around 30fps. With r600c I got around 90fps. So I'm not sure if that is due to the change in mesa to reduce tearing or not.  Vdrift and Extreme TuxRacer both ran at around 20fps both in a 800x600 window on my desktop. That is the fastest Vdrift has ran on my machine. Google Earth also ran quite well even in 32bit mode.

I ran Diablo II via wine in both directdraw and opengl mode and it ran at a solid 25fps for the few minutes I played it.

So far the r600g driver appears to be working decently, I'm sure there are things to fix as it is still in development. But, it appears to be working well.

Tuesday, September 21, 2010

Asterisk in Operation

In my last post I talked about how I got the Openvox A800P card. I found that the card was sharing an interrupt with one of the SATA controllers in the machine. The card would work fine, until the disks on that controller were accessed. So I ended up pulling the card and moving it to a new slot so that it did not share an interrupt. This helped with the majority of the clicking I was getting on the card. But I still had some problems with echoing when I talked on the line. The echo problem was solved by running 'fxotune'. After running this tool the audio quality really improved.

I still get a few clicks every now and then, that I believe are related to the PCI bus. I talked to the Openvox support people and they recommend trying a new motherboard. This is not something I have handy at the moment, so I'll wait on that. I do think that going to pure VoIP phones will help with some of the noise. The VoIP adapter I bought has some of the clearest calls.

Being able to tweak the Asterisk dial plans has really been interesting. It is actually a little trickier that I expected, but once you get the concepts down it becomes a little clearer how to really make it work smoothly.

Saturday, August 21, 2010

New FXS/FXO Card

Well the initial experiments with the X100P card (single line) went well. The card itself was a little flaky, but the overall concept looked good. So I decided to take the plunge and get a real TDM card. I decided on the OpenVox A800P card. This card is a knock off of the Digicom TDM800P, but at 1/3 the cost. I got the card with 2 FXS and 3 FXO daughter-cards. This well allow me to reuse all the phones in the house and several other devices without change and also allow me to run 3 outgoing lines. The card is large and requires a power connector (due to the FXS options). I actually had a hard time getting it into my PC case. Especially with the 3 hard drives I have in that machine. I have a total of 5 drives connected to the machine, so I may need to rethink that layout in the future.

Anyway, again getting the card installed and working was tricker than expected. I followed the instructions on the OpenVox website on how to get the drivers working. They didn't even compile, but it was due to a kernel issue. So I made a minor patch to the OpenVox drivers and then it compiled. Again the dahdi-tools had trouble with the card. I had to force some of the things to work. Hopefully, when I reboot the machine next time it all just comes up. I would think that the hardware drivers would be better than this.

I setup asterisk and I've made a couple of outgoing calls, the call quality seems ok so far. I'll have to test it on a longer call next week to ensure it doesn't drop, this is a problem the X100P card had.

Thursday, August 12, 2010

Desktop Eye Candy

I was reading the post about a good looking desktop by Seif Lotfy on My sexy desktop I really liked some of the things that he had setup but there were others that were not for me.

For example he was using some docks and the mac-ish menu bar at the top. Both of these tools really don't work for me and my daily usage. I also didn't care for the scroll bar in the theme. But I did find somethings that I like.

1. The background - I have to admit the wood background is quite nice.
2. The grey theme and the dark panels. I've been using the grey theme "Inverted" for awhile, so I stuck with that.
3. The icon set

So I used his background


I chose the "Inverted" Gnome widget theme
I chose the "Inverted" Window border
I chose the "Faenza-Dark" Icon set, it can be found here
I chose the "comfortaa" font that Fedora is using, it can be found here there is a Fedora rpm available for this as well, just search for comfortaa. The Droid fonts also look quite nice.

Now it gets a little tricky, but not bad.


Set your panel background color to color name: #716968, which matches the selected color of the title bar of the active window from the theme, keeping the colors consistent.

We set the panel to be a dark color, but the theme has dark text so to be able to read the text on the panel, we need to alter the font color on the panel. We do that by altering the theme colors.

Edit ~/.gtkrc-2.0 and add the following lines. These lines change the dark font color to white on just the panel and the user-switch-applet.

style "panel_color"
{
fg[NORMAL] = "#eeeeee"
}
widget "*PanelWidget*" style "panel_color"
widget "*PanelApplet*" style "panel_color"
widget "*user-switch-applet*" style "panel_color"

Then logout and log back in. And you should get a desktop that looks something like this:



Comments?

Sunday, July 25, 2010

The no-desktop experience

After seeing a couple of posts about the concept of working on a computer without desktop being an active clutter space. I'm going to try running my Fedora 13 desktop with the nautilus desktop disabled.

It is very simple to do, just open gconf-editor and choose

/apps/nautilus/preferences and uncheck the show_desktop box. So I'm going to see how this works for me and if life feels uncluttered afterwards.

Thursday, July 22, 2010

Asterisk PBX - Adventures in building a home PBX

We have a lot of phone lines here that are really a mess to manage. So I've been experimenting with Asterisk. Luckily Fedora has Asterisk in its repository. So I decided to take the plunge and try it out.

The first thing I wanted to do, was to get basic callout working. I found tollfreegateway.com and setup their sip server so I could make US tollfree calls from my Asterisk server. I used Linphone and Ekiga on my desktop to connect to the Asterisk server. Setting up accounts on the Asterisk server was harder than expected due to trying to use one of the guis and all of them having particular limitation. I eventually dumped the GUIs and just modified the .conf files. I got my desktop connected to the local Asterisk server and then called a 877 number. It actually worked. So I had the proof of concept working.

The next step was to get callin working. As I already have several phone lines, I didn't want to add another line via SIP so I looked into an FXO device. These devices allow you to plug a standard phone line into the Asterisk server and have the server accept the calls. I wanted to be cheap about it, so I got a X100P adapter off eBay. I Figured $20 was not bad for a test. I installed the card in my server and for some reason the drivers would not find it. I found that the card required that it have its own interrupt.. geesh, I thought we were done with dealing with interrupts when the ISA bus died. Anyway, I disable the parallel, serial and firewire ports as I don't use them anyway and after that the card drivers started loading correctly. I have simplified this alot, I spent several hours getting this stuff to work and a lot of missteps so far. Challenging but fun at the same time.

Once the drivers were working, I had to configure Asterisk to respond to incoming calls. So I following the directions for editing the extensions.conf file and then I called the system and got prompt to select an extension. I dialed on and my desktop rang. I then setup the dial rules to call the extension I wanted and it worked automatically.

The next step is to get a OpenVox A800P card and configure all my incoming lines properly and make the system work the way I want it to. At $200 for the device it is a significant cost to make this work for a project. But it should make things work better. I also have purchased a couple ATA devices a Linksys SPA1001 and a Linksys PAP2  for adding phone extensions around the house. The one SPA1001 device works great so far. So I might pick up a few more on eBay.

So more to come with adventures in home PBX...

Thursday, June 10, 2010

Laptop Screens

Lately, I've been shopping for a laptop. I would like a model with an I5 or I7 processor and a 14" screen. However, all the of the 14" models have the 1366x768 resolution. This is an absolute disaster for anyone trying to use a computer. My job recently issued me a new laptop that has a 1440x900 screen and this feels really tight. I can't imagine what a smaller screen would be like to work on. My last 14" laptop (Lenovo T60p) has a 1600x1280 screen and it was great. I hate that the screens we are using today are much much worse than the screens we had 5 yrs ago.

So manufactures out there... quit using crappy screen on otherwise decent laptops. Or at least give us the option to upgrade to a decent screen.

Thursday, April 08, 2010

Gnome Icon Theme

It is not often that an icon theme really blows me away, but I found something today that is pretty darn neat.


Any Color You Like 0.8.2

This icon theme which includes a large set of icons for Gnome, also allows you to customize it with different colors or gradients or other neat things. Quit impressive what can be done with this. So give it a try, I think you'll be glad you did.

Monday, March 01, 2010

UPS for Linux / Fedora 12

Can anyone recommend a good UPS that works well with Linux? I've had a few power glitches where I live and would love to suppress a few of those. I've been looking at the APC ones like these.
But so far I cannot decide on which one would be best. I have a server with 5 hard drives in it and I also have my routers plugged in. So I think that I would need about 10 mins of runtime so the machine could properly shutdown.

Comments?

Thursday, February 25, 2010

ANNOUNCE gnome-mplayer and gecko-mediaplayer 0.9.9.2

gnome-mplayer and gecko-mediaplayer 0.9.9.2 have been released

gnome-mplayer:
http://gnome-mplayer.googlecode.com/files/gnome-mplayer-0.9.9.2.tar.gz

gecko-mediaplayer:
http://gecko-mediaplayer.googlecode.com/files/gecko-mediaplayer-0.9.9.2.tar.gz

Changes

gecko-mediaplayer

identify and fix problems from 0.9.9 including better playlist support and support for firefox 3.5, 3.6 and Opera.

Opera still has issues with apple.com/trailers sites, due to user agent issues.

gnome-mplayer

A ton of translation updates and additional languages.
Better seeking using position tracker
Several assertion fixes


Kevin

Monday, February 22, 2010

gnome-mplayer and volume getting set to 100%

If you are using gnome-mplayer and have pulse audio installed on your machine, you may notice situations where the volume is set to 100%. This appears to be an issue with mplayer and pulse audio. My suggested work around is to use the pulse audio alsa emulation. To do this select 'alsa' as the default audio output in gnome-mplayer.

The problem stems from the change in pulse audio from separate volumes per each application to a single flat volume control. So if flat volumes are disabled on your system, you will not experience this issue.

This issue happens by default on Fedora 12 when used with mplayer from rpmfusion, so adjust your configurations as needed.

RPMFusion bug #1011

Google Chrome on Linux with videos at http://www.apple.com/trailers

Many people are now starting to ask me if gecko-mediaplayer works on Google Chrome on Linux. For the most part I can say yes, but the main exception appears to the media at http://www.apple.com/trailers . What appears to be happening is that the code to switch the user agent from Chrome to QuickTime does not appear to be working. I believe this is due to Chromes emulation (or not) of the NS_GetServiceManager function call. So until that is fixed, apple.com media will be unplayable in Chrome on Linux.

Tuesday, February 16, 2010

r600 tearfree video on Linux, it is a reality

For some reason I always read "tear" as in crying. I understand that tearing can make some people cry so maybe I am not that far off. Anyway, I got the latest git of drm-radeon-testing, libdrm, mesa and xf86-video-ati. After installing all that everything seems to be running really nicely. I can drag an gnome-mplayer window around the screen and the video does not exhibit any tearing. Even large windows like a browser look good. The only tearing I do get is when I drag a window from one display to another in my dual head setup. I talked to agd5f on #radeon and he said that was due to different pixel clocks on the two displays. He said it could be fixed in software, however. I said while it would be nice to have fixed. I'm sure there are more important things to deal with first.

Thursday, February 11, 2010

Album Cover Art with Shoutcast

I noticed that many shoutcast sites have their track data in a common format "Artist - Song Title'. Based on this, I could use the code I use to obtain the album cover art for MP3 files where not much meta data is available. So a simple parse of the content and a call to the art lookup code and we get this.

This is from http://yp.shoutcast.com/sbin/tunein-station.pls?id=7022 which is an 80's shoutcast station Sky.FM.

Wednesday, February 10, 2010

gecko-mediaplayer and gnome-mplayer 0.9.9

I released gecko-mediaplayer and gnome-mplayer 0.9.9 on 2009-02-05 and the release was decent for the most part. But compile issues where found with various flavors of libxul and there were some other problems with shoutcast and other websites.

So I reworked some code and found some bad problems. So I released a gecko-mediaplayer 0.9.9.1 only on the mailing list which was a snapshot of SVN as of 2009-02-08.

So expect a new release coming soon to fix some of these issues.

Wednesday, January 20, 2010

r600 and Fedora 12 Update

I've done a few posts about the r600 chipset and Fedora Linux. I did one awhile back in April of 2008 and I did another in Sept of 2009 so I thought it was about time for another update.

First of all let me say that the r600 driver has gotten much better since April of 2008, it is hardly in the same ballpark. So I am running Fedora 12 will all the currrent updates. The 2.6.32.3-24 kernel and mesa from git. The mesa in F12 is fine, but the one from git contains support for glsl and OpenGL 2.0 vs the OpenGL 1.5 in mesa 7.7.

So lets get to the raw data...

gtkperf -c 500 -a now runs in 36 - 39 seconds on my machine (Q6600 at 2.4Ghz, 64bit, 8GB of RAM). I have switched to using compiz as my window manger which actually may slow the results down a little. And I also have found that the GTK theme can really impact the performance of GTK.

3d apps for the most part run solid, glxgears is around 2000 fps, Quake 3 runs as 90, Nexiuz is 30-40 depending on the detail. Diablo 2 under Wine gives 25fps (which is its max for the most part). I have had some issues with screen corruption when running diablo with -opengl.

My video player, fosfor, that is based on clutter and gstreamer plays quite well. Even with larger files.

So when testing the radeon r6xx driver on Linux, ensure you have the latest packages available. It really makes a difference.