From da1b20173cec9bf4a5fa7b5c3d5bd251c4741610 Mon Sep 17 00:00:00 2001
From: Michael Hanson <hansonorders@verizon.net>
Date: Fri, 12 Nov 2010 21:58:33 +0000
Subject: lame: update to latest

---
 abs/core/lame/03_lame-ffmpeg.diff | 72 +++++++++++++++++++++++++++++++++++++++
 abs/core/lame/PKGBUILD            | 25 ++++++++------
 abs/core/lame/__changelog         |  1 +
 3 files changed, 87 insertions(+), 11 deletions(-)
 create mode 100644 abs/core/lame/03_lame-ffmpeg.diff
 create mode 100644 abs/core/lame/__changelog

diff --git a/abs/core/lame/03_lame-ffmpeg.diff b/abs/core/lame/03_lame-ffmpeg.diff
new file mode 100644
index 0000000..a803935
--- /dev/null
+++ b/abs/core/lame/03_lame-ffmpeg.diff
@@ -0,0 +1,72 @@
+--- lame-3.98.2.orig/libmp3lame/lame.c	2009-07-07 10:52:01.000000000 +0200
++++ lame-3.98.2/libmp3lame/lame.c	2009-07-07 10:52:03.000000000 +0200
+@@ -1602,6 +1602,13 @@
+         /* update mfbuf[] counters */
+         gfc->mf_size += n_out;
+         assert(gfc->mf_size <= MFSIZE);
++
++        /* lame_encode_flush may have set gfc->mf_sample_to_encode to 0
++         * so we have to reinitialize it here when that happened.
++         */
++        if (gfc->mf_samples_to_encode < 1) {
++            gfc->mf_samples_to_encode = ENCDELAY + POSTDELAY;
++        }
+         gfc->mf_samples_to_encode += n_out;
+ 
+ 
+@@ -1931,6 +1938,10 @@
+     int     frames_left;
+     int     samples_to_encode = gfc->mf_samples_to_encode;
+ 
++    /* Was flush already called? */
++    if (gfc->mf_samples_to_encode < 1) {
++        return 0;
++    }
+     memset(buffer, 0, sizeof(buffer));
+     mp3count = 0;
+     
+@@ -1942,7 +1953,9 @@
+     end_padding += pad_out_samples;
+ 
+     frames_left = (samples_to_encode + pad_out_samples) / gfp->framesize;
+-    while (frames_left > 0) {
++
++    /* send in a frame of 0 padding until all internal sample buffers are flushed */
++    while (frames_left > 0 && imp3 >= 0) {
+         int frame_num = gfp->frameNum;
+ 
+         mp3buffer_size_remaining = mp3buffer_size - mp3count;
+@@ -1951,22 +1964,23 @@
+         if (mp3buffer_size == 0)
+             mp3buffer_size_remaining = 0;
+ 
+-        /* send in a frame of 0 padding until all internal sample buffers
+-         * are flushed
+-         */
+         imp3 = lame_encode_buffer(gfp, buffer[0], buffer[1], 32,
+                                   mp3buffer, mp3buffer_size_remaining);
+         
+-        if (frame_num != gfp->frameNum) {
+-            --frames_left;
+-        }
+-        if (imp3 < 0) {
+-            /* some type of fatal error */
+-            return imp3;
+-        }
+         mp3buffer += imp3;
+         mp3count += imp3;
++        frames_left -= (frame_num != gfp->frameNum) ? 1 : 0;
+     }
++    /* Set gfc->mf_samples_to_encode to 0, so we may detect
++     * and break loops calling it more than once in a row.
++     */
++    gfc->mf_samples_to_encode = 0;
++
++    if (imp3 < 0) {
++        /* some type of fatal error */
++        return imp3;
++    }
++
+     mp3buffer_size_remaining = mp3buffer_size - mp3count;
+     /* if user specifed buffer size = 0, dont check size */
+     if (mp3buffer_size == 0)
diff --git a/abs/core/lame/PKGBUILD b/abs/core/lame/PKGBUILD
index 7be3e87..6853b74 100644
--- a/abs/core/lame/PKGBUILD
+++ b/abs/core/lame/PKGBUILD
@@ -1,8 +1,9 @@
-# $Id: PKGBUILD 4167 2008-07-04 18:00:32Z hugo $
-# Maintainer: Hugo Doria <hugo@archlinux.org>
+# $Id: PKGBUILD 80636 2010-05-20 16:06:46Z ibiru $
+# Maintainer:  Ionut Biru <ibiru@archlinux.org>
 # Contributor: Hugo Doria <hugo@archlinux.org>
+
 pkgname=lame
-pkgver=3.98
+pkgver=3.98.4
 pkgrel=1
 pkgdesc="An MP3 encoder and graphical frame analyzer"
 arch=('i686' 'x86_64')
@@ -10,14 +11,16 @@ url="http://lame.sourceforge.net/"
 depends=('ncurses')
 makedepends=('nasm')
 license=('LGPL')
-source=(http://downloads.sourceforge.net/sourceforge/lame/lame-398.tar.gz \
-	shared-frontend.patch)
-md5sums=('f44b9f8e1b5d8835d0a77f9cc9cedd1c' 'e7fc0e6d82dd35a01411be96fc8effab')
+options=('!libtool')
+source=(http://downloads.sourceforge.net/sourceforge/${pkgname}/${pkgname}-${pkgver}.tar.gz)
+md5sums=('8e9866ad6b570c6c95c8cba48060473f')
 
 build() {
-  cd $startdir/src/$pkgname-398
-  ./configure --prefix=/usr --enable-nasm --enable-shared
-  make || return 1
-  make DESTDIR=$startdir/pkg install
-  find $startdir/pkg -name '*.la' -exec rm {} \;
+  cd "${srcdir}/${pkgname}-${pkgver}"
+
+  ./configure --prefix=/usr \
+              --enable-nasm \
+              --enable-shared
+  make -j1 || return 1
+  make DESTDIR="${pkgdir}" install || return 1
 }
diff --git a/abs/core/lame/__changelog b/abs/core/lame/__changelog
new file mode 100644
index 0000000..1cb148f
--- /dev/null
+++ b/abs/core/lame/__changelog
@@ -0,0 +1 @@
+add -j1 to make command
-- 
cgit v0.12

