Signed-off-by: Shawn M. Chapla schapla@codeweavers.com --- dlls/dsound/tests/capture.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/dlls/dsound/tests/capture.c b/dlls/dsound/tests/capture.c index e326fe8d839..fb445794bd1 100644 --- a/dlls/dsound/tests/capture.c +++ b/dlls/dsound/tests/capture.c @@ -30,7 +30,8 @@
#include "dsound_test.h"
-#define NOTIFICATIONS 5 +#define TIMESTAMP_CAPTURE_NTFCTNS 5 +#define TOTAL_CAPTURE_NTFCTNS (TIMESTAMP_CAPTURE_NTFCTNS + 1)
static const char * get_format_str(WORD format) { @@ -264,8 +265,8 @@ typedef struct {
LPDIRECTSOUNDCAPTUREBUFFER dscbo; LPWAVEFORMATEX wfx; - DSBPOSITIONNOTIFY posnotify[NOTIFICATIONS]; - HANDLE event[NOTIFICATIONS]; + DSBPOSITIONNOTIFY posnotify[TOTAL_CAPTURE_NTFCTNS]; + HANDLE event[TOTAL_CAPTURE_NTFCTNS]; LPDIRECTSOUNDNOTIFY notify;
DWORD buffer_size; @@ -369,21 +370,24 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco, state.dscbo=dscbo; state.wfx=&wfx; state.buffer_size = dscbcaps.dwBufferBytes; - for (i = 0; i < NOTIFICATIONS; i++) + for (i = 0; i < TOTAL_CAPTURE_NTFCTNS; i++) state.event[i] = CreateEventW(NULL, FALSE, FALSE, NULL); - state.size = dscbcaps.dwBufferBytes / NOTIFICATIONS; + state.size = dscbcaps.dwBufferBytes / TIMESTAMP_CAPTURE_NTFCTNS;
rc=IDirectSoundCaptureBuffer_QueryInterface(dscbo,&IID_IDirectSoundNotify, (void **)&(state.notify)); ok((rc==DS_OK)&&(state.notify!=NULL), "IDirectSoundCaptureBuffer_QueryInterface() failed: %08x\n", rc);
- for (i = 0; i < NOTIFICATIONS; i++) { + for (i = 0; i < TIMESTAMP_CAPTURE_NTFCTNS; i++) { state.posnotify[i].dwOffset = (i * state.size) + state.size - 1; state.posnotify[i].hEventNotify = state.event[i]; }
- rc=IDirectSoundNotify_SetNotificationPositions(state.notify,NOTIFICATIONS, + state.posnotify[i].dwOffset = DSBPN_OFFSETSTOP; + state.posnotify[i].hEventNotify = state.event[i]; + + rc = IDirectSoundNotify_SetNotificationPositions(state.notify, TOTAL_CAPTURE_NTFCTNS, state.posnotify); ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions() failed: %08x\n", rc);
@@ -403,15 +407,15 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco, "GetStatus: bad status: %x\n",status);
if (record) { - /* wait for the notifications */ - for (i = 0; i < (NOTIFICATIONS * 2); i++) { - rc=WaitForMultipleObjects(NOTIFICATIONS,state.event,FALSE,3000); - ok(rc==(WAIT_OBJECT_0+(i%NOTIFICATIONS)), + /* wait for timestamp notifications */ + for (i = 0; i < (TIMESTAMP_CAPTURE_NTFCTNS * 2); i++) { + rc = WaitForMultipleObjects(TOTAL_CAPTURE_NTFCTNS, state.event, FALSE, 3000); + ok(rc == (WAIT_OBJECT_0 + (i % TIMESTAMP_CAPTURE_NTFCTNS)), "WaitForMultipleObjects failed: 0x%x\n",rc); - if (rc!=(WAIT_OBJECT_0+(i%NOTIFICATIONS))) { + if (rc != (WAIT_OBJECT_0 + (i % TIMESTAMP_CAPTURE_NTFCTNS))) { ok((rc==WAIT_TIMEOUT)||(rc==WAIT_FAILED), "Wrong notification: should be %d, got %d\n", - i%NOTIFICATIONS,rc-WAIT_OBJECT_0); + i % TIMESTAMP_CAPTURE_NTFCTNS, rc - WAIT_OBJECT_0); } if (!capture_buffer_service(&state)) break; @@ -421,6 +425,10 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco, rc=IDirectSoundCaptureBuffer_Stop(dscbo); ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
+ /* wait for stop notification */ + rc = WaitForSingleObject(state.event[TIMESTAMP_CAPTURE_NTFCTNS], 3000); + todo_wine ok(rc == WAIT_OBJECT_0, "WaitForSingleObject failed: 0x%x\n", rc); + rc=IDirectSoundCaptureBuffer_Stop(dscbo); ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc); }
Signed-off-by: Shawn M. Chapla schapla@codeweavers.com --- dlls/dsound/capture.c | 7 ++++++- dlls/dsound/tests/capture.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c index 10690f7df0d..02579ca064c 100644 --- a/dlls/dsound/capture.c +++ b/dlls/dsound/capture.c @@ -527,6 +527,8 @@ out: return DS_OK; }
+static void capture_CheckNotify(IDirectSoundCaptureBufferImpl *This, DWORD from, DWORD len); + static HRESULT WINAPI IDirectSoundCaptureBufferImpl_Stop(IDirectSoundCaptureBuffer8 *iface) { IDirectSoundCaptureBufferImpl *This = impl_from_IDirectSoundCaptureBuffer8(iface); @@ -544,8 +546,10 @@ static HRESULT WINAPI IDirectSoundCaptureBufferImpl_Stop(IDirectSoundCaptureBuff TRACE("old This->device->state=%s\n",captureStateString[This->device->state]); if (This->device->state == STATE_CAPTURING) This->device->state = STATE_STOPPING; - else if (This->device->state == STATE_STARTING) + else if (This->device->state == STATE_STARTING) { This->device->state = STATE_STOPPED; + capture_CheckNotify(This->device->capture_buffer, 0, 0); + } TRACE("new This->device->state=%s\n",captureStateString[This->device->state]);
if(This->device->client){ @@ -880,6 +884,7 @@ static HRESULT DSOUND_capture_data(DirectSoundCaptureDevice *device)
if(device->state == STATE_STOPPING){ device->state = STATE_STOPPED; + capture_CheckNotify(device->capture_buffer, 0, 0); return S_FALSE; }
diff --git a/dlls/dsound/tests/capture.c b/dlls/dsound/tests/capture.c index fb445794bd1..aa124ebd70d 100644 --- a/dlls/dsound/tests/capture.c +++ b/dlls/dsound/tests/capture.c @@ -427,7 +427,7 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco,
/* wait for stop notification */ rc = WaitForSingleObject(state.event[TIMESTAMP_CAPTURE_NTFCTNS], 3000); - todo_wine ok(rc == WAIT_OBJECT_0, "WaitForSingleObject failed: 0x%x\n", rc); + ok(rc == WAIT_OBJECT_0, "WaitForSingleObject failed: 0x%x\n", rc);
rc=IDirectSoundCaptureBuffer_Stop(dscbo); ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
On Mon, Jan 11, 2021 at 08:41:23PM -0500, Shawn M. Chapla wrote:
diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c index 10690f7df0d..02579ca064c 100644 --- a/dlls/dsound/capture.c +++ b/dlls/dsound/capture.c @@ -544,8 +546,10 @@ static HRESULT WINAPI IDirectSoundCaptureBufferImpl_Stop(IDirectSoundCaptureBuff TRACE("old This->device->state=%s\n",captureStateString[This->device->state]); if (This->device->state == STATE_CAPTURING) This->device->state = STATE_STOPPING;
- else if (This->device->state == STATE_STARTING)
else if (This->device->state == STATE_STARTING) { This->device->state = STATE_STOPPED;
capture_CheckNotify(This->device->capture_buffer, 0, 0);
} TRACE("new This->device->state=%s\n",captureStateString[This->device->state]);
if(This->device->client){
Introduces an indent issue here, too.
Andrew
On Mon, Jan 11, 2021 at 08:41:22PM -0500, Shawn M. Chapla wrote:
diff --git a/dlls/dsound/tests/capture.c b/dlls/dsound/tests/capture.c index e326fe8d839..fb445794bd1 100644 --- a/dlls/dsound/tests/capture.c +++ b/dlls/dsound/tests/capture.c @@ -30,7 +30,8 @@
#include "dsound_test.h"
-#define NOTIFICATIONS 5 +#define TIMESTAMP_CAPTURE_NTFCTNS 5 +#define TOTAL_CAPTURE_NTFCTNS (TIMESTAMP_CAPTURE_NTFCTNS + 1)
I'd s/CAPTURE_NTFCTNS/NOTIFICATIONS/g, but I won't argue if you prefer this.
@@ -403,15 +407,15 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco, "GetStatus: bad status: %x\n",status);
if (record) {
- /* wait for the notifications */
- for (i = 0; i < (NOTIFICATIONS * 2); i++) {
rc=WaitForMultipleObjects(NOTIFICATIONS,state.event,FALSE,3000);
ok(rc==(WAIT_OBJECT_0+(i%NOTIFICATIONS)),
/* wait for timestamp notifications */
for (i = 0; i < (TIMESTAMP_CAPTURE_NTFCTNS * 2); i++) {
rc = WaitForMultipleObjects(TOTAL_CAPTURE_NTFCTNS, state.event, FALSE, 3000);
ok(rc == (WAIT_OBJECT_0 + (i % TIMESTAMP_CAPTURE_NTFCTNS)), "WaitForMultipleObjects failed: 0x%x\n",rc);
if (rc!=(WAIT_OBJECT_0+(i%NOTIFICATIONS))) {
ok((rc==WAIT_TIMEOUT)||(rc==WAIT_FAILED), "Wrong notification: should be %d, got %d\n",if (rc != (WAIT_OBJECT_0 + (i % TIMESTAMP_CAPTURE_NTFCTNS))) {
i%NOTIFICATIONS,rc-WAIT_OBJECT_0);
break;i % TIMESTAMP_CAPTURE_NTFCTNS, rc - WAIT_OBJECT_0); } if (!capture_buffer_service(&state))
I know the indent style sucks, but it is (mostly) consistent: it uses four-space indentation, with each group of eight spaces replaced with a tab. Please either match that style (my preference), or just convert this whole paragraph to use spaces.
@@ -421,6 +425,10 @@ static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco, rc=IDirectSoundCaptureBuffer_Stop(dscbo); ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
- /* wait for stop notification */
- rc = WaitForSingleObject(state.event[TIMESTAMP_CAPTURE_NTFCTNS], 3000);
- todo_wine ok(rc == WAIT_OBJECT_0, "WaitForSingleObject failed: 0x%x\n", rc);
- rc=IDirectSoundCaptureBuffer_Stop(dscbo); ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
}
I think you should merge the two patches into one. It will avoid a very long delay due to this 3-second timeout for every test loop, and there isn't enough new code to need splitting. The long delay caused test timeouts in the testbot: https://testbot.winehq.org/JobDetails.pl?Key=83923#k401
Andrew