[PATCH 04/25] mciseq: Create player thread in the synchronous case too.

Joerg-Cyril.Hoehle at t-systems.com Joerg-Cyril.Hoehle at t-systems.com
Thu Oct 4 05:34:07 CDT 2012


Hi,

+	WaitForSingleObject(wmm->hThread, INFINITE);
That is one key feature: be able to wait for a player to terminate.

Since w2k, the sequence
play m from 0
status m mode -- optional
play m wait
plays without audible interruption. The second call to play appears to
wait for the initial player to finish.  (Playing without FROM parameter
means to play from the current position).

Waiting for the thread to finish guarantees that at CLOSE time, we can
reliably shut down and free resources.  That cannot be achieved with a
final SetEvent from within the player thread: the driver could then
exit while the player thread (is waiting to or) performs its last instructions.

There's one weakness: Suppose 2 threads are waiting for the player to
finish and a third one starts a new player, freeing the old thread
handle after itself using WaitForSingleObject(wmm->hThread, ...).
What happens to the other WaitForSingleObject(wmm->hThread, ...)?

In theory, all waiters would become unblocked and scheduled for
execution at the time the thread terminates.  Does that time pass by
unnoticed by some waiters such that they reach the time of
CloseHandle(wmm->hThread)?  MSDN specifically says that the effect of
waiting on a thread handle that gets freed while waiting is undefined.

Well, that's somewhat theoretical, I've yet to see an app try and play
several songs concurrently.  The typical scenario play + stop is safe
from such considerations, as well as play + play from the same thread.

+    if (1) {
This looks superfluous, however the patch series has been written
(and constantly re-edited and rebased) to mostly prevent subsequent
patches from changing unrelated previous work such as indentation.
This particular line will be updated in patch 10/25.

Regards,
	Jörg Höhle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-mciseq-Create-player-thread-in-the-synchronous-case.patch
Type: application/octet-stream
Size: 9272 bytes
Desc: 0004-mciseq-Create-player-thread-in-the-synchronous-case.patch
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20121004/8bf45dcf/attachment-0001.obj>


More information about the wine-patches mailing list