From 17d72de2ac16ba78d05b2210112fa2c4335cf1f9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 30 Nov 2013 18:56:44 +0100 Subject: ao_alsa: remove unneeded checks If initialization succeeds, p->alsa should always be set. Additional checks are not needed, and also this wasn't even done consistently. --- audio/out/ao_alsa.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 2c6df71cd0..b8de922cb9 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -646,11 +646,6 @@ static int play(struct ao *ao, void **data, int samples, int flags) if (!(flags & AOPLAY_FINAL_CHUNK)) samples = samples / p->outburst * p->outburst; - if (!p->alsa) { - MP_ERR(ao, "Device configuration error."); - return -1; - } - if (samples == 0) return 0; @@ -709,23 +704,20 @@ alsa_error: static float get_delay(struct ao *ao) { struct priv *p = ao->priv; - if (p->alsa) { - snd_pcm_sframes_t delay; - - if (snd_pcm_state(p->alsa) == SND_PCM_STATE_PAUSED) - return p->delay_before_pause; + snd_pcm_sframes_t delay; - if (snd_pcm_delay(p->alsa, &delay) < 0) - return 0; + if (snd_pcm_state(p->alsa) == SND_PCM_STATE_PAUSED) + return p->delay_before_pause; - if (delay < 0) { - /* underrun - move the application pointer forward to catch up */ - snd_pcm_forward(p->alsa, -delay); - delay = 0; - } - return (float)delay / (float)ao->samplerate; - } else + if (snd_pcm_delay(p->alsa, &delay) < 0) return 0; + + if (delay < 0) { + /* underrun - move the application pointer forward to catch up */ + snd_pcm_forward(p->alsa, -delay); + delay = 0; + } + return (float)delay / (float)ao->samplerate; } #define OPT_BASE_STRUCT struct priv -- cgit v1.2.3