mirror of
https://github.com/mpv-player/mpv
synced 2024-12-24 15:52:25 +00:00
ao_wasapi: get rid of Vistablob hack
This was required to work around XP linking issues and is no longer required.
This commit is contained in:
parent
4f103b2093
commit
00b7fb3023
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user