Author: janderwald Date: Mon Feb 21 04:22:45 2011 New Revision: 50851
URL: http://svn.reactos.org/svn/reactos?rev=50851&view=rev Log: [MMEBUDDY] - Check if there is a reset request in progress while the wave thread is active. In that case exit the wave buffer commiting activity - In the reset routine, perform an alertable wait in order to make the apc io completion complete [PORTCLS] - Only perform copying audio bytes to dma buffer while the adapter is reset state is KSREST_END - Set the reset state indicator before canceling the audio buffers - Should fix the audio hang experienced in Winamp when skipping audio bytes
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp trunk/reactos/lib/drivers/sound/mmebuddy/wave/streaming.c
Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/p... ============================================================================== --- trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp [iso-8859-1] (original) +++ trunk/reactos/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp [iso-8859-1] Mon Feb 21 04:22:45 2011 @@ -823,7 +823,7 @@
PC_ASSERT_IRQL(DISPATCH_LEVEL);
- if (m_State == KSSTATE_RUN) + if (m_State == KSSTATE_RUN && m_ResetState == KSRESET_END) { Status = m_Stream->GetPosition(&Position);
@@ -904,13 +904,19 @@ /* check for success */ if (NT_SUCCESS(Status)) { + //determine state of reset request if (ResetValue == KSRESET_BEGIN) { + // start reset procress + // incoming read/write requests will be rejected + m_ResetState = KSRESET_BEGIN; + + // cancel existing buffers m_IrpQueue->CancelBuffers(); - m_ResetState = KSRESET_BEGIN; } else if (ResetValue == KSRESET_END) { + // end of reset process m_ResetState = KSRESET_END; } }
Modified: trunk/reactos/lib/drivers/sound/mmebuddy/wave/streaming.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/sound/mmebuddy/... ============================================================================== --- trunk/reactos/lib/drivers/sound/mmebuddy/wave/streaming.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/sound/mmebuddy/wave/streaming.c [iso-8859-1] Mon Feb 21 04:22:45 2011 @@ -60,7 +60,7 @@ }
while ( ( SoundDeviceInstance->OutstandingBuffers < SoundDeviceInstance->BufferCount ) && - ( Header ) ) + ( Header ) && SoundDeviceInstance->ResetInProgress == FALSE) { HeaderExtension = (PWAVEHDR_EXTENSION) Header->reserved; SND_ASSERT( HeaderExtension ); @@ -176,8 +176,6 @@ WaveHdr = (PWAVEHDR) SoundOverlapped->Header; SND_ASSERT( WaveHdr );
- SND_ASSERT( ERROR_SUCCESS == dwErrorCode ); - HdrExtension = (PWAVEHDR_EXTENSION) WaveHdr->reserved; SND_ASSERT( HdrExtension );
@@ -305,6 +303,12 @@ /* cancel all current audio buffers */ FunctionTable->ResetStream(SoundDeviceInstance, DeviceType, TRUE); } + while(SoundDeviceInstance->OutstandingBuffers) + { + SND_TRACE(L"StopStreamingInSoundThread OutStandingBufferCount %lu\n", SoundDeviceInstance->OutstandingBuffers); + /* wait until pending i/o has completed */ + SleepEx(10, TRUE); + }
/* complete all current headers */ while( SoundDeviceInstance->HeadWaveHeader ) @@ -316,12 +320,6 @@ /* there should be no oustanding buffers now */ SND_ASSERT(SoundDeviceInstance->OutstandingBuffers == 0);
- while(SoundDeviceInstance->OutstandingBuffers) - { - SND_ERR("StopStreamingInSoundThread OutStandingBufferCount %lu\n", SoundDeviceInstance->OutstandingBuffers); - /* my hack of doom */ - Sleep(10); - }
/* Check if reset function is supported */ if (FunctionTable->ResetStream)