Ignore:
Timestamp:
Oct 8, 2008, 11:28:16 PM (17 years ago)
Author:
rjerant
Message:

Add GetHwPtr() to code base

File:
1 edited

Legend:

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

    r288 r391  
    233233    //while the stream is playing.
    234234    ULONG minimumsize = ulFirstBufSize/2;
    235     if(minimumsize && minimumsize < fragsize) 
     235    if(minimumsize && minimumsize < fragsize)
    236236    {
    237237        while(minimumsize < fragsize) fragsize = fragsize / 2;
    238238
    239             if(fragsize < ulPCMConsumeRate/256) 
     239            if(fragsize < ulPCMConsumeRate/256)
    240240            {//lower limit; don't accept extremely small buffers
    241241                fragsize = ulPCMConsumeRate/256;
    242242            }
    243     }   
     243    }
    244244    samplesize = (int)pConfigInfo->ulHwSampleSize;
    245245
     
    280280//Convert (if required) and write wave data to audio device
    281281//******************************************************************************
    282 BOOL WAVEPLAY::Transfer(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, 
    283                         LINEAR pUserBuffer, ULONG ulBytesToTransfer, 
     282BOOL WAVEPLAY::Transfer(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo,
     283                        LINEAR pUserBuffer, ULONG ulBytesToTransfer,
    284284                        ULONG FAR *pulBytesTransferred)
    285285{
     
    301301//    if (!waveOpened) return TRUE;
    302302
    303     if(pConfigInfo->usConversion == CONVERT_NONE) 
     303    if(pConfigInfo->usConversion == CONVERT_NONE)
    304304    {
    305305#ifdef DEBUG
    306306        dprintf(("Transfer. NoConv ulB %ld",ulBytesToTransfer));
    307307#endif /* DEBUG */
    308         if(AddBuffer(StreamId, pConfigInfo, pUserBuffer, ulBytesToTransfer, pulBytesTransferred) == FALSE) 
     308        if(AddBuffer(StreamId, pConfigInfo, pUserBuffer, ulBytesToTransfer, pulBytesTransferred) == FALSE)
    309309        {
    310310            *pulBytesTransferred = 0;
     
    320320            ulCvtBufferSize = min(CONVERSION_BUFFER_SIZE, ulCvtBufferSize);
    321321
    322             //convert back from conversion to 'real' 
     322            //convert back from conversion to 'real'
    323323            ulBytesToTransfer = CONVERT_LENGTH(ulCvtBufferSize, CONVERSION_INVERT(pConfigInfo->ulConversionFactor));
    324324
     
    331331            }
    332332            pConfigInfo->pfnConvert(pUserBuffer, ulBytesToTransfer, pConfigInfo->pConversionBuffer);
    333             if(AddBuffer(StreamId, pConfigInfo, pConfigInfo->pConversionBuffer, ulCvtBufferSize, pulBytesTransferred) == FALSE) 
     333            if(AddBuffer(StreamId, pConfigInfo, pConfigInfo->pConversionBuffer, ulCvtBufferSize, pulBytesTransferred) == FALSE)
    334334            {
    335335                *pulBytesTransferred = 0;
    336336                return FALSE;
    337337            }
    338             //convert back from conversion to 'real' 
     338            //convert back from conversion to 'real'
    339339            *pulBytesTransferred = CONVERT_LENGTH(*pulBytesTransferred, CONVERSION_INVERT(pConfigInfo->ulConversionFactor));
    340340            if(*pulBytesTransferred & (pConfigInfo->ulSampleSize-1)) {
     
    355355// Perform sample rate conversion if required, else send buffer directly to ALSA
    356356//******************************************************************************
    357 BOOL WAVEPLAY::AddBuffer(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, LINEAR pUserBuffer, 
     357BOOL WAVEPLAY::AddBuffer(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, LINEAR pUserBuffer,
    358358                         ULONG ulBytesToTransfer, ULONG FAR *pulBytesTransferred)
    359359{
     
    378378
    379379        //bytes to convert is bounded by bytes to transfer & max conversion buffer size
    380         ulCvtBufferSize = SRATE_CONVERT_LENGTH(ulBytesToTransfer, pConfigInfo->ulSRatePosition, 
     380        ulCvtBufferSize = SRATE_CONVERT_LENGTH(ulBytesToTransfer, pConfigInfo->ulSRatePosition,
    381381                                               pConfigInfo->ulSRateIncrement);
    382382        ulCvtBufferSize = min(CONVERSION_BUFFER_SIZE, ulCvtBufferSize);
    383383        //round to sample boundary
    384384        ulCvtBufferSize &= ~(pConfigInfo->ulHwSampleSize - 1);
    385        
     385
    386386        if(ulCvtBufferSize == 0) {
    387387            *pulBytesTransferred = ulBytesToTransfer;
    388             if(pConfigInfo->ulSRatePosition >= pConfigInfo->ulSRateIncrement) { 
     388            if(pConfigInfo->ulSRatePosition >= pConfigInfo->ulSRateIncrement) {
    389389                pConfigInfo->ulSRatePosition -= pConfigInfo->ulSRateIncrement;
    390390            }
     
    394394            return TRUE;
    395395        }
    396         pConfigInfo->pfnSRateConv(pUserBuffer, ulCvtBufferSize, pConfigInfo->pSRateConvBuffer, 
     396        pConfigInfo->pfnSRateConv(pUserBuffer, ulCvtBufferSize, pConfigInfo->pSRateConvBuffer,
    397397                                  pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement);
    398398//PS++ !!!!! This don't be !!!!!!!
     
    413413        }
    414414        if((rc = OSS16_WaveAddBuffer(StreamId, pConfigInfo->pSRateConvBuffer, ulCvtBufferSize, pulBytesTransferred)) != OSSERR_SUCCESS ||
    415            *pulBytesTransferred == 0) 
     415           *pulBytesTransferred == 0)
    416416        {
    417417            if(rc == OSSERR_BUFFER_FULL) {
     
    425425        ulHwSampleCount = *pulBytesTransferred/pConfigInfo->ulHwSampleSize;
    426426
    427         //convert back from conversion to 'real' 
    428         ulSampleCount   = SRATE_CONVERT_LENGTH_INVERT(ulHwSampleCount, 
    429                                                       pConfigInfo->ulSRatePosition, 
     427        //convert back from conversion to 'real'
     428        ulSampleCount   = SRATE_CONVERT_LENGTH_INVERT(ulHwSampleCount,
     429                                                      pConfigInfo->ulSRatePosition,
    430430                                                      pConfigInfo->ulSRateIncrement);
    431431
     
    447447        *pulBytesTransferred = ulSampleCount*pConfigInfo->ulHwSampleSize;
    448448    }
    449     else 
    450     {
    451        if( (rc=OSS16_WaveAddBuffer(StreamId, pUserBuffer, ulBytesToTransfer, pulBytesTransferred)) != OSSERR_SUCCESS) 
     449    else
     450    {
     451       if( (rc=OSS16_WaveAddBuffer(StreamId, pUserBuffer, ulBytesToTransfer, pulBytesTransferred)) != OSSERR_SUCCESS)
    452452       {
    453453        *pulBytesTransferred = 0;
     
    500500    //round to sample boundary
    501501    *pulStreamSpace =cvt & ( ~(pConfigInfo->ulSampleSize - 1));
     502    return TRUE;
     503}
     504//******************************************************************************
     505//Get Bytes written to cyclic buffer (+ take conversion factor into account)
     506//******************************************************************************
     507BOOL WAVEPLAY::GetHwPtr(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, ULONG FAR *pulHwPtr)
     508{
     509    ULONG space,cvt;
     510
     511    if(OSS16_WaveGetHwPtr(StreamId, &space) != OSSERR_SUCCESS) {
     512        *pulHwPtr = 0;
     513        #ifdef DEBUG
     514        dprintf(("OSS16_WAVEPLAY::WaveGetHwPtr: Failed"));
     515        #endif /* DEBUG */
     516        return FALSE;
     517    }
     518    cvt  = ConvertLengthInvert(space, pConfigInfo);
     519    //round to sample boundary
     520    *pulHwPtr = cvt & ( ~(pConfigInfo->ulSampleSize - 1));
    502521    return TRUE;
    503522}
Note: See TracChangeset for help on using the changeset viewer.