[PATCH 2/2] dsound: Wait on thread handle instead of dedicated event in DirectSoundDevice_Release.
Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> --- dlls/dsound/dsound.c | 4 +--- dlls/dsound/dsound_private.h | 1 - dlls/dsound/mixer.c | 1 - 3 files changed, 1 insertion(+), 5 deletions(-)
Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com> On Thu, Nov 22, 2018 at 08:24:08PM +0100, Jacek Caban wrote:
Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> --- dlls/dsound/dsound.c | 4 +--- dlls/dsound/dsound_private.h | 1 - dlls/dsound/mixer.c | 1 - 3 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c index 12f1e286b3..71ede7d870 100644 --- a/dlls/dsound/dsound.c +++ b/dlls/dsound/dsound.c @@ -203,9 +203,8 @@ static ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
SetEvent(device->sleepev); if (device->thread) { - WaitForSingleObject(device->thread_finished, INFINITE); + WaitForSingleObject(device->thread, INFINITE); CloseHandle(device->thread); - CloseHandle(device->thread_finished); }
EnterCriticalSection(&DSOUND_renderers_lock); @@ -383,7 +382,6 @@ static HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGU
ZeroMemory(&device->volpan, sizeof(device->volpan));
- device->thread_finished = CreateEventW(0, 0, 0, 0); device->thread = CreateThread(0, 0, DSOUND_mixthread, device, 0, 0); SetThreadPriority(device->thread, THREAD_PRIORITY_TIME_CRITICAL);
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index c045b38f4a..45a100eee7 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -106,7 +106,6 @@ struct DirectSoundDevice IAudioRenderClient *render;
HANDLE sleepev, thread; - HANDLE thread_finished; struct list entry; };
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c index 9b3e730961..32bde3800e 100644 --- a/dlls/dsound/mixer.c +++ b/dlls/dsound/mixer.c @@ -765,6 +765,5 @@ DWORD CALLBACK DSOUND_mixthread(void *p) DSOUND_PerformMix(dev); RtlReleaseResource(&(dev->buffer_list_lock)); } - SetEvent(dev->thread_finished); return 0; }
Just curious, do these patches fix some specific bug, or just cleanup you noticed? Andrew On Thu, Nov 22, 2018 at 08:24:08PM +0100, Jacek Caban wrote:
Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> --- dlls/dsound/dsound.c | 4 +--- dlls/dsound/dsound_private.h | 1 - dlls/dsound/mixer.c | 1 - 3 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c index 12f1e286b3..71ede7d870 100644 --- a/dlls/dsound/dsound.c +++ b/dlls/dsound/dsound.c @@ -203,9 +203,8 @@ static ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
SetEvent(device->sleepev); if (device->thread) { - WaitForSingleObject(device->thread_finished, INFINITE); + WaitForSingleObject(device->thread, INFINITE); CloseHandle(device->thread); - CloseHandle(device->thread_finished); }
EnterCriticalSection(&DSOUND_renderers_lock); @@ -383,7 +382,6 @@ static HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGU
ZeroMemory(&device->volpan, sizeof(device->volpan));
- device->thread_finished = CreateEventW(0, 0, 0, 0); device->thread = CreateThread(0, 0, DSOUND_mixthread, device, 0, 0); SetThreadPriority(device->thread, THREAD_PRIORITY_TIME_CRITICAL);
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h index c045b38f4a..45a100eee7 100644 --- a/dlls/dsound/dsound_private.h +++ b/dlls/dsound/dsound_private.h @@ -106,7 +106,6 @@ struct DirectSoundDevice IAudioRenderClient *render;
HANDLE sleepev, thread; - HANDLE thread_finished; struct list entry; };
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c index 9b3e730961..32bde3800e 100644 --- a/dlls/dsound/mixer.c +++ b/dlls/dsound/mixer.c @@ -765,6 +765,5 @@ DWORD CALLBACK DSOUND_mixthread(void *p) DSOUND_PerformMix(dev); RtlReleaseResource(&(dev->buffer_list_lock)); } - SetEvent(dev->thread_finished); return 0; }
Hi Andrew, On 11/26/18 3:59 PM, Andrew Eikum wrote:
Just curious, do these patches fix some specific bug, or just cleanup you noticed?
Those patches are things I noticed when looking for possible explanations of why Sleep in bug 41271 helps. Those patches are not enough to fix the bug, so I didn't mark them with Wine-Bug header. Patch 2 is just a clean up, the first patch fixes a real race. Jacek
participants (2)
-
Andrew Eikum -
Jacek Caban