Ignore:
Timestamp:
May 6, 2010, 3:08:34 AM (15 years ago)
Author:
David Azarewicz
Message:

Rework buffer management

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OCO/trunk/drv16/waveplay.cpp

    r478 r483  
    189189    }
    190190#ifdef DEBUG
    191     dprintf(("WAVEPLAY::ConfigDev1 SampleRate %ld", pConfigInfo->ulHwSampleRate));
    192     dprintf(("ulFirstBufSize %ld", ulFirstBufSize));
    193     dprintf(("ulFragsize %ld", pConfigInfo->ulFragsize));
     191    dprintf(("WAVEPLAY::ConfigDev SampleRate %ld", pConfigInfo->ulHwSampleRate));
     192    dprintf(("WAVEPLAY::ConfigDev ulFirstBufSize=%lx ulFragsize=%lx", ulFirstBufSize, pConfigInfo->ulFragsize));
    194193#endif
    195194
     
    197196    {
    198197        ulFirstBufSize = pConfigInfo->ulFragsize; //no conversion required (see below)
    199         if (ulFirstBufSize == 0) 
     198        if (ulFirstBufSize == 0)
    200199        {
    201200            DebugInt3();
     
    206205        }
    207206    }
    208     else 
     207    else
    209208    {
    210209        //convert size of first buffer
    211210        ulFirstBufSize = ConvertLength(ulFirstBufSize, pConfigInfo);
    212211#ifdef DEBUG
    213         dprintf(("ulFirstBufSize %ld", ulFirstBufSize));
     212        dprintf(("ulFirstBufSize %lx", ulFirstBufSize));
    214213#endif /* DEBUG */
    215214    }
     
    223222    ulPCMConsumeRate = ConvertLength(pConfigInfo->ulPCMConsumeRate, pConfigInfo);
    224223#ifdef DEBUG
    225     dprintf(("cons rate %ld buf size %ld init rate %ld", ulPCMConsumeRate, ulFirstBufSize, pConfigInfo->ulHwSampleRate));
     224    dprintf(("cons rate %lx buf size %lx init rate %ld", ulPCMConsumeRate, ulFirstBufSize, pConfigInfo->ulHwSampleRate));
    226225#endif /* DEBUG */
    227226
     
    237236    {
    238237        while(minimumsize < fragsize) fragsize = fragsize / 2; //
    239  
     238
    240239            if(fragsize < ulPCMConsumeRate/256)
    241240            {//lower limit; don't accept extremely small buffers
     
    252251
    253252#ifdef DEBUG
    254     dprintf(("fragsize %ld", fragsize));
     253    dprintf(("fragsize %lx", fragsize));
    255254#endif
    256255    hwparam.ulSampleRate    = pConfigInfo->ulHwSampleRate;
     
    288287
    289288#ifdef DEBUG
    290 //    dprintf(("WAVEPLAY::Transfer %ld",ulBytesToTransfer));
     289    //dprintf(("WAVEPLAY::Transfer %ld",ulBytesToTransfer));
    291290#endif
    292291
     
    319318        }
    320319    }
    321     else 
    322     {
    323         if(pConfigInfo->pfnConvert) 
     320    else
     321    {
     322        if(pConfigInfo->pfnConvert)
    324323        {
    325324            ULONG ulCvtBufferSize;
     
    332331            ulBytesToTransfer = CONVERT_LENGTH(ulCvtBufferSize, CONVERSION_INVERT(pConfigInfo->ulConversionFactor));
    333332
    334             if(ulBytesToTransfer & (pConfigInfo->ulSampleSize-1)) 
     333            if(ulBytesToTransfer & (pConfigInfo->ulSampleSize-1))
    335334            {
    336335                dprintf(("Transfer New ulBr %ld" , ulBytesToTransfer));
     
    349348            //convert back from conversion to 'real'
    350349            *pulBytesTransferred = CONVERT_LENGTH(*pulBytesTransferred, CONVERSION_INVERT(pConfigInfo->ulConversionFactor));
    351             if(*pulBytesTransferred & (pConfigInfo->ulSampleSize-1)) 
     350            if(*pulBytesTransferred & (pConfigInfo->ulSampleSize-1))
    352351            {
    353352#ifdef DEBUG
     
    357356            }
    358357        }
    359         else 
     358        else
    360359        {
    361360            dprintf(("Transfer Zero pConfigInfo->pfnConvert"));
     
    374373    OSSRET rc;
    375374    ULONG  Space;
    376     ULONG i;
    377375//    if (!waveOpened) return TRUE;
    378376
     
    398396        ulCvtBufferSize &= ~(pConfigInfo->ulHwSampleSize - 1);
    399397
    400         if(ulCvtBufferSize == 0) 
     398        if(ulCvtBufferSize == 0)
    401399        {
    402400            *pulBytesTransferred = ulBytesToTransfer;
    403             if(pConfigInfo->ulSRatePosition >= pConfigInfo->ulSRateIncrement) 
     401            if(pConfigInfo->ulSRatePosition >= pConfigInfo->ulSRateIncrement)
    404402            {
    405403                pConfigInfo->ulSRatePosition -= pConfigInfo->ulSRateIncrement;
     
    423421                ulCvtBufferSize = Space & ~(pConfigInfo->ulHwSampleSize - 1);
    424422        }
    425         if ((rc = OSS16_WaveAddBuffer(StreamId, pConfigInfo->pSRateConvBuffer, ulCvtBufferSize, pulBytesTransferred)) != OSSERR_SUCCESS 
     423        if ((rc = OSS16_WaveAddBuffer(StreamId, pConfigInfo->pSRateConvBuffer, ulCvtBufferSize, pulBytesTransferred)) != OSSERR_SUCCESS
    426424             ||  *pulBytesTransferred == 0)
    427425        {
    428             if(rc == OSSERR_BUFFER_FULL) 
     426            if(rc == OSSERR_BUFFER_FULL)
    429427            {
    430428                 GetSpace(StreamId, pConfigInfo, &Space);
     
    432430            }
    433431#ifdef DEBUG
    434             else 
     432            else
    435433                dprintf(("WPLAY::AddBuffer; %ld rc=%x failed", ulCvtBufferSize, (USHORT)rc));
    436434#endif
     
    452450        // if the last sample is still needed for the next run, then adjust sample count and
    453451        // sample rate conversion position
    454         if(lSRatePosition < 0) 
     452        if(lSRatePosition < 0)
    455453        {
    456454            dprintf4(("WAVEPLAY::AddBuffer; sratepos < 0"));
     
    458456            pConfigInfo->ulSRatePosition = 0;
    459457        }
    460         else 
     458        else
    461459        {
    462460            pConfigInfo->ulSRatePosition = (ULONG)lSRatePosition;
     
    507505//    if (!waveOpened) return TRUE;
    508506
    509     if(OSS16_WaveGetSpace(StreamId, &space) != OSSERR_SUCCESS) 
     507    if(OSS16_WaveGetSpace(StreamId, &space) != OSSERR_SUCCESS)
    510508    {
    511509        *pulStreamSpace = 0;
     
    529527    ULONG space,cvt;
    530528
    531     if(OSS16_WaveGetHwPtr(StreamId, &space) != OSSERR_SUCCESS) 
     529    if(OSS16_WaveGetHwPtr(StreamId, &space) != OSSERR_SUCCESS)
    532530    {
    533531        *pulHwPtr = 0;
Note: See TracChangeset for help on using the changeset viewer.