Archive for the 'Hacks' Category

Page 4 of 9

Releasing a rewrite of mt-daapd/Firefly Media Server

About a year ago, I bought a SoundBridge, having grown tired of running a media player on one machine or another to listen to music. The SoundBridge really fits my needs perfectly.

The server-side counterpart, mt-daapd (Firefly Media Server), on the other hand… not so much. Feature-wise, it works and does what it’s supposed to do, so the issues aren’t there.

The first issue was with the crappy, below-average packaging of mt-daapd in Debian. I’ve fixed that since I think, at least now it’s in a state where I’m not looking away from the screen while typing apt-get install mt-daapd.

The second issue came after looking at the code, while writing patches for Debian. Eek. It’s horrible in about every aspect you can think of. No coding standard, outdated comments, cruft everywhere, either #ifdef’d out or not, useless code left lying around inside functions, obvious memory leaks, and way more levels of indirection than is actually needed, let alone sane. Also, someone is clearly in deep and urgent need of taking “Pointers in C 101″. My eyes still hurt.

Well anyway, I’ve been contemplating either fixing it or rewriting it because I can’t stand such crappy code. Also, mt-daapd has been unmaintained upstream for something like 2 years, given that the upstream developer just pretty much disappeared.

So, with way more time on my hands than I’d like these days, I’ve finally jumped in, pulled the whole SVN into a git repository and started cleaning things up then rewriting it piece by piece. Good way to keep myself busy, producing something useful while doing so and playing with a couple new things.

This rewrite is called forked-daapd, for lack of a better name at the moment, it’s GPLv2+, and the code is available in a git repository at

git://git.debian.org/~jblache/forked-daapd.git

It’s not a feature-for-feature rewrite. I’ve tossed out a few things.

It’s Linux-only for a start, and then I’ve thrown out the web interface, the XML-RPC interface that goes with it,  the iTunes XML playlist support (only useful on Mac OS X) and the smart playlists. Maybe a couple other minor things I can’t think of right now.

It’s Linux-only because it uses signalfd and inotify. It’s built on libevent and pthreads, but doesn’t abuse threads either like mt-daapd does (spawning one thread per HTTP request … seriously). Parsers for the RSP and DAAP queries are built with ANTLR v3. Media handling is mostly done by ffmpeg, though ffmpeg suckiness in parsing metadata in some formats had to be compensated by dedicated metadata parsers. It’s a shame ffmpeg can’t handle raw FLAC streams with VORBIS comments, that is, bog-standard .flac files, while it goes to great length to support proprietary formats (though I should note it fails miserably on WMA too).

So, new things I played with: signalfd, libevent, threads, ANTLR, ffmpeg. Threads aren’t really a first, but I did some new things. inotify isn’t a first either, but it’s the first time I use it to watch events other than IN_CREATE or IN_MODIFY; that leads to quite some unhappiness towards the inotify API, which has some real shortcomings. I’m still shaking my head in disbelief.

It will happily support multiple concurrent clients, even when decoding media files to WAV, without abusing the machine it’s running on. I thought of adding more threading, especially in the decoding case, but I doubt this will be needed by anyone. Unless you’re streaming to hundreds of clients at the same time, which doesn’t look like a plausible usage scenario to me.

I don’t know where I’m going with this project. Right now it works for me and covers my needs. I’ve tested both the RSP and DAAP protocols with my SoundBridge, and DAAP with iTunes. I’m not an iTunes user so I may have skipped on the complicated things with iTunes, although I looked hard.

If there’s enough interest in this project, it can become a full-blown project on Alioth (it can even have a name that doesn’t suck!).

pommed v1.26: new external keyboard, fixes

I’ve just released a maintenance release of pommed. Nothing new under the sun in this one:

  • support for the new mini external keyboard,
  • the keyboard backlight idle timer now only takes keystrokes on the built-in keyboard into account,
  • move away from using /dev/mem to access PCI memory, use sysfs resource files instead.

There are a couple of ideas floating around, we’ll see if any one of those lands into a future release.

mt-daapd EPIC WIN

I’ve been doing some code lately, fixing things here and there, and over the last few days gave mt-daapd some attention.

First, I was reported a segfault of mt-daapd when reloading web pages too fast. Surprisingly, it turned out to be a stupid omission in a simple routine and it is hard to hit without disabling the cache in the browser.

Now, I just fixed something that’s been bugging me for a while: mt-daapd did not handle Avahi daemon restarts, leading to mt-daapd becoming invisible to clients relying on mDNS until you restarted it.

And, wow, that went a bit further than expected. As I expected, the simple piece of code needed to handle that wasn’t there. But still it did not work, as it turns out the event loop for the Avahi polling wasn’t being run. Replace stupid code reinventing the wheel by the Avahi-provided wheel and there, it works. But not when run as a daemon (aka foreground only). Well yes, starting the thread before daemonizing isn’t going to work well, so fix that. EPIC WIN \o/

