Changeset 271
- Timestamp:
- Nov 19, 2007, 8:44:17 AM (18 years ago)
- Location:
- OCO/trunk/drv16
- Files:
-
- 3 edited
-
convert.h (modified) (1 diff)
-
waudio.cpp (modified) (3 diffs)
-
waveplay.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OCO/trunk/drv16/convert.h
r33 r271 3 3 4 4 //Use one page to temporarily hold converted wave data 5 #define CONVERSION_BUFFER_SIZE (1 6384UL)5 #define CONVERSION_BUFFER_SIZE (12288UL) 6 6 #define CONVERSION_FACTOR(lshift,rshift) (lshift << 8 | rshift) 7 7 #define CONVERSION_LSHIFT(factor) (factor >> 8) -
OCO/trunk/drv16/waudio.cpp
r221 r271 1453 1453 return newlen; 1454 1454 } 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) 1455 1458 //****************************************************************************** 1456 1459 //NOTE: Can only be used for small numbers (up to about 4mb)!! (overflow) … … 1458 1461 ULONG WAVEAUDIO::ConvertLengthInvert(ULONG length, PWAVECONFIGINFO pConfigInfo) 1459 1462 { 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 )); 1463 1491 1464 1492 if(newlen >= 4UL*1024UL*1024UL) { … … 1467 1495 return newlen; 1468 1496 } 1497 /*PS++ 1469 1498 if(newlen && pConfigInfo->fSampleRateConversion) { 1470 1499 newlen = SRATE_CONVERT_LENGTH_INVERT(newlen, pConfigInfo->ulSRatePosition, 1471 1500 pConfigInfo->ulSRateIncrement); 1472 1501 } 1502 */ 1473 1503 return newlen; 1474 1475 } 1476 //****************************************************************************** 1477 //****************************************************************************** 1478 1504 } 1505 //****************************************************************************** 1506 //****************************************************************************** 1507 -
OCO/trunk/drv16/waveplay.cpp
r266 r271 46 46 { 47 47 ULONG open_strategy = 0UL; 48 ULONG LastSpace=0; 48 49 // int force_close(void); 49 50 } … … 339 340 if(ulBytesToTransfer & (pConfigInfo->ulSampleSize-1)) { 340 341 DebugInt3(); 341 *pulBytesTransferred = *pulBytesTransferred & ~(pConfigInfo->ulSampleSize-1); 342 ulBytesToTransfer = ulBytesToTransfer & ~(pConfigInfo->ulSampleSize-1); 343 #ifdef DEBUG 344 dprintf(("New ulBr %d" , ulBytesToTransfer)); 345 #endif 342 346 } 343 347 pConfigInfo->pfnConvert(pUserBuffer, ulBytesToTransfer, pConfigInfo->pConversionBuffer); … … 351 355 if(*pulBytesTransferred & (pConfigInfo->ulSampleSize-1)) { 352 356 DebugInt3(); 357 #ifdef DEBUG 358 dprintf(("New pulBr %d" , pulBytesTransferred)); 359 #endif 353 360 } 354 361 } … … 366 373 ULONG ulBytesToTransfer, ULONG FAR *pulBytesTransferred) 367 374 { 375 OSSRET rc; 376 ULONG Space; 377 ULONG i; 368 378 // if (!waveOpened) return TRUE; 369 379 … … 381 391 ULONG ulCvtBufferSize, ulSampleCount, ulHwSampleCount; 382 392 LONG lSRatePosition; 383 OSSRET rc;384 393 385 394 //bytes to convert is bounded by bytes to transfer & max conversion buffer size … … 402 411 pConfigInfo->pfnSRateConv(pUserBuffer, ulCvtBufferSize, pConfigInfo->pSRateConvBuffer, 403 412 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 } 405 429 if((rc = OSS16_WaveAddBuffer(StreamId, pConfigInfo->pSRateConvBuffer, ulCvtBufferSize, pulBytesTransferred)) != OSSERR_SUCCESS || 406 430 *pulBytesTransferred == 0) 407 431 { 408 432 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)); 410 435 } 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)); 414 437 *pulBytesTransferred = 0; 415 438 return FALSE; … … 423 446 424 447 //update sample rate position 425 lSRatePosition = (LONG)(pConfigInfo->ulSRatePosition + ulHwSampleCount*pConfigInfo->ulSRateIncrement); 448 449 lSRatePosition = (LONG)(pConfigInfo->ulSRatePosition + ulHwSampleCount * pConfigInfo->ulSRateIncrement); 426 450 lSRatePosition = lSRatePosition - (LONG)ulSampleCount*(LONG)SRATE_SHIFT_VALUE; 427 451 … … 439 463 } 440 464 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 { 443 468 *pulBytesTransferred = 0; 469 dprintf(("WPLAY::AddBuffer; OSS16_WaveAddBuffer failed due to an error rc=%x",(USHORT)rc)); 444 470 return FALSE; 471 } 445 472 } 446 473 return TRUE; … … 473 500 BOOL WAVEPLAY::GetSpace(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, ULONG FAR *pulStreamSpace) 474 501 { 475 ULONG space ;502 ULONG space,cvt; 476 503 477 504 // if (!waveOpened) return TRUE; … … 484 511 return FALSE; 485 512 } 486 487 *pulStreamSpace= ConvertLengthInvert(space, pConfigInfo);513 LastSpace = space; 514 cvt = ConvertLengthInvert(space, pConfigInfo); 488 515 //round to sample boundary 489 *pulStreamSpace &= ~(pConfigInfo->ulSampleSize - 1);516 *pulStreamSpace =cvt & ( ~(pConfigInfo->ulSampleSize - 1)); 490 517 return TRUE; 491 518 }
Note:
See TracChangeset
for help on using the changeset viewer.
