diff 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
line wrap: on
line diff
--- a/src/alac/plugin.c	Sat Sep 30 23:25:06 2006 -0700
+++ b/src/alac/plugin.c	Sun Oct 01 00:05:37 2006 -0700
@@ -245,6 +245,8 @@
 {
     demux_res_t demux_res;
     unsigned int output_size, i;
+    gulong duration = 0;	/* samples added up */
+    gint framesize;
 
     set_endian();
 
@@ -262,8 +264,12 @@
     /* initialise the sound converter */
     init_sound_converter(&demux_res);
 
+    /* Sample rates are multiples of 251?! Apple is *fucking* *insane*! -nenolod */
+    duration = (demux_res.num_sample_byte_sizes * (float)((1024 * demux_res.sample_size) - 1.0) /
+	(float)(demux_res.sample_rate / 251));
+
     alac_ip.output->open_audio(FMT_S16_LE, demux_res.sample_rate, demux_res.num_channels);
-    alac_ip.set_info((char *) args, -1, -1, demux_res.sample_rate, demux_res.num_channels);
+    alac_ip.set_info((char *) args, duration, -1, demux_res.sample_rate, demux_res.num_channels);
 
     /* will convert the entire buffer */
     GetBuffer(&demux_res);