From: Andrew Eikum Subject: [PATCH] dsound: Don't send notify events before played range Message-Id: <20141219151046.GZ828@foghorn.codeweavers.com> Date: Fri, 19 Dec 2014 09:10:46 -0600 --- Turns out the event order wasn't as well-ordered as I thought. This test update is less strict and should fix the test failures. Interesting to note the failures only occurred on Win7. dlls/dsound/mixer.c | 18 +++++++++++------- dlls/dsound/tests/dsound.c | 5 +---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c index 8d6b379..0fae20e 100644 --- a/dlls/dsound/mixer.c +++ b/dlls/dsound/mixer.c @@ -223,16 +223,20 @@ void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len } } - TRACE("Not stopped: first notify: %u (%u), range: [%u,%u)\n", first, - dsb->notifies[check].dwOffset, playpos, (playpos + len) % dsb->buflen); + TRACE("Not stopped: first notify: %u (%u), left notify: %u (%u), range: [%u,%u)\n", + first, dsb->notifies[first].dwOffset, + left, dsb->notifies[left].dwOffset, + playpos, (playpos + len) % dsb->buflen); /* send notifications in range */ - for(check = left; check < dsb->nrofnotifies; ++check){ - if(dsb->notifies[check].dwOffset >= playpos + len) - break; + if(dsb->notifies[left].dwOffset >= playpos){ + for(check = left; check < dsb->nrofnotifies; ++check){ + if(dsb->notifies[check].dwOffset >= playpos + len) + break; - TRACE("Signalling %p (%u)\n", dsb->notifies[check].hEventNotify, dsb->notifies[check].dwOffset); - SetEvent(dsb->notifies[check].hEventNotify); + TRACE("Signalling %p (%u)\n", dsb->notifies[check].hEventNotify, dsb->notifies[check].dwOffset); + SetEvent(dsb->notifies[check].hEventNotify); + } } if(playpos + len > dsb->buflen){ diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c index 1df7ce4..e5a9110 100644 --- a/dlls/dsound/tests/dsound.c +++ b/dlls/dsound/tests/dsound.c @@ -1532,10 +1532,9 @@ static void test_notifications(LPGUID lpGuid) rc = IDirectSoundBuffer_QueryInterface(buf, &IID_IDirectSoundNotify, (void**)&buf_notif); ok(rc == DS_OK, "QueryInterface(IID_IDirectSoundNotify): %08x\n", rc); - /* create notifications at each end of the buffer */ notifies[0].dwOffset = 0; handles[0] = notifies[0].hEventNotify = CreateEventW(NULL, FALSE, FALSE, NULL); - notifies[1].dwOffset = bufdesc.dwBufferBytes - 1; + notifies[1].dwOffset = bufdesc.dwBufferBytes / 2; handles[1] = notifies[1].hEventNotify = CreateEventW(NULL, FALSE, FALSE, NULL); rc = IDirectSoundNotify_SetNotificationPositions(buf_notif, 2, notifies); @@ -1550,8 +1549,6 @@ static void test_notifications(LPGUID lpGuid) for(cycles = 0; cycles < 6 /* 1.5s */; ++cycles){ DWORD wait; - /* since the notifications are on opposite ends of the entire buffer, - * they should arrive well-ordered in an alternating sequence. */ wait = WaitForMultipleObjects(2, handles, FALSE, 1000); ok(wait <= WAIT_OBJECT_0 + 1 && wait - WAIT_OBJECT_0 == expect, "Got unexpected notification order or timeout: %u\n", wait); -- 2.2.0