View | Details | Raw Unified | Return to bug 137907
Collapse All | Expand All

(-)Makefile (-1 / +1 lines)
Lines 7-13 Link Here
7
7
8
PORTNAME=	lame
8
PORTNAME=	lame
9
PORTVERSION=	3.98.2
9
PORTVERSION=	3.98.2
10
PORTREVISION=	1
10
PORTREVISION=	2
11
CATEGORIES=	audio
11
CATEGORIES=	audio
12
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE} \
12
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE} \
13
		ftp://ftp.fu-berlin.de/unix/sound/%SUBDIR%/
13
		ftp://ftp.fu-berlin.de/unix/sound/%SUBDIR%/
(-)files/patch-libmp3lame-lame.c (+72 lines)
Added Link Here
1
--- libmp3lame/lame.c.orig	2008-08-05 19:26:02.000000000 +0200
2
+++ libmp3lame/lame.c	2009-08-17 21:25:17.749630168 +0200
3
@@ -1602,6 +1602,13 @@
4
         /* update mfbuf[] counters */
5
         gfc->mf_size += n_out;
6
         assert(gfc->mf_size <= MFSIZE);
7
+
8
+        /* lame_encode_flush may have set gfc->mf_sample_to_encode to 0
9
+         * so we have to reinitialize it here when that happened.
10
+         */
11
+        if (gfc->mf_samples_to_encode < 1) {
12
+            gfc->mf_samples_to_encode = ENCDELAY + POSTDELAY;
13
+        }
14
         gfc->mf_samples_to_encode += n_out;
15
 
16
 
17
@@ -1931,6 +1938,10 @@
18
     int     frames_left;
19
     int     samples_to_encode = gfc->mf_samples_to_encode;
20
 
21
+    /* Was flush already called? */
22
+    if (gfc->mf_samples_to_encode < 1) {
23
+        return 0;
24
+    }
25
     memset(buffer, 0, sizeof(buffer));
26
     mp3count = 0;
27
     
28
@@ -1942,7 +1953,9 @@
29
     end_padding += pad_out_samples;
30
 
31
     frames_left = (samples_to_encode + pad_out_samples) / gfp->framesize;
32
-    while (frames_left > 0) {
33
+
34
+    /* send in a frame of 0 padding until all internal sample buffers are flushed */
35
+    while (frames_left > 0 && imp3 >= 0) {
36
         int frame_num = gfp->frameNum;
37
 
38
         mp3buffer_size_remaining = mp3buffer_size - mp3count;
39
@@ -1951,22 +1964,22 @@
40
         if (mp3buffer_size == 0)
41
             mp3buffer_size_remaining = 0;
42
 
43
-        /* send in a frame of 0 padding until all internal sample buffers
44
-         * are flushed
45
-         */
46
         imp3 = lame_encode_buffer(gfp, buffer[0], buffer[1], 32,
47
                                   mp3buffer, mp3buffer_size_remaining);
48
-        
49
-        if (frame_num != gfp->frameNum) {
50
-            --frames_left;
51
-        }
52
-        if (imp3 < 0) {
53
-            /* some type of fatal error */
54
-            return imp3;
55
-        }
56
         mp3buffer += imp3;
57
         mp3count += imp3;
58
+	frames_left -= (frame_num != gfp->frameNum) ? 1 : 0;
59
     }
60
+    /* Set gfc->mf_samples_to_encode to 0, so we may detect
61
+     * and break loops calling it more than once in a row.
62
+     */
63
+    gfc->mf_samples_to_encode = 0;
64
+
65
+    if (imp3 < 0) {
66
+        /* some type of fatal error */
67
+        return imp3;
68
+    }
69
+
70
     mp3buffer_size_remaining = mp3buffer_size - mp3count;
71
     /* if user specifed buffer size = 0, dont check size */
72
     if (mp3buffer_size == 0)

Return to bug 137907