comparison src/alac/plugin.c @ 71:5b0619b09745 trunk

[svn] Detect duration: - this took a lot of brute forcing - oh, and apparently apple has a sense of humour about their format, it uses a samplesize multiple of 251.
author nenolod
date Sun, 01 Oct 2006 00:05:37 -0700
parents 31799ddaf2e9
children c2981235af26
comparison
equal deleted inserted replaced
70:31799ddaf2e9 71:5b0619b09745
243 243
244 gpointer decode_thread(void *args) 244 gpointer decode_thread(void *args)
245 { 245 {
246 demux_res_t demux_res; 246 demux_res_t demux_res;
247 unsigned int output_size, i; 247 unsigned int output_size, i;
248 gulong duration = 0; /* samples added up */
249 gint framesize;
248 250
249 set_endian(); 251 set_endian();
250 252
251 input_file = vfs_fopen((char *) args, "rb"); 253 input_file = vfs_fopen((char *) args, "rb");
252 input_stream = stream_create_file(input_file, 1); 254 input_stream = stream_create_file(input_file, 1);
260 return 0; 262 return 0;
261 263
262 /* initialise the sound converter */ 264 /* initialise the sound converter */
263 init_sound_converter(&demux_res); 265 init_sound_converter(&demux_res);
264 266
267 /* Sample rates are multiples of 251?! Apple is *fucking* *insane*! -nenolod */
268 duration = (demux_res.num_sample_byte_sizes * (float)((1024 * demux_res.sample_size) - 1.0) /
269 (float)(demux_res.sample_rate / 251));
270
265 alac_ip.output->open_audio(FMT_S16_LE, demux_res.sample_rate, demux_res.num_channels); 271 alac_ip.output->open_audio(FMT_S16_LE, demux_res.sample_rate, demux_res.num_channels);
266 alac_ip.set_info((char *) args, -1, -1, demux_res.sample_rate, demux_res.num_channels); 272 alac_ip.set_info((char *) args, duration, -1, demux_res.sample_rate, demux_res.num_channels);
267 273
268 /* will convert the entire buffer */ 274 /* will convert the entire buffer */
269 GetBuffer(&demux_res); 275 GetBuffer(&demux_res);
270 276
271 going = 0; 277 going = 0;