[MMEBUDDY]

- Store the internal state if an audio stream has been stopped
- Construct a thread when WODM_RESTART is received. This thread then triggers performs a callback to the wave thread, which finally restarts playback
- Only start the wave thread when playback is active (not paused by WODM_PAUSE)
- Fixes playback in Winamp 5.601 despite graphical issues
- Tested in Vbox 4.0 + 512MB RAM + Winamp 5.601

svn path=/trunk/; revision=50897
This commit is contained in:
Johannes Anderwald 2011-02-25 14:10:31 +00:00
parent e1d7a14438
commit c50e27e4bf
4 changed files with 63 additions and 2 deletions

View file

@ -366,6 +366,7 @@ typedef struct _SOUND_DEVICE_INSTANCE
HANDLE hStopEvent;
HANDLE hResetEvent;
BOOL ResetInProgress;
BOOL bPaused;
} SOUND_DEVICE_INSTANCE, *PSOUND_DEVICE_INSTANCE;
/* This lives in WAVEHDR.reserved */
@ -702,6 +703,9 @@ MMRESULT
StopStreaming(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
VOID
InitiateSoundStreaming(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance);
/*
kernel.c

View file

@ -29,6 +29,7 @@ MmeSetState(
PMMFUNCTION_TABLE FunctionTable;
PSOUND_DEVICE SoundDevice;
PSOUND_DEVICE_INSTANCE SoundDeviceInstance;
BOOL OldState;
VALIDATE_MMSYS_PARAMETER( PrivateHandle );
SoundDeviceInstance = (PSOUND_DEVICE_INSTANCE) PrivateHandle;
@ -53,6 +54,20 @@ MmeSetState(
/* Try change state */
Result = FunctionTable->SetState(SoundDeviceInstance, bStart);
if ( MMSUCCESS(Result) )
{
/* Get old audio stream state */
OldState = SoundDeviceInstance->bPaused;
/* Store audio stream pause state */
SoundDeviceInstance->bPaused = !bStart;
if (SoundDeviceInstance->bPaused == FALSE && OldState == TRUE)
{
InitiateSoundStreaming(SoundDeviceInstance);
}
}
return Result;
}

View file

@ -242,7 +242,11 @@ EnqueueWaveHeader(
SoundDeviceInstance->HeadWaveHeader = WaveHeader;
SoundDeviceInstance->TailWaveHeader = WaveHeader;
DoWaveStreaming(SoundDeviceInstance);
/* Only do wave streaming when the stream has not been paused */
if (SoundDeviceInstance->bPaused == FALSE)
{
DoWaveStreaming(SoundDeviceInstance);
}
}
else
{
@ -258,7 +262,11 @@ EnqueueWaveHeader(
SoundDeviceInstance->TailWaveHeader = WaveHeader;
DUMP_WAVEHDR_QUEUE(SoundDeviceInstance);
DoWaveStreaming(SoundDeviceInstance);
/* Only do wave streaming when the stream has not been paused */
if ( SoundDeviceInstance->bPaused == FALSE )
{
DoWaveStreaming(SoundDeviceInstance);
}
}
}

View file

@ -361,3 +361,37 @@ StopStreaming(
StopStreamingInSoundThread,
NULL);
}
MMRESULT
PerformWaveStreaming(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
IN PVOID Parameter)
{
DoWaveStreaming(SoundDeviceInstance);
return MMSYSERR_NOERROR;
}
DWORD
WINAPI
WaveActivateSoundStreaming(
IN PVOID lpParameter)
{
CallSoundThread((PSOUND_DEVICE_INSTANCE)lpParameter,
PerformWaveStreaming,
NULL);
ExitThread(0);
}
VOID
InitiateSoundStreaming(
IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
{
HANDLE hThread;
hThread = CreateThread(NULL, 0, WaveActivateSoundStreaming, (PVOID)SoundDeviceInstance, 0, NULL);
if (hThread != NULL)
CloseHandle(hThread);
}