diff options
Diffstat (limited to 'audio/out')
-rw-r--r-- | audio/out/ao_wasapi.c | 4 | ||||
-rwxr-xr-x | audio/out/ao_wasapi.h | 11 | ||||
-rwxr-xr-x | audio/out/ao_wasapi_utils.c | 41 | ||||
-rwxr-xr-x | audio/out/ao_wasapi_utils.h | 1 |
4 files changed, 6 insertions, 51 deletions
diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c index 83e7f469df..2edbdf5ef0 100644 --- a/audio/out/ao_wasapi.c +++ b/audio/out/ao_wasapi.c @@ -237,8 +237,6 @@ static void uninit(struct ao *ao) MP_ERR(ao, "Audio loop thread refuses to abort\n"); return; } - if (state->VistaBlob.hAvrt) - FreeLibrary(state->VistaBlob.hAvrt); SAFE_RELEASE(state->hInitDone, CloseHandle(state->hInitDone)); SAFE_RELEASE(state->hWake, CloseHandle(state->hWake)); @@ -255,8 +253,6 @@ static int init(struct ao *ao) struct wasapi_state *state = ao->priv; state->log = ao->log; - if(!wasapi_fill_VistaBlob(state)) - MP_WARN(ao, "Error loading thread priority functions\n"); state->hInitDone = CreateEventW(NULL, FALSE, FALSE, NULL); state->hWake = CreateEventW(NULL, FALSE, FALSE, NULL); diff --git a/audio/out/ao_wasapi.h b/audio/out/ao_wasapi.h index 24b9b862ed..2fbd2d5a9c 100755 --- a/audio/out/ao_wasapi.h +++ b/audio/out/ao_wasapi.h @@ -79,7 +79,6 @@ typedef struct wasapi_state { /* for setting the audio thread priority */ HANDLE hTask; /* AV thread */ - DWORD taskIndex; /* AV task ID */ /* WASAPI proxy handles, for Single-Threaded Apartment communication. One is needed for each audio thread object that's accessed from the main thread. */ @@ -110,16 +109,6 @@ typedef struct wasapi_state { size_t buffer_block_size; /* Size of each block in bytes */ UINT32 bufferFrameCount; /* wasapi buffer block size, number of frames, frame size at format.nBlockAlign */ - /* Don't use these functions directly in case - they are unimplemented for some reason. - (XP shouldn't be an issue since it doesn't support wasapi, maybe wine?) - Blob is owned by the main thread */ - struct { - HMODULE hAvrt; - HANDLE (WINAPI *pAvSetMmThreadCharacteristicsW)(LPCWSTR, LPDWORD); - WINBOOL (WINAPI *pAvRevertMmThreadCharacteristics)(HANDLE); - } VistaBlob; - change_notify change; } wasapi_state; diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 108db17d32..be81f0e730 100755 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -185,36 +185,6 @@ char *mp_HRESULT_to_str_buf(char *buf, size_t buf_size, HRESULT hr) wasapi_explain_err(hr), (uint32_t) hr); return buf; } - -bool wasapi_fill_VistaBlob(wasapi_state *state) -{ - if (!state) - goto exit_label; - state->VistaBlob.hAvrt = LoadLibraryW(L"avrt.dll"); - if (!state->VistaBlob.hAvrt) - goto exit_label; - - state->VistaBlob.pAvSetMmThreadCharacteristicsW = - (HANDLE (WINAPI *)(LPCWSTR, LPDWORD)) - GetProcAddress(state->VistaBlob.hAvrt, "AvSetMmThreadCharacteristicsW"); - if (!state->VistaBlob.pAvSetMmThreadCharacteristicsW) - goto exit_label; - - state->VistaBlob.pAvRevertMmThreadCharacteristics = - (WINBOOL (WINAPI *)(HANDLE)) - GetProcAddress(state->VistaBlob.hAvrt, "AvRevertMmThreadCharacteristics"); - if (!state->VistaBlob.pAvRevertMmThreadCharacteristics) - goto exit_label; - - return true; -exit_label: - if (state->VistaBlob.hAvrt) { - FreeLibrary(state->VistaBlob.hAvrt); - state->VistaBlob.hAvrt = NULL; - } - return false; -} - static void update_waveformat_datarate(WAVEFORMATEXTENSIBLE *wformat) { WAVEFORMATEX *wf = &wformat->Format; @@ -738,9 +708,10 @@ reinit: hr = init_session_display(state); EXIT_ON_ERROR(hr); - if (state->VistaBlob.hAvrt) { - state->hTask = - state->VistaBlob.pAvSetMmThreadCharacteristicsW(L"Pro Audio", &state->taskIndex); + state->hTask = AvSetMmThreadCharacteristics(L"Pro Audio", &(DWORD){0}); + if (!state->hTask) { + MP_WARN(state, "Failed to set AV thread to Pro Audio: %s\n", + mp_LastError_to_str()); } MP_VERBOSE(state, "Format fixed. Using %lld byte buffer block size\n", @@ -1194,8 +1165,6 @@ void wasapi_thread_uninit(struct ao *ao) SAFE_RELEASE(state->pAudioClient, IAudioClient_Release(state->pAudioClient)); SAFE_RELEASE(state->pDevice, IMMDevice_Release(state->pDevice)); SAFE_RELEASE(state->pEnumerator, IMMDeviceEnumerator_Release(state->pEnumerator)); - - if (state->hTask) - state->VistaBlob.pAvRevertMmThreadCharacteristics(state->hTask); + SAFE_RELEASE(state->hTask, AvRevertMmThreadCharacteristics(state->hTask)); MP_DBG(ao, "Thread uninit done\n"); } diff --git a/audio/out/ao_wasapi_utils.h b/audio/out/ao_wasapi_utils.h index 5ac2d3efba..deaffd77e4 100755 --- a/audio/out/ao_wasapi_utils.h +++ b/audio/out/ao_wasapi_utils.h @@ -33,6 +33,7 @@ char *mp_HRESULT_to_str_buf(char *buf, size_t buf_size, HRESULT hr); #define mp_GUID_to_str(guid) mp_GUID_to_str_buf((char[40]){0}, 40, (guid)) #define mp_PKEY_to_str(pkey) mp_PKEY_to_str_buf((char[42]){0}, 42, (pkey)) #define mp_HRESULT_to_str(hr) mp_HRESULT_to_str_buf((char[60]){0}, 60, (hr)) +#define mp_LastError_to_str() mp_HRESULT_to_str(HRESULT_FROM_WIN32(GetLastError())) bool wasapi_fill_VistaBlob(wasapi_state *state); |