From fcfb3c0951b6e2e06e7bf282e867576d8abb00c4 Mon Sep 17 00:00:00 2001 From: Manuel Bachmann Date: Wed, 17 Feb 2016 11:31:59 +0100 Subject: Audio plugin: choose between Pulse/ALSA at runtime If the AFB_AUDIO_OUTPUT environment variable is defined to "Pulse/Alsa", it will try to initialize the given backend (still falling back to Alsa for now). Signed-off-by: Manuel Bachmann --- plugins/audio/audio-api.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'plugins/audio/audio-api.c') diff --git a/plugins/audio/audio-api.c b/plugins/audio/audio-api.c index 4a8d0da1..637f9d03 100644 --- a/plugins/audio/audio-api.c +++ b/plugins/audio/audio-api.c @@ -22,10 +22,18 @@ void _backend_init (const char *name, audioCtxHandleT *ctx) { + char *backend_env = getenv ("AFB_AUDIO_OUTPUT"); + unsigned char res = -1; + # ifdef HAVE_PULSE - if (_pulse_init (name, ctx) < 0) -# endif - _alsa_init (name, ctx); + if (!backend_env || (strcasecmp (backend_env, "Alsa") != 0)) + res = _pulse_init (name, ctx); + if (res < 0) +#endif + res = _alsa_init (name, ctx); + + if (res < 0 && verbose) + fprintf (stderr, "Could not initialize Audio backend\n"); } void _backend_free (audioCtxHandleT *ctx) { -- cgit 1.2.3-korg