Changeset 513 for OCO/branches/DAZ/drv16/wavestrm.cpp
- Timestamp:
- Jul 12, 2010, 12:57:31 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OCO/branches/DAZ/drv16/wavestrm.cpp
r512 r513 42 42 extern "C" ULONG __cdecl __saveregs OSSIDC_EntryPoint(ULONG cmd, ULONG param1, ULONG param2); 43 43 44 #define SNDRV_PCM_STATE_XRUN 4 /* stream reached an xrun */ 44 45 45 46 //****************************************************************************** … … 148 149 { 149 150 if (ulStreamState == STREAM_STOPPED) return; 150 rprintf(("%s: BufferUnderrun-stop", pchStr));151 pahw->SetVolume(StreamId, getMixerStreamId(), 0);151 rprintf(("%s: Underrun-stop", pchStr)); 152 //pahw->SetVolume(StreamId, getMixerStreamId(), 0); 152 153 pahw->Stop(StreamId); 153 154 ulStreamState = STREAM_STOPPED; … … 160 161 { 161 162 if (ulStreamState == STREAM_STREAMING) return 0; 163 rprintf(("Underrun-start")); 162 164 PSTREAMBUFFER pTemp = (PSTREAMBUFFER)qhInProcess.Head(); 163 if(pahw->ConfigDev(StreamId, &_configinfo, (pTemp) ? pTemp->ulBuffsz : 0) == FALSE) { 164 rprintf(("WS::Write: ConfigDev failed")); 165 return ERROR_INSUFF_BUFFER; 166 } 165 // if(pahw->ConfigDev(StreamId, &_configinfo, (pTemp) ? pTemp->ulBuffsz : 0) == FALSE) { 166 // rprintf(("WS::Write: ConfigDev failed")); 167 // return ERROR_INSUFF_BUFFER; 168 // } 169 _configinfo.ulSRatePosition = 0; 167 170 // prepare wave device for playback/recording 168 171 if(pahw->Prepare(StreamId) == FALSE) { 169 rprintf(("WS:: Write: Prepare failed"));172 rprintf(("WS::UR Start: Prepare failed")); 170 173 return ERROR_START_STREAM; 171 174 } … … 175 178 ulStreamState = STREAM_STREAMING; 176 179 fUnderrun = FALSE; 177 if (ulStreamType == STREAM_WAVE_PLAY) pahw->SetVolume(StreamId, getMixerStreamId(), volume);180 //if (ulStreamType == STREAM_WAVE_PLAY) pahw->SetVolume(StreamId, getMixerStreamId(), volume); 178 181 return 0; 179 182 } … … 185 188 // if this is a write stream call _vFillAudioBuf 186 189 //****************************************************************************** 190 short sDbgInProcess = 0; 191 short sDbgSave; 187 192 #pragma off (unreferenced) 188 void WAVESTREAM::AddBuffers( BOOL fFirst)193 void WAVESTREAM::AddBuffers(SHORT sFirst) 189 194 #pragma on (unreferenced) 190 195 { … … 193 198 ULONG ulStatus; 194 199 195 //dprintf(("WS:AddBuffers First=%d, SampleSize=%lx", fFirst, _configinfo.ulSampleSize)); 200 //dprintf(("WS:AddBuffers First=%d, SampleSize=%lx", sFirst, _configinfo.ulSampleSize)); 201 202 if (sDbgInProcess) { 203 rprintf(("WS::ABS InProcess Now=%x Save=%x", sFirst, sDbgSave)); 204 return; 205 } 206 sDbgInProcess++; 207 sDbgSave = sFirst; 196 208 197 209 ulBytesWritten = 0; … … 204 216 // In extream cases we will stay stuck in this loop long enough to casue a trap rjj 205 217 if (pahw->GetSpace(StreamId, &_configinfo, &ulSpace) == FALSE) { 206 rprintf(("W AVESTREAM::AddBuffersGetSpace failed"));218 rprintf(("WS::ABS GetSpace failed")); 207 219 return; 208 220 } 209 221 ulSpace &= (~(_configinfo.ulSampleSize - 1)); 210 222 #if 1 223 /* DAZ testing -- underrun detection */ 211 224 if (ulSpace == 0) { 212 225 OSS16_WaveGetStatus(StreamId, &ulStatus); 213 rprintf(("W AVESTREAM::AddBuffers ulSpace=0, u32status=%lx", ulStatus));214 215 _vUnderrunStop("WS:AB ");226 rprintf(("WS::ABS ulSpace=0 state=%lx u32status=%lx", ulStreamState, ulStatus)); 227 228 _vUnderrunStop("WS:ABS"); 216 229 _vUnderrunStart(); 217 230 218 231 if (pahw->GetSpace(StreamId, &_configinfo, &ulSpace) == FALSE) { 219 rprintf(("WS::AB GetSpace failed"));232 rprintf(("WS::ABS GetSpace failed")); 220 233 return; 221 234 } 222 235 ulSpace &= (~(_configinfo.ulSampleSize - 1)); 236 if (ulSpace ==0) rprintf(("WS::ABS still no space")); 223 237 } 224 238 #endif … … 227 241 { 228 242 if (ulDAZ++ > 20) { 229 rprintf(("W AVESTREAM::AddBuffersDAZ break")); // Temporary hack to prevent lockups when uniaud32 stops (underrun)243 rprintf(("WS::ABS DAZ break")); // Temporary hack to prevent lockups when uniaud32 stops (underrun) 230 244 int3(); /* should never happen */ 231 245 break; 232 246 } 233 #if 0234 //DAZ move the ProcBlock to the start stream code, if really needed235 // First time is in task time. For I7 need to give time for interrupt time236 if (fFirst == TRUE) //PS+++237 {238 //cli();239 DevHelp_ProcBlock (0x5541, 20, 0); // ok since the first call is at task time240 ulBytesWritten = AddBuffer(ulSpace);241 return;242 }243 #endif244 247 ulBytesWritten = AddBuffer(ulSpace); 245 248 if (ulBytesWritten == (ULONG)-1) { 246 249 OSS16_WaveGetStatus(StreamId, &ulStatus); 247 rprintf(("W AVESTREAM::AddBuffersAddBuffer returns -1 u32Status=%lx", ulStatus));250 rprintf(("WS::ABS AddBuffer returns -1 u32Status=%lx", ulStatus)); 248 251 break; 249 252 } … … 255 258 // } 256 259 } 260 sDbgInProcess--; 257 261 } 258 262 … … 296 300 if (pahw->Transfer(StreamId, &_configinfo, pDataBuf, ulBuffLeft, &ulBytesWritten) == FALSE) { 297 301 // This could mean that the hardware has underrun TODO: implement underrun logic 298 rprintf(("WS::A ddBuffer: pahw->Transfer failed"));302 rprintf(("WS::AB: pahw->Transfer failed")); 299 303 return (ULONG)-1; 300 304 } 305 //dprintf(("WS::AB: %lx of %lx bytes written", ulBytesWritten, ulBuffLeft)); 301 306 if (ulBytesWritten == 0) { 302 307 // This could mean that the hardware has underrun TODO: implement underrun logic 303 rprintf(("WS::AddBuffer: 0 of %lx bytes written by transfer", ulBuffLeft));308 //rprintf(("WS::AddBuffer: 0 of %lx bytes written by transfer", ulBuffLeft)); 304 309 return (ULONG)-1; 305 310 } … … 396 401 break; 397 402 } 398 if (qhInProcess.IsElements()) AddBuffers( FALSE);403 if (qhInProcess.IsElements()) AddBuffers(1); 399 404 // Return any buffers that have been completely written to uniaud32 400 405 //dprintf(("WS::Process usBufferMode=%x", usBufferMode)); … … 418 423 while(_vReadAudioBuf()) { 419 424 if (ulDAZ++ > 20) { /* temporary hack to prevent hangs when uniaud32 stops (overruns) */ 420 rprintf(("W AVESTREAM::Process Read DAZ Break"));425 rprintf(("WS::Process Read DAZ Break")); 421 426 break; 422 427 } … … 442 447 //****************************************************************************** 443 448 //****************************************************************************** 444 #define SNDRV_PCM_STATE_XRUN 4 /* stream reached an xrun */445 449 ULONG WAVESTREAM::Write(PSTREAMBUFFER pStreamBuf) 446 450 { … … 457 461 fUnderrun = TRUE; 458 462 } 459 #else460 if (!fUnderrun && !qhInProcess.IsElements()) {461 rprintf(("WS::Write: Buffer Underrun detect"));462 fUnderrun = TRUE;463 }464 463 #endif 465 464 qhInProcess.PushOnTail((PQUEUEELEMENT)pStreamBuf); 466 //dprintf(("WS::Write: sz=%lx IRQ=%lx", pStreamBuf->ulBuffsz, _configinfo.ulBytesPerIRQ));467 // if (pStreamBuf->ulBuffsz < (_configinfo.ulBytesPerIRQ*2)) {468 // dprintf(("WS::Write: BufferMode=1"));469 // usBufferMode = 1;470 // }471 465 if (fUnderrun) { 472 466 _vUnderrunStart(); 473 AddBuffers( FALSE);467 AddBuffers(2); 474 468 } 475 469 return 0; … … 614 608 if (ulStreamType == STREAM_WAVE_PLAY) 615 609 { 610 //DAZ moved from AddBuffers, for I7, might not be needed 611 //DevHelp_ProcBlock (0x5541, 20, 0); 616 612 pahw->SetVolume(StreamId, getMixerStreamId(), volume); //PS 617 AddBuffers( TRUE);613 AddBuffers(3); 618 614 } 619 615 else … … 641 637 { 642 638 if(ulStreamState == STREAM_STOPPED) { 643 dprintf(("WAVESTREAM::StopStream %lx (already stopped)", StreamId));639 //dprintf(("WS::StopStream %lx (already stopped)", StreamId)); 644 640 fUnderrun = FALSE; 645 641 pControl->ulTime = GetCurrentTime(); … … 676 672 677 673 if(ulStreamState == STREAM_PAUSED) { 678 dprintf(("W AVESTREAM::PauseStream %lx (already paused)", StreamId));674 dprintf(("WS::PauseStream %lx (already paused)", StreamId)); 679 675 fUnderrun = FALSE; 680 676 pControl->ulTime = GetCurrentTime(); … … 691 687 if (pahw->GetPosition(StreamId, &_configinfo, &ulEndPos2) == FALSE) ulEndPos2 = 0; 692 688 if (ulEndPos2 != ulEndPos) { 693 dprintf(("W AVESTREAM::PauseStream %lx!=%lx", ulEndPos, ulEndPos2));689 dprintf(("WS::PauseStream %lx!=%lx", ulEndPos, ulEndPos2)); 694 690 if (ulEndPos2) ulEndPos = ulEndPos2; 695 691 } … … 699 695 ulStreamState = STREAM_PAUSED; 700 696 701 dprintf(("W AVESTREAM::PauseStream %lx", StreamId));697 dprintf(("WS::PauseStream %lx", StreamId)); 702 698 703 699 _ulBytesProcessed = ulEndPos; … … 717 713 ULONG WAVESTREAM::ResumeStream(void) 718 714 { 719 #ifdef DEBUG720 715 //dprintf(("WAVESTREAM::ResumeStream %lx", StreamId)); 721 #endif722 716 return StartStream(); 723 717 } … … 729 723 case PROPERTY_VOLUME: 730 724 volume = value; 731 dprintf(("W AVESTREAM::SetProperty() Vol: %0lx",value));725 dprintf(("WS::SetProperty() Vol: %0lx",value)); 732 726 if(ulStreamState == STREAM_STREAMING && ulStreamType == STREAM_WAVE_PLAY) { 733 727 MixerSetWaveVolume(getMixerStreamId(), StreamId, volume);
Note:
See TracChangeset
for help on using the changeset viewer.