Posts Tagged ‘api

Upgrade to rv-split now!

If you’ve been hanging around the XMMS2 hype-sphere lately, you’ve certainly heard “wait for rv-split to be merged” almost as often as “it should be a service client”. Well, wait no more, for rv-split has made it into the -devel tree!

It means that all C clients are broken now, and possibly clients in other languages too. Yes, yours too. It needs fixing, and I’m going to explain how.

But, you ask, what is rv-split in the first place?

The result/value-split, AKA “rv-split” or sometimes just “rv”, is a change in the XMMS2 clientlib. Up until now, values returned by the server were kept inside the

xmmsc_result_t

structure that you got back from the call. The data was to be fetched directly from the result.

In sync mode, it went something like this:

xmmsc_result_t *result;
const char *name;

result = xmmsc_playlist_current_active (conn);
xmmsc_result_wait (result);

if (xmmsc_result_iserror (result)) {
   printf ("Server error: %s\n", xmmsc_result_get_error (result));
   exit (1);
}

// The name is retrieved from the result
if (xmmsc_result_get_string (result, &name)) {
   printf ("Active playlist is %s\n", name);
}

// We free the result, which also frees all the data it referenced,
// i.e. the ‘name’ string
xmmsc_result_unref (result);

The goal of rv-split was to isolate values outside of the result structure (for reasons that will become more obvious when we talk about the async calls). To do that, we introduced a new structure called

xmmsv_t

(for “xmms value”), that can contain any type of value. Accessor functions are used to extract each type from it, in a similar way to how it was done with result structures.

Let’s show the sync example again:

xmmsc_result_t *result;
xmmsv_t *value;
const char *name, *errbuf;

result = xmmsc_playlist_current_active (conn);
xmmsc_result_wait (result);
value = xmmsc_result_get_value (result);

if (xmmsv_get_error (value, &errbuf)) {
   printf ("Server error: %s\n", errbuf);
   exit (1);
}

if (xmmsv_get_string (value, &name)) {
   printf ("Active playlist is %s\n", name);
}

// We free the result, which also frees the value it contained,
// i.e. the ‘value’ variable, and the ‘name’ string
xmmsc_result_unref (result);

All we have to do is extract the

xmmsv_t

from the

xmmsc_result_t

. No raw data is stored in the result structure anymore.

read the rest of this entry »

MP3Tunes contest: XMMS2 support?

MP3Tunes may or may not be an Evil (as in Axis of ~) service, but it just announced a developer contest to encourage people to implement its API and create new interfaces (on the desktop, mobile phone, TV, toilet seat, whatever).

The contest page on the official website isn’t quite as verbose as one would have hoped, though, and the link to the rules points to a missing webpage. Some more intel is however available in a blog post on Michael Robertson’s blog. Yes, Michael MP3.Com/Linspire Robertson, who is also Michael MP3Tunes Robertson, obviously.

The deal: you have until November 5th, 2007, to submit an interface to MP3Tunes in one of the ten predefined categories (Desktop Player, Game Console, WebUI, PDA, etc). The winner in each category will receive a cosy $1000. I haven’t determined whether it’s a public vote, a closed jury, or some other semi-random algorithm involving car-driving girafes.

I haven’t yet checked what the API offers, either, but I sure wonder whether we could hack something together with XMMS2. If it could be hooked into the daemon, and apart from the obvious ever satisfying benefit of being neat and fun, it might allow using any of our interfaces (AKA clients) to play music from MP3Tunes.
read the rest of this entry »