Index: src/audio/decode/decode.c =================================================================== --- src/audio/decode/decode.c (revision 9404) +++ src/audio/decode/decode.c (working copy) @@ -1005,6 +1005,7 @@ static int decode_audio_open(lua_State *L) { struct decode_audio_func *f = NULL; + char *errstr = NULL; if (decode_audio || decode_thread) { /* already initialized */ @@ -1012,33 +1013,42 @@ return 1; } - /* initialise audio output */ + /* initialise audio output - try in order: null, alsa, portaudio */ + /* this allows fallback from alsa to portaudio on systems where this fails - e.g. ubuntu desktop */ + +#ifdef HAVE_NULLAUDIO + f = &decode_null; + if (!f->init(L)) { + errstr = "null audio init failed"; + f = NULL; + } +#endif #ifdef HAVE_LIBASOUND - f = &decode_alsa; + if (!f) { + f = &decode_alsa; + if (!f->init(L)) { + errstr = "alsa audio init failed"; + f = NULL; + } + } #endif #ifdef HAVE_LIBPORTAUDIO if (!f) { f = &decode_portaudio; + if (!f->init(L)) { + errstr = "port audio init failed"; + f = NULL; + } } #endif -#ifdef HAVE_NULLAUDIO - f = &decode_null; -#endif + + /* no audio device available */ if (!f) { - /* no audio support */ lua_pushnil(L); - lua_pushstring(L, "No audio support"); + lua_pushstring(L, errstr ? errstr : "No audio support"); return 2; } - /* audio initialization */ - if (!f->init(L)) { - /* audio init failed */ - lua_pushnil(L); - lua_pushstring(L, "Error in audio init"); - return 2; - } - assert(decode_audio); assert(decode_fifo_buf); Index: src/audio/decode/decode_alsa.c =================================================================== --- src/audio/decode/decode_alsa.c (revision 9404) +++ src/audio/decode/decode_alsa.c (working copy) @@ -276,7 +276,7 @@ lua_pop(L, 2); - return 1; + return playback_pid > 0 ? 1 : 0; }