summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2014-11-30 16:44:19 -0800
committerKevin Mitchell <kevmitch@gmail.com>2014-12-01 03:40:23 -0800
commit9a0b97d2141cd93f99718f8c5175eba9e14614ef (patch)
tree64dbb7c58644ebb31d91d2c0fa0dd80b50abf4ae /audio
parent18a621ae26610e5facba9b784425543ce8118c15 (diff)
downloadmpv-9a0b97d2141cd93f99718f8c5175eba9e14614ef.tar.bz2
mpv-9a0b97d2141cd93f99718f8c5175eba9e14614ef.tar.xz
ao/wasapi: get rid of WAVEFMT union
It only confused the issue. Replace it's functionality with waveformat_copy function where needed.
Diffstat (limited to 'audio')
-rwxr-xr-xaudio/out/ao_wasapi_utils.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c
index 10b435dbe8..62fcac0334 100755
--- a/audio/out/ao_wasapi_utils.c
+++ b/audio/out/ao_wasapi_utils.c
@@ -88,11 +88,6 @@ char *mp_PKEY_to_str_buf(char *buf, size_t buf_size, const PROPERTYKEY *pkey)
return buf;
}
-union WAVEFMT {
- WAVEFORMATEX *ex;
- WAVEFORMATEXTENSIBLE *extensible;
-};
-
bool wasapi_fill_VistaBlob(wasapi_state *state)
{
if (!state)
@@ -190,6 +185,14 @@ static void set_format(WAVEFORMATEXTENSIBLE *wformat, WORD bytepersample,
wformat->dwChannelMask = chanmask;
}
+static void waveformat_copy(WAVEFORMATEXTENSIBLE* dst, WAVEFORMATEX* src)
+{
+ if ( src->wFormatTag == WAVE_FORMAT_EXTENSIBLE )
+ *dst = *(WAVEFORMATEXTENSIBLE *)src;
+ else
+ dst->Format = *src;
+}
+
static int format_set_bits(int old_format, int bits, bool fp)
{
if (fp) {
@@ -247,22 +250,13 @@ static bool try_format(struct ao *ao,
MP_VERBOSE(ao, "Trying %dch %s @ %dhz\n",
channels.num, af_fmt_to_str(af_format), samplerate);
- union WAVEFMT u;
- u.extensible = &wformat;
-
WAVEFORMATEX *closestMatch;
HRESULT hr = IAudioClient_IsFormatSupported(state->pAudioClient,
state->share_mode,
- u.ex, &closestMatch);
+ &wformat.Format, &closestMatch);
if (closestMatch) {
- if (closestMatch->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
- u.ex = closestMatch;
- wformat = *u.extensible;
- } else {
- wformat.Format = *closestMatch;
- }
-
+ waveformat_copy(&wformat, closestMatch);
CoTaskMemFree(closestMatch);
}
@@ -288,18 +282,11 @@ static bool try_mix_format(struct ao *ao)
{
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
WAVEFORMATEX *deviceFormat = NULL;
-
HRESULT hr = IAudioClient_GetMixFormat(state->pAudioClient, &deviceFormat);
EXIT_ON_ERROR(hr);
- union WAVEFMT u;
- u.ex = deviceFormat;
- WAVEFORMATEXTENSIBLE wformat = *u.extensible;
-
- bool ret = try_format(ao, wformat.Format.wBitsPerSample,
- wformat.Format.nSamplesPerSec, ao->channels);
- if (ret)
- state->format = wformat;
+ bool ret = try_format(ao, deviceFormat->wBitsPerSample,
+ deviceFormat->nSamplesPerSec, ao->channels);
SAFE_RELEASE(deviceFormat, CoTaskMemFree(deviceFormat));
return ret;
@@ -329,14 +316,11 @@ static bool try_passthrough(struct ao *ao)
};
wformat.SubFormat.Data1 = WAVE_FORMAT_DOLBY_AC3_SPDIF; // see INIT_WAVEFORMATEX_GUID macro
- union WAVEFMT u;
- u.extensible = &wformat;
-
MP_VERBOSE(ao, "Trying passthrough for %s...\n", af_fmt_to_str(ao->format));
HRESULT hr = IAudioClient_IsFormatSupported(state->pAudioClient,
state->share_mode,
- u.ex, NULL);
+ &wformat.Format, NULL);
if (!FAILED(hr)) {
ao->format = ao->format;
state->format = wformat;