[PATCH 1/2] winmm: Trivial code simplifications and fixes.

Joerg-Cyril.Hoehle at t-systems.com Joerg-Cyril.Hoehle at t-systems.com
Fri Jul 29 02:46:42 CDT 2011


these fixes all trivial errors I mentioned recently but one, plus a few ones I discovered since then.

  - Document that g_device_handles MUST ONLY be modified within the player
    thread (otherwise MsgWait operates on undefined data),
    demonstrating that (part of) wave*Open must be handled there.

- if(wait == 1 - WAIT_OBJECT_0) should be WAIT_OBJECT_0 + 1 (same by chance)
  Same with if(wait == g_devhandle_count - WAIT_OBJECT_0)
Note that my patch still assumes WAIT_OBJECT_0==0, otherwise an additional check
&& wait >= WAIT_OBJECT_0 would be needed, which gcc would complain about.

- The caller of WINMM_BeginPlaying supplying the device argument will
  have locked it already, thus Enter/LeaveCS therein is superfluous.
  Generally, functions that take a WINMM_Device* parameter should
  receive it locked by the caller.

- Memory leak in WINMM_PrepareHeader in case of acmStreamPrepareHeader error

- WOD_Open/WID_Open:cb_info is unused, memcpy(&cb_info,...) useless.
  Same for WOD/WID_Close

- WINMM_OpenDevice passed_fmt HeapAlloc is unchecked
  Prefer a stack-allocated WAVEFORMATEX and set passed_fmt = &stack_var

- Prefer C structure copy over memcpy

New ones:

- boolean logic error involving negation

- WINMM_CheckCallback had been lost in wave*Open.

- WINMM_StartDevicesThread does not return a hr and was redundant.

I've not fixed the leaking device->event because I didn't
figure out the exact life cycle of the device objects
(when is it reusable, which slots could be reused?).

	Jörg Höhle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-winmm-Trivial-code-simplifications-and-fixes.patch
Type: application/octet-stream
Size: 13102 bytes
Desc: 0001-winmm-Trivial-code-simplifications-and-fixes.patch
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20110729/b91cf5d4/attachment-0001.obj>

More information about the wine-patches mailing list