Hi,

There might almost be a way to do what you want, using on_end as you
suspected. The trick would be to use on_end to set a flag, that
triggers the switching from the normal source to a version wrapper in
eat blank. To clarify, I'm thinking of something like:

source = ...
flag = ref false
set_flag = fun (_,_) -> flag := true
unset_flag = fun (_) -> flag := false
source = on_end(5.,set_flag,on_track(unset_flag,source))
source = switch([({!flag},eat_blank(source)),({true},source)])

Unfortunately this should be forbidden for clock inconsistency
reasons: using eat_blank forces us to protect the source in a
dedicated clock (owned by eat_blank) to avoid that somebody tries to
access the source while we eat out silence. This protection is
incompatible with using the source directly in the switch.

Therefore Romain's proposal makes more sense. It seems a little
ad-hoc, though... How about using on_blank to issue a source.skip if
source.remaining is small enough? More experimentation is needed.

In the meantime let me explain that error (to compensate the
complexity of the above example):

2011/6/15 Kerozen <[email protected]>:
> output = on_end(5.,[eat_blank(source)], source)
> But I don't know if on_end works that way, and can't figure out a working
> syntax for on_end. If I try it the way described above, I get the following
> error :
> At line 61, char 18-19:
>   this value has type
>     float
>   but it should be a subtype of
>     (_,_)->_

The on_end function has type
(?id:string,?delay:float,
 ((float,[(string*string)])->unit),source('a))->
source('a)

This means it takes optional parameters named "id" and "delay", and
two mandatory unnamed parameters: the handler function and the source.
The handler is expected to have type (float,[(string*string)])->source
which means that it should take a float (the remaining time) and a
list of string pairs (the current metadata).

In your code you passed 5. as first unnamed parameter, but liquidsoap
expects the function there. So it tells you that this is a float but
it should be a function. In more details (_,_)->_ is the general shape
of the type of functions that take two parameters. You can generally
ignore "a subtype of" and read "it should be of type".

An example of subtyping for the sake of completeness: source(1,0,0) is
a subtype of source(*,0,0), meaning that mono sources can be viewed
(and used) as sources having an arbitrary number of audio channels
(the two zeros stand for video and midi). Because of that we
distinguish between identical types and subtypes (which can be thought
of as an inclusion relation).

Hope this helps,
-- 
David

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to