Hi, again!

i have solved the problem by rewriting feed method with this code.

method feed socket  =
    self#log#f 3 "Decoding..." ;
    let close () = () in
    let t0 = Unix.gettimeofday () in
    let read len =
      let buf = String.make len ' ' in
      let () =
        let rec wait n =
          let l,_,_ = Unix.select [socket] [] [] 1. in
            if l=[] then begin
              self#log#f 4 "No network activity for %d second(s)." n ;
              
              if n>20 then
              begin
                self#log#f 4 "network activity timeout! disconnecting source" ;
                self#disconnect;
              end
              else
                wait (n+1);
            end
        in wait 1
      in
      let input = Unix.read socket buf 0 len in
      if input<=0 then raise End_of_file ;
      let s = String.sub buf 0 input in
      begin match dump with
        | Some b -> output_string b s
        | None -> ()
      end ;
      begin match logf with
        | Some b ->
            let time = (Unix.gettimeofday () -. t0) /. 60. in
              Printf.fprintf b "%f %d\n%!" time self#length
        | None -> ()
      end ;
      s
    in
    let sink =
      { put = self#put ; read = read ;
        insert_metadata = self#insert_metadata ; close = close }
    in
     begin
      try decoder sink with
        | e -> self#log#f 2 "Feeding stopped: %s" (Printexc.to_string e) ;
               if debug then raise e
     end;
    self#disconnect ;
    try
      Unix.shutdown socket Unix.SHUTDOWN_ALL ;
      Unix.close socket
    with
      | _ -> () 

it works, but instead of comparing n with constant 20 it must be compared with 
max variable that is passed into object constructor.

i don't know how to do this with OCaml. if you can help, please let me know

log now says something like this

=======================
2009/04/01 21:01:30 [mainFallback:3] Switch to playlist with forgetful 
transition.
2009/04/01 21:01:30 [noiseAmp:4] Activations changed: static=[], 
dynamic=[mainFallback:64mp3:64mp3].
2009/04/01 21:01:30 [playlist:4] Activations changed: 
static=[mainFallback:64mp3:64mp3], dynamic=[mainFallback:64mp3:64mp3].
2009/04/01 21:02:11 [ogg.demuxer:4] Reached last page of logical stream b5e45
2009/04/01 21:02:11 [ogg.demuxer:4] Found a ogg logical stream, serial: 81791
2009/04/01 21:02:11 [ogg.demuxer:4] Trying ogg/vorbis format
2009/04/01 21:02:11 [playlist:3] New metadata chunk "? -- 8bit"
2009/04/01 21:02:19 [playlist:4] No network activity for 1 second(s).
<...>
2009/04/01 21:02:27 [playlist:4] No network activity for 9 second(s).
2009/04/01 21:02:28 [playlist:4] End of track.
2009/04/01 21:02:28 [playlist:4] Buffer emptied, starting buffering.
2009/04/01 21:02:28 [mainFallback:3] Switch to noiseAmp with forgetful 
transition.
2009/04/01 21:02:28 [playlist:4] Activations changed: static=[], 
dynamic=[mainFallback:64mp3:64mp3].
2009/04/01 21:02:28 [noiseAmp:4] Activations changed: 
static=[mainFallback:64mp3:64mp3], dynamic=[mainFallback:64mp3:64mp3].
2009/04/01 21:02:28 [playlist:4] No network activity for 10 second(s).
<...>
2009/04/01 21:02:39 [playlist:4] No network activity for 21 second(s).
<here cycle breaks with my pacth>
2009/04/01 21:02:39 [playlist:4] network activity timeout! disconnecting source
2009/04/01 21:02:39 [lang:3] [PLAYLIST-END]: playlist source goes down! 
Switching to noise...
2009/04/01 21:03:09 [playlist:2] Feeding stopped: Unix.Unix_error(2, "read", "")
2009/04/01 21:03:09 [threads:3] Thread "harbor source feeding" exited (1 
remaining).
<now client can take mountpoint again>
2009/04/01 21:04:26 [harbor:3] New client: 109.164.249.ozerki.net
2009/04/01 21:04:26 [harbor:4] Header: CONTENT-TYPE, value: application/ogg.
2009/04/01 21:04:26 [harbor:4] Header: ICE-NAME, value: RadioVKontakte.ru.
2009/04/01 21:04:26 [harbor:4] Header: ICE-URL, value: 
http://radiovkontakte.ru:/table.
2009/04/01 21:04:26 [harbor:4] Header: ICE-GENRE, value: Various.
2009/04/01 21:04:26 [harbor:4] Header: ICE-PUBLIC, value: 1.
2009/04/01 21:04:26 [harbor:4] Header: ICE-BITRATE, value: Quality 3,51.
2009/04/01 21:04:26 [harbor:4] Header: ICE-AUDIO-INFO, value: 
ice-samplerate=44100;ice-quality=3,51;ice-channels=2.
2009/04/01 21:04:26 [harbor:4] Client logged in.
2009/04/01 21:04:26 [harbor:3] SOURCE request on /playlist.ogg.
2009/04/01 21:04:26 [harbor:3] Adding source on mountpoint '/playlist.ogg' with 
type 'application/ogg'.
2009/04/01 21:04:26 [lang:3] [PLAYLIST-START]: playlist source goes up! 
Switching from noise...
2009/04/01 21:04:26 [threads:3] Created thread "harbor source feeding" (2 
total).
2009/04/01 21:04:26 [playlist:3] Decoding...
2009/04/01 21:04:26 [ogg.demuxer:4] Found a ogg logical stream, serial: d24bc
2009/04/01 21:04:26 [ogg.demuxer:4] Trying ogg/vorbis format
2009/04/01 21:04:26 [playlist:3] New metadata chunk "RadioVKontakte.ru -- ?"
2009/04/01 21:04:36 [mainFallback:3] Switch to playlist with forgetful 
transition.
=======================

patch included

01.04.09, 15:49, "Romain Beauxis" <[email protected]>:

>       Hi !
> Le Wednesday 01 April 2009 13:20:26 Romeo, vous avez écrit :
> > seems to go in a loop as the closest events that brings the process out of
> > the loop are socket error or EOF(which means correct end of stream), but
> > not timeout.
> >
> > maybe it will be usefull to set a timeout here that equals to (buffer*2)or
> > (max*2)?
> >
> > i could try it by myself, but OCaml is a new language for me and it can
> > take a time to learn the basics of it...
> Indeed, this loop could be an issue..
> Are you able to comment out this code and report us if this fixes your issue ?
> There is a timeout on the client socket, if your issue is indeed this loop, I 
> will try to understand why the timeout fails.;
> Romain

Attachment: harbor_input.ml
Description: Binary data

------------------------------------------------------------------------------
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to