From 59a04562b1d72cb6aaddb88332e26b599f30c14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Sat, 24 Mar 2018 03:30:51 +0200 Subject: ao_opensles: re-flow interface/configuration retrieval This manages to make the code more readable. Thanks to MakeGho@IRCnet for the snippet on which this was based. --- audio/out/ao_opensles.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'audio') diff --git a/audio/out/ao_opensles.c b/audio/out/ao_opensles.c index f54f4db035..b03aa8a555 100644 --- a/audio/out/ao_opensles.c +++ b/audio/out/ao_opensles.c @@ -205,16 +205,25 @@ static int init(struct ao *ao) SLAndroidConfigurationItf android_config; SLuint32 audio_latency = 0, value_size = sizeof(SLuint32); - SLint32 result = (*p->player)->GetInterface(p->player, - SL_IID_ANDROIDCONFIGURATION, &android_config); - if (result == SL_RESULT_SUCCESS) { - result = (*android_config)->GetConfiguration(android_config, + + SLint32 get_interface_result = (*p->player)->GetInterface( + p->player, + SL_IID_ANDROIDCONFIGURATION, + &android_config + ); + + if (get_interface_result == SL_RESULT_SUCCESS) { + SLint32 get_configuration_result = (*android_config)->GetConfiguration( + android_config, (const SLchar *)"androidGetAudioLatency", - &value_size, &audio_latency); - } - if (result == SL_RESULT_SUCCESS) { - p->audio_latency = (double)audio_latency / 1000.0; - MP_INFO(ao, "Device latency is %f\n", p->audio_latency); + &value_size, + &audio_latency + ); + + if (get_configuration_result == SL_RESULT_SUCCESS) { + p->audio_latency = (double)audio_latency / 1000.0; + MP_INFO(ao, "Device latency is %f\n", p->audio_latency); + } } return 1; -- cgit v1.2.3