Mercurial > audlegacy-plugins
comparison src/alac/plugin.c @ 79:722fd456ae1a trunk
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
| author | nenolod |
|---|---|
| date | Mon, 02 Oct 2006 20:54:57 -0700 |
| parents | 096db10ce25f |
| children | 86ce11c6b8c3 |
comparison
equal
deleted
inserted
replaced
| 78:096db10ce25f | 79:722fd456ae1a |
|---|---|
| 50 static GThread *playback_thread; | 50 static GThread *playback_thread; |
| 51 static int going = 0; | 51 static int going = 0; |
| 52 | 52 |
| 53 extern void set_endian(); | 53 extern void set_endian(); |
| 54 | 54 |
| 55 static gchar * | |
| 56 extname(const char *filename) | |
| 57 { | |
| 58 gchar *ext = strrchr(filename, '.'); | |
| 59 | |
| 60 if (ext != NULL) | |
| 61 ++ext; | |
| 62 | |
| 63 return ext; | |
| 64 } | |
| 65 | |
| 55 static void alac_about(void) | 66 static void alac_about(void) |
| 56 { | 67 { |
| 57 static GtkWidget *aboutbox; | 68 static GtkWidget *aboutbox; |
| 58 | 69 |
| 59 if(aboutbox != NULL) | 70 if(aboutbox != NULL) |
| 104 vfs_fclose(input_file); | 115 vfs_fclose(input_file); |
| 105 | 116 |
| 106 return TRUE; | 117 return TRUE; |
| 107 } | 118 } |
| 108 | 119 |
| 120 TitleInput *build_tuple_from_demux(demux_res_t *demux_res, char *path) | |
| 121 { | |
| 122 TitleInput *ti = bmp_title_input_new(); | |
| 123 | |
| 124 if (demux_res->tuple.art != NULL) | |
| 125 ti->performer = g_strdup(demux_res->tuple.art); | |
| 126 if (demux_res->tuple.nam != NULL) | |
| 127 ti->track_name = g_strdup(demux_res->tuple.nam); | |
| 128 if (demux_res->tuple.alb != NULL) | |
| 129 ti->album_name = g_strdup(demux_res->tuple.alb); | |
| 130 if (demux_res->tuple.gen != NULL) | |
| 131 ti->genre = g_strdup(demux_res->tuple.gen); | |
| 132 if (demux_res->tuple.cmt != NULL) | |
| 133 ti->comment = g_strdup(demux_res->tuple.cmt); | |
| 134 if (demux_res->tuple.day != NULL) | |
| 135 ti->year = atoi(demux_res->tuple.day); | |
| 136 | |
| 137 ti->file_name = g_path_get_basename(path); | |
| 138 ti->file_path = g_path_get_dirname(path); | |
| 139 ti->file_ext = extname(path); | |
| 140 | |
| 141 return ti; | |
| 142 } | |
| 143 | |
| 144 TitleInput *build_tuple(char *filename) | |
| 145 { | |
| 146 demux_res_t demux_res; | |
| 147 VFSFile *input_file; | |
| 148 stream_t *input_stream; | |
| 149 TitleInput *ti; | |
| 150 | |
| 151 input_file = vfs_fopen(filename, "rb"); | |
| 152 input_stream = stream_create_file(input_file, 1); | |
| 153 | |
| 154 set_endian(); | |
| 155 | |
| 156 if (!input_stream) | |
| 157 { | |
| 158 vfs_fclose(input_file); | |
| 159 return NULL; | |
| 160 } | |
| 161 | |
| 162 /* if qtmovie_read returns successfully, the stream is up to | |
| 163 * the movie data, which can be used directly by the decoder */ | |
| 164 if (!qtmovie_read(input_stream, &demux_res)) | |
| 165 { | |
| 166 stream_destroy(input_stream); | |
| 167 vfs_fclose(input_file); | |
| 168 return NULL; | |
| 169 } | |
| 170 | |
| 171 stream_destroy(input_stream); | |
| 172 vfs_fclose(input_file); | |
| 173 | |
| 174 return build_tuple_from_demux(&demux_res, filename); | |
| 175 } | |
| 176 | |
| 109 static void play_file(char *filename) | 177 static void play_file(char *filename) |
| 110 { | 178 { |
| 111 going = 1; | 179 going = 1; |
| 112 playback_thread = g_thread_create(decode_thread, filename, TRUE, NULL); | 180 playback_thread = g_thread_create(decode_thread, filename, TRUE, NULL); |
| 113 } | 181 } |
| 154 NULL, | 222 NULL, |
| 155 NULL, | 223 NULL, |
| 156 NULL, | 224 NULL, |
| 157 NULL, | 225 NULL, |
| 158 NULL, /* file_info_box */ | 226 NULL, /* file_info_box */ |
| 159 NULL | 227 NULL, |
| 228 build_tuple | |
| 160 }; | 229 }; |
| 161 | 230 |
| 162 static int get_sample_info(demux_res_t *demux_res, uint32_t samplenum, | 231 static int get_sample_info(demux_res_t *demux_res, uint32_t samplenum, |
| 163 uint32_t *sample_duration, | 232 uint32_t *sample_duration, |
| 164 uint32_t *sample_byte_size) | 233 uint32_t *sample_byte_size) |
| 238 unsigned int output_size, i; | 307 unsigned int output_size, i; |
| 239 gulong duration = 0; /* samples added up */ | 308 gulong duration = 0; /* samples added up */ |
| 240 gint framesize; | 309 gint framesize; |
| 241 VFSFile *input_file; | 310 VFSFile *input_file; |
| 242 stream_t *input_stream; | 311 stream_t *input_stream; |
| 312 TitleInput *ti; | |
| 313 gchar *title; | |
| 243 | 314 |
| 244 memset(&demux_res, '\0', sizeof(demux_res_t)); | 315 memset(&demux_res, '\0', sizeof(demux_res_t)); |
| 245 | 316 |
| 246 set_endian(); | 317 set_endian(); |
| 247 | 318 |
| 256 if (!qtmovie_read(input_stream, &demux_res)) | 327 if (!qtmovie_read(input_stream, &demux_res)) |
| 257 return 0; | 328 return 0; |
| 258 | 329 |
| 259 demux_res.stream = input_stream; | 330 demux_res.stream = input_stream; |
| 260 | 331 |
| 332 /* Get the titlestring ready. */ | |
| 333 ti = build_tuple_from_demux(&demux_res, (char *) args); | |
| 334 title = xmms_get_titlestring(xmms_get_gentitle_format(), ti); | |
| 335 | |
| 261 /* initialise the sound converter */ | 336 /* initialise the sound converter */ |
| 262 demux_res.alac = create_alac(demux_res.sample_size, demux_res.num_channels); | 337 demux_res.alac = create_alac(demux_res.sample_size, demux_res.num_channels); |
| 263 alac_set_info(demux_res.alac, demux_res.codecdata); | 338 alac_set_info(demux_res.alac, demux_res.codecdata); |
| 264 | 339 |
| 265 /* Sample rates are multiples of 251?! Apple is *fucking* *insane*! -nenolod */ | 340 /* Sample rates are multiples of 251?! Apple is *fucking* *insane*! -nenolod */ |
| 266 duration = (demux_res.num_sample_byte_sizes * (float)((1024 * demux_res.sample_size) - 1.0) / | 341 duration = (demux_res.num_sample_byte_sizes * (float)((1024 * demux_res.sample_size) - 1.0) / |
| 267 (float)(demux_res.sample_rate / 251)); | 342 (float)(demux_res.sample_rate / 251)); |
| 268 | 343 |
| 269 alac_ip.output->open_audio(FMT_S16_LE, demux_res.sample_rate, demux_res.num_channels); | 344 alac_ip.output->open_audio(FMT_S16_LE, demux_res.sample_rate, demux_res.num_channels); |
| 270 alac_ip.set_info((char *) args, duration, -1, demux_res.sample_rate, demux_res.num_channels); | 345 alac_ip.set_info(title, duration, -1, demux_res.sample_rate, demux_res.num_channels); |
| 271 | 346 |
| 272 /* will convert the entire buffer */ | 347 /* will convert the entire buffer */ |
| 273 GetBuffer(&demux_res); | 348 GetBuffer(&demux_res); |
| 274 | 349 |
| 275 going = 0; | 350 going = 0; |
