Hi,

Thanks a lot for your answer.

Your add_timeout is a great idea, I missed this operator...

Anyway, I've set the alsa buffer to 10 and added a fast track for the  
add_timeout code. I also added a clear_metadata and a lag of 1 second  
before the output.  As it was still not resolving the problem, I used  
a dummy on_metadata which was defined as it :

def updateStatus(meta)
        x=1
end

And still with this function, I'm getting the underrun...  Seems that  
it's not our problem here.  A point that should maybe be noted is the  
way metadata are sendt.  The source of the icecast server is also a  
liquidsaop instance running on another computer with an  
insert_metadata operator.  I'm using a net socket to insert the  
metadata on liquidsoap thanks to a python script (running on a third  
computer but it's not the problem here).

Another point that may be interesting is that I'm using an ogg vorbis  
stream running at constant bitrate.




I'm also havin another problem : sometimes we switch to the backup  
playlist for less than 10 seconds without any apparent reason.  (No  
stream loss and no blank)  Could it be due to an empty buffer for the  
http input?

Thanks a lot for your help/ideas/suggestion!!!

ps : I could eventually send the metadata with another way but I would  
really like it to go with the stream for synchronization purpose...
ps2 : here is the new script :

------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# importation
%include "config.liq.aux"


# fonction pratique
def crossfade(cur,next)
  add(id=source.id(next), normalize=false,
          [ sequence([ blank(duration=1.),
                       fade.initial(duration=2.,next)]),
            fade.final(duration=2.,cur) ])
end
def outFade(cur,next)
  add(id=source.id(next), normalize=false,
          [ sequence([ blank(duration=1.),
                       next]),
            fade.final(duration=2.,cur) ])
end
def inFade(cur,next)
  add(id=source.id(next), normalize=false,
          [ sequence([ blank(duration=1.),
                       fade.initial(duration=2.,next)]),
            cur ])
end

#################################
# Huge block here handle metada update on lower priority thread
#################################
update=string.ref("")
getUpdate = fst(update)
setUpdate = snd(update)
def back_updateStatus()
        if getUpdate()!="" then
                system(metaUpdaterCommand^" "^getUpdate()^" &")
                log(getUpdate())
                setUpdate("")
        end
        0.2
end

# Schedule update every 0.2 seconds
add_timeout(fast=false,0.2,back_updateStatus)

# insert new meta
def updateStatus(meta)
        # Script should be fast since it's running in main thread
        # problem : since variable are not implemented, we cannot
        # update a kind of global metadata list.  Since we can
        # use a kind of global string thanks to the string.ref workaround
        # we still have to hande metadata in this main thread and relay the
        # system call alone in a lower priority thread.
        #
        # Note : An faster way could be to only add the interesting tags
        
        
        x = string.ref("")
        # getting the get function of the pair
        get = fst(x)
        # gettint the set function of the pair
        set = snd(x)
        
        def makeArgs(meta)
                # this function concatenate any input string (meta)
                # with the current string of the get function
                def replacer(txt)
                        "<apo/>"
                end
                txt = "<Tag>"^fst(meta)^"="^snd(meta)^"</Tag>"
                txt = string.replace(pattern="'", replacer, txt)
                set("'"^txt^"' "^get())
        end
        list.iter(makeArgs, meta)
        setUpdate(get())
end
#################################

# Structure radio

jingles = playlist.safe(reload=86400, DB^"/safe/jingles/")
playlist = playlist.safe(reload=86400, DB^"/safe/songs/")

#secours = playlist
secours = random(weights=[4, 1], [playlist, jingles])
main = strip_blank(length=15., input.http(id="mainStream", buffer=3.,  
max=5., mainStream))

radio= fallback(transitions = [crossfade, crossfade],  
track_sensitive=false, [main, secours])

# This allow to have several outputs
# useful for using alsa on linux and ao/jack on other platform
# This also add the metaData management for title updates
out = lag(1., clear_metadata(on_metadata(updateStatus, radio)))


# sortie son
%include "out.liq.aux"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Le 07 Jan 2010 à 18:12, David Baelde a écrit :

> Hi Simon,
>
> Your problem is caused by an excessive latency in processing the
> metadata. I don't have much time and many ideas so I'll just ask for
> more details:
> - Did you try to tweak the buffer length, e.g.  
> set("alsa.buffer_length",10)?
> - Seems stupid, but do we still have this problem with a dummy
> on_metadata hook? by removing only the system() call?
>
> I think the first point should help, because the current default (1,
> at least on SVN) leaves very little room for latency. The second point
> can help fine-tune, detect the cause of latency, and possibly find an
> alternate way (e.g. add_timeout() can be used to launch tasks in a an
> other thread than the main streaming one).
>
> Hope that helps a bit,
> -- 
> David



------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to