changeset 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 510b147fa744
files ChangeLog src/alac/plugin.c
diffstat 2 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Sep 30 23:25:06 2006 -0700
+++ b/ChangeLog	Sun Oct 01 00:05:37 2006 -0700
@@ -1,3 +1,11 @@
+2006-10-01 06:25:06 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [140]
+  - fix memory leaks
+  
+  trunk/src/alac/plugin.c |    3 +++
+  1 file changed, 3 insertions(+)
+
+
 2006-10-01 06:18:01 +0000  William Pitcock <nenolod@nenolod.net>
   revision [138]
   - about box
--- 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);