Changeset 6689

Show
Ignore:
Timestamp:
06/25/09 10:51:20 (14 months ago)
Author:
dbaelde
Message:

Add on_noise handler to on_blank(), called when blank ends. (BTW, contrary to what I said on the mailing list, there was no technical problem with sf.net this morning. However, the testing version of libneon in Debian is broken, I had to upgrade it to unstable.)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/liquidsoap/src/operators/noblank.ml

    r6527 r6689  
    5454end 
    5555 
    56 class on_blank ~length ~threshold handler source = 
     56class on_blank ~length ~threshold ~on_blank ~on_noise source = 
    5757object (self) 
    5858  inherit operator [source] 
     
    7575      if AFrame.is_partial ab || p0 > 0 then blank_len <- 0 else begin 
    7676        self#check_blank ab p0 ; 
    77         if blank_len <= length then 
    78           in_blank <- false 
    79         else 
     77        if blank_len <= length then begin 
     78          if in_blank then begin 
     79            ignore (Lang.apply on_noise []) ; 
     80            in_blank <- false 
     81          end 
     82        end else 
    8083          if not in_blank then begin 
    8184            in_blank <- true ; 
    82             ignore (Lang.apply handler []) 
     85            ignore (Lang.apply on_blank []) 
    8386          end 
    8487      end 
     
    232235    ~category:Lang.TrackProcessing 
    233236    ~descr:"Calls a given handler when detecting a blank." 
    234     (("",Lang.fun_t [] Lang.unit_t, None, None)::proto) 
    235     (fun p _ -> 
    236        let f = Lang.assoc "" 1 p in 
     237    (("", Lang.fun_t [] Lang.unit_t, None, 
     238      Some "Handler called when blank is detected."):: 
     239     ("on_noise",Lang.fun_t [] Lang.unit_t, 
     240      Some (Lang.val_cst_fun [] Lang.unit), 
     241      Some "Handler called when noise is detected."):: 
     242     proto) 
     243    (fun p _ -> 
     244       let on_blank = Lang.assoc "" 1 p in 
     245       let on_noise = Lang.assoc "on_noise" 1 p in 
    237246       let p = List.remove_assoc "" p in 
    238247       let length,threshold,s = extract p in 
    239          new on_blank ~length ~threshold f s) ; 
     248         new on_blank ~length ~threshold ~on_blank ~on_noise s) ; 
    240249  Lang.add_operator "skip_blank" 
    241250    ~category:Lang.TrackProcessing