As mt-daapd’s upstream is not active anymore I’m accumulating fixes for mt-daapd in the Debian package, to the point I’m starting to consider setting up a git repository somewhere with those fixes and possibly some more code rework if I feel like it.

pommed: now using git

I’ve migrated pommed to git yesterday. The public URLs for the git repository are:

git://git.debian.org/git/pommed/pommed.git

http://git.debian.org/git/pommed/pommed.git

The SVN repository will disappear shortly.

pommed v1.25: wireless keyboard, DBus configuration

Two fixes in this release, let’s start with the more important one :)

The DBus configuration file shipped with pommed now explicitly allows method calls to org.pommed, which is needed with the newer versions of DBus where the default configuration on the system bus has been made more strict to close a security hole. If the pommed clients stopped working for you after a DBus update, replace /etc/dbus-1/system.d/pommed.conf by the dbus-policy.conf file shipped with pommed.

Second fix is related to the Apple wireless (Bluetooth) keyboard, which previous versions of pommed would recognize just fine but reject because it exposes a type of events usually indicative of a mouse (and pommed doesn’t listen to mouse devices). This is now fixed for this particular keyboard, so pommed will react to the hotkeys on this keyboard too.

For the complete list of changes, see the ChangeLog file in the source distribution. Comments at the usual address :)

pommed v1.24: maintenance release for 2.6.28

pommed 1.24 is out; this is a maintenance release addressing the HID changes in the 2.6.28 kernel.

HID quirks have been split out into hardware/vendor-specific submodules; consequently the sysfs path for the fnmode parameter changed as it’s now handled by the hid_apple module and that needed to be accounted for.

No rush if you’re running an older kernel :)

pommed v1.23: full late 2008 laptops support

pommed v1.23 is out, with full support for the late 2008 laptops.

The LCD backlight inner workings got figured out finally, but there’s a catch: the backlight won’t react to the settings when running X11 with the proprietary nVidia drivers on the MacBook5,1 and the MacBookAir2,1. It works fine on the MacBookPro5,1 and it works fine on all three machines with the opensource nouveau driver. Switching to the console before setting the backlight and then back to X does work as a workaround.

So there’s something up with the proprietary nVidia driver, and my uneducated guess is that the MacBook Pro may somehow be exempt from the issue due to its dual GPU config.

I’ve also switched the nVidia machines to using the generic sysfs backlight driver in pommed. This driver has been there for some time for the PowerPC machines, so now it’s part of the generic pommed code. You need the mbp_nvidia_bl driver in your kernel for this to work.

Don’t panic! If you don’t have it, pommed will fall back to the native driver (nv8600mgt) and everything will work just as before. Pommed will tell you if it has to fall back to the native driver, so check your logs if you want to know.

This release of pommed needs testing on all nVidia machines: MacBookPro3,1, MacBookPro4,1, MacBookPro5,1, MacBook5,1 and MacBookAir2,1. If anything doesn’t work, tell me about it and I’ll fix it.

pommed v1.22: various improvements, Late 2008 laptops

I’ve just released pommed v1.22, which has been collecting improvements and reworks over the past few weeks; this release also adds partial support for the Late 2008 laptops.

Partial support means the LCD backlight is not supported yet. The method for controlling the backlight has to be figured out; if you hear of anything, let me know.

You’ll need a recent kernel for full support on these machines, which means either a late 2.6.28-rc or possibly an early 2.6.29-rc. It all depends on how fast the patches get applied to mainline. Patches are needed for the keyboard quirks, trackpad support, applesmc support and sound support, as usual.

Update: proper trackpad support has not been merged in 2.6.28 and is scheduled for 2.6.29.

On the improvements front, wmpomme has become event-driven, eliminating the fixed-rate update and associated wakeups and visual ugliness in some configurations; pommed has got some code fixes, though nothing major; gpomme has got a new Japanese translation.

Hopefully the next release will bring full Late 2008 support.

Looking for the EFI UGA spec

Lazyweb-type post ahead :)

I am looking for the UGA (Universal Graphics Adapter) specification. It is part of EFI 1.10, but was developed by Microsoft, so it’s not documented in the Intel spec.

Instead, the Intel spec contains a Microsoft URL where the spec used to be available, but that URL doesn’t exist anymore and I can’t find the spec anywhere.

So, if anybody out there has a copy of that spec, I’d very much like to get it.

I am looking for the UGA IO Protocol spec, which may very well be the key to solving an annoying framebuffer issue I’m working on.

Thanks!

pommed v1.21: composited gpomme

It’s been on the TODO list for ages now, and Soeren finally tackled it: compositing support for gpomme.

This is the only change in this release. Please report any issue with gpomme and compositing, as this code has only been tested on a limited number of configurations.

For people not running a compositing manager (like myself), don’t worry, gpomme works just as before.