diff options
authorwm4 <wm4@nowhere>2014-10-31 01:09:53 +0100
committerwm4 <wm4@nowhere>2014-10-31 01:09:53 +0100
commit8607b0c44b60ffe59ab571e896bee498f5098d9b (patch)
parentb17585e636e2ea964d858d7157dcc35e791430c6 (diff)
ao_alsa: don't make snd_pcm_hw_params_set_buffer_time_near() error fatal
Apparently this can "sometimes" return an error. In my opinion, this should never return an error: neither the semantics of the function, nor the ALSA documentation or ALSA sample code seem to indicate that a failure is to be expected. I'm not perfectly sure about this though (I blame ALSA being a weird, big, underdocumented API). Since it causes problems for some users, and since there is really no reason why we should abort on such an error, turn it into a warning. Fixes #1231.
1 files changed, 7 insertions, 1 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 0d078d17fe..31c4ff6831 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -78,6 +78,12 @@ struct priv {
} \
} while (0)
+#define CHECK_ALSA_WARN(message) \
+ do { \
+ if (err < 0) \
+ MP_WARN(ao, "%s: %s\n", (message), snd_strerror(err)); \
+ } while (0)
static float get_delay(struct ao *ao);
static void uninit(struct ao *ao);
@@ -474,7 +480,7 @@ static int init(struct ao *ao)
err = snd_pcm_hw_params_set_buffer_time_near
(p->alsa, alsa_hwparams, &(unsigned int){BUFFER_TIME}, NULL);
- CHECK_ALSA_ERROR("Unable to set buffer time near");
+ CHECK_ALSA_WARN("Unable to set buffer time near");
err = snd_pcm_hw_params_set_periods_near
(p->alsa, alsa_hwparams, &(unsigned int){FRAGCOUNT}, NULL);