2012/1/8 Alban Peignier <[email protected]>: > Hi all, Hi Alban!
> We're integrating a new tool FileScheduler [0] with LiquidSoap. > > To make short, FileScheduler can choose in a directory the "next" > content to be played (by LiquidSoap in this case). This part works fine > (with a simple request.dynamic/request.create). > > FileScheduler can also manage contents with a "forced time". For > example, to start at exactly 14h00 a given file. This "forced" content > must skip the current content in LiquidSoap. > > The FileScheduler usage is very simple : > > file-scheduler <directory> next : returns the next file > file-scheduler <directory> forced_next : returns nothing or the "forced" > file > > This small LiquidSoap script integrates FileScheduler : > https://gist.github.com/1577924 All of this sounds great! > This "forced_next" part is more difficult to integrate. We're using a > fallback.skip with an "conditional" switch. But I have some difficulties > to make an efficient forced_change predicate > (https://gist.github.com/1577924#L10) [1]. > > As the switch checks several times per second the predicate, the "if 0s > then" condition isn't enough strict and the external check is performed > several times in the same second. It's very expensive (mainly because > we're using this script on our small PlayBoxes). > > I tried to save the last gettimeofday in variable/list/... to skip > checks in the same second ... but I didn't found a way to "store" this > value with LiquidSoap language/API. > > There are other solutions to make a single forced_next at each 0s like > using a more complex switch, etc. But I prefer to have feedback from > real LiquidSoap users :) Indeed, checking for 0s can lead to these types of errors. What I would advise is to setup a guard to prevent this from happening. Something on these lines: # Prevents subsequent check to return true within in the same second. guard = ref false def check_zero_seconds() = # If 0s and not guarded, return true if 0s and not !guard then guard := true true # Otherwise.. else # If we're no longer in the same second, # reinitiate the guard if not 0s then guard := false end # Return false false end end I have not tested this code but I believe it should be correct (or almost). Let me know if that's enough for you of if you wish to have more detailed explanations. Romain ------------------------------------------------------------------------------ Write once. Port to many. Get the SDK and tools to simplify cross-platform app development. Create new or port existing apps to sell to consumers worldwide. Explore the Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join http://p.sf.net/sfu/intel-appdev _______________________________________________ Savonet-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/savonet-users
