mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 23:00:41 +00:00
ao_wasapi: remove redundant casts
This commit is contained in:
parent
b6c28dd26b
commit
e408dd20c7
@ -70,7 +70,7 @@ exit_label:
|
||||
|
||||
static void thread_feed(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
HRESULT hr;
|
||||
|
||||
UINT32 frame_count = state->bufferFrameCount;
|
||||
@ -115,7 +115,7 @@ exit_label:
|
||||
|
||||
static void thread_resume(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
HRESULT hr;
|
||||
|
||||
MP_DBG(state, "Thread Resume\n");
|
||||
@ -142,7 +142,7 @@ static void thread_resume(struct ao *ao)
|
||||
|
||||
static void thread_reset(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
HRESULT hr;
|
||||
MP_DBG(state, "Thread Reset\n");
|
||||
hr = IAudioClient_Stop(state->pAudioClient);
|
||||
@ -168,7 +168,7 @@ static void thread_reset(struct ao *ao)
|
||||
static DWORD __stdcall ThreadLoop(void *lpParameter)
|
||||
{
|
||||
struct ao *ao = lpParameter;
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
|
||||
state->init_ret = wasapi_thread_init(ao);
|
||||
@ -215,7 +215,7 @@ exit_label:
|
||||
|
||||
static void closehandles(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
if (state->init_done) CloseHandle(state->init_done);
|
||||
if (state->hUninit) CloseHandle(state->hUninit);
|
||||
if (state->hFeed) CloseHandle(state->hFeed);
|
||||
@ -227,7 +227,7 @@ static void closehandles(struct ao *ao)
|
||||
static void uninit(struct ao *ao)
|
||||
{
|
||||
MP_DBG(ao, "Uninit wasapi\n");
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
wasapi_release_proxies(state);
|
||||
if (state->hUninit)
|
||||
SetEvent(state->hUninit);
|
||||
@ -248,7 +248,7 @@ static int init(struct ao *ao)
|
||||
MP_DBG(ao, "Init wasapi\n");
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
state->log = ao->log;
|
||||
if(!wasapi_fill_VistaBlob(state))
|
||||
MP_WARN(ao, "Error loading thread priority functions\n");
|
||||
@ -274,7 +274,7 @@ static int init(struct ao *ao)
|
||||
}
|
||||
|
||||
state->init_ret = E_FAIL;
|
||||
state->threadLoop = (HANDLE) CreateThread(NULL, 0, &ThreadLoop, ao, 0, NULL);
|
||||
state->threadLoop = CreateThread(NULL, 0, &ThreadLoop, ao, 0, NULL);
|
||||
if (!state->threadLoop) {
|
||||
/* failed to init thread */
|
||||
MP_ERR(ao, "Failed to create thread\n");
|
||||
@ -297,8 +297,8 @@ static int init(struct ao *ao)
|
||||
|
||||
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
ao_control_vol_t *vol = arg;
|
||||
BOOL mute;
|
||||
|
||||
switch (cmd) {
|
||||
@ -376,20 +376,20 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
||||
|
||||
static void audio_reset(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
SetEvent(state->hReset);
|
||||
}
|
||||
|
||||
static void audio_resume(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
SetEvent(state->hResume);
|
||||
}
|
||||
|
||||
static void hotplug_uninit(struct ao *ao)
|
||||
{
|
||||
MP_DBG(ao, "Hotplug uninit\n");
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
wasapi_change_uninit(ao);
|
||||
SAFE_RELEASE(state->pEnumerator, IMMDeviceEnumerator_Release(state->pEnumerator));
|
||||
CoUninitialize();
|
||||
@ -398,7 +398,7 @@ static void hotplug_uninit(struct ao *ao)
|
||||
static int hotplug_init(struct ao *ao)
|
||||
{
|
||||
MP_DBG(ao, "Hotplug init\n");
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
||||
&IID_IMMDeviceEnumerator, (void **)&state->pEnumerator);
|
||||
|
@ -127,7 +127,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDefaultDeviceChanged(
|
||||
{
|
||||
change_notify *change = (change_notify *)This;
|
||||
struct ao *ao = change->ao;
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
|
||||
/* don't care about "eCapture" or non-"eMultimedia" roles */
|
||||
if (flow == eCapture || role != eMultimedia) return S_OK;
|
||||
@ -198,7 +198,7 @@ static CONST_VTBL IMMNotificationClientVtbl sIMMDeviceEnumeratorVtbl_vtbl = {
|
||||
|
||||
HRESULT wasapi_change_init(struct ao *ao, bool is_hotplug)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
struct change_notify *change = &state->change;
|
||||
HRESULT hr;
|
||||
/* COM voodoo to emulate c++ class */
|
||||
@ -234,7 +234,7 @@ exit_label:
|
||||
|
||||
void wasapi_change_uninit(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
struct change_notify *change = &state->change;
|
||||
|
||||
if (state->pEnumerator && change->client.lpVtbl) {
|
||||
|
@ -312,7 +312,7 @@ static void waveformat_copy(WAVEFORMATEXTENSIBLE* dst, WAVEFORMATEX* src)
|
||||
|
||||
static bool set_ao_format(struct ao *ao, WAVEFORMATEX *wf)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
|
||||
int format = format_from_waveformat(wf);
|
||||
if (!format) {
|
||||
@ -338,7 +338,7 @@ static bool set_ao_format(struct ao *ao, WAVEFORMATEX *wf)
|
||||
|
||||
static bool try_format_exclusive(struct ao *ao, WAVEFORMATEXTENSIBLE *wformat)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
MP_VERBOSE(ao, "Trying %s\n", waveformat_to_str(&wformat->Format));
|
||||
HRESULT hr = IAudioClient_IsFormatSupported(state->pAudioClient,
|
||||
AUDCLNT_SHAREMODE_EXCLUSIVE,
|
||||
@ -424,7 +424,7 @@ static bool search_samplerates(struct ao *ao, WAVEFORMATEXTENSIBLE *wformat,
|
||||
|
||||
static bool search_channels(struct ao *ao, WAVEFORMATEXTENSIBLE *wformat)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
struct mp_chmap_sel chmap_sel = {.tmp = state};
|
||||
struct mp_chmap entry;
|
||||
// put common layouts first so that we find sample rate/format early
|
||||
@ -485,7 +485,7 @@ static bool find_formats_exclusive(struct ao *ao)
|
||||
|
||||
static bool find_formats_shared(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
|
||||
WAVEFORMATEXTENSIBLE wformat;
|
||||
set_waveformat_with_ao(&wformat, ao);
|
||||
@ -535,7 +535,7 @@ static bool try_passthrough(struct ao *ao)
|
||||
// that the resulting waveformat is actually consistent with the ao
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd370811%28v=vs.85%29.aspx
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd316761(v=vs.85).aspx
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
|
||||
WAVEFORMATEXTENSIBLE wformat = {
|
||||
.Format = {
|
||||
@ -568,7 +568,7 @@ static bool try_passthrough(struct ao *ao)
|
||||
|
||||
static bool find_formats(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
|
||||
if (state->opt_exclusive) {
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd370811%28v=vs.85%29.aspx
|
||||
@ -586,11 +586,9 @@ static bool find_formats(struct ao *ao)
|
||||
}
|
||||
|
||||
static HRESULT init_clock(struct wasapi_state *state) {
|
||||
HRESULT hr;
|
||||
|
||||
hr = IAudioClient_GetService(state->pAudioClient,
|
||||
&IID_IAudioClock,
|
||||
(void **)&state->pAudioClock);
|
||||
HRESULT hr = IAudioClient_GetService(state->pAudioClient,
|
||||
&IID_IAudioClock,
|
||||
(void **)&state->pAudioClock);
|
||||
EXIT_ON_ERROR(hr);
|
||||
hr = IAudioClock_GetFrequency(state->pAudioClock, &state->clock_frequency);
|
||||
EXIT_ON_ERROR(hr);
|
||||
@ -610,12 +608,11 @@ exit_label:
|
||||
}
|
||||
|
||||
static HRESULT init_session_display(struct wasapi_state *state) {
|
||||
HRESULT hr;
|
||||
wchar_t path[MAX_PATH+12] = {0};
|
||||
|
||||
hr = IAudioClient_GetService(state->pAudioClient,
|
||||
&IID_IAudioSessionControl,
|
||||
(void **)&state->pSessionControl);
|
||||
HRESULT hr = IAudioClient_GetService(state->pAudioClient,
|
||||
&IID_IAudioSessionControl,
|
||||
(void **)&state->pSessionControl);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
GetModuleFileNameW(NULL, path, MAX_PATH);
|
||||
@ -635,12 +632,11 @@ exit_label:
|
||||
|
||||
static HRESULT fix_format(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
HRESULT hr;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
|
||||
REFERENCE_TIME devicePeriod, bufferDuration, bufferPeriod;
|
||||
MP_DBG(state, "IAudioClient::GetDevicePeriod\n");
|
||||
hr = IAudioClient_GetDevicePeriod(state->pAudioClient,&devicePeriod, NULL);
|
||||
HRESULT hr = IAudioClient_GetDevicePeriod(state->pAudioClient,&devicePeriod, NULL);
|
||||
MP_VERBOSE(state, "Device period: %.2g ms\n", (double) devicePeriod / 10000.0 );
|
||||
|
||||
/* integer multiple of device period close to 50ms */
|
||||
@ -831,7 +827,7 @@ end:
|
||||
|
||||
void wasapi_list_devs(struct ao *ao, struct ao_device_list *list)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
IMMDeviceCollection *pDevices = NULL;
|
||||
IMMDevice *pDevice = NULL;
|
||||
char *name = NULL, *id = NULL;
|
||||
@ -905,7 +901,7 @@ static HRESULT find_and_load_device(struct ao *ao, IMMDeviceEnumerator* pEnumera
|
||||
LPWSTR deviceID = NULL;
|
||||
|
||||
char *end;
|
||||
int devno = (int) strtol(search, &end, 10);
|
||||
int devno = strtol(search, &end, 10);
|
||||
|
||||
char *devid = NULL;
|
||||
if (end == search || *end)
|
||||
@ -1071,15 +1067,14 @@ void wasapi_dispatch(void)
|
||||
|
||||
HRESULT wasapi_thread_init(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
HRESULT hr;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
MP_DBG(ao, "Init wasapi thread\n");
|
||||
int64_t retry_wait = 1;
|
||||
retry:
|
||||
state->initial_volume = -1.0;
|
||||
|
||||
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
||||
&IID_IMMDeviceEnumerator, (void **)&state->pEnumerator);
|
||||
HRESULT hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
||||
&IID_IMMDeviceEnumerator, (void **)&state->pEnumerator);
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
char *device = state->opt_device;
|
||||
@ -1163,7 +1158,7 @@ exit_label:
|
||||
|
||||
void wasapi_thread_uninit(struct ao *ao)
|
||||
{
|
||||
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
|
||||
wasapi_dispatch();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user