comparison src/alac/plugin.c @ 1423:c5bbf2c90ba3

alac: new tuple API
author William Pitcock <nenolod@atheme-project.org>
date Fri, 10 Aug 2007 06:38:58 -0500
parents 761e17b23e0c
children 6b1f888a4c52
comparison
equal deleted inserted replaced
1422:35c8b1faf27b 1423:c5bbf2c90ba3
44 44
45 #include <glib.h> 45 #include <glib.h>
46 #include <audacious/i18n.h> 46 #include <audacious/i18n.h>
47 47
48 #include <audacious/plugin.h> 48 #include <audacious/plugin.h>
49 #include <audacious/main.h>
49 #include <audacious/output.h> 50 #include <audacious/output.h>
50 #include <audacious/vfs.h> 51 #include <audacious/vfs.h>
51 #include <audacious/util.h> 52 #include <audacious/util.h>
52 53
53 #include "demux.h" 54 #include "demux.h"
114 stream_destroy(input_stream); 115 stream_destroy(input_stream);
115 116
116 return TRUE; 117 return TRUE;
117 } 118 }
118 119
119 TitleInput *build_tuple_from_demux(demux_res_t *demux_res, char *path) 120 Tuple *build_tuple_from_demux(demux_res_t *demux_res, char *path)
120 { 121 {
121 TitleInput *ti = bmp_title_input_new(); 122 Tuple *ti = tuple_new();
123 gchar *scratch;
122 124
123 if (demux_res->tuple.art != NULL) 125 if (demux_res->tuple.art != NULL)
124 ti->performer = g_strdup(demux_res->tuple.art); 126 tuple_associate_string(ti, "artist", demux_res->tuple.art);
125 if (demux_res->tuple.nam != NULL) 127 if (demux_res->tuple.nam != NULL)
126 ti->track_name = g_strdup(demux_res->tuple.nam); 128 tuple_associate_string(ti, "title", demux_res->tuple.nam);
127 if (demux_res->tuple.alb != NULL) 129 if (demux_res->tuple.alb != NULL)
128 ti->album_name = g_strdup(demux_res->tuple.alb); 130 tuple_associate_string(ti, "album", demux_res->tuple.alb);
129 if (demux_res->tuple.gen != NULL) 131 if (demux_res->tuple.gen != NULL)
130 ti->genre = g_strdup(demux_res->tuple.gen); 132 tuple_associate_string(ti, "genre", demux_res->tuple.gen);
131 if (demux_res->tuple.cmt != NULL) 133 if (demux_res->tuple.cmt != NULL)
132 ti->comment = g_strdup(demux_res->tuple.cmt); 134 tuple_associate_string(ti, "comment", demux_res->tuple.cmt);
133 if (demux_res->tuple.day != NULL) 135 if (demux_res->tuple.day != NULL)
134 ti->year = atoi(demux_res->tuple.day); 136 tuple_associate_int(ti, "year", atoi(demux_res->tuple.day));
135 137
136 ti->file_name = g_path_get_basename(path); 138 scratch = g_path_get_basename(path);
137 ti->file_path = g_path_get_dirname(path); 139 tuple_associate_string(ti, "file-name", scratch);
138 ti->file_ext = extname(path); 140 g_free(scratch);
141
142 scratch = g_path_get_dirname(path);
143 tuple_associate_string(ti, "file-path", scratch);
144 g_free(scratch);
145
146 tuple_associate_string(ti, "file-ext", extname(path));
147 tuple_associate_string(ti, "codec", "Apple Lossless (ALAC)");
148 tuple_associate_string(ti, "quality", "lossless");
139 149
140 return ti; 150 return ti;
141 } 151 }
142 152
143 TitleInput *build_tuple(char *filename) 153 Tuple *build_tuple(char *filename)
144 { 154 {
145 demux_res_t demux_res; 155 demux_res_t demux_res;
146 VFSFile *input_file; 156 VFSFile *input_file;
147 stream_t *input_stream; 157 stream_t *input_stream;
148 158
311 { 321 {
312 demux_res_t demux_res; 322 demux_res_t demux_res;
313 gulong duration = 0; /* samples added up */ 323 gulong duration = 0; /* samples added up */
314 VFSFile *input_file; 324 VFSFile *input_file;
315 stream_t *input_stream; 325 stream_t *input_stream;
316 TitleInput *ti; 326 Tuple *ti;
317 gchar *title; 327 gchar *title;
318 328
319 memset(&demux_res, 0, sizeof(demux_res)); 329 memset(&demux_res, 0, sizeof(demux_res));
320 330
321 set_endian(); 331 set_endian();
333 343
334 demux_res.stream = input_stream; 344 demux_res.stream = input_stream;
335 345
336 /* Get the titlestring ready. */ 346 /* Get the titlestring ready. */
337 ti = build_tuple_from_demux(&demux_res, (char *) args); 347 ti = build_tuple_from_demux(&demux_res, (char *) args);
338 title = xmms_get_titlestring(xmms_get_gentitle_format(), ti); 348 title = tuple_formatter_process_string(ti, cfg.gentitle_format);
339 349
340 /* initialise the sound converter */ 350 /* initialise the sound converter */
341 demux_res.alac = create_alac(demux_res.sample_size, demux_res.num_channels); 351 demux_res.alac = create_alac(demux_res.sample_size, demux_res.num_channels);
342 alac_set_info(demux_res.alac, demux_res.codecdata); 352 alac_set_info(demux_res.alac, demux_res.codecdata);
343 353