1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 00:42:57 +00:00

ao/wasapi: style/code formatting tweaks

This commit is contained in:
Kevin Mitchell 2015-01-02 14:26:08 -08:00
parent 155c8e20ef
commit 6a6620a554
3 changed files with 63 additions and 64 deletions

View File

@ -44,7 +44,7 @@ static HRESULT get_device_delay(struct wasapi_state *state, double *delay) {
hr = IAudioClock_GetPosition(state->pAudioClock, &position, &qpc_position); hr = IAudioClock_GetPosition(state->pAudioClock, &position, &qpc_position);
/* GetPosition succeeded, but the result may be inaccurate due to the length of the call */ /* GetPosition succeeded, but the result may be inaccurate due to the length of the call */
/* http://msdn.microsoft.com/en-us/library/windows/desktop/dd370889%28v=vs.85%29.aspx */ /* http://msdn.microsoft.com/en-us/library/windows/desktop/dd370889%28v=vs.85%29.aspx */
if ( hr == S_FALSE) { if (hr == S_FALSE) {
MP_DBG(state, "Possibly inaccurate device position.\n"); MP_DBG(state, "Possibly inaccurate device position.\n");
hr = S_OK; hr = S_OK;
} }
@ -54,7 +54,7 @@ static HRESULT get_device_delay(struct wasapi_state *state, double *delay) {
QueryPerformanceCounter(&qpc_count); QueryPerformanceCounter(&qpc_count);
double qpc_diff = (qpc_count.QuadPart * 1e7 / state->qpc_frequency.QuadPart) - qpc_position; double qpc_diff = (qpc_count.QuadPart * 1e7 / state->qpc_frequency.QuadPart) - qpc_position;
position += state->clock_frequency * (uint64_t)(qpc_diff / 1e7); position += state->clock_frequency * (uint64_t) (qpc_diff / 1e7);
/* convert position to the same base as sample_count */ /* convert position to the same base as sample_count */
position = position * state->format.Format.nSamplesPerSec / state->clock_frequency; position = position * state->format.Format.nSamplesPerSec / state->clock_frequency;
@ -67,7 +67,7 @@ static HRESULT get_device_delay(struct wasapi_state *state, double *delay) {
return S_OK; return S_OK;
exit_label: exit_label:
MP_ERR(state, "Error getting device delay: %s (0x%"PRIx32")\n", MP_ERR(state, "Error getting device delay: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
return hr; return hr;
} }
@ -110,7 +110,7 @@ static void thread_feed(struct ao *ao)
return; return;
exit_label: exit_label:
MP_ERR(state, "Error feeding audio: %s (0x%"PRIx32")\n", MP_ERR(state, "Error feeding audio: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
MP_VERBOSE(ao, "Requesting ao reload\n"); MP_VERBOSE(ao, "Requesting ao reload\n");
ao_request_reload(ao); ao_request_reload(ao);
return; return;
@ -131,7 +131,7 @@ static DWORD __stdcall ThreadLoop(void *lpParameter)
HANDLE playcontrol[] = HANDLE playcontrol[] =
{state->hUninit, state->hFeed, state->hForceFeed, NULL}; {state->hUninit, state->hFeed, state->hForceFeed, NULL};
MP_DBG(ao, "Entering dispatch loop\n"); MP_DBG(ao, "Entering dispatch loop\n");
while (1) { /* watch events */ while (true) { /* watch events */
waitstatus = MsgWaitForMultipleObjects(3, playcontrol, FALSE, INFINITE, waitstatus = MsgWaitForMultipleObjects(3, playcontrol, FALSE, INFINITE,
QS_POSTMESSAGE | QS_SENDMESSAGE); QS_POSTMESSAGE | QS_SENDMESSAGE);
switch (waitstatus) { switch (waitstatus) {
@ -181,7 +181,7 @@ static void uninit(struct ao *ao)
if (state->hUninit) if (state->hUninit)
SetEvent(state->hUninit); SetEvent(state->hUninit);
/* wait up to 10 seconds */ /* wait up to 10 seconds */
if (WaitForSingleObject(state->threadLoop, 10000) == WAIT_TIMEOUT){ if (WaitForSingleObject(state->threadLoop, 10000) == WAIT_TIMEOUT) {
MP_ERR(ao, "Audio loop thread refuses to abort\n"); MP_ERR(ao, "Audio loop thread refuses to abort\n");
return; return;
} }
@ -235,7 +235,7 @@ static int init(struct ao *ao)
} }
state->init_ret = E_FAIL; state->init_ret = E_FAIL;
state->threadLoop = (HANDLE)CreateThread(NULL, 0, &ThreadLoop, ao, 0, NULL); state->threadLoop = (HANDLE) CreateThread(NULL, 0, &ThreadLoop, ao, 0, NULL);
if (!state->threadLoop) { if (!state->threadLoop) {
/* failed to init thread */ /* failed to init thread */
MP_ERR(ao, "Failed to create thread\n"); MP_ERR(ao, "Failed to create thread\n");

View File

@ -32,7 +32,7 @@
static char* ERole_to_str(ERole role) static char* ERole_to_str(ERole role)
{ {
switch(role){ switch (role) {
case eConsole: return "console"; case eConsole: return "console";
case eMultimedia: return "multimedia"; case eMultimedia: return "multimedia";
case eCommunications: return "communications"; case eCommunications: return "communications";
@ -42,7 +42,7 @@ static char* ERole_to_str(ERole role)
static char* EDataFlow_to_str(EDataFlow flow) static char* EDataFlow_to_str(EDataFlow flow)
{ {
switch(flow){ switch (flow) {
case eRender: return "render"; case eRender: return "render";
case eCapture: return "capture"; case eCapture: return "capture";
case eAll: return "all"; case eAll: return "all";
@ -54,8 +54,8 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_QueryInterface(
IMMNotificationClient* This, REFIID riid, void **ppvObject) IMMNotificationClient* This, REFIID riid, void **ppvObject)
{ {
/* Compatible with IMMNotificationClient and IUnknown */ /* Compatible with IMMNotificationClient and IUnknown */
if ( IsEqualGUID(&IID_IMMNotificationClient, riid) || if (IsEqualGUID(&IID_IMMNotificationClient, riid) ||
IsEqualGUID(&IID_IUnknown, riid) ) { IsEqualGUID(&IID_IUnknown, riid)) {
*ppvObject = (void *)This; *ppvObject = (void *)This;
return S_OK; return S_OK;
} else { } else {
@ -86,7 +86,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDeviceStateChanged(
change_notify *change = (change_notify *)This; change_notify *change = (change_notify *)This;
struct ao *ao = change->ao; struct ao *ao = change->ao;
if (pwstrDeviceId && !wcscmp(change->monitored, pwstrDeviceId)){ if (pwstrDeviceId && !wcscmp(change->monitored, pwstrDeviceId)) {
switch (dwNewState) { switch (dwNewState) {
case DEVICE_STATE_DISABLED: case DEVICE_STATE_DISABLED:
case DEVICE_STATE_NOTPRESENT: case DEVICE_STATE_NOTPRESENT:
@ -146,8 +146,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDefaultDeviceChanged(
MP_VERBOSE(ao, "New default device %S\n", pwstrDeviceId); MP_VERBOSE(ao, "New default device %S\n", pwstrDeviceId);
/* don't care about "eCapture" or non-"eMultimedia" roles */ /* don't care about "eCapture" or non-"eMultimedia" roles */
if ( flow == eCapture || if (flow == eCapture || role != eMultimedia) return S_OK;
role != eMultimedia ) return S_OK;
/* stay on the device the user specified */ /* stay on the device the user specified */
if (state->opt_device) { if (state->opt_device) {
@ -156,7 +155,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDefaultDeviceChanged(
} }
/* don't reload if already on the new default */ /* don't reload if already on the new default */
if ( pwstrDeviceId && !wcscmp(change->monitored, pwstrDeviceId) ){ if (pwstrDeviceId && !wcscmp(change->monitored, pwstrDeviceId)) {
MP_VERBOSE(ao, "Already using default device, no reload required\n"); MP_VERBOSE(ao, "Already using default device, no reload required\n");
return S_OK; return S_OK;
} }
@ -178,7 +177,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnPropertyValueChanged(
if (pwstrDeviceId && !wcscmp(change->monitored, pwstrDeviceId)) { if (pwstrDeviceId && !wcscmp(change->monitored, pwstrDeviceId)) {
MP_VERBOSE(ao, "OnPropertyValueChanged triggered\n"); MP_VERBOSE(ao, "OnPropertyValueChanged triggered\n");
MP_VERBOSE(ao, "Changed property: "); MP_VERBOSE(ao, "Changed property: ");
if ( IsEqualPropertyKey(PKEY_AudioEngine_DeviceFormat, key) ) { if (IsEqualPropertyKey(PKEY_AudioEngine_DeviceFormat, key)) {
MP_VERBOSE(change->ao, MP_VERBOSE(change->ao,
"PKEY_AudioEngine_DeviceFormat - requesting ao reload\n"); "PKEY_AudioEngine_DeviceFormat - requesting ao reload\n");
ao_request_reload(change->ao); ao_request_reload(change->ao);
@ -235,7 +234,7 @@ void wasapi_change_uninit(struct ao *ao)
struct wasapi_state *state = (struct wasapi_state *)ao->priv; struct wasapi_state *state = (struct wasapi_state *)ao->priv;
struct change_notify *change = &state->change; struct change_notify *change = &state->change;
if( state->pEnumerator && change->client.lpVtbl ) if(state->pEnumerator && change->client.lpVtbl)
IMMDeviceEnumerator_UnregisterEndpointNotificationCallback( IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(
state->pEnumerator, (IMMNotificationClient *)change); state->pEnumerator, (IMMNotificationClient *)change);

View File

@ -66,7 +66,7 @@ char *mp_PKEY_to_str_buf(char *buf, size_t buf_size, const PROPERTYKEY *pkey)
{ {
buf = mp_GUID_to_str_buf(buf, buf_size, &pkey->fmtid); buf = mp_GUID_to_str_buf(buf, buf_size, &pkey->fmtid);
size_t guid_len = strnlen(buf, buf_size); size_t guid_len = strnlen(buf, buf_size);
snprintf(buf + guid_len, buf_size - guid_len, ",%"PRIu32, (uint32_t)pkey->pid ); snprintf(buf + guid_len, buf_size - guid_len, ",%"PRIu32, (uint32_t) pkey->pid);
return buf; return buf;
} }
@ -182,15 +182,15 @@ static WORD waveformat_valid_bits(const WAVEFORMATEX *wf)
static char *waveformat_to_str_buf(char *buf, size_t buf_size, WAVEFORMATEX *wf) static char *waveformat_to_str_buf(char *buf, size_t buf_size, WAVEFORMATEX *wf)
{ {
char* type = "?"; char* type = "?";
switch(wf->wFormatTag) { switch (wf->wFormatTag) {
case WAVE_FORMAT_EXTENSIBLE: case WAVE_FORMAT_EXTENSIBLE:
{ {
WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf; WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf;
if ( IsEqualGUID(&mp_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, if (IsEqualGUID(&mp_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT,
&wformat->SubFormat) ) &wformat->SubFormat))
type = "float"; type = "float";
else if ( IsEqualGUID(&mp_KSDATAFORMAT_SUBTYPE_PCM, else if (IsEqualGUID(&mp_KSDATAFORMAT_SUBTYPE_PCM,
&wformat->SubFormat) ) &wformat->SubFormat))
type = "s"; type = "s";
break; break;
} }
@ -202,13 +202,13 @@ static char *waveformat_to_str_buf(char *buf, size_t buf_size, WAVEFORMATEX *wf)
break; break;
} }
int valid_bits = waveformat_valid_bits(wf); int valid_bits = waveformat_valid_bits(wf);
if (valid_bits == wf->wBitsPerSample){ if (valid_bits == wf->wBitsPerSample) {
snprintf(buf, buf_size, "%"PRIu16"ch %s%"PRIu16" @ %"PRIu32"hz", snprintf(buf, buf_size, "%"PRIu16"ch %s%"PRIu16" @ %"PRIu32"hz",
wf->nChannels, type, valid_bits, (unsigned)wf->nSamplesPerSec); wf->nChannels, type, valid_bits, (unsigned) wf->nSamplesPerSec);
} else { } else {
snprintf(buf, buf_size, "%"PRIu16"ch %s%"PRIu16" (in %s%"PRIu16") @ %"PRIu32"hz", snprintf(buf, buf_size, "%"PRIu16"ch %s%"PRIu16" (in %s%"PRIu16") @ %"PRIu32"hz",
wf->nChannels, type, valid_bits, type, wf->wBitsPerSample, wf->nChannels, type, valid_bits, type, wf->wBitsPerSample,
(unsigned)wf->nSamplesPerSec); (unsigned) wf->nSamplesPerSec);
} }
return buf; return buf;
} }
@ -216,7 +216,7 @@ static char *waveformat_to_str_buf(char *buf, size_t buf_size, WAVEFORMATEX *wf)
static bool waveformat_is_float(WAVEFORMATEX *wf) static bool waveformat_is_float(WAVEFORMATEX *wf)
{ {
switch(wf->wFormatTag) { switch (wf->wFormatTag) {
case WAVE_FORMAT_EXTENSIBLE: case WAVE_FORMAT_EXTENSIBLE:
{ {
WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf; WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf;
@ -231,7 +231,7 @@ static bool waveformat_is_float(WAVEFORMATEX *wf)
static bool waveformat_is_pcm(WAVEFORMATEX *wf) static bool waveformat_is_pcm(WAVEFORMATEX *wf)
{ {
switch(wf->wFormatTag) { switch (wf->wFormatTag) {
case WAVE_FORMAT_EXTENSIBLE: case WAVE_FORMAT_EXTENSIBLE:
{ {
WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf; WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf;
@ -246,7 +246,7 @@ static bool waveformat_is_pcm(WAVEFORMATEX *wf)
static void waveformat_copy(WAVEFORMATEXTENSIBLE* dst, WAVEFORMATEX* src) static void waveformat_copy(WAVEFORMATEXTENSIBLE* dst, WAVEFORMATEX* src)
{ {
if ( src->wFormatTag == WAVE_FORMAT_EXTENSIBLE ) if (src->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
*dst = *(WAVEFORMATEXTENSIBLE *)src; *dst = *(WAVEFORMATEXTENSIBLE *)src;
else else
dst->Format = *src; dst->Format = *src;
@ -262,7 +262,7 @@ static bool set_ao_format(struct ao *ao, WAVEFORMATEX *wf)
return false; return false;
int format; int format;
if (waveformat_is_float(wf)){ if (waveformat_is_float(wf)) {
format = AF_FORMAT_FLOAT; format = AF_FORMAT_FLOAT;
} else if (waveformat_is_pcm(wf)) { } else if (waveformat_is_pcm(wf)) {
format = AF_FORMAT_S32; format = AF_FORMAT_S32;
@ -279,14 +279,14 @@ static bool set_ao_format(struct ao *ao, WAVEFORMATEX *wf)
ao->bps = wf->nAvgBytesPerSec; ao->bps = wf->nAvgBytesPerSec;
ao->format = format; ao->format = format;
if ( wf->wFormatTag == WAVE_FORMAT_EXTENSIBLE ){ if (wf->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf; WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf;
mp_chmap_from_waveext(&ao->channels, wformat->dwChannelMask); mp_chmap_from_waveext(&ao->channels, wformat->dwChannelMask);
} else { } else {
mp_chmap_from_channels(&ao->channels, wf->nChannels); mp_chmap_from_channels(&ao->channels, wf->nChannels);
} }
if ( ao->channels.num != wf->nChannels ) { if (ao->channels.num != wf->nChannels) {
MP_ERR(ao, "Channel map doesn't match number of channels\n"); MP_ERR(ao, "Channel map doesn't match number of channels\n");
return false; return false;
} }
@ -352,7 +352,7 @@ static bool try_mix_format(struct ao *ao)
return ret; return ret;
exit_label: exit_label:
MP_ERR(state, "Error getting mix format: %s (0x%"PRIx32")\n", MP_ERR(state, "Error getting mix format: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
SAFE_RELEASE(wf, CoTaskMemFree(wf)); SAFE_RELEASE(wf, CoTaskMemFree(wf));
return false; return false;
} }
@ -392,7 +392,7 @@ static bool try_passthrough(struct ao *ao)
static bool search_sample_formats(struct ao *ao, int samplerate, struct mp_chmap *channels) static bool search_sample_formats(struct ao *ao, int samplerate, struct mp_chmap *channels)
{ {
// try float // try float
for (int bits = 64; bits; bits -= 32){ for (int bits = 64; bits; bits -= 32) {
if (try_format(ao, bits, bits, true, samplerate, channels)) if (try_format(ao, bits, bits, true, samplerate, channels))
return true; return true;
} }
@ -450,7 +450,7 @@ static bool find_formats(struct ao *ao)
int samplerates[] = {384000, 352800, 192000, 176400, 96000, 88200, int samplerates[] = {384000, 352800, 192000, 176400, 96000, 88200,
48000, 44100, 32000, 22050, 16000, 11025, 48000, 44100, 32000, 22050, 16000, 11025,
8000}; 8000};
for (int i = 0; i < MP_ARRAY_SIZE(samplerates); i++){ for (int i = 0; i < MP_ARRAY_SIZE(samplerates); i++) {
if (search_sample_formats(ao, samplerates[i], &ao->channels)) if (search_sample_formats(ao, samplerates[i], &ao->channels))
return true; return true;
} }
@ -484,7 +484,7 @@ static HRESULT init_clock(struct wasapi_state *state) {
return S_OK; return S_OK;
exit_label: exit_label:
MP_ERR(state, "Error obtaining the audio device's timing: %s (0x%"PRIx32")\n", MP_ERR(state, "Error obtaining the audio device's timing: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
return hr; return hr;
} }
@ -494,7 +494,7 @@ static HRESULT init_session_display(struct wasapi_state *state) {
hr = IAudioClient_GetService(state->pAudioClient, hr = IAudioClient_GetService(state->pAudioClient,
&IID_IAudioSessionControl, &IID_IAudioSessionControl,
(void **) &state->pSessionControl); (void **)&state->pSessionControl);
EXIT_ON_ERROR(hr); EXIT_ON_ERROR(hr);
GetModuleFileNameW(NULL, path, MAX_PATH); GetModuleFileNameW(NULL, path, MAX_PATH);
@ -508,7 +508,7 @@ static HRESULT init_session_display(struct wasapi_state *state) {
return S_OK; return S_OK;
exit_label: exit_label:
MP_WARN(state, "Error setting audio session display name: %s (0x%"PRIx32")\n", MP_WARN(state, "Error setting audio session display name: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
return S_OK; // No reason to abort initialization. return S_OK; // No reason to abort initialization.
} }
@ -523,7 +523,7 @@ static HRESULT fix_format(struct ao *ao)
MP_VERBOSE(state, "Device period: %.2g ms\n", (double) devicePeriod / 10000.0 ); MP_VERBOSE(state, "Device period: %.2g ms\n", (double) devicePeriod / 10000.0 );
/* integer multiple of device period close to 50ms */ /* integer multiple of device period close to 50ms */
bufferPeriod = bufferDuration = ceil( 50.0 * 10000.0 / devicePeriod ) * devicePeriod; bufferPeriod = bufferDuration = ceil(50.0 * 10000.0 / devicePeriod) * devicePeriod;
/* handle unsupported buffer size */ /* handle unsupported buffer size */
/* hopefully this shouldn't happen because of the above integer device period */ /* hopefully this shouldn't happen because of the above integer device period */
@ -549,12 +549,12 @@ reinit:
retries ++; retries ++;
MP_VERBOSE(state, "IAudioClient::Initialize negotiation failed with %s (0x%"PRIx32"), used %lld * 100ns\n", MP_VERBOSE(state, "IAudioClient::Initialize negotiation failed with %s (0x%"PRIx32"), used %lld * 100ns\n",
wasapi_explain_err(hr), (uint32_t)hr, bufferDuration); wasapi_explain_err(hr), (uint32_t) hr, bufferDuration);
IAudioClient_GetBufferSize(state->pAudioClient, &state->bufferFrameCount); IAudioClient_GetBufferSize(state->pAudioClient, &state->bufferFrameCount);
bufferPeriod = bufferDuration = bufferPeriod = bufferDuration =
(REFERENCE_TIME)((10000.0 * 1000 / state->format.Format.nSamplesPerSec * (REFERENCE_TIME) ((10000.0 * 1000 / state->format.Format.nSamplesPerSec *
state->bufferFrameCount) + 0.5); state->bufferFrameCount) + 0.5);
IAudioClient_Release(state->pAudioClient); IAudioClient_Release(state->pAudioClient);
state->pAudioClient = NULL; state->pAudioClient = NULL;
@ -574,7 +574,7 @@ reinit:
MP_DBG(state, "IAudioClient::Initialize pAudioVolume\n"); MP_DBG(state, "IAudioClient::Initialize pAudioVolume\n");
hr = IAudioClient_GetService(state->pAudioClient, hr = IAudioClient_GetService(state->pAudioClient,
&IID_ISimpleAudioVolume, &IID_ISimpleAudioVolume,
(void **) &state->pAudioVolume); (void **)&state->pAudioVolume);
EXIT_ON_ERROR(hr); EXIT_ON_ERROR(hr);
MP_DBG(state, "IAudioClient::Initialize IAudioClient_SetEventHandle\n"); MP_DBG(state, "IAudioClient::Initialize IAudioClient_SetEventHandle\n");
@ -591,8 +591,8 @@ reinit:
state->format.Format.wBitsPerSample / 8 * state->format.Format.wBitsPerSample / 8 *
state->bufferFrameCount; state->bufferFrameCount;
bufferDuration = bufferDuration =
(REFERENCE_TIME)((10000.0 * 1000 / state->format.Format.nSamplesPerSec * (REFERENCE_TIME) ((10000.0 * 1000 / state->format.Format.nSamplesPerSec *
state->bufferFrameCount) + 0.5); state->bufferFrameCount) + 0.5);
MP_VERBOSE(state, "Buffer frame count: %"PRIu32" (%.2g ms)\n", MP_VERBOSE(state, "Buffer frame count: %"PRIu32" (%.2g ms)\n",
state->bufferFrameCount, (double) bufferDuration / 10000.0 ); state->bufferFrameCount, (double) bufferDuration / 10000.0 );
@ -613,7 +613,7 @@ reinit:
return S_OK; return S_OK;
exit_label: exit_label:
MP_ERR(state, "Error initializing device: %s (0x%"PRIx32")\n", MP_ERR(state, "Error initializing device: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
return hr; return hr;
} }
@ -798,7 +798,7 @@ bool wasapi_enumerate_devices(struct mp_log *log, struct ao *ao,
return true; return true;
exit_label: exit_label:
mp_err(log, "Error enumerating devices: %s (0x%"PRIx32")\n", mp_err(log, "Error enumerating devices: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
return false; return false;
} }
@ -817,7 +817,7 @@ static HRESULT load_default_device(struct ao *ao, IMMDeviceEnumerator* pEnumerat
return S_OK; return S_OK;
exit_label: exit_label:
MP_ERR(ao , "Error loading default device: %s (0x%"PRIx32")\n", MP_ERR(ao , "Error loading default device: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
return hr; return hr;
} }
@ -926,7 +926,7 @@ static HRESULT find_and_load_device(struct ao *ao, IMMDeviceEnumerator* pEnumera
exit_label: exit_label:
SAFE_RELEASE(pTempDevice, IMMDevice_Release(pTempDevice)); SAFE_RELEASE(pTempDevice, IMMDevice_Release(pTempDevice));
SAFE_RELEASE(pDevices, IMMDeviceCollection_Release(pDevices)); SAFE_RELEASE(pDevices, IMMDeviceCollection_Release(pDevices));
CoTaskMemFree(deviceID); CoTaskMemFree(deviceID);
return hr; return hr;
@ -946,7 +946,7 @@ int wasapi_validate_device(struct mp_log *log, const m_option_t *opt,
int devno = (int) strtol(param.start, &end, 10); int devno = (int) strtol(param.start, &end, 10);
int ret = 1; int ret = 1;
if ((end == (void*)param.start || *end) && devno < 0) if ((end == (void *)param.start || *end) && devno < 0)
ret = M_OPT_OUT_OF_RANGE; ret = M_OPT_OUT_OF_RANGE;
mp_dbg(log, "device=%s %svalid\n", param.start, ret == 1 ? "" : "not "); mp_dbg(log, "device=%s %svalid\n", param.start, ret == 1 ? "" : "not ");
@ -957,7 +957,7 @@ HRESULT wasapi_setup_proxies(struct wasapi_state *state) {
HRESULT hr; HRESULT hr;
#define UNMARSHAL(type, to, from) do { \ #define UNMARSHAL(type, to, from) do { \
hr = CoGetInterfaceAndReleaseStream((from), &(type), (void**) &(to)); \ hr = CoGetInterfaceAndReleaseStream((from), &(type), (void **)&(to)); \
(from) = NULL; \ (from) = NULL; \
EXIT_ON_ERROR(hr); \ EXIT_ON_ERROR(hr); \
} while (0) } while (0)
@ -972,7 +972,7 @@ HRESULT wasapi_setup_proxies(struct wasapi_state *state) {
return S_OK; return S_OK;
exit_label: exit_label:
MP_ERR(state, "Error reading COM proxy: %s (0x%"PRIx32")\n", MP_ERR(state, "Error reading COM proxy: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
return hr; return hr;
} }
@ -990,7 +990,7 @@ static HRESULT create_proxies(struct wasapi_state *state) {
hr = CreateStreamOnHGlobal(NULL, TRUE, &(to)); \ hr = CreateStreamOnHGlobal(NULL, TRUE, &(to)); \
EXIT_ON_ERROR(hr); \ EXIT_ON_ERROR(hr); \
hr = CoMarshalInterThreadInterfaceInStream(&(type), \ hr = CoMarshalInterThreadInterfaceInStream(&(type), \
(IUnknown*) (from), \ (IUnknown *)(from), \
&(to)); \ &(to)); \
EXIT_ON_ERROR(hr); \ EXIT_ON_ERROR(hr); \
} while (0) } while (0)
@ -1003,13 +1003,13 @@ static HRESULT create_proxies(struct wasapi_state *state) {
return S_OK; return S_OK;
exit_label: exit_label:
MP_ERR(state, "Error creating COM proxy: %s (0x%"PRIx32")\n", MP_ERR(state, "Error creating COM proxy: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
return hr; return hr;
} }
static void destroy_proxies(struct wasapi_state *state) { static void destroy_proxies(struct wasapi_state *state) {
SAFE_RELEASE(state->sAudioClient, IUnknown_Release(state->sAudioClient)); SAFE_RELEASE(state->sAudioClient, IUnknown_Release(state->sAudioClient));
SAFE_RELEASE(state->sAudioVolume, IUnknown_Release(state->sAudioVolume)); SAFE_RELEASE(state->sAudioVolume, IUnknown_Release(state->sAudioVolume));
SAFE_RELEASE(state->sEndpointVolume, IUnknown_Release(state->sEndpointVolume)); SAFE_RELEASE(state->sEndpointVolume, IUnknown_Release(state->sEndpointVolume));
SAFE_RELEASE(state->sSessionControl, IUnknown_Release(state->sSessionControl)); SAFE_RELEASE(state->sSessionControl, IUnknown_Release(state->sSessionControl));
} }
@ -1032,7 +1032,7 @@ retry:
state->initial_volume = -1.0; state->initial_volume = -1.0;
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
&IID_IMMDeviceEnumerator, (void**)&state->pEnumerator); &IID_IMMDeviceEnumerator, (void **)&state->pEnumerator);
EXIT_ON_ERROR(hr); EXIT_ON_ERROR(hr);
char *device = state->opt_device; char *device = state->opt_device;
@ -1064,21 +1064,21 @@ retry:
MP_DBG(ao, "Query hardware volume support\n"); MP_DBG(ao, "Query hardware volume support\n");
hr = IAudioEndpointVolume_QueryHardwareSupport(state->pEndpointVolume, hr = IAudioEndpointVolume_QueryHardwareSupport(state->pEndpointVolume,
&state->vol_hw_support); &state->vol_hw_support);
if ( hr != S_OK ) if (hr != S_OK)
MP_WARN(ao, "Error querying hardware volume control: %s (0x%"PRIx32")\n", MP_WARN(ao, "Error querying hardware volume control: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
MP_DBG(ao, "Probing formats\n"); MP_DBG(ao, "Probing formats\n");
if (!find_formats(ao)){ if (!find_formats(ao)) {
hr = E_FAIL; hr = E_FAIL;
EXIT_ON_ERROR(hr); EXIT_ON_ERROR(hr);
} }
MP_DBG(ao, "Fixing format\n"); MP_DBG(ao, "Fixing format\n");
hr = fix_format(ao); hr = fix_format(ao);
if ( (hr == AUDCLNT_E_DEVICE_IN_USE || if ((hr == AUDCLNT_E_DEVICE_IN_USE ||
hr == AUDCLNT_E_DEVICE_INVALIDATED) && hr == AUDCLNT_E_DEVICE_INVALIDATED) &&
retry_wait <= 8 ) { retry_wait <= 8) {
wasapi_thread_uninit(ao); wasapi_thread_uninit(ao);
MP_WARN(ao, "Retrying in %"PRId64" us\n", retry_wait); MP_WARN(ao, "Retrying in %"PRId64" us\n", retry_wait);
mp_sleep_us(retry_wait); mp_sleep_us(retry_wait);
@ -1107,7 +1107,7 @@ retry:
return S_OK; return S_OK;
exit_label: exit_label:
MP_ERR(state, "Error setting up audio thread: %s (0x%"PRIx32")\n", MP_ERR(state, "Error setting up audio thread: %s (0x%"PRIx32")\n",
wasapi_explain_err(hr), (uint32_t)hr); wasapi_explain_err(hr), (uint32_t) hr);
return hr; return hr;
} }