Ignore:
Timestamp:
Nov 19, 2007, 8:44:17 AM (18 years ago)
Author:
Brendan Oakley
Message:

Pavel's work on Uniaud16 to improve HDA

File:
1 edited

Legend:

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

    r266 r271  
    4646{
    4747    ULONG open_strategy = 0UL;
     48    ULONG LastSpace=0;
    4849//    int force_close(void);
    4950}
     
    339340            if(ulBytesToTransfer & (pConfigInfo->ulSampleSize-1)) {
    340341                DebugInt3();
    341                 *pulBytesTransferred = *pulBytesTransferred & ~(pConfigInfo->ulSampleSize-1);
     342                ulBytesToTransfer = ulBytesToTransfer & ~(pConfigInfo->ulSampleSize-1);
     343#ifdef DEBUG
     344                dprintf(("New ulBr %d" , ulBytesToTransfer));
     345#endif
    342346            }
    343347            pConfigInfo->pfnConvert(pUserBuffer, ulBytesToTransfer, pConfigInfo->pConversionBuffer);
     
    351355            if(*pulBytesTransferred & (pConfigInfo->ulSampleSize-1)) {
    352356                DebugInt3();
     357#ifdef DEBUG
     358                dprintf(("New pulBr %d" , pulBytesTransferred));
     359#endif
    353360            }
    354361        }
     
    366373                         ULONG ulBytesToTransfer, ULONG FAR *pulBytesTransferred)
    367374{
     375    OSSRET rc;
     376    ULONG  Space;
     377    ULONG i;
    368378//    if (!waveOpened) return TRUE;
    369379
     
    381391        ULONG  ulCvtBufferSize, ulSampleCount, ulHwSampleCount;
    382392        LONG   lSRatePosition;
    383         OSSRET rc;
    384393
    385394        //bytes to convert is bounded by bytes to transfer & max conversion buffer size
     
    402411        pConfigInfo->pfnSRateConv(pUserBuffer, ulCvtBufferSize, pConfigInfo->pSRateConvBuffer,
    403412                                  pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement);
    404 
     413//PS++ !!!!! This don't be !!!!!!!
     414        OSS16_WaveGetSpace(StreamId, &Space);
     415        if (ulCvtBufferSize > Space)
     416        {
     417#ifdef DEBUG
     418            dprintf(("WPLAY::AddBuffer need %ld space:%ld", ulCvtBufferSize, Space));
     419#endif
     420            for (i=0; i < 0xffffff; i++)
     421            {
     422                 OSS16_WaveGetSpace(StreamId, &Space);
     423                 if (ulCvtBufferSize <= Space) break;
     424            }
     425#ifdef DEBUG
     426            dprintf(("OUT %ld need %ld space:%ld Last:%ld",i, ulCvtBufferSize, Space,LastSpace));
     427#endif
     428        }
    405429        if((rc = OSS16_WaveAddBuffer(StreamId, pConfigInfo->pSRateConvBuffer, ulCvtBufferSize, pulBytesTransferred)) != OSSERR_SUCCESS ||
    406430           *pulBytesTransferred == 0)
    407431        {
    408432            if(rc == OSSERR_BUFFER_FULL) {
    409                  dprintf2(("WAVEPLAY::AddBuffer; OSS16_WaveAddBuffer %lx %x failed due to full buffer", ulCvtBufferSize, (USHORT)rc));
     433                 GetSpace(StreamId, pConfigInfo, &Space);
     434                 dprintf(("WPLAY::AddBuffer; OSS16_WaveAddBuffer %ld %x failed due to full buffer free space:%ld", ulCvtBufferSize, (USHORT)rc,Space));
    410435            }
    411 #ifdef DEBUG
    412             else dprintf(("WAVEPLAY::AddBuffer; OSS16_WaveAddBuffer %lx %x failed", ulCvtBufferSize, (USHORT)rc));
    413 #endif /* DEBUG */
     436            else dprintf(("WPLAY::AddBuffer; OSS16_WaveAddBuffer %ld rc=%x failed", ulCvtBufferSize, (USHORT)rc));
    414437            *pulBytesTransferred = 0;
    415438            return FALSE;
     
    423446
    424447        //update sample rate position
    425         lSRatePosition = (LONG)(pConfigInfo->ulSRatePosition + ulHwSampleCount*pConfigInfo->ulSRateIncrement);
     448
     449        lSRatePosition = (LONG)(pConfigInfo->ulSRatePosition + ulHwSampleCount * pConfigInfo->ulSRateIncrement);
    426450        lSRatePosition = lSRatePosition - (LONG)ulSampleCount*(LONG)SRATE_SHIFT_VALUE;
    427451
     
    439463    }
    440464    else
    441     if(OSS16_WaveAddBuffer(StreamId, pUserBuffer, ulBytesToTransfer, pulBytesTransferred) != OSSERR_SUCCESS)
    442     {
     465    {
     466       if( (rc=OSS16_WaveAddBuffer(StreamId, pUserBuffer, ulBytesToTransfer, pulBytesTransferred)) != OSSERR_SUCCESS)
     467       {
    443468        *pulBytesTransferred = 0;
     469        dprintf(("WPLAY::AddBuffer; OSS16_WaveAddBuffer failed due to an error rc=%x",(USHORT)rc));
    444470        return FALSE;
     471        }
    445472    }
    446473    return TRUE;
     
    473500BOOL WAVEPLAY::GetSpace(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, ULONG FAR *pulStreamSpace)
    474501{
    475     ULONG space;
     502    ULONG space,cvt;
    476503
    477504//    if (!waveOpened) return TRUE;
     
    484511        return FALSE;
    485512    }
    486 
    487     *pulStreamSpace  = ConvertLengthInvert(space, pConfigInfo);
     513    LastSpace = space;
     514    cvt  = ConvertLengthInvert(space, pConfigInfo);
    488515    //round to sample boundary
    489     *pulStreamSpace &= ~(pConfigInfo->ulSampleSize - 1);
     516    *pulStreamSpace =cvt & ( ~(pConfigInfo->ulSampleSize - 1));
    490517    return TRUE;
    491518}
Note: See TracChangeset for help on using the changeset viewer.