Le 26/08/2011 14:41, Martin Hamant a écrit :
>
> I was totally far from it.
> Found the trick !
>
>
>     x = insert_metadata(s0)
>     insert = fst(x)
>     s = snd(x)
>
>     # A reference to the latest metadata
>     latest_meta = ref []
>
>     # A function to update metadata
>     def update_meta() =
>       data = http.get("bla/titles")
>        m = [("title", snd(data))] # <= this is the right type of m !!
>       if m != !latest_meta then
>         latest_meta := m
>         insert(m)
>         print("new metadata !")
>       end
>       # Restart in 10. seconds
>       10.
>     end
>
>     # Start polling now
>     add_timeout(0., update_meta)
>
> :D

Now... I have to put all of this into a conditional :)
I was thinking of:


     s0 =
     if source_device == "pulse" then
           input.pulseaudio(client='#{stream_name}')
     else
         input.alsa(device="#{source_device}")
     end

     s =
     if stream_metasource != "disabled" then

         # Attach metadata insertion hooks
         x = insert_metadata(s0)
         insert = fst(x)
         s = snd(x)

         # A reference to the latest metadata
         latest_meta = ref []
         #list.append(["coucou"], !latest_meta)

         # A function to update metadata
         def update_meta() =
           data = http.get("http://martin-virtualbox/titles";)
           m = [("title", snd(data))]
           print(m)
           if m != !latest_meta then
             latest_meta := m
             insert(m)
             print("new metadata !")
           end
           # Restart in 10. seconds
           10.
         end

         # Start polling now
         add_timeout(0., update_meta)
         s
     else
         s0
     end

(...)

   # The output
   output = out(id="#{stream_id}", host="#{stream_host}", 
port=int_of_string("#{stream_port}"), password="#{stream_password}", 
genre="#{stream_genre}", url="#{stream_url}", s)


The problem is the iteration part where I return "s",  else s0 ... which 
leads to the error:
   this value has type
     (...)->source(_)
   but it should be a subtype of
     (...)->active_source(_)

Am I close to it ?

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to