[PATCH v3] dsound: Notify DSBPN_OFFSETSTOP earlier.

Andrew Eikum aeikum at codeweavers.com
Mon Jun 7 10:03:02 CDT 2021


Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>

---

I wrote some tests for this which are not worth merging:

    https://www.winehq.org/pipermail/wine-devel/2021-June/188312.html

On Sat, Jun 05, 2021 at 12:28:47PM +0900, Hiroki Awata wrote:
> Some games may not receive the DSBPN_OFFSETSTOP event and get stuck if CloseHandle is called immediately after IDirectSoundBuffer::Stop.
> To solve this problem, IDirectSoundBuffer::Stop will immediately notify the DSBPN_OFFSETSTOP event.
> 
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41292
> Signed-off-by: Hiroki Awata <castaneai at by.black>
> ---
> v3: removed dead code
> ---
>  dlls/dsound/buffer.c | 7 ++-----
>  dlls/dsound/mixer.c  | 6 +-----
>  2 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
> index fafa6fc6015..dc3b54906ce 100644
> --- a/dlls/dsound/buffer.c
> +++ b/dlls/dsound/buffer.c
> @@ -296,8 +296,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Play(IDirectSoundBuffer8 *iface, DW
>  	if (This->state == STATE_STOPPED) {
>  		This->leadin = TRUE;
>  		This->state = STATE_STARTING;
> -	} else if (This->state == STATE_STOPPING)
> -		This->state = STATE_PLAYING;
> +	}
>  
>  	for (i = 0; i < This->num_filters; i++) {
>  		IMediaObject_Discontinuity(This->filters[i].obj, 0);
> @@ -317,9 +316,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Stop(IDirectSoundBuffer8 *iface)
>  
>  	AcquireSRWLockExclusive(&This->lock);
>  
> -	if (This->state == STATE_PLAYING)
> -		This->state = STATE_STOPPING;
> -	else if (This->state == STATE_STARTING)
> +	if (This->state == STATE_PLAYING || This->state == STATE_STARTING)
>  	{
>  		This->state = STATE_STOPPED;
>  		DSOUND_CheckEvent(This, 0, 0);
> diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c
> index a6402b09eff..124d1e4fba1 100644
> --- a/dlls/dsound/mixer.c
> +++ b/dlls/dsound/mixer.c
> @@ -593,11 +593,7 @@ static void DSOUND_MixToPrimary(const DirectSoundDevice *device, float *mix_buff
>  		if (dsb->buflen && dsb->state) {
>  			TRACE("Checking %p, frames=%d\n", dsb, frames);
>  			AcquireSRWLockShared(&dsb->lock);
> -			/* if buffer is stopping it is stopped now */
> -			if (dsb->state == STATE_STOPPING) {
> -				dsb->state = STATE_STOPPED;
> -				DSOUND_CheckEvent(dsb, 0, 0);
> -			} else if (dsb->state != STATE_STOPPED) {
> +			if (dsb->state != STATE_STOPPED) {
>  
>  				/* if the buffer was starting, it must be playing now */
>  				if (dsb->state == STATE_STARTING)
> -- 
> 2.27.0
> 
> 



More information about the wine-devel mailing list