Archive for December, 2008

C linked list macro

Here’s a simple macro I came up with a few weeks ago for easily defining linked list types in C.

#define LINKED_LIST(type, name)     \
    struct name ## _ {              \
        struct name ## _ * next;    \
        type data;                  \
    };                              \
    typedef struct name ## _ name;

Usage is simple:

LINKED_LIST(int, int_ll);

gives the same type as

struct int_ll_ {
    struct int_ll_ * next;
    int data;
};
typedef int_ll_ int_ll;

Why I dislike PulseAudio (for now)

Before this sounds like a rant, I’d like to first say that I think PulseAudio is a very nice concept, from a technical perspective.  It’s about time Linux got a managable sound subsystem, and some of the features–such as network streaming and synchronised playback–are quite impressive.

However, one thing that really irks me is that, as deployed by major distributions, it appears to enforce the narrow-minded view that a desktop is used by only one person, and that sound is only ever going to play when somebody is logged in to a graphical session.  Anybody who uses MPD has probably experienced the pain caused by this already.  Unfortunately my experience so far with Ubuntu Intrepid is that trying to change this results in even more pain.  Having set up a system-wide instance I’m now in the position where the first time I attempt to play sound works correctly, but any subsequent attempts fail until I kill a per-session PulseAudio instance that has magically spawned (even though I’ve set it not to).  Once the per-session instance is dead, I have no more problems and everything works perfectly until the next time I log in.

I’m currently trialing Fedora 10 on my desktop, so I’ll update this post if I have any more luck there.  Feel free to correct me in the comments if I’m just being stupid or missing something!

Edit: I’ve since fixed this problem: MPD + PulseAudio + Ubuntu Intrepid (8.10).

Yet another blog

The title says it all.  Yet another blog.  And I don’t just mean in the sense of adding more noise to the Internet.  In the time I’ve been maintaining websites, I’ve probably had around 10 things that might be classified as blog-like, ranging through various pre-existing systems (like WordPress) and several self-written content management systems, frameworks, blogs, wikis, etc.

This can be explained by the kind of person I am–I like to work things out, usually from some set of basic principles.  For me, putting a site together using something like Joomla is no fun–the real fun to be had is in actually working out how to write a database-backed content management system with a plugin architecture and theming.  This means that for all personal websites I have a natural tendency to try and write everything myself.  The symptoms are reminiscent of “not invented here” syndrome, yet the cause is different to most.  Most of my projects that fall in this category have been web applications, for some reason.

Which is why using WordPress is a significant step in the right direction for me.  With the time pressures I’ve gained over the past two years, time to work on fun projects is much shorter than before, and the end result is never finishing anything.  If I have a limited amount of time to spend on a project, I spend it on the one that is the most interesting at the time.  Unfortunately, the “interesting” bits tend to die out about 1/3 of the way through most projects, the other 2/3 being hard work to actually mold it into something usable.  When, for example, my blog software is incomplete and not very nice to use because I never got around to finishing the administration interface, I end up not using it, creating yet another stagnant website.  I regularly have ideas for things to write about, but only have about 30 minutes free in which to write them–the downside of wrestling with unfinished software outweighs the smug feeling of “I wrote this”, turning it to “why did I bother?”.  I’ve started giving up on these dead-end projects, moving project documentation to DokuWiki, moving my blog to WordPress, using gitweb instead of my own Git browser, etc.  This is leading me to consider a wider approach of evaluating my projects based on criterias such as “has it been done already?”, “can I get it done in a short period of time?”, etc., and ditching projects which will be a huge amount of effort for little or no gain.  I simply don’t have the time any more.  It’s become painfully obvious that I need to weed out some of my projects to have any hope of producing anything ever.

Still here?  Awesome.  So after that little ramble, let me tell you what this blog should be…  My aim is to generally write about interesting technical stuff I come across that I think like-minded people would be interested in.  What I’m not going to do is use it to ramble on about my own life in general—I’m sure nobody cares.  (Ok, this post was a bad example—I’m tired, it’s to be expected.)  Hopefully along the way I can improve my writing style to be a bit more readable.

Still here???  Wow.  Congratulations—you win one Internet!  Check back later, I might have written something interesting!  (Or use the RSS feed.)