[PATCH 08/12] winemp3.acm: Remove unnecessary checks.

Zebediah Figura z.figura12 at gmail.com
Tue Jun 6 15:14:57 CDT 2017


These are already checked in msacm32 or not checked on Windows.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/msacm32/tests/msacm.c |  2 --
 dlls/winemp3.acm/mpegl3.c  | 52 ++++++++++++++++++----------------------------
 2 files changed, 20 insertions(+), 34 deletions(-)

diff --git a/dlls/msacm32/tests/msacm.c b/dlls/msacm32/tests/msacm.c
index 930c06c4c1..b9520822ca 100644
--- a/dlls/msacm32/tests/msacm.c
+++ b/dlls/msacm32/tests/msacm.c
@@ -210,7 +210,6 @@ static BOOL CALLBACK FormatTagEnumProc(HACMDRIVERID hadid,
                "acmFormatDetailsA(): rc = %08x, should be %08x\n",
                rc, MMSYSERR_NOERROR);
             if (paftd->dwFormatTag != WAVE_FORMAT_PCM)
-                todo_wine_if(fd.pwfx->cbSize != paftd->cbFormatSize - sizeof(WAVEFORMATEX)) /* remove when fixed */
                 ok(fd.pwfx->cbSize == paftd->cbFormatSize - sizeof(WAVEFORMATEX),
                    "expected cbSize %d, got %d\n",
                    paftd->cbFormatSize - sizeof(WAVEFORMATEX), fd.pwfx->cbSize);
@@ -303,7 +302,6 @@ static BOOL CALLBACK FormatEnumProc(HACMDRIVERID hadid,
            "acmFormatSuggest(): rc = %08x, should be %08x\n",
            rc, MMSYSERR_NOERROR);
     else
-        todo_wine_if(rc != ACMERR_NOTPOSSIBLE)
         ok(rc == ACMERR_NOTPOSSIBLE,
            "acmFormatSuggest(): rc = %08x, should be %08x\n",
            rc, ACMERR_NOTPOSSIBLE);
diff --git a/dlls/winemp3.acm/mpegl3.c b/dlls/winemp3.acm/mpegl3.c
index cc6008da59..f6e21e1c01 100644
--- a/dlls/winemp3.acm/mpegl3.c
+++ b/dlls/winemp3.acm/mpegl3.c
@@ -749,39 +749,31 @@ static	LRESULT	MPEG3_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery)
     return MMSYSERR_NOERROR;
 }
 
-static void fill_in_mp3(unsigned cbwfx, WAVEFORMATEX* wfx, unsigned bit_rate)
+static void fill_in_mp3(WAVEFORMATEX* wfx, unsigned bit_rate)
 {
     MPEGLAYER3WAVEFORMAT*   mp3wfx = (MPEGLAYER3WAVEFORMAT*)wfx;
 
     wfx->nAvgBytesPerSec = bit_rate / 8;
-    if (cbwfx >= sizeof(WAVEFORMATEX))
-        wfx->cbSize = sizeof(MPEGLAYER3WAVEFORMAT) - sizeof(WAVEFORMATEX);
-    if (cbwfx >= sizeof(MPEGLAYER3WAVEFORMAT))
-    {
-        mp3wfx->wID = MPEGLAYER3_ID_MPEG;
-        mp3wfx->fdwFlags = MPEGLAYER3_FLAG_PADDING_OFF;
-        mp3wfx->nBlockSize = (bit_rate * 144) / wfx->nSamplesPerSec;
-        mp3wfx->nFramesPerBlock = 1;
-        mp3wfx->nCodecDelay = 0x0571;
-    }
+    wfx->cbSize = sizeof(MPEGLAYER3WAVEFORMAT) - sizeof(WAVEFORMATEX);
+    mp3wfx->wID = MPEGLAYER3_ID_MPEG;
+    mp3wfx->fdwFlags = MPEGLAYER3_FLAG_PADDING_OFF;
+    mp3wfx->nBlockSize = (bit_rate * 144) / wfx->nSamplesPerSec;
+    mp3wfx->nFramesPerBlock = 1;
+    mp3wfx->nCodecDelay = 0x0571;
 }
 
-static void fill_in_mpeg(unsigned cbwfx, WAVEFORMATEX* wfx, unsigned bit_rate)
+static void fill_in_mpeg(WAVEFORMATEX* wfx, unsigned bit_rate)
 {
     MPEG1WAVEFORMAT*   mp3wfx = (MPEG1WAVEFORMAT*)wfx;
 
     wfx->nAvgBytesPerSec = bit_rate / 8;
-    if (cbwfx >= sizeof(WAVEFORMATEX))
-        wfx->cbSize = sizeof(MPEG1WAVEFORMAT) - sizeof(WAVEFORMATEX);
-    if (cbwfx >= sizeof(MPEG1WAVEFORMAT))
-    {
-        mp3wfx->fwHeadLayer = ACM_MPEG_LAYER3;
-        mp3wfx->dwHeadBitrate = wfx->nAvgBytesPerSec * 8;
-        mp3wfx->fwHeadMode = ACM_MPEG_JOINTSTEREO;
-        mp3wfx->fwHeadModeExt = 0xf;
-        mp3wfx->wHeadEmphasis = 1;
-        mp3wfx->fwHeadFlags = ACM_MPEG_ID_MPEG1;
-    }
+    wfx->cbSize = sizeof(MPEG1WAVEFORMAT) - sizeof(WAVEFORMATEX);
+    mp3wfx->fwHeadLayer = ACM_MPEG_LAYER3;
+    mp3wfx->dwHeadBitrate = wfx->nAvgBytesPerSec * 8;
+    mp3wfx->fwHeadMode = ACM_MPEG_JOINTSTEREO;
+    mp3wfx->fwHeadModeExt = 0xf;
+    mp3wfx->wHeadEmphasis = 1;
+    mp3wfx->fwHeadFlags = ACM_MPEG_ID_MPEG1;
 }
 
 /***********************************************************************
@@ -800,7 +792,6 @@ static	LRESULT	MPEG3_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)
 	switch (afd->dwFormatTag)
         {
 	case WAVE_FORMAT_PCM:
-	    if (afd->dwFormatIndex >= NUM_PCM_FORMATS) return ACMERR_NOTPOSSIBLE;
 	    afd->pwfx->nChannels = PCM_Formats[afd->dwFormatIndex].nChannels;
 	    afd->pwfx->nSamplesPerSec = PCM_Formats[afd->dwFormatIndex].rate;
 	    afd->pwfx->wBitsPerSample = PCM_Formats[afd->dwFormatIndex].nBits;
@@ -814,15 +805,14 @@ static	LRESULT	MPEG3_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)
 	    break;
 	case WAVE_FORMAT_MPEGLAYER3:
 	case WAVE_FORMAT_MPEG:
-	    if (afd->dwFormatIndex >= NUM_MPEG3_FORMATS) return ACMERR_NOTPOSSIBLE;
 	    afd->pwfx->nChannels = MPEG3_Formats[afd->dwFormatIndex].nChannels;
 	    afd->pwfx->nSamplesPerSec = MPEG3_Formats[afd->dwFormatIndex].rate;
 	    afd->pwfx->wBitsPerSample = MPEG3_Formats[afd->dwFormatIndex].nBits;
 	    afd->pwfx->nBlockAlign = 1;
 	    if (afd->dwFormatTag == WAVE_FORMAT_MPEGLAYER3)
-		fill_in_mp3(afd->cbwfx, afd->pwfx, 192000);
+		fill_in_mp3(afd->pwfx, 192000);
 	    else
-		fill_in_mpeg(afd->cbwfx, afd->pwfx, 192000);
+		fill_in_mpeg(afd->pwfx, 192000);
 	    break;
 	default:
             WARN("Unsupported tag %08x\n", afd->dwFormatTag);
@@ -846,10 +836,8 @@ static	LRESULT	MPEG3_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery)
 static	LRESULT	MPEG3_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
 {
     /* some tests ... */
-    if (adfs->cbwfxSrc < sizeof(PCMWAVEFORMAT) ||
-	adfs->cbwfxDst < sizeof(PCMWAVEFORMAT) ||
+    if (adfs->pwfxSrc->wFormatTag == adfs->pwfxDst->wFormatTag ||
 	MPEG3_GetFormatIndex(adfs->pwfxSrc) == 0xFFFFFFFF) return ACMERR_NOTPOSSIBLE;
-    /* FIXME: should do those tests against the real size (according to format tag */
 
     /* If no suggestion for destination, then copy source value */
     if (!(adfs->fdwSuggest & ACM_FORMATSUGGESTF_NCHANNELS))
@@ -884,11 +872,11 @@ static	LRESULT	MPEG3_FormatSuggest(PACMDRVFORMATSUGGEST adfs)
         break;
     case WAVE_FORMAT_MPEG:
         adfs->pwfxDst->nBlockAlign = 1;
-        fill_in_mpeg(adfs->cbwfxDst, adfs->pwfxDst, 192000);
+        fill_in_mpeg(adfs->pwfxDst, 192000);
         break;
     case WAVE_FORMAT_MPEGLAYER3:
         adfs->pwfxDst->nBlockAlign = 1;
-        fill_in_mp3(adfs->cbwfxDst, adfs->pwfxDst, 192000);
+        fill_in_mp3(adfs->pwfxDst, 192000);
         break;
     default:
         FIXME("\n");
-- 
2.13.0




More information about the wine-patches mailing list