Friday, May 23, 2008

Ubuntu 8.04, mplayer, and my HVR-950 driver

I upgraded to Ubuntu 8.04 this week to test the V4L HVR-950 driver and ran into a problem where mplayer would work the first time but then subsequent attempts to run it would show an error suggesting that the open() call to /dev/dvb/adapter0/dvr0 would always return EBUSY. I assumed this was some bug in my driver exposed by upgrading to the new kernel, and I wanted to get it fixed before the 2.6.26 merge window closed.

After spending the morning littering the driver with debug code trying to locate what I thought was a bug in the referencing counting, it occurred to me to just run fuser against the device file.

root@devin-desktop:~# fuser -v /dev/dvb/adapter0/dvr0
USER PID ACCESS COMMAND
/dev/dvb/adapter0/dvr0:
root 6455 f.... mplayer
root 6459 f.... dbus-launch
root 6460 f.... dbus-daemon

Looks like they integrated mplayer with dbus, but they don't close the file handles on fork() so dbus inherits the file indefinitely (since it doesn't exit when mplayer exits).

I then put "ubuntu dbus" into my search and it turns up I'm about a week behind Markus Rechberger because he appears to have already found the issue:

http://www.mail-archive.com/em28xx@mcentral.de/msg01097.html

And he has already submitted a fix to Ubuntu:

https://bugs.launchpad.net/ubuntu/+source/dbus/+bug/230877

While I'm happy it wasn't a bug in my driver, I'm a bit annoyed about spending the first half of my day off from work debugging what turned up to be an issue somebody already found and fixed.