output.cpp
上传用户:qiulin1960
上传日期:2013-10-16
资源大小:2844k
文件大小:16k
源码类别:

Windows CE

开发平台:

Windows_Unix

  1. // -----------------------------------------------------------------------------
  2. //
  3. //      THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  4. //      ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  5. //      THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  6. //      PARTICULAR PURPOSE.
  7. //      Copyright (c) 1995-2000 Microsoft Corporation.  All rights reserved.
  8. //
  9. // -----------------------------------------------------------------------------
  10. #include "wavemain.h"
  11. HRESULT OutputStreamContext::Open(DeviceContext *pDeviceContext, LPWAVEOPENDESC lpWOD, DWORD dwFlags)
  12. {
  13.     HRESULT Result;
  14.     Result = WaveStreamContext::Open(pDeviceContext, lpWOD, dwFlags);
  15.     if (Result==MMSYSERR_NOERROR)
  16.     {
  17.         // Note: Output streams should be initialized in the run state.
  18.         Run();
  19.     }
  20.     return Result;
  21. }
  22. DWORD OutputStreamContext::Reset()
  23. {
  24.     HRESULT Result;
  25.     Result = WaveStreamContext::Reset();
  26.     if (Result==MMSYSERR_NOERROR)
  27.     {
  28.         // Note: Output streams should be reset to the run state.
  29.         Run();
  30.     }
  31.     return Result;
  32. };
  33. // Init m_DeltaT with (SampleRate/HWSampleRate) calculated in 24.8 fixed point form
  34. // Note that we need to hold the result in a 64-bit value until we're done shifting,
  35. // since the result of the multiply will overflow 32 bits for sample rates greater than
  36. // or equal to the hardware's sample rate.
  37. DWORD OutputStreamContext::SetRate(DWORD dwMultiplier)
  38. {
  39.     m_dwMultiplier = dwMultiplier;
  40.     UINT64 Delta = (m_WaveFormat.nSamplesPerSec * m_dwMultiplier) >> 16;
  41.     Delta = (Delta * INVSAMPLERATE) >> 24;  // Convert to 24.8 format
  42.     m_DeltaT = (DWORD)Delta;
  43.     return MMSYSERR_NOERROR;
  44. }
  45. // Originally, this code used to be in each renderer, and each one would call GetNextBuffer as needed.
  46. // Pulling this code out of each low level renderer allows the inner loop to be in a leaf routine (ie no
  47. // subroutine calls out of that routine), which helps the compiler optimize the inner loop.
  48. PBYTE WaveStreamContext::Render(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
  49. {
  50.     if (!m_bRunning || !m_lpCurrData)
  51.     {
  52.         return pBuffer;
  53.     }
  54.     while (pBuffer < pBufferEnd)
  55.     {
  56.         while (m_lpCurrData>=m_lpCurrDataEnd)
  57.         {
  58.             if (!GetNextBuffer())
  59.             {
  60.                 return pBuffer;
  61.             }
  62.         }
  63.         pBuffer = Render2(pBuffer,pBufferEnd,pBufferLast);
  64.     }
  65.     return pBuffer;
  66. }
  67. PBYTE OutputStreamContextM8::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
  68. {
  69.     LONG CurrT = m_CurrT;
  70.     LONG DeltaT = m_DeltaT;
  71.     LONG CurrSamp0 = m_CurrSamp[0];
  72.     LONG PrevSamp0 = m_PrevSamp[0];
  73.     PBYTE pCurrData = m_lpCurrData;
  74.     PBYTE pCurrDataEnd = m_lpCurrDataEnd;
  75.     LONG fxpGain = m_fxpGain;
  76.     while (pBuffer < pBufferEnd)
  77.     {
  78.         while (CurrT >= 0x100)
  79.         {
  80.             if (pCurrData>=pCurrDataEnd)
  81.             {
  82.                 goto Exit;
  83.             }
  84.             CurrT -= 0x100;
  85.             PrevSamp0 = CurrSamp0;
  86.             PPCM_SAMPLE pSampleSrc = (PPCM_SAMPLE)pCurrData;
  87.             CurrSamp0 = (LONG)pSampleSrc->m8.sample;
  88.             CurrSamp0 = (CurrSamp0 - 128) << 8;
  89.             pCurrData+=1;
  90.         }
  91.         LONG OutSamp0;
  92.         OutSamp0 = PrevSamp0 + (((CurrSamp0 - PrevSamp0) * CurrT) >> 8);
  93.         OutSamp0 = (OutSamp0 * fxpGain) >> VOLSHIFT;
  94.         CurrT += DeltaT;
  95. #if (OUTCHANNELS==2)
  96.         LONG OutSamp1;
  97.         OutSamp1=OutSamp0;
  98.         if (pBuffer < pBufferLast)
  99.         {
  100.             OutSamp0 += ((HWSAMPLE *)pBuffer)[0];
  101.             OutSamp1 += ((HWSAMPLE *)pBuffer)[1];
  102. #if USE_MIX_SATURATE
  103.             // Handle saturation
  104.             if (OutSamp0>AUDIO_SAMPLE_MAX)
  105.             {
  106.                 OutSamp0=AUDIO_SAMPLE_MAX;
  107.             }
  108.             else if (OutSamp0<AUDIO_SAMPLE_MIN)
  109.             {
  110.                 OutSamp0=AUDIO_SAMPLE_MIN;
  111.             }
  112.             if (OutSamp1>AUDIO_SAMPLE_MAX)
  113.             {
  114.                 OutSamp1=AUDIO_SAMPLE_MAX;
  115.             }
  116.             else if (OutSamp1<AUDIO_SAMPLE_MIN)
  117.             {
  118.                 OutSamp1=AUDIO_SAMPLE_MIN;
  119.             }
  120. #endif
  121.         }
  122.         ((HWSAMPLE *)pBuffer)[0] = (HWSAMPLE)OutSamp0;
  123.         ((HWSAMPLE *)pBuffer)[1] = (HWSAMPLE)OutSamp1;
  124.         pBuffer += 2*sizeof(HWSAMPLE);
  125. #else
  126.         if (pBuffer < pBufferLast)
  127.         {
  128.             OutSamp0 += ((HWSAMPLE *)pBuffer)[0];
  129. #if USE_MIX_SATURATE
  130.             // Handle saturation
  131.             if (OutSamp0>AUDIO_SAMPLE_MAX)
  132.             {
  133.                 OutSamp0=AUDIO_SAMPLE_MAX;
  134.             }
  135.             else if (OutSamp0<AUDIO_SAMPLE_MIN)
  136.             {
  137.                 OutSamp0=AUDIO_SAMPLE_MIN;
  138.             }
  139. #endif
  140.         }
  141.         ((HWSAMPLE *)pBuffer)[0] = (HWSAMPLE)OutSamp0;
  142.         pBuffer += sizeof(HWSAMPLE);
  143. #endif
  144.     }
  145.     Exit:
  146.     m_dwByteCount += (pCurrData - m_lpCurrData);
  147.     m_lpCurrData = pCurrData;
  148.     m_CurrT = CurrT;
  149.     m_PrevSamp[0] = PrevSamp0;
  150.     m_CurrSamp[0] = CurrSamp0;
  151.     return pBuffer;
  152. }
  153. PBYTE OutputStreamContextM16::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
  154. {
  155.     LONG CurrT = m_CurrT;
  156.     LONG DeltaT = m_DeltaT;
  157.     LONG CurrSamp0 = m_CurrSamp[0];
  158.     LONG PrevSamp0 = m_PrevSamp[0];
  159.     PBYTE pCurrData = m_lpCurrData;
  160.     PBYTE pCurrDataEnd = m_lpCurrDataEnd;
  161.     LONG fxpGain = m_fxpGain;
  162.     LONG OutSamp0;
  163.     while (pBuffer < pBufferEnd)
  164.     {
  165.         while (CurrT >= 0x100)
  166.         {
  167.             if (pCurrData>=pCurrDataEnd)
  168.             {
  169.                 goto Exit;
  170.             }
  171.             CurrT -= 0x100;
  172.             PrevSamp0 = CurrSamp0;
  173.             PPCM_SAMPLE pSampleSrc = (PPCM_SAMPLE)pCurrData;
  174.             CurrSamp0 = (LONG)pSampleSrc->m16.sample;
  175.             pCurrData+=2;
  176.         }
  177.         OutSamp0 = PrevSamp0 + (((CurrSamp0 - PrevSamp0) * CurrT) >> 8);
  178.         OutSamp0 = (OutSamp0 * fxpGain) >> VOLSHIFT;
  179.         CurrT += DeltaT;
  180.         // DEBUGMSG(1, (TEXT("PrevSamp0=0x%x, CurrSamp0=0x%x, CurrT=0x%x, OutSamp0=0x%xrn"), PrevSamp0,CurrSamp0,CurrT,OutSamp0));
  181. #if (OUTCHANNELS==2)
  182.         LONG OutSamp1;
  183.         OutSamp1=OutSamp0;
  184.         if (pBuffer < pBufferLast)
  185.         {
  186.             OutSamp0 += ((HWSAMPLE *)pBuffer)[0];
  187.             OutSamp1 += ((HWSAMPLE *)pBuffer)[1];
  188. #if USE_MIX_SATURATE
  189.             // Handle saturation
  190.             if (OutSamp0>AUDIO_SAMPLE_MAX)
  191.             {
  192.                 OutSamp0=AUDIO_SAMPLE_MAX;
  193.             }
  194.             else if (OutSamp0<AUDIO_SAMPLE_MIN)
  195.             {
  196.                 OutSamp0=AUDIO_SAMPLE_MIN;
  197.             }
  198.             if (OutSamp1>AUDIO_SAMPLE_MAX)
  199.             {
  200.                 OutSamp1=AUDIO_SAMPLE_MAX;
  201.             }
  202.             else if (OutSamp1<AUDIO_SAMPLE_MIN)
  203.             {
  204.                 OutSamp1=AUDIO_SAMPLE_MIN;
  205.             }
  206. #endif
  207.         }
  208.         ((HWSAMPLE *)pBuffer)[0] = (HWSAMPLE)OutSamp0;
  209.         ((HWSAMPLE *)pBuffer)[1] = (HWSAMPLE)OutSamp1;
  210.         pBuffer += 2*sizeof(HWSAMPLE);
  211. #else
  212.         if (pBuffer < pBufferLast)
  213.         {
  214.             OutSamp0 += ((HWSAMPLE *)pBuffer)[0];
  215. #if USE_MIX_SATURATE
  216.             // Handle saturation
  217.             if (OutSamp0>AUDIO_SAMPLE_MAX)
  218.             {
  219.                 OutSamp0=AUDIO_SAMPLE_MAX;
  220.             }
  221.             else if (OutSamp0<AUDIO_SAMPLE_MIN)
  222.             {
  223.                 OutSamp0=AUDIO_SAMPLE_MIN;
  224.             }
  225. #endif
  226.         }
  227.         ((HWSAMPLE *)pBuffer)[0] = (HWSAMPLE)OutSamp0;
  228.         pBuffer += sizeof(HWSAMPLE);
  229. #endif
  230.     }
  231.     Exit:
  232.     m_dwByteCount += (pCurrData - m_lpCurrData);
  233.     m_lpCurrData = pCurrData;
  234.     m_CurrT = CurrT;
  235.     m_PrevSamp[0] = PrevSamp0;
  236.     m_CurrSamp[0] = CurrSamp0;
  237.     return pBuffer;
  238. }
  239. #if (OUTCHANNELS==2)
  240. PBYTE OutputStreamContextS8::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
  241. {
  242.     LONG CurrT = m_CurrT;
  243.     LONG DeltaT = m_DeltaT;
  244.     LONG CurrSamp0 = m_CurrSamp[0];
  245.     LONG CurrSamp1 = m_CurrSamp[1];
  246.     LONG PrevSamp0 = m_PrevSamp[0];
  247.     LONG PrevSamp1 = m_PrevSamp[1];
  248.     PBYTE pCurrData = m_lpCurrData;
  249.     PBYTE pCurrDataEnd = m_lpCurrDataEnd;
  250.     LONG fxpGain = m_fxpGain;
  251.     LONG OutSamp0;
  252.     LONG OutSamp1;
  253.     while (pBuffer < pBufferEnd)
  254.     {
  255.         while (CurrT >= 0x100)
  256.         {
  257.             if (pCurrData>=pCurrDataEnd)
  258.             {
  259.                 goto Exit;
  260.             }
  261.             CurrT -= 0x100;
  262.             PrevSamp0 = CurrSamp0;
  263.             PrevSamp1 = CurrSamp1;
  264.             PPCM_SAMPLE pSampleSrc = (PPCM_SAMPLE)pCurrData;
  265.             CurrSamp0 =  (LONG)pSampleSrc->s8.sample_left;
  266.             CurrSamp0 = (CurrSamp0 - 128) << 8;
  267.             CurrSamp1 = (LONG)pSampleSrc->s8.sample_right;
  268.             CurrSamp1 = (CurrSamp1 - 128) << 8;
  269.             pCurrData+=2;
  270.         }
  271.         OutSamp0 = PrevSamp0 + (((CurrSamp0 - PrevSamp0) * CurrT) >> 8);
  272.         OutSamp0 = (OutSamp0 * fxpGain) >> VOLSHIFT;
  273.         OutSamp1 = PrevSamp1 + (((CurrSamp1 - PrevSamp1) * CurrT) >> 8);
  274.         OutSamp1 = (OutSamp1 * fxpGain) >> VOLSHIFT;
  275.         CurrT += DeltaT;
  276.         // DEBUGMSG(1, (TEXT("PrevSamp0=0x%x, CurrSamp0=0x%x, CurrT=0x%x, OutSamp0=0x%xrn"), PrevSamp0,CurrSamp0,CurrT,OutSamp0));
  277.         if (pBuffer < pBufferLast)
  278.         {
  279.             OutSamp0 += ((HWSAMPLE *)pBuffer)[0];
  280.             OutSamp1 += ((HWSAMPLE *)pBuffer)[1];
  281. #if USE_MIX_SATURATE
  282.             // Handle saturation
  283.             if (OutSamp0>AUDIO_SAMPLE_MAX)
  284.             {
  285.                 OutSamp0=AUDIO_SAMPLE_MAX;
  286.             }
  287.             else if (OutSamp0<AUDIO_SAMPLE_MIN)
  288.             {
  289.                 OutSamp0=AUDIO_SAMPLE_MIN;
  290.             }
  291.             if (OutSamp1>AUDIO_SAMPLE_MAX)
  292.             {
  293.                 OutSamp1=AUDIO_SAMPLE_MAX;
  294.             }
  295.             else if (OutSamp1<AUDIO_SAMPLE_MIN)
  296.             {
  297.                 OutSamp1=AUDIO_SAMPLE_MIN;
  298.             }
  299. #endif
  300.         }
  301.         ((HWSAMPLE *)pBuffer)[0] = (HWSAMPLE)OutSamp0;
  302.         ((HWSAMPLE *)pBuffer)[1] = (HWSAMPLE)OutSamp1;
  303.         pBuffer += 2*sizeof(HWSAMPLE);
  304.     }
  305.     Exit:
  306.     m_dwByteCount += (pCurrData - m_lpCurrData);
  307.     m_lpCurrData = pCurrData;
  308.     m_CurrT = CurrT;
  309.     m_PrevSamp[0] = PrevSamp0;
  310.     m_PrevSamp[1] = PrevSamp1;
  311.     m_CurrSamp[0] = CurrSamp0;
  312.     m_CurrSamp[1] = CurrSamp1;
  313.     return pBuffer;
  314. }
  315. PBYTE OutputStreamContextS16::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
  316. {
  317.     LONG CurrT = m_CurrT;
  318.     LONG DeltaT = m_DeltaT;
  319.     LONG CurrSamp0 = m_CurrSamp[0];
  320.     LONG CurrSamp1 = m_CurrSamp[1];
  321.     LONG PrevSamp0 = m_PrevSamp[0];
  322.     LONG PrevSamp1 = m_PrevSamp[1];
  323.     PBYTE pCurrData = m_lpCurrData;
  324.     PBYTE pCurrDataEnd = m_lpCurrDataEnd;
  325.     LONG fxpGain = m_fxpGain;
  326.     LONG OutSamp0;
  327.     LONG OutSamp1;
  328.     while (pBuffer < pBufferEnd)
  329.     {
  330.         while (CurrT >= 0x100)
  331.         {
  332.             if (pCurrData>=pCurrDataEnd)
  333.             {
  334.                 goto Exit;
  335.             }
  336.             CurrT -= 0x100;
  337.             PrevSamp0 = CurrSamp0;
  338.             PrevSamp1 = CurrSamp1;
  339.             PPCM_SAMPLE pSampleSrc = (PPCM_SAMPLE)pCurrData;
  340.             CurrSamp0 = (LONG)pSampleSrc->s16.sample_left;
  341.             CurrSamp1 = (LONG)pSampleSrc->s16.sample_right;
  342.             pCurrData+=4;
  343.         }
  344.         OutSamp0 = PrevSamp0 + (((CurrSamp0 - PrevSamp0) * CurrT) >> 8);
  345.         OutSamp0 = (OutSamp0 * fxpGain) >> VOLSHIFT;
  346.         OutSamp1 = PrevSamp1 + (((CurrSamp1 - PrevSamp1) * CurrT) >> 8);
  347.         OutSamp1 = (OutSamp1 * fxpGain) >> VOLSHIFT;
  348.         CurrT += DeltaT;
  349.         // DEBUGMSG(1, (TEXT("PrevSamp0=0x%x, CurrSamp0=0x%x, CurrT=0x%x, OutSamp0=0x%xrn"), PrevSamp0,CurrSamp0,CurrT,OutSamp0));
  350.         if (pBuffer < pBufferLast)
  351.         {
  352.             OutSamp0 += ((HWSAMPLE *)pBuffer)[0];
  353.             OutSamp1 += ((HWSAMPLE *)pBuffer)[1];
  354. #if USE_MIX_SATURATE
  355.             // Handle saturation
  356.             if (OutSamp0>AUDIO_SAMPLE_MAX)
  357.             {
  358.                 OutSamp0=AUDIO_SAMPLE_MAX;
  359.             }
  360.             else if (OutSamp0<AUDIO_SAMPLE_MIN)
  361.             {
  362.                 OutSamp0=AUDIO_SAMPLE_MIN;
  363.             }
  364.             if (OutSamp1>AUDIO_SAMPLE_MAX)
  365.             {
  366.                 OutSamp1=AUDIO_SAMPLE_MAX;
  367.             }
  368.             else if (OutSamp1<AUDIO_SAMPLE_MIN)
  369.             {
  370.                 OutSamp1=AUDIO_SAMPLE_MIN;
  371.             }
  372. #endif
  373.         }
  374.         ((HWSAMPLE *)pBuffer)[0] = (HWSAMPLE)OutSamp0;
  375.         ((HWSAMPLE *)pBuffer)[1] = (HWSAMPLE)OutSamp1;
  376.         pBuffer += 2*sizeof(HWSAMPLE);
  377.     }
  378.     Exit:
  379.     m_dwByteCount += (pCurrData - m_lpCurrData);
  380.     m_lpCurrData = pCurrData;
  381.     m_CurrT = CurrT;
  382.     m_PrevSamp[0] = PrevSamp0;
  383.     m_PrevSamp[1] = PrevSamp1;
  384.     m_CurrSamp[0] = CurrSamp0;
  385.     m_CurrSamp[1] = CurrSamp1;
  386.     return pBuffer;
  387. }
  388. #else
  389. PBYTE OutputStreamContextS8::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
  390. {
  391.     LONG CurrT = m_CurrT;
  392.     LONG DeltaT = m_DeltaT;
  393.     LONG CurrSamp0 = m_CurrSamp[0];
  394.     LONG PrevSamp0 = m_PrevSamp[0];
  395.     PBYTE pCurrData = m_lpCurrData;
  396.     PBYTE pCurrDataEnd = m_lpCurrDataEnd;
  397.     LONG fxpGain = m_fxpGain;
  398.     LONG OutSamp0;
  399.     while (pBuffer < pBufferEnd)
  400.     {
  401.         while (CurrT >= 0x100)
  402.         {
  403.             if (pCurrData>=pCurrDataEnd)
  404.             {
  405.                 goto Exit;
  406.             }
  407.             CurrT -= 0x100;
  408.             PrevSamp0 = CurrSamp0;
  409.             PPCM_SAMPLE pSampleSrc = (PPCM_SAMPLE)pCurrData;
  410.             CurrSamp0 =  (LONG)pSampleSrc->s8.sample_left;
  411.             CurrSamp0 += (LONG)pSampleSrc->s8.sample_right;
  412.             CurrSamp0 = (CurrSamp0 - 256) << 7;
  413.             pCurrData+=2;
  414.         }
  415.         OutSamp0 = PrevSamp0 + (((CurrSamp0 - PrevSamp0) * CurrT) >> 8);
  416.         OutSamp0 = (OutSamp0 * fxpGain) >> VOLSHIFT;
  417.         CurrT += DeltaT;
  418.         // DEBUGMSG(1, (TEXT("PrevSamp0=0x%x, CurrSamp0=0x%x, CurrT=0x%x, OutSamp0=0x%xrn"), PrevSamp0,CurrSamp0,CurrT,OutSamp0));
  419.         if (pBuffer < pBufferLast)
  420.         {
  421.             OutSamp0 += *(HWSAMPLE *)pBuffer;
  422. #if USE_MIX_SATURATE
  423.             // Handle saturation
  424.             if (OutSamp0>AUDIO_SAMPLE_MAX)
  425.             {
  426.                 OutSamp0=AUDIO_SAMPLE_MAX;
  427.             }
  428.             else if (OutSamp0<AUDIO_SAMPLE_MIN)
  429.             {
  430.                 OutSamp0=AUDIO_SAMPLE_MIN;
  431.             }
  432. #endif
  433.         }
  434.         *(HWSAMPLE *)pBuffer = (HWSAMPLE)OutSamp0;
  435.         pBuffer += sizeof(HWSAMPLE);
  436.     }
  437.     Exit:
  438.     m_dwByteCount += (pCurrData - m_lpCurrData);
  439.     m_lpCurrData = pCurrData;
  440.     m_CurrT = CurrT;
  441.     m_PrevSamp[0] = PrevSamp0;
  442.     m_CurrSamp[0] = CurrSamp0;
  443.     return pBuffer;
  444. }
  445. PBYTE OutputStreamContextS16::Render2(PBYTE pBuffer, PBYTE pBufferEnd, PBYTE pBufferLast)
  446. {
  447.     LONG CurrT = m_CurrT;
  448.     LONG DeltaT = m_DeltaT;
  449.     LONG CurrSamp0 = m_CurrSamp[0];
  450.     LONG PrevSamp0 = m_PrevSamp[0];
  451.     PBYTE pCurrData = m_lpCurrData;
  452.     PBYTE pCurrDataEnd = m_lpCurrDataEnd;
  453.     LONG fxpGain = m_fxpGain;
  454.     LONG OutSamp0;
  455.     while (pBuffer < pBufferEnd)
  456.     {
  457.         while (CurrT >= 0x100)
  458.         {
  459.             if (pCurrData>=pCurrDataEnd)
  460.             {
  461.                 goto Exit;
  462.             }
  463.             CurrT -= 0x100;
  464.             PrevSamp0 = CurrSamp0;
  465.             PPCM_SAMPLE pSampleSrc = (PPCM_SAMPLE)pCurrData;
  466.             CurrSamp0 =  (LONG)pSampleSrc->s16.sample_left;
  467.             CurrSamp0 += (LONG)pSampleSrc->s16.sample_right;
  468.             CurrSamp0 = CurrSamp0>>1;
  469.             pCurrData+=4;
  470.         }
  471.         OutSamp0 = PrevSamp0 + (((CurrSamp0 - PrevSamp0) * CurrT) >> 8);
  472.         OutSamp0 = (OutSamp0 * fxpGain) >> VOLSHIFT;
  473.         CurrT += DeltaT;
  474.         // DEBUGMSG(1, (TEXT("PrevSamp0=0x%x, CurrSamp0=0x%x, CurrT=0x%x, OutSamp0=0x%xrn"), PrevSamp0,CurrSamp0,CurrT,OutSamp0));
  475.         if (pBuffer < pBufferLast)
  476.         {
  477.             OutSamp0 += *(HWSAMPLE *)pBuffer;
  478. #if USE_MIX_SATURATE
  479.             // Handle saturation
  480.             if (OutSamp0>AUDIO_SAMPLE_MAX)
  481.             {
  482.                 OutSamp0=AUDIO_SAMPLE_MAX;
  483.             }
  484.             else if (OutSamp0<AUDIO_SAMPLE_MIN)
  485.             {
  486.                 OutSamp0=AUDIO_SAMPLE_MIN;
  487.             }
  488. #endif
  489.         }
  490.         *(HWSAMPLE *)pBuffer = (HWSAMPLE)OutSamp0;
  491.         pBuffer += sizeof(HWSAMPLE);
  492.     }
  493.     Exit:
  494.     m_dwByteCount += (pCurrData - m_lpCurrData);
  495.     m_lpCurrData = pCurrData;
  496.     m_CurrT = CurrT;
  497.     m_PrevSamp[0] = PrevSamp0;
  498.     m_CurrSamp[0] = CurrSamp0;
  499.     return pBuffer;
  500. }
  501. #endif