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
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:
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
(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:
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
from the
. No raw data is stored in the result structure anymore.