Silly C errors in gjay

Gjay GUI

I have been working on Gjay to add support for http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki where I had what initially looked like a strange problem. When WITH_MPDCLIENT was defined, the program would crash in all sorts of weird places when the main program structure had this:

#ifdef WITH_MPDCLIENT
struct mpd_connection *mpdclient_connection;
#endif

But would work fine when it was:

struct mpd_connection *mpdclient_connection;
#ifdef WITH_MPDCLIENT
#endif /* WITH_MPDCLIENT */

I tried changing the structure to just void *blah to see if it made a difference and it didn’t. The program would crash every time.

The answer was pretty simple in the end. The WITH_MPDCLIENT is defined in the file config.h and not every c source file was including it. Needless to say, they should! So half the program was using one version of the structure and the other was using another; no wonder the whole program was a mess because anything beyond this entry in the structure would be a few bytes out.

With that little insanity out of the way, I can get back to making gjay work with MPD.

Comments

6 responses to “Silly C errors in gjay”

  1. Anonymous Avatar
    Anonymous

    Would you consider including the entirety of your posts in your feed, rather than just the first few words and a link? That would make Planet Debian more useful.

  2. Craig Avatar
    Craig

    Thanks for pointing it out, I didn’t realise the syndication was doing that. It should be full articles now.

  3. Joshua Judson Rosen Avatar

    It’s interesting to hear that you’re adding MPD support to GJay, because I actually just started hacking on GJay as part of my own GJay + MPD' project--though it's sort-ofinverted’ from what you’re probably doing: I started by writing an external script http://www.hackerposse.com/~rozzin/mpdjay that uses GJay to automatically refill MPD’s play-queue rather than letting it run out (see the comments in the script), and that script actually seems to have been sufficient for the initial project (a smart home jukebox), but then my wife was so impressed with it that she asked me to figure out how make her a portable version…, so I’ve been looking into modularising-out things that are superfluous dependencies for me (like Audacious) to make it easier to integrate MPD+mpdjay+(headless) GJay+ncmpc into a NanoNote-based player, and making whatever other modifications end up being necessary to support that mode of operation.

    1. Craig Avatar
      Craig

      Currently the version in git works with mpd fine. There is a restriction that the mpd program must be on the same system as gjay, or at the very least have the same directory for the music files.

      gjay is soft-linked (I think that’s the right term) to mpdclient libraries using dlopen and dlsym, meaning that you don’t need that library there for it to run. I was going to do the same for audacious too so mpd people don’t need to have libaudclient installed for gjay.

      I hadn’t thought of a “none” music player where you just use it to make playlists but it would be a trivial add-on. That can probably make the next release.

      Someone else has asked for a non-gtk version, at least at compile time. That’s harder to do but not impossible but will probably wait for another version.

      1. Joshua Judson Rosen Avatar

        What’s the preferred way of submitting patches for GJay, these days? I can post a git repository to my web-site, or just generate a patch-series if that’s preferred; would you rather I e-mail notice/patches to you, send them to a mailing-list, post them to the Debian BTS, or something else?

        The web-page on SourceForge still seems to imply that I should just e-mail Chuck… 🙂

        1. Craig Avatar
          Craig

          Email them to me, preferably patched off the git source to reduce the chances of a conflict. The other way is to put it into the sourceforge tracker which has the advantage I’ll not lose it in my email folders.

Leave a Reply

Your email address will not be published. Required fields are marked *