29 struct xmms_stream_type_St {
41 typedef struct xmms_stream_type_val_St {
59 for (n = st->list; n; n = g_list_next (n)) {
62 g_free (val->d.string);
67 g_list_free (st->list);
87 key = va_arg (ap,
int);
92 res->name = g_strdup (va_arg (ap,
char *));
97 res->priority = va_arg (ap,
int);
108 val->d.string = g_strdup (va_arg (ap,
char *));
114 val->d.num = va_arg (ap,
int);
122 res->list = g_list_append (res->list, val);
130 res->name = g_strconcat (mime,
":", url, NULL);
132 res->name = g_strdup (mime);
134 g_assert_not_reached ();
137 g_strdelimit (res->name,
".",
'_');
140 if (res->priority < 0) {
156 for (n = st->list; n; n = g_list_next (n)) {
158 if (val->key == key) {
159 if (val->type !=
STRING) {
160 XMMS_DBG (
"Key passed to get_str is not string");
163 return val->d.string;
179 for (n = st->list; n; n = g_list_next (n)) {
181 if (val->key == key) {
182 if (val->type !=
INT) {
183 XMMS_DBG (
"Key passed to get_int is not int");
198 if (vin->type != vout->type)
202 return g_pattern_match_simple (vin->d.string, vout->d.string);
204 return vin->d.num == vout->d.num;
214 for (in = in_type->list; in; in = g_list_next (in)) {
218 for (n = out_type->list; n; n = g_list_next (n)) {
220 if (inval->key == outval->key) {
221 if (!match_val (inval, outval))
245 gint bestscore = 100000;
246 gint format, samplerate, channels;
247 gint gformat, gsamplerate, gchannels;
254 if (format == -1 || samplerate == -1 || channels == -1) {
255 xmms_log_info (
"In-type lacks format, samplerate or channels");
259 for (on = goal_types ; on; on = g_list_next (on)) {
265 if (strcmp (mime,
"audio/pcm") != 0) {
272 if (gsamplerate == -1) {
273 gsamplerate = samplerate;
275 if (gformat == -1 || gchannels == -1) {
280 if (gchannels > channels) {
282 score += gchannels - channels;
283 }
else if (gchannels < channels) {
285 score += 10 * (channels - gchannels);
290 if (gformat > format) {
292 score += gformat - format;
293 }
else if (gformat < format) {
295 score += 10 * (format - gformat);
299 if (gsamplerate > samplerate) {
301 score += 2 * gsamplerate / samplerate;
302 }
else if (gsamplerate < samplerate) {
304 score += 20 * samplerate / gsamplerate;
307 if (score < bestscore) {
315 xmms_log_error (
"Couldn't convert sample format to any of the %d goal formats",
316 g_list_length ((GList *)goal_types));
326 if (gsamplerate == -1) {
327 gsamplerate = samplerate;
367 va_start (ap, begin);
enum xmms_stream_type_key_E xmms_stream_type_key_t
gint xmms_stream_type_get_int(const xmms_stream_type_t *st, xmms_stream_type_key_t key)
#define xmms_object_unref(obj)
struct xmms_stream_type_St xmms_stream_type_t
xmms_stream_type_val_type_E
xmms_stream_type_t * xmms_stream_type_coerce(const xmms_stream_type_t *in, const GList *goal_types)
Find the best pair of formats.
gboolean xmms_stream_type_match(const xmms_stream_type_t *in_type, const xmms_stream_type_t *out_type)
xmms_stream_type_t * _xmms_stream_type_new(const gchar *begin,...)
#define xmms_log_error(fmt,...)
#define XMMS_STREAM_TYPE_BEGIN
enum xmms_stream_type_val_type_E xmms_stream_type_val_type_t
#define xmms_log_info(fmt,...)
#define XMMS_STREAM_TYPE_PRIORITY_DEFAULT
#define XMMS_DBG(fmt,...)
#define xmms_object_new(objtype, destroyfunc)
const char * xmms_stream_type_get_str(const xmms_stream_type_t *st, xmms_stream_type_key_t key)
xmms_stream_type_t * xmms_stream_type_parse(va_list ap)
struct xmms_stream_type_val_St xmms_stream_type_val_t