mirror of https://github.com/mpv-player/mpv
ao/wasapi: handle VistaBlob failure more gracefully
This commit is contained in:
parent
b83e447e2b
commit
77f675a151
|
@ -106,7 +106,10 @@ typedef struct wasapi_state {
|
|||
int opt_list;
|
||||
char *opt_device;
|
||||
|
||||
/* We still need to support XP, don't use these functions directly, blob owned by main thread */
|
||||
/* 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);
|
||||
|
|
|
@ -100,16 +100,25 @@ bool wasapi_fill_VistaBlob(wasapi_state *state)
|
|||
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)
|
||||
if (state->VistaBlob.hAvrt) {
|
||||
FreeLibrary(state->VistaBlob.hAvrt);
|
||||
state->VistaBlob.hAvrt = NULL;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -581,8 +590,11 @@ reinit:
|
|||
hr = init_session_display(state);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
if (state->VistaBlob.hAvrt) {
|
||||
state->hTask =
|
||||
state->VistaBlob.pAvSetMmThreadCharacteristicsW(L"Pro Audio", &state->taskIndex);
|
||||
}
|
||||
|
||||
MP_VERBOSE(state, "Format fixed. Using %lld byte buffer block size\n",
|
||||
(long long) state->buffer_block_size);
|
||||
|
||||
|
|
Loading…
Reference in New Issue