Changeset 391 for OCO/trunk/drv16/waveplay.cpp
- Timestamp:
- Oct 8, 2008, 11:28:16 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OCO/trunk/drv16/waveplay.cpp
r288 r391 233 233 //while the stream is playing. 234 234 ULONG minimumsize = ulFirstBufSize/2; 235 if(minimumsize && minimumsize < fragsize) 235 if(minimumsize && minimumsize < fragsize) 236 236 { 237 237 while(minimumsize < fragsize) fragsize = fragsize / 2; 238 238 239 if(fragsize < ulPCMConsumeRate/256) 239 if(fragsize < ulPCMConsumeRate/256) 240 240 {//lower limit; don't accept extremely small buffers 241 241 fragsize = ulPCMConsumeRate/256; 242 242 } 243 } 243 } 244 244 samplesize = (int)pConfigInfo->ulHwSampleSize; 245 245 … … 280 280 //Convert (if required) and write wave data to audio device 281 281 //****************************************************************************** 282 BOOL WAVEPLAY::Transfer(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, 283 LINEAR pUserBuffer, ULONG ulBytesToTransfer, 282 BOOL WAVEPLAY::Transfer(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, 283 LINEAR pUserBuffer, ULONG ulBytesToTransfer, 284 284 ULONG FAR *pulBytesTransferred) 285 285 { … … 301 301 // if (!waveOpened) return TRUE; 302 302 303 if(pConfigInfo->usConversion == CONVERT_NONE) 303 if(pConfigInfo->usConversion == CONVERT_NONE) 304 304 { 305 305 #ifdef DEBUG 306 306 dprintf(("Transfer. NoConv ulB %ld",ulBytesToTransfer)); 307 307 #endif /* DEBUG */ 308 if(AddBuffer(StreamId, pConfigInfo, pUserBuffer, ulBytesToTransfer, pulBytesTransferred) == FALSE) 308 if(AddBuffer(StreamId, pConfigInfo, pUserBuffer, ulBytesToTransfer, pulBytesTransferred) == FALSE) 309 309 { 310 310 *pulBytesTransferred = 0; … … 320 320 ulCvtBufferSize = min(CONVERSION_BUFFER_SIZE, ulCvtBufferSize); 321 321 322 //convert back from conversion to 'real' 322 //convert back from conversion to 'real' 323 323 ulBytesToTransfer = CONVERT_LENGTH(ulCvtBufferSize, CONVERSION_INVERT(pConfigInfo->ulConversionFactor)); 324 324 … … 331 331 } 332 332 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) 334 334 { 335 335 *pulBytesTransferred = 0; 336 336 return FALSE; 337 337 } 338 //convert back from conversion to 'real' 338 //convert back from conversion to 'real' 339 339 *pulBytesTransferred = CONVERT_LENGTH(*pulBytesTransferred, CONVERSION_INVERT(pConfigInfo->ulConversionFactor)); 340 340 if(*pulBytesTransferred & (pConfigInfo->ulSampleSize-1)) { … … 355 355 // Perform sample rate conversion if required, else send buffer directly to ALSA 356 356 //****************************************************************************** 357 BOOL WAVEPLAY::AddBuffer(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, LINEAR pUserBuffer, 357 BOOL WAVEPLAY::AddBuffer(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, LINEAR pUserBuffer, 358 358 ULONG ulBytesToTransfer, ULONG FAR *pulBytesTransferred) 359 359 { … … 378 378 379 379 //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, 381 381 pConfigInfo->ulSRateIncrement); 382 382 ulCvtBufferSize = min(CONVERSION_BUFFER_SIZE, ulCvtBufferSize); 383 383 //round to sample boundary 384 384 ulCvtBufferSize &= ~(pConfigInfo->ulHwSampleSize - 1); 385 385 386 386 if(ulCvtBufferSize == 0) { 387 387 *pulBytesTransferred = ulBytesToTransfer; 388 if(pConfigInfo->ulSRatePosition >= pConfigInfo->ulSRateIncrement) { 388 if(pConfigInfo->ulSRatePosition >= pConfigInfo->ulSRateIncrement) { 389 389 pConfigInfo->ulSRatePosition -= pConfigInfo->ulSRateIncrement; 390 390 } … … 394 394 return TRUE; 395 395 } 396 pConfigInfo->pfnSRateConv(pUserBuffer, ulCvtBufferSize, pConfigInfo->pSRateConvBuffer, 396 pConfigInfo->pfnSRateConv(pUserBuffer, ulCvtBufferSize, pConfigInfo->pSRateConvBuffer, 397 397 pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement); 398 398 //PS++ !!!!! This don't be !!!!!!! … … 413 413 } 414 414 if((rc = OSS16_WaveAddBuffer(StreamId, pConfigInfo->pSRateConvBuffer, ulCvtBufferSize, pulBytesTransferred)) != OSSERR_SUCCESS || 415 *pulBytesTransferred == 0) 415 *pulBytesTransferred == 0) 416 416 { 417 417 if(rc == OSSERR_BUFFER_FULL) { … … 425 425 ulHwSampleCount = *pulBytesTransferred/pConfigInfo->ulHwSampleSize; 426 426 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, 430 430 pConfigInfo->ulSRateIncrement); 431 431 … … 447 447 *pulBytesTransferred = ulSampleCount*pConfigInfo->ulHwSampleSize; 448 448 } 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) 452 452 { 453 453 *pulBytesTransferred = 0; … … 500 500 //round to sample boundary 501 501 *pulStreamSpace =cvt & ( ~(pConfigInfo->ulSampleSize - 1)); 502 return TRUE; 503 } 504 //****************************************************************************** 505 //Get Bytes written to cyclic buffer (+ take conversion factor into account) 506 //****************************************************************************** 507 BOOL 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)); 502 521 return TRUE; 503 522 }
Note:
See TracChangeset
for help on using the changeset viewer.