diff options
author | James Ross-Gowan <rossymiles@gmail.com> | 2017-01-29 23:59:24 +1100 |
---|---|---|
committer | James Ross-Gowan <rossymiles@gmail.com> | 2017-01-30 00:22:30 +1100 |
commit | 9692814502223574b575931d32ddd458b9476bb6 (patch) | |
tree | 8a86cb132d6b03e46a28fa18218be1da20607ea6 /audio/out/ao_wasapi.c | |
parent | a6d29494ca6e45b66570deda99c2eef79f72d16c (diff) | |
download | mpv-9692814502223574b575931d32ddd458b9476bb6.tar.bz2 mpv-9692814502223574b575931d32ddd458b9476bb6.tar.xz |
win32: add COM-specific SAFE_RELEASE to windows_utils.h
See: https://msdn.microsoft.com/en-us/library/windows/desktop/dd743946.aspx
Microsoft example code often uses a SAFE_RELEASE macro like the one in
the above link. This makes it easier to avoid errors when releasing COM
interfaces. It also reduces noise in COM-heavy code.
ao_wasapi.h also had a macro called SAFE_RELEASE, though unlike the
version above, its SAFE_RELEASE macro accepted a second parameter which
allowed it to destroy arbitrary objects other than just COM interfaces.
This renames ao_wasapi's SAFE_RELEASE to SAFE_DESTROY, which should more
accurately reflect what it does and prevent confusion with the Microsoft
version.
Diffstat (limited to 'audio/out/ao_wasapi.c')
-rw-r--r-- | audio/out/ao_wasapi.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c index b2e035d3dc..3a4c341387 100644 --- a/audio/out/ao_wasapi.c +++ b/audio/out/ao_wasapi.c @@ -255,9 +255,9 @@ static void uninit(struct ao *ao) "while waiting for audio thread to terminate\n"); } - SAFE_RELEASE(state->hInitDone, CloseHandle(state->hInitDone)); - SAFE_RELEASE(state->hWake, CloseHandle(state->hWake)); - SAFE_RELEASE(state->hAudioThread,CloseHandle(state->hAudioThread)); + SAFE_DESTROY(state->hInitDone, CloseHandle(state->hInitDone)); + SAFE_DESTROY(state->hWake, CloseHandle(state->hWake)); + SAFE_DESTROY(state->hAudioThread,CloseHandle(state->hAudioThread)); wasapi_change_uninit(ao); @@ -305,7 +305,7 @@ static int init(struct ao *ao) } WaitForSingleObject(state->hInitDone, INFINITE); // wait on init complete - SAFE_RELEASE(state->hInitDone,CloseHandle(state->hInitDone)); + SAFE_DESTROY(state->hInitDone,CloseHandle(state->hInitDone)); if (FAILED(state->init_ret)) { if (!ao->probing) MP_FATAL(ao, "Received failure from audio thread\n"); @@ -418,10 +418,10 @@ static int thread_control(struct ao *ao, enum aocontrol cmd, void *arg) do { IAudioSessionControl_SetDisplayName(state->pSessionControl, title, NULL); - SAFE_RELEASE(tmp, CoTaskMemFree(tmp)); + SAFE_DESTROY(tmp, CoTaskMemFree(tmp)); IAudioSessionControl_GetDisplayName(state->pSessionControl, &tmp); } while (lstrcmpW(title, tmp)); - SAFE_RELEASE(tmp, CoTaskMemFree(tmp)); + SAFE_DESTROY(tmp, CoTaskMemFree(tmp)); talloc_free(title); return CONTROL_OK; } |