Liquidsoap Underruns
  • Hi folks, I've been getting a lot of underruns and stuttering lately.
    When I check liquidsoap I get the following output - 

    sudo airtime-log -t liquidsoap

    johngough@johngough-desktop:~$ sudo airtime-log -t liquidsoap
    Tail liquidsoap log2013/02/06 12:46:15 [alsa_out(default):2] Trying to recover..
    2013/02/06 12:46:15 [alsa_out(default):2] Underrun!
    2013/02/06 12:46:15 [alsa_out(default):2] Trying to recover..
    2013/02/06 12:46:15 [alsa_out(default):2] Underrun!
    2013/02/06 12:46:15 [alsa_out(default):2] Trying to recover..
    2013/02/06 12:46:15 [switch_5401:3] Switch to cross_5396.
    2013/02/06 12:46:15 [default_switch:3] Switch to switch_5401 with transition.
    2013/02/06 12:46:15 [alsa_out(default):2] Underrun!
    2013/02/06 12:46:15 [lang:3] transition called...

    when I run airtime-check-system

    johngough@johngough-desktop:~$ sudo airtime-check-system 
    AIRTIME_SERVER_RESPONDING      = OK
    KERNEL_VERSION                 = 2.6.32-45-generic-pae
    MACHINE_ARCHITECTURE           = i686
    TOTAL_MEMORY_MBYTES            = 4120692
    TOTAL_SWAP_MBYTES              = UNKNOWN
    AIRTIME_VERSION                = 2.2.1
    OS                             = Ubuntu 10.04.4 LTS i686
    CPU                            = AMD Athlon(tm) 64 X2 Dual Core Processor 4000+
    WEB_SERVER                     = Apache/2.2.14 (Ubuntu)
    PLAYOUT_ENGINE_PROCESS_ID      = 11706
    PLAYOUT_ENGINE_RUNNING_SECONDS = 227
    PLAYOUT_ENGINE_MEM_PERC        = 0.2%
    PLAYOUT_ENGINE_CPU_PERC        = 0.0%
    LIQUIDSOAP_PROCESS_ID          = 12549
    LIQUIDSOAP_RUNNING_SECONDS     = 39
    LIQUIDSOAP_MEM_PERC            = 0.6%
    LIQUIDSOAP_CPU_PERC            = 37.9%
    MEDIA_MONITOR_PROCESS_ID       = 1448
    MEDIA_MONITOR_RUNNING_SECONDS  = 2570
    MEDIA_MONITOR_MEM_PERC         = 0.2%
    MEDIA_MONITOR_CPU_PERC         = 0.0%
    RABBITMQ_PROCESS_ID            = 1543
    RABBITMQ_RUNNING_SECONDS       = 2568
    RABBITMQ_MEM_PERC              = 0.3%
    RABBITMQ_CPU_PERC              = 0.0%
    -- Your installation of Airtime looks OK!
     
    Any thoughts most welcome. This mainly happens when grabbing webstreams but it has also happened when just playing scheduled audio. I ran the test tone to see if its my soundcard but the tone sounded fine.

    Cheers
    John
    Post edited by johngough at 2013-02-06 13:21:57
  • 21 Comments sorted by
  • ok so all other audio is playing fine on my machine its just liquidsoap thats choppy.

    I think it might be simply a matter of changing the buffer size in liquidsoap but I can't locate the config file for liquidsoap. 


  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    I think no
    send your airtime logs

    and perhaps try to upgrade your installation with 12.04
  • Try using AO instead of alsa in your system Stream Setting's page.
    On Feb 7, 2013 4:27 AM, "Albert FR"
    wrote:

    > I think no
    > send your airtime logs
    >
    > and perhaps try to upgrade your installation with 12.04
    >
    >
    Airtime Pro Hosting: http://airtime.pro
  • HI guys I've tried all of the sound system options and no joy. I'm going to upload to 12.0.4 but I fear thats not the issue as I've had similiar issues on another 12.0.4 box recently too. 

    I've attached my logs. Hope you guys can help. Cheers
    John
  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    how did you try to install airtime ?
  • This is an old install it's been working fine for months. Installed via the Automated Install method and have been updating using synaptic ever since.
  • Hi guys, I'm having this problem now on two servers. Any help most welcome as I'm really struggling to fix the issue. Everything is fine with Alsa all other apps play fine.

    I've attached liquidsoap log for second machine, I am running 12.04 and Airtime 2.2.1


  • By chance, are you running on a virtual server?
  • Hey Roger. Nope neither and both are in the real World.
    J
  • Hey! How long are your playlists these days versus when you started off? Maybe you're bumping into this?
  • Hi Roger, no all playlists and shows are no more than an hour or two long.
    Thanks for the reply though
    J
  • Hi,

    I'm struggling with this same problem with Airtime 2.5.1 on Ubuntu 12.04.

    I am setting up Airtime for a community radio station in the Highlands of Scotland so that they can go 24 hours a day. Airtime seems perfect except for this underrun issue which causes the sound output via Alsa to stutter twice at the beginning of every track.

    For me it only happens when I also stream MP3 to icecast. If I switch off the MP3 stream or change it to Ogg Vorbis the Alsa output is smooth and glitch free.

    Unfortunately I need both Alsa output for FM and an MP3 stream for the internet (Ogg Vorbis is not compatible with Pure wifi radios)

    Has anybody got a solution? I can't use Airtime with this issue and I'm running out of time.

    Thanks

    Marcus
  • Please read my last comment on why not to post in older post.

    And now lets see if we can get to the bottom of this
    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • Are you running pulseaudio and alsa on the same machine?
    That is are you using the same machine for web browsing etc,that you use for Airtime?
    Lets disable pulseaudio

    pico /etc/pulse/client.conf
    Then and change the line: ; autospawn = yes to autospawn = no
    yes is default so you might just have to put autospawn = no (watch for that ;)

    Now we need to kill and running instances of Pulse Audio with:

    killall pulseaudio

     (restart the machine does this too but we have some more fixing so not now)

    After that run

    ps -C pulseaudio

    to check if pulseaudio is still running.  If you do not get back something similar to:

    PID TTY          TIME CMD
    17065 ?        00:00:02 pulseaudio

    Then pulse audio is still running, however if you get back:

    PID TTY          TIME CMD


    without any information its dead and gone

    If you want a volume control then install gnome alsamixer

    There are many tutorial which suggest purge or remove pulse audio but since 12.04,the default mixer(sound server) is pulse audio and its wrap into your browser and many other application,so if you remove or purge pulse audio,then not even your browser might work properly.

    Should you remove pulse audio reinstall it and follow the procedure above

    You can find a lovely read up here

    And look at Step 1.

    Next the liquidsoap fixed

    Post edited by Voisses Tech at 2014-02-20 23:19:15
    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • Now run the following command as a regular user (not root or sudo)

    liquidsoap 'output.alsa(bufferize = false,
                            input.alsa(bufferize = false))'


    You should get something like this

    2014/02/20 22:21:41 [alsa_out(default):3] Samplefreq=44100Hz, Bufsize=1764B, Frame=4B, Periods=55
    2014/02/20 22:21:41 [threads:3] Created thread "wallclock_alsa" (1 total).
    2014/02/20 22:21:41 [clock.wallclock_alsa:3] Streaming loop starts, synchronized by active sources.
    2014/02/20 22:21:41 [alsa_out(default):2] Underrun! You may minimize them by increasing the buffer size.
    2014/02/20 22:21:41 [alsa_out(default):2] Trying to recover..
    2014/02/20 22:21:41 [alsa_out(default):2] Underrun! You may minimize them by increasing the buffer size.
    2014/02/20 22:21:41 [alsa_out(default):2] Trying to recover..
    2014/02/20 22:22:01 [alsa_out(default):2] Underrun! You may minimize them by increasing the buffer size.
    2014/02/20 22:22:01 [alsa_out(default):2] Trying to recover..


    notice the line which tells you about  the
    Sample frequency,buffer size etc

    Lets fixed that

    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • These are the values you will now put in your liquidsoap

    Samplefreq=44100Hz,     in liquidsoap this is called  frame.samplerate
     Bufsize=1764B,             in liquidsoap this is called  frame.size
     Frame=4B,                    leave these alone no need for tweaking
    Periods=55                    leave these alone no need for tweaking

    I divide my buffer size by 4  (1764/4 =441) and start with 1/2 the size of the recommended buffersize (2x441) =882.

    Why i divide it by 4 is that the buffersize should be multiple of the recommended (1764).

    If you are not too good at maths just divide it into two and start with that number (its for tweaking until you reach a sweet spot.) there is no hard and fast rule here.

    Now edit your liquidsoap ls_script and put this at the top in the "set" declaration section

    # for Alsa
    set("frame.size",800)
    set("decoding.buffer_length", 20.)
    set("frame.channels", 2)
    set("frame.samplerate", 44100)

    now tweak away,nobody can give you the exact values so just increase or decrease the value of the size and buffer lenght seperately until when you run the above command you see the following


    2014/02/20 22:46:57 [alsa_in(default):3] Samplefreq=44100Hz, Bufsize=1764B, Frame=4B, Periods=55
    2014/02/20 22:46:57 [alsa_out(default):3] Using ALSA 1.0.25.
    2014/02/20 22:46:57 [alsa_out(default):2] Falling back on interleaved S16LE
    2014/02/20 22:46:57 [alsa_out(default):3] Samplefreq=44100Hz, Bufsize=1764B, Frame=4B, Periods=55
    2014/02/20 22:46:57 [threads:3] Created thread "wallclock_alsa" (1 total).
    2014/02/20 22:46:57 [clock.wallclock_alsa:3] Streaming loop starts, synchronized by active sources.


    No underruns.
     but if you were paying attention and have not fall asleep,then you will see that my frame size is 800 and not 882

    So expect a line like this if you use none multiple of the recommended

    2014/02/20 22:46:57 [frame:3] Frame size must be a multiple of 1764 ticks = 1764 audio samples = 1 video samples.


    • Nobody can guarantee you the settings for your card ,All soundcard differs by vendor even two same card can differ (not identical twins). I think that's why pulse audio came about
    • If you do not know how to modify an ls_scipt then read the first part of this tutorial
    • IMHO,I think the sound output was design for monitoring,but if you get it to work with the above,it really sound excellent.
    • Remember you do not have to restart your LS until you get that sweet spot.



    Good luck


    Ps. I give you the broad parameters to check and based on @marcus gregory comments below


    If you have a 44100 card (the default) you do not need to put in the ls_script,If you have a 48000 then include

    Most internal cards comes with an internal clock already set, if you do not need to set buffersize you do not. basically you just have to tweak to get there.

    Only read This is you have special Hardware sound cards.( not internals or any device that your OS recognizes)

    Just a note,Servers are never comes with idea that you put in a sound card,If for any reason you install a sound card After your OS installation , and you get this

    Error when starting alsa_in(default): Failure("Error while setting open_pcm: No such file or directory")!

    on Both the input and output,notice I said both then worst case your soundcard might not be properly install.

    Ubuntu put the default card already and in most case it will be solve but the correct thing to do is in a terminal type

    aplay -l

    if no default card is set,You've set your audio device as "default"and you have to defined a default device in your .asoundrc configuration.

    the normal thing to do is set this parameter in the .asoundrc configuration.

    defaults.pcm.card 0
    defaults.pcm.device 0
    defaults.ctl.card 0

    and look through the modprobe configuration

    A good reading to customize special hardware sound cards are found in the gentoo tutorials

    Please read the above carefully

    Watch

    Die Hard: With a Vengeance (1995)

    To see how I got my fuzzy maths



    Post edited by Voisses Tech at 2014-02-21 09:47:59
    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • How to modify your ls_script

    Key things to note.

        back up your original ls_script before any modification make two backup if you can mybackup and mynextbackup

              sudo cp /usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq  /usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq.mybackup

        to get to  your script


     sudo pico /usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq


        then after every modification always see if your script are ok issue the following command.


    sudo /usr/lib/airtime/pypo/bin/airtime-liquidsoap  /usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq
    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • An Important Note to All

    Please always use (create) a new thread,and then make reference to the older post,no matter how your problem seems similar to the old post.

    f.e.

    New Topic    I cannot connect to Airtime
    Body         In  http://forum.sourcefabric.org/discussion/xxxxx/mixxx not connected,
                 I am having now a similar problem,please can you help


    The Reason why I ask this is.

    •     On mobile devices it creates problem for me to have to scroll to find your problem
    •     Sometimes your problem are unique to you and its best express by your own experience
    •      Most times the old problem might have been solved and therefore it may no longer be an issue


    Thanks
    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • Hi Voisses Tech,

    Thanks for your help! 

    Pulse Audio is not installed. I'm running Ubunbtu server and the machine is dedicated to Airtime.

    The output from "liquidsoap 'output.alsa(bufferize = false,input.alsa(bufferize = false))'" is as follows:


    feralkid@Airtime:~$ liquidsoap 'output.alsa(bufferize = false,input.alsa(bufferize = false))'
    2014/02/21 09:44:19 >>> LOG START
    2014/02/21 09:44:19 [protocols.external:3] Found "/usr/bin/wget".
    2014/02/21 09:44:19 [main:3] Liquidsoap 1.1.1+scm (git://github.com/savonet/liquidsoap.git@616e31bb1c41b3c5424b5395c21d524ea4e61164:20130515:145140)
    2014/02/21 09:44:19 [main:3] Using: graphics=[distributed with Ocaml] pcre=6.2.3 dtools=0.3.1 duppy=0.5.1 duppy.syntax=0.5.1 cry=0.2.2 mm=0.2.1 xmlplaylist=0.1.3 ogg=0.4.5 vorbis=0.6.1 opus=0.1.0 mad=0.4.4 flac=0.1.1 flac.ogg=0.1.1 dynlink=[distributed with Ocaml] lame=0.3.2 voaacenc=0.1.0 alsa=0.2.1 ao=0.2.0 taglib=0.3.1 camomile=0.8.3 faad=0.3.2 portaudio=0.2.0 pulseaudio=0.1.2 ladspa=0.1.4 camlimages=4.0.0
    2014/02/21 09:44:19 [main:2]
    2014/02/21 09:44:19 [main:2] DISCLAIMER: This version of Liquidsoap has been
    2014/02/21 09:44:19 [main:2] compiled from a snapshot of the development code.
    2014/02/21 09:44:19 [main:2] As such, it should not be used in production
    2014/02/21 09:44:19 [main:2] unless you know what you are doing!
    2014/02/21 09:44:19 [main:2]
    2014/02/21 09:44:19 [main:2] We are, however, very interested in any feedback
    2014/02/21 09:44:19 [main:2] about our development code and committed to fix
    2014/02/21 09:44:19 [main:2] issues as soon as possible.
    2014/02/21 09:44:19 [main:2]
    2014/02/21 09:44:19 [main:2] If you are interested in collaborating to
    2014/02/21 09:44:19 [main:2] the development of Liquidsoap, feel free to
    2014/02/21 09:44:19 [main:2] drop us a mail at <savonet-devl@lists.sf.net>
    2014/02/21 09:44:19 [main:2] or to join the #savonet IRC channel on Freenode.
    2014/02/21 09:44:19 [main:2]
    2014/02/21 09:44:19 [main:2] Please send any bug report or feature request
    2014/02/21 09:44:19 [main:2] at <https://github.com/savonet/liquidsoap/issues>.
    2014/02/21 09:44:19 [main:2]
    2014/02/21 09:44:19 [main:2] We hope you enjoy this snapshot build of Liquidsoap!
    2014/02/21 09:44:19 [main:2]
    2014/02/21 09:44:19 [dynamic.loader:3] Could not find dynamic module for aacplus encoder.
    2014/02/21 09:44:19 [dynamic.loader:2] Could not load plugins in directory /usr/local/lib/liquidsoap/scm/plugins.
    2014/02/21 09:44:19 [frame:3] Using 44100Hz audio, 25Hz video, 44100Hz master.
    2014/02/21 09:44:19 [frame:3] Frame size must be a multiple of 1764 ticks = 1764 audio samples = 1 video samples.
    2014/02/21 09:44:19 [frame:3] Targetting 'frame.duration': 0.04s = 1764 audio samples = 1764 ticks.
    2014/02/21 09:44:19 [frame:3] Frames last 0.04s = 1764 audio samples = 1 video samples = 1764 ticks.
    2014/02/21 09:44:19 [threads:3] Created thread "generic queue #1".
    2014/02/21 09:44:19 [threads:3] Created thread "generic queue #2".
    2014/02/21 09:44:19 [alsa_in(default):3] Using ALSA 1.0.25.
    2014/02/21 09:44:19 [clock.wallclock_alsa:2] Error when starting alsa_in(default): Failure("Error while setting open_pcm: No such file or directory")!
    2014/02/21 09:44:19 [clock.wallclock_alsa:3] Raised at file "pervasives.ml", line 22, characters 22-33
    2014/02/21 09:44:19 [alsa_in(default):1] Got ill-balanced activations (from alsa_in(default))!
    2014/02/21 09:44:19 [clock:2] Error when leaving output alsa_in(default): File "source.ml", line 403, characters 10-16: Assertion failed!
    2014/02/21 09:44:19 [alsa_in(default):3] Using ALSA 1.0.25.
    2014/02/21 09:44:19 [clock.wallclock_alsa:2] Error when starting alsa_out(default): Failure("Error while setting open_pcm: No such file or directory")!
    2014/02/21 09:44:19 [clock.wallclock_alsa:3] Raised at file "pervasives.ml", line 22, characters 22-33
    2014/02/21 09:44:19 [alsa_out(default):1] Got ill-balanced activations (from alsa_out(default))!
    2014/02/21 09:44:19 [clock:2] Error when leaving output alsa_out(default): File "source.ml", line 403, characters 10-16: Assertion failed!
    2014/02/21 09:44:19 [main:3] Shutdown started!
    2014/02/21 09:44:19 [main:3] Waiting for threads to terminate...
    2014/02/21 09:44:19 [main:3] Cleaning downloaded files...
    2014/02/21 09:44:19 [main:3] Freeing memory...
    2014/02/21 09:44:19 >>> LOG END

    I have some Alsa errors showing here. What should I check?


    Thanks

    Marcus
  • Hi,

    Thanks Voisses Tech. Your comments put me on the right track.

    In the end all I needed was to add:

    set("alsa.buffer_length",25)

    to ls_script.ls

    Sound from the soundcard is delayed about approx 1 second, but no glitches.

    I'm liking Airtime a lot :)

    Thanks again

    Marcus

  • ok


    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.