diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index 0d1987be28bec100a8c2e576b9dd21d09e395d79..ea6c21cc6aa45dfadd5fc52db1c324e15fa995cd 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -207,11 +207,11 @@ callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time)
 
 //    dump_videohdr(s, vdhdr);
 
-    if(shall_we_drop(s))
-        return;
-
     WaitForSingleObject(ctx->mutex, INFINITE);
 
+    if(shall_we_drop(s))
+        goto fail;
+
     pktl_next = av_mallocz(sizeof(AVPacketList));
     if(!pktl_next)
         goto fail;