mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
ao_wasapi: log return code when probing audio formats
We log a large number of formats, but we rarely log the result of the probing. Change this. The logic in try_format_exclusive() changes slightly, but should be equivalent. EXIT_ON_ERROR() checks for FAILED(), which should be exclusive to SUCCEEDED().
This commit is contained in:
@@ -50,6 +50,10 @@ void wasapi_change_uninit(struct ao* ao);
|
|||||||
#define SAFE_RELEASE(unk, release) \
|
#define SAFE_RELEASE(unk, release) \
|
||||||
do { if ((unk) != NULL) { release; (unk) = NULL; } } while(0)
|
do { if ((unk) != NULL) { release; (unk) = NULL; } } while(0)
|
||||||
|
|
||||||
|
#define mp_format_res_str(hres) \
|
||||||
|
(SUCCEEDED(hres) ? "ok" : ((hres) == AUDCLNT_E_UNSUPPORTED_FORMAT) \
|
||||||
|
? "unsupported" : mp_HRESULT_to_str(hres))
|
||||||
|
|
||||||
enum wasapi_thread_state {
|
enum wasapi_thread_state {
|
||||||
WASAPI_THREAD_FEED = 0,
|
WASAPI_THREAD_FEED = 0,
|
||||||
WASAPI_THREAD_RESUME,
|
WASAPI_THREAD_RESUME,
|
||||||
|
|||||||
@@ -289,18 +289,12 @@ static bool set_ao_format(struct ao *ao, WAVEFORMATEX *wf,
|
|||||||
static bool try_format_exclusive(struct ao *ao, WAVEFORMATEXTENSIBLE *wformat)
|
static bool try_format_exclusive(struct ao *ao, WAVEFORMATEXTENSIBLE *wformat)
|
||||||
{
|
{
|
||||||
struct wasapi_state *state = ao->priv;
|
struct wasapi_state *state = ao->priv;
|
||||||
MP_VERBOSE(ao, "Trying %s (exclusive)\n",
|
|
||||||
waveformat_to_str(&wformat->Format));
|
|
||||||
HRESULT hr = IAudioClient_IsFormatSupported(state->pAudioClient,
|
HRESULT hr = IAudioClient_IsFormatSupported(state->pAudioClient,
|
||||||
AUDCLNT_SHAREMODE_EXCLUSIVE,
|
AUDCLNT_SHAREMODE_EXCLUSIVE,
|
||||||
&wformat->Format, NULL);
|
&wformat->Format, NULL);
|
||||||
if (hr != AUDCLNT_E_UNSUPPORTED_FORMAT)
|
MP_VERBOSE(ao, "Trying %s (exclusive) -> %s\n",
|
||||||
EXIT_ON_ERROR(hr);
|
waveformat_to_str(&wformat->Format), mp_format_res_str(hr));
|
||||||
|
|
||||||
return SUCCEEDED(hr);
|
return SUCCEEDED(hr);
|
||||||
exit_label:
|
|
||||||
MP_ERR(state, "Error testing exclusive format: %s\n", mp_HRESULT_to_str(hr));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This works like try_format_exclusive(), but will try to fallback to the AC3
|
// This works like try_format_exclusive(), but will try to fallback to the AC3
|
||||||
@@ -393,11 +387,8 @@ static bool search_channels(struct ao *ao, WAVEFORMATEXTENSIBLE *wformat)
|
|||||||
for (int j = 0; channel_layouts[j]; j++) {
|
for (int j = 0; channel_layouts[j]; j++) {
|
||||||
mp_chmap_from_str(&entry, bstr0(channel_layouts[j]));
|
mp_chmap_from_str(&entry, bstr0(channel_layouts[j]));
|
||||||
if (!wformat->Format.nSamplesPerSec) {
|
if (!wformat->Format.nSamplesPerSec) {
|
||||||
if (search_samplerates(ao, wformat, &entry)) {
|
if (search_samplerates(ao, wformat, &entry))
|
||||||
mp_chmap_sel_add_map(&chmap_sel, &entry);
|
mp_chmap_sel_add_map(&chmap_sel, &entry);
|
||||||
MP_VERBOSE(ao, "%s is supported\n",
|
|
||||||
waveformat_to_str(&wformat->Format));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
change_waveformat_channels(wformat, &entry);
|
change_waveformat_channels(wformat, &entry);
|
||||||
if (try_format_exclusive(ao, wformat))
|
if (try_format_exclusive(ao, wformat))
|
||||||
@@ -442,11 +433,12 @@ static bool find_formats_shared(struct ao *ao)
|
|||||||
WAVEFORMATEXTENSIBLE wformat;
|
WAVEFORMATEXTENSIBLE wformat;
|
||||||
set_waveformat_with_ao(&wformat, ao);
|
set_waveformat_with_ao(&wformat, ao);
|
||||||
|
|
||||||
MP_VERBOSE(ao, "Trying %s (shared)\n", waveformat_to_str(&wformat.Format));
|
|
||||||
WAVEFORMATEX *closestMatch;
|
WAVEFORMATEX *closestMatch;
|
||||||
HRESULT hr = IAudioClient_IsFormatSupported(state->pAudioClient,
|
HRESULT hr = IAudioClient_IsFormatSupported(state->pAudioClient,
|
||||||
AUDCLNT_SHAREMODE_SHARED,
|
AUDCLNT_SHAREMODE_SHARED,
|
||||||
&wformat.Format, &closestMatch);
|
&wformat.Format, &closestMatch);
|
||||||
|
MP_VERBOSE(ao, "Trying %s (shared) -> %s\n",
|
||||||
|
waveformat_to_str(&wformat.Format), mp_format_res_str(hr));
|
||||||
if (hr != AUDCLNT_E_UNSUPPORTED_FORMAT)
|
if (hr != AUDCLNT_E_UNSUPPORTED_FORMAT)
|
||||||
EXIT_ON_ERROR(hr);
|
EXIT_ON_ERROR(hr);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user