From 3dc677cc631038c924a7bda511bce94f4fc3e0db Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 25 Aug 2009 23:27:57 -0700 Subject: [PATCH] winemp3.acm: Fix reading/decoding loop. --- dlls/winemp3.acm/mpegl3.c | 49 ++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/dlls/winemp3.acm/mpegl3.c b/dlls/winemp3.acm/mpegl3.c index eb97e75ced4..2d291cf68bb 100644 --- a/dlls/winemp3.acm/mpegl3.c +++ b/dlls/winemp3.acm/mpegl3.c @@ -151,39 +151,40 @@ static void mp3_horse(PACMDRVSTREAMINSTANCE adsi, DWORD dpos = 0; - ret = mpg123_feed(amd->mh, src, *nsrc); - if (ret != MPG123_OK) + if (*nsrc > 0) { - ERR("Error feeding data\n"); - *ndst = *nsrc = 0; - return; - } - - ret = mpg123_read(amd->mh, NULL, 0, &size); - if (ret == MPG123_NEW_FORMAT) - { - if TRACE_ON(mpeg3) + ret = mpg123_feed(amd->mh, src, *nsrc); + if (ret != MPG123_OK) { - long rate; - int channels, enc; - mpg123_getformat(amd->mh, &rate, &channels, &enc); - TRACE("New format: %li Hz, %i channels, encoding value %i\n", rate, channels, enc); + ERR("Error feeding data\n"); + *ndst = *nsrc = 0; + return; } } - else if (ret == MPG123_ERR) - { - FIXME("Error occurred during decoding!\n"); - *ndst = *nsrc = 0; - return; - } do { - dpos += size; - if (*ndst - dpos < 4608) break; + size = 0; ret = mpg123_read(amd->mh, dst + dpos, *ndst - dpos, &size); + if (ret == MPG123_ERR) + { + FIXME("Error occurred during decoding!\n"); + *ndst = *nsrc = 0; + return; + } + + if (ret == MPG123_NEW_FORMAT) + { + if TRACE_ON(mpeg3) + { + long rate; + int channels, enc; + mpg123_getformat(amd->mh, &rate, &channels, &enc); + TRACE("New format: %li Hz, %i channels, encoding value %i\n", rate, channels, enc); + } + } + dpos += size; } while (ret == MPG123_OK); *ndst = dpos; - *nsrc = 0; } /***********************************************************************