X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=lib%2Fdrivers%2Fsound%2Fmmebuddy%2Fwave%2Fstreaming.c;h=847adebc137a08f12cda1124127782eca66d305e;hp=2d4608949fac376eb064edfce25e38259c8d8f30;hb=a0f720954dd99b87da0b00811858a224c23669fd;hpb=7ae8c563ccbcef365bcf022638cb82b0b5874f81 diff --git a/lib/drivers/sound/mmebuddy/wave/streaming.c b/lib/drivers/sound/mmebuddy/wave/streaming.c index 2d4608949fa..847adebc137 100644 --- a/lib/drivers/sound/mmebuddy/wave/streaming.c +++ b/lib/drivers/sound/mmebuddy/wave/streaming.c @@ -277,8 +277,62 @@ StopStreamingInSoundThread( IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN PVOID Parameter) { - /* TODO */ - return MMSYSERR_NOTSUPPORTED; + MMDEVICE_TYPE DeviceType; + PMMFUNCTION_TABLE FunctionTable; + MMRESULT Result; + PSOUND_DEVICE SoundDevice; + + /* set state reset in progress */ + SoundDeviceInstance->ResetInProgress = TRUE; + + /* Get sound device */ + Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice); + SND_ASSERT( Result == MMSYSERR_NOERROR ); + + /* Obtain the function table */ + Result = GetSoundDeviceFunctionTable(SoundDevice, &FunctionTable); + SND_ASSERT( Result == MMSYSERR_NOERROR ); + + /* Obtain device instance type */ + Result = GetSoundDeviceType(SoundDevice, &DeviceType); + SND_ASSERT( Result == MMSYSERR_NOERROR ); + + /* Check if reset function is supported */ + if (FunctionTable->ResetStream) + { + /* cancel all current audio buffers */ + FunctionTable->ResetStream(SoundDeviceInstance, DeviceType, TRUE); + } + + /* complete all current headers */ + while( SoundDeviceInstance->HeadWaveHeader ) + { + SND_TRACE(L"StopStreamingInSoundThread: Completing Header %p\n", SoundDeviceInstance->HeadWaveHeader); + CompleteWaveHeader( SoundDeviceInstance, SoundDeviceInstance->HeadWaveHeader ); + } + + /* 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) + { + /* finish the reset */ + FunctionTable->ResetStream(SoundDeviceInstance, DeviceType, FALSE); + } + + /* clear state reset in progress */ + SoundDeviceInstance->ResetInProgress = FALSE; + + + return MMSYSERR_NOERROR; } MMRESULT