diff options
author | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2013-07-21 13:11:44 -0300 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-07-22 02:42:38 +0200 |
commit | dcf38e01905c40c9fd6dd603320395e808472a04 (patch) | |
tree | 602d7a955f9bf750496f88ef485202cd2be0baf8 /audio | |
parent | bcb398ddb42b7327f47897cb7884b50d275de58d (diff) | |
download | mpv-dcf38e01905c40c9fd6dd603320395e808472a04.tar.bz2 mpv-dcf38e01905c40c9fd6dd603320395e808472a04.tar.xz |
ao_wasapi: Support S/PDIF passthrough
Entirely untested as this troper has no S/PDIF hardware.
Refuses trying any other format if we can't use passthrough, or we would
end up sending white noise at the user.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/out/ao_wasapi.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c index 03a7c767a1..38d1637fb4 100644 --- a/audio/out/ao_wasapi.c +++ b/audio/out/ao_wasapi.c @@ -392,10 +392,55 @@ exit_label: return ret; } +static int try_passthrough(struct wasapi_state *state, + struct ao *const ao) +{ + WAVEFORMATEXTENSIBLE wformat = { + .Format = { + .wFormatTag = WAVE_FORMAT_EXTENSIBLE, + .nChannels = ao->channels.num, + .nSamplesPerSec = ao->samplerate * 4, + .nAvgBytesPerSec = (ao->samplerate * 4) * (ao->channels.num * 2), + .nBlockAlign = ao->channels.num * 2, + .wBitsPerSample = 16, + .cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX), + }, + .Samples.wValidBitsPerSample = 16, + .dwChannelMask = mp_chmap_to_waveext(&ao->channels), + .SubFormat = local_KSDATAFORMAT_SUBTYPE_PCM, + }; + wformat.SubFormat.Data1 = WAVE_FORMAT_DOLBY_AC3_SPDIF; // see INIT_WAVEFORMATEX_GUID macro + + union WAVEFMT u; + u.extensible = &wformat; + + HRESULT hr = IAudioClient_IsFormatSupported(state->pAudioClient, + state->share_mode, + u.ex, NULL); + if (!FAILED(hr)) { + state->format = wformat; + return 1; + } + return 0; +} + static int find_formats(struct ao *const ao) { struct wasapi_state *state = (struct wasapi_state *)ao->priv; + if (AF_FORMAT_IS_IEC61937(ao->format)) { + if (try_passthrough(state, ao)) + return 0; + + EnterCriticalSection(&state->print_lock); + mp_msg(MSGT_AO, MSGL_ERR, "ao-wasapi: couldn't use passthrough!"); + if (!state->opt_exclusive) + mp_msg(MSGT_AO, MSGL_ERR, " (try exclusive mode)"); + mp_msg(MSGT_AO, MSGL_ERR, "\n"); + LeaveCriticalSection(&state->print_lock); + return -1; + } + /* See if the format works as-is */ int bits = af_fmt2bits(ao->format); /* don't try 8bits -- there are various 8bit modes other than PCM (*-law et al); |