Changeset 468 for OCO/trunk/drv16/waveplay.cpp
- Timestamp:
- Nov 4, 2009, 4:21:24 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OCO/trunk/drv16/waveplay.cpp
r391 r468 79 79 dprintf(("OSS16_WaveOpen failed!!")); 80 80 #endif 81 // DevHelp_Beep(1000, 100);82 81 DebugInt3(); 83 82 // StreamId = 0; … … 108 107 { 109 108 #ifdef DEBUG 110 dprintf(("WAVEPLAY::Close stream: %lx, %lx, os: %lx \n", StreamId, waveOpened,open_strategy));109 dprintf(("WAVEPLAY::Close stream: %lx, %lx, os: %lx", StreamId, waveOpened,open_strategy)); 111 110 #endif 112 111 #if 0 // fixme to be gone? … … 120 119 force_closed = 0; 121 120 #ifdef DEBUG 122 dprintf(("WAVEPLAY::Closed stream: %lx, %lx, os: %lx \n", StreamId, waveOpened,open_strategy));121 dprintf(("WAVEPLAY::Closed stream: %lx, %lx, os: %lx", StreamId, waveOpened,open_strategy)); 123 122 #endif 124 123 return TRUE; … … 141 140 open_strategy = 0UL; 142 141 #ifdef DEBUG 143 dprintf(("OSS16_WAVECLOSE: Success \n"));142 dprintf(("OSS16_WAVECLOSE: Success")); 144 143 #endif /* DEBUG */ 145 144 return TRUE; 146 145 } else 147 146 #ifdef DEBUG 148 dprintf(("OSS16_WAVECLOSE: Error \n"));147 dprintf(("OSS16_WAVECLOSE: Error")); 149 148 #endif /* DEBUG */ 150 149 return FALSE; … … 166 165 int samplesize; 167 166 ULONG ulPCMConsumeRate; 168 intrc;167 USHORT rc; 169 168 170 169 … … 195 194 #endif 196 195 197 if(ulFirstBufSize == 0) { 196 if(ulFirstBufSize == 0) 197 { 198 198 ulFirstBufSize = pConfigInfo->ulFragsize; //no conversion required (see below) 199 if(ulFirstBufSize == 0) { 199 if (ulFirstBufSize == 0) 200 { 200 201 DebugInt3(); 201 202 ulFirstBufSize = 8192; //should never happen! … … 205 206 } 206 207 } 207 else { 208 else 209 { 208 210 //convert size of first buffer 209 211 ulFirstBufSize = ConvertLength(ulFirstBufSize, pConfigInfo); … … 212 214 #endif /* DEBUG */ 213 215 } 214 215 216 //Must call this method (i.e. resets sample rate conversion position) 216 217 WAVEAUDIO::ConfigDev(StreamId, pConfigInfo, ulFirstBufSize); … … 225 226 #endif /* DEBUG */ 226 227 227 fragsize = ulPCMConsumeRate/64; //start with 64 irqs/sec 228 fragsize = ulPCMConsumeRate/64; //start with 64 irqs/sec 2756 228 229 229 230 //if the buffer is smaller than our predefined fragmentsize (*2), then correct it … … 232 233 //There's nothing we can do about it as the fragment size can't be changed 233 234 //while the stream is playing. 234 ULONG minimumsize = ulFirstBufSize/2; 235 ULONG minimumsize = ulFirstBufSize/2; //650 235 236 if(minimumsize && minimumsize < fragsize) 236 237 { 237 while(minimumsize < fragsize) fragsize = fragsize / 2; 238 238 while(minimumsize < fragsize) fragsize = fragsize / 2; // 239 239 240 if(fragsize < ulPCMConsumeRate/256) 240 241 {//lower limit; don't accept extremely small buffers … … 257 258 hwparam.ulNumChannels = pConfigInfo->ulHwNumChannels; 258 259 hwparam.ulDataType = QueryOSSDataFormat(OPERATION_PLAY, pConfigInfo->ulDataType, pConfigInfo->ulHwBitsPerSample); 259 rc = ( int)OSS16_WaveSetFormat(StreamId, &hwparam);260 rc = (USHORT)OSS16_WaveSetFormat(StreamId, &hwparam); 260 261 #ifdef DEBUG 261 262 dprintf(("WAVEPLAY:ConfigDev:OSS16_WaveSetFormat . rc = %d",rc)); … … 267 268 #endif 268 269 if( rc != OSSERR_SUCCESS) { 269 // DevHelp_Beep(500, 100);270 dprintf(("WAVEPLAY:ConfigDev: rc %d",rc)); 270 271 DebugInt3(); 271 272 // vladest … … 287 288 288 289 #ifdef DEBUG 289 // dprintf(("WAVEPLAY::Transfer "));290 // dprintf(("WAVEPLAY::Transfer %ld",ulBytesToTransfer)); 290 291 #endif 291 292 … … 299 300 } 300 301 302 //PS very strange 303 if (!ulBytesToTransfer) 304 { 305 return TRUE; 306 } 307 301 308 // if (!waveOpened) return TRUE; 302 309 303 310 if(pConfigInfo->usConversion == CONVERT_NONE) 304 311 { 305 #ifdef DEBUG 306 dprintf(("Transfer. NoConv ulB %ld",ulBytesToTransfer));307 # endif /* DEBUG */308 if(AddBuffer(StreamId, pConfigInfo, pUserBuffer, ulBytesToTransfer, pulBytesTransferred) == FALSE)309 { 312 if (AddBuffer(StreamId, pConfigInfo, pUserBuffer, ulBytesToTransfer, pulBytesTransferred) == FALSE) 313 { 314 #ifdef DEBUG 315 dprintf(("Transfer.False. NoConv ulB %ld tr:%ld",ulBytesToTransfer,*pulBytesTransferred)); 316 #endif /* DEBUG */ 310 317 *pulBytesTransferred = 0; 311 318 return FALSE; 312 319 } 313 320 } 314 else { 315 if(pConfigInfo->pfnConvert) { 321 else 322 { 323 if(pConfigInfo->pfnConvert) 324 { 316 325 ULONG ulCvtBufferSize; 317 326 … … 323 332 ulBytesToTransfer = CONVERT_LENGTH(ulCvtBufferSize, CONVERSION_INVERT(pConfigInfo->ulConversionFactor)); 324 333 325 if(ulBytesToTransfer & (pConfigInfo->ulSampleSize-1)) { 326 DebugInt3(); 334 if(ulBytesToTransfer & (pConfigInfo->ulSampleSize-1)) 335 { 336 dprintf(("Transfer New ulBr %ld" , ulBytesToTransfer)); 337 // DebugInt3(); 327 338 ulBytesToTransfer = ulBytesToTransfer & ~(pConfigInfo->ulSampleSize-1); 328 339 #ifdef DEBUG 329 dprintf((" New ulBr %ld" , ulBytesToTransfer));340 dprintf(("Transfer New ulBr %ld" , ulBytesToTransfer)); 330 341 #endif 331 342 } … … 338 349 //convert back from conversion to 'real' 339 350 *pulBytesTransferred = CONVERT_LENGTH(*pulBytesTransferred, CONVERSION_INVERT(pConfigInfo->ulConversionFactor)); 340 if(*pulBytesTransferred & (pConfigInfo->ulSampleSize-1)) { 341 DebugInt3(); 342 #ifdef DEBUG 343 dprintf(("New pulBr %ld" , pulBytesTransferred)); 344 #endif 351 if(*pulBytesTransferred & (pConfigInfo->ulSampleSize-1)) 352 { 353 #ifdef DEBUG 354 dprintf(("Transfer New pulBr %ld" , pulBytesTransferred)); 355 #endif 356 // DebugInt3(); 345 357 } 346 358 } 347 else { 348 DebugInt3(); 359 else 360 { 361 dprintf(("Transfer Zero pConfigInfo->pfnConvert")); 362 // DebugInt3(); 349 363 return FALSE; 350 364 } … … 363 377 // if (!waveOpened) return TRUE; 364 378 379 //PS Here is inrerrupt time.... 365 380 if (fAPMSuspend) 366 381 { 367 382 #ifdef DEBUG 368 dprintf(("WAVEPLAY::AddBuffer. Suspend state"));383 // dprintf(("WAVEPLAY::AddBuffer. Suspend state")); 369 384 #endif 370 385 apm_resume(); … … 372 387 } 373 388 374 if (pConfigInfo->fSampleRateConversion)389 if (pConfigInfo->fSampleRateConversion) 375 390 { 376 391 ULONG ulCvtBufferSize, ulSampleCount, ulHwSampleCount; … … 378 393 379 394 //bytes to convert is bounded by bytes to transfer & max conversion buffer size 380 ulCvtBufferSize = SRATE_CONVERT_LENGTH(ulBytesToTransfer, pConfigInfo->ulSRatePosition, 381 pConfigInfo->ulSRateIncrement); 395 ulCvtBufferSize = SRATE_CONVERT_LENGTH(ulBytesToTransfer, pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement); 382 396 ulCvtBufferSize = min(CONVERSION_BUFFER_SIZE, ulCvtBufferSize); 383 397 //round to sample boundary 384 398 ulCvtBufferSize &= ~(pConfigInfo->ulHwSampleSize - 1); 385 399 386 if(ulCvtBufferSize == 0) { 400 if(ulCvtBufferSize == 0) 401 { 387 402 *pulBytesTransferred = ulBytesToTransfer; 388 if(pConfigInfo->ulSRatePosition >= pConfigInfo->ulSRateIncrement) { 403 if(pConfigInfo->ulSRatePosition >= pConfigInfo->ulSRateIncrement) 404 { 389 405 pConfigInfo->ulSRatePosition -= pConfigInfo->ulSRateIncrement; 390 406 } 391 #ifdef DEBUG392 dprintf(("WAVEPLAY::AddBuffer %lx %lx %lx -> nothing left", ulBytesToTransfer, pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement));393 #endif /* DEBUG */394 407 return TRUE; 395 408 } 396 409 pConfigInfo->pfnSRateConv(pUserBuffer, ulCvtBufferSize, pConfigInfo->pSRateConvBuffer, 397 410 pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement); 398 //PS++ !!!!! This don't be !!!!!!!399 411 OSS16_WaveGetSpace(StreamId, &Space); 400 412 if (ulCvtBufferSize > Space) … … 403 415 dprintf(("WPLAY::AddBuffer need %ld space:%ld", ulCvtBufferSize, Space)); 404 416 #endif 405 for (i=0; i < 0xffffff; i++) 417 while (!Space) 418 for (i=0; i < 0xffffff; i++) 419 { 420 OSS16_WaveGetSpace(StreamId, &Space); 421 if (Space & ~(pConfigInfo->ulHwSampleSize - 1)) break; 422 } 423 #ifdef DEBUG 424 dprintf(("OUT %lx need %ld space:%ld ",i, ulCvtBufferSize, Space)); 425 #endif 426 if (ulCvtBufferSize > Space) 427 ulCvtBufferSize = Space & ~(pConfigInfo->ulHwSampleSize - 1); 428 } 429 if ((rc = OSS16_WaveAddBuffer(StreamId, pConfigInfo->pSRateConvBuffer, ulCvtBufferSize, pulBytesTransferred)) != OSSERR_SUCCESS 430 || *pulBytesTransferred == 0) 431 { 432 if(rc == OSSERR_BUFFER_FULL) 406 433 { 407 OSS16_WaveGetSpace(StreamId, &Space);408 if (ulCvtBufferSize <= Space) break;409 }410 #ifdef DEBUG411 dprintf(("OUT %ld need %ld space:%ld Last:%ld",i, ulCvtBufferSize, Space,LastSpace));412 #endif413 }414 if((rc = OSS16_WaveAddBuffer(StreamId, pConfigInfo->pSRateConvBuffer, ulCvtBufferSize, pulBytesTransferred)) != OSSERR_SUCCESS ||415 *pulBytesTransferred == 0)416 {417 if(rc == OSSERR_BUFFER_FULL) {418 434 GetSpace(StreamId, pConfigInfo, &Space); 419 435 dprintf(("WPLAY::AddBuffer; OSS16_WaveAddBuffer %ld %x failed due to full buffer free space:%ld", ulCvtBufferSize, (USHORT)rc,Space)); 420 436 } 421 else dprintf(("WPLAY::AddBuffer; OSS16_WaveAddBuffer %ld rc=%x failed", ulCvtBufferSize, (USHORT)rc)); 437 #ifdef DEBUG 438 else 439 dprintf(("WPLAY::AddBuffer; OSS16_WaveAddBuffer %ld rc=%x failed", ulCvtBufferSize, (USHORT)rc)); 440 #endif 422 441 *pulBytesTransferred = 0; 423 442 return FALSE; … … 437 456 // if the last sample is still needed for the next run, then adjust sample count and 438 457 // sample rate conversion position 439 if(lSRatePosition < 0) { 458 if(lSRatePosition < 0) 459 { 440 460 dprintf4(("WAVEPLAY::AddBuffer; sratepos < 0")); 441 461 dprintf4(("ulHwSampleCount %lx pConfigInfo->ulSRateIncrement %lx ulSampleCount %lx", ulHwSampleCount, pConfigInfo->ulSRateIncrement, ulSampleCount)); 442 462 pConfigInfo->ulSRatePosition = 0; 443 463 } 444 else { 464 else 465 { 445 466 pConfigInfo->ulSRatePosition = (ULONG)lSRatePosition; 446 467 } … … 451 472 if( (rc=OSS16_WaveAddBuffer(StreamId, pUserBuffer, ulBytesToTransfer, pulBytesTransferred)) != OSSERR_SUCCESS) 452 473 { 453 *pulBytesTransferred = 0; 454 dprintf(("WPLAY::AddBuffer; OSS16_WaveAddBuffer failed due to an error rc=%x",(USHORT)rc)); 455 return FALSE; 456 } 474 *pulBytesTransferred = 0; 475 dprintf(("WPLAY::AddBuffer; OSS16_WaveAddBuffer failed due to an error rc=%x",(USHORT)rc)); 476 dprintf(("StreamID:%x PUB:%lx BtTr:%ld",(USHORT)StreamId, pUserBuffer, ulBytesToTransfer)); 477 return FALSE; 478 } 457 479 } 458 480 return TRUE; … … 489 511 // if (!waveOpened) return TRUE; 490 512 491 if(OSS16_WaveGetSpace(StreamId, &space) != OSSERR_SUCCESS) { 513 if(OSS16_WaveGetSpace(StreamId, &space) != OSSERR_SUCCESS) 514 { 492 515 *pulStreamSpace = 0; 493 516 #ifdef DEBUG … … 496 519 return FALSE; 497 520 } 498 LastSpace = space; 521 522 // dprintf(("GetSpace: len %ld",space)); 499 523 cvt = ConvertLengthInvert(space, pConfigInfo); 500 524 //round to sample boundary … … 509 533 ULONG space,cvt; 510 534 511 if(OSS16_WaveGetHwPtr(StreamId, &space) != OSSERR_SUCCESS) { 535 if(OSS16_WaveGetHwPtr(StreamId, &space) != OSSERR_SUCCESS) 536 { 512 537 *pulHwPtr = 0; 513 538 #ifdef DEBUG … … 516 541 return FALSE; 517 542 } 543 518 544 cvt = ConvertLengthInvert(space, pConfigInfo); 519 545 //round to sample boundary 520 *pulHwPtr = cvt & ( 546 *pulHwPtr = cvt & (~(pConfigInfo->ulSampleSize - 1)); 521 547 return TRUE; 522 548 }
Note:
See TracChangeset
for help on using the changeset viewer.