Changeset 271


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

Pavel's work on Uniaud16 to improve HDA

Location:
OCO/trunk/drv16
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • OCO/trunk/drv16/convert.h

    r33 r271  
    33
    44//Use one page to temporarily hold converted wave data
    5 #define CONVERSION_BUFFER_SIZE           (16384UL)
     5#define CONVERSION_BUFFER_SIZE           (12288UL)
    66#define CONVERSION_FACTOR(lshift,rshift) (lshift << 8 | rshift)
    77#define CONVERSION_LSHIFT(factor)        (factor >> 8)
  • OCO/trunk/drv16/waudio.cpp

    r221 r271  
    14531453    return newlen;
    14541454}
     1455
     1456#define CONVERT_POSITION_INVERT(pos, ulFactor)  ( ( pos << CONVERSION_RSHIFT(ulFactor)) >> CONVERSION_LSHIFT(ulFactor) )
     1457#define CONVERT_LENGTH_INVERT(pos, ulFactor)    CONVERT_POSITION_INVERT(pos, ulFactor)
    14551458//******************************************************************************
    14561459//NOTE: Can only be used for small numbers (up to about 4mb)!! (overflow)
     
    14581461ULONG WAVEAUDIO::ConvertLengthInvert(ULONG length, PWAVECONFIGINFO pConfigInfo)
    14591462{
    1460     ULONG newlen;
    1461 
    1462     newlen = CONVERT_LENGTH(length, CONVERSION_INVERT(pConfigInfo->ulConversionFactor));
     1463    ULONG newlen,tmp,len;
     1464
     1465    if (!length) return 0;
     1466
     1467    len = length;
     1468
     1469    if (pConfigInfo->fSampleRateConversion)
     1470    {
     1471        tmp =  SRATE_CONVERT_LENGTH_INVERT(len, pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement);
     1472        if (tmp && (len != SRATE_CONVERT_LENGTH (tmp, pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement)))
     1473            tmp--;
     1474    }
     1475    else
     1476        tmp = len;
     1477
     1478    if (!tmp) return 0;
     1479   
     1480    if (pConfigInfo->usConversion != CONVERT_NONE)
     1481    {
     1482        newlen =  CONVERT_LENGTH_INVERT (tmp, pConfigInfo->ulConversionFactor);
     1483        if (newlen && (tmp != CONVERT_LENGTH (newlen, pConfigInfo->ulConversionFactor)) )
     1484           newlen--;
     1485    }
     1486    else
     1487        newlen = tmp;
     1488
     1489   if ( newlen > length )
     1490       dprintf(("!!!!Back len %ld tmp %ld new %ld",length,tmp,newlen ));
    14631491
    14641492    if(newlen >= 4UL*1024UL*1024UL) {
     
    14671495        return newlen;
    14681496    }
     1497/*PS++
    14691498    if(newlen && pConfigInfo->fSampleRateConversion) {
    14701499        newlen = SRATE_CONVERT_LENGTH_INVERT(newlen, pConfigInfo->ulSRatePosition,
    14711500                                             pConfigInfo->ulSRateIncrement);
    14721501    }
     1502*/
    14731503    return newlen;
    1474 
    1475 }
    1476 //******************************************************************************
    1477 //******************************************************************************
    1478 
     1504}
     1505//******************************************************************************
     1506//******************************************************************************
     1507
  • 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.