From ae43b28ac4fe3b20682f7e5c8baa2415bf4c3369 Mon Sep 17 00:00:00 2001 From: "bart@bart" Date: Fri, 21 Aug 2009 16:30:39 +0200 Subject: [PATCH] Enabled looping for libmpg123 --- src/modules/sound/lullaby/Mpg123Decoder.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/modules/sound/lullaby/Mpg123Decoder.cpp b/src/modules/sound/lullaby/Mpg123Decoder.cpp index 8c7675780..13be6cba3 100644 --- a/src/modules/sound/lullaby/Mpg123Decoder.cpp +++ b/src/modules/sound/lullaby/Mpg123Decoder.cpp @@ -103,8 +103,16 @@ namespace lullaby // If we're done, then EOF. If some error occurred, pretend we EOF'd. if (r == MPG123_DONE || r != MPG123_OK) { - eof = true; - numbytes = 0; + if ( r == MPG123_NEED_MORE ) + { + size_t numbytes = 0; + mpg123_decode(handle, (unsigned char*) data->getData(), data->getSize(), (unsigned char*) buffer, bufferSize, &numbytes); + } + else + { + eof = true; + numbytes = 0; + } } return numbytes; @@ -112,13 +120,13 @@ namespace lullaby bool Mpg123Decoder::seek(int ms) { - mpg123_seek(handle, SEEK_SET, ms); + mpg123_seek(handle, ms, SEEK_SET); return true; } bool Mpg123Decoder::rewind() { - if(mpg123_seek(handle, SEEK_SET, 0) < 0) + if(mpg123_seek(handle, 0, SEEK_SET) < 0) return false; return true; }