Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all warnings. #162

Merged
merged 21 commits into from
May 11, 2014
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ if test "x$enable_optimize" = "xyes" ; then
CFLAGS="$CFLAGS -O3 -march=native -mtune=native"
fi

liquidsoap_ocamlcflags="-ccopt \"\$(CFLAGS)\""
liquidsoap_ocamlcflags="$OCAMLFLAGS -ccopt \"\$(CFLAGS)\""
liquidsoap_ocamllflags="-linkpkg -package unix -package threads -package str -package bigarray"
requires="unix threads str"
if test "$enable_debugging" \!= "no" ; then
Expand Down Expand Up @@ -614,7 +614,7 @@ AC_CHECK_OCAML_BINDING([camomile])

if test -z "$W_CAMOMILE" ; then
if test "x$enable_camomile" = "xno" ; then
echo let recode_tag ?in_enc ?out_enc s = s >> src/configure.ml
echo let recode_tag ?in_enc:_ ?out_enc:_ s = s >> src/configure.ml
else
AC_MSG_ERROR([Camomile provides charset detection and conversions. It is strongly advised to enable those features. If you really don't want this, use --disable-camomile.])
fi
Expand Down Expand Up @@ -725,7 +725,7 @@ let recode_tag ?in_enc ?out_enc s =

let recode_tag =
if env_has "LIQ_DISABLE_CAMOMILE" then
fun ?in_enc ?out_enc s -> s
fun ?in_enc:_ ?out_enc:_ s -> s
else
recode_tag
EOCONF
Expand Down
2 changes: 1 addition & 1 deletion src/analyze/analyze_rms.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*****************************************************************************)

class rms ~kind ~window_length ~update source =
object (self)
object
inherit Source.operator ~name:"rms" kind [source]

method stype = source#stype
Expand Down
3 changes: 1 addition & 2 deletions src/clock.ml
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ end

class self_sync id =
object
inherit wallclock ~sync:true id as super
inherit wallclock ~sync:true id

val mutable blocking_sources = 0
val bs_lock = Mutex.create ()
Expand Down Expand Up @@ -474,7 +474,6 @@ end
* collect. *)
let after_collect_tasks = ref 1
let lock = Mutex.create ()
let cond = Condition.create ()

(** We might not need a default clock, so we use a lazy clock value.
* We don't use Lazy because we need a thread-safe mechanism. *)
Expand Down
5 changes: 2 additions & 3 deletions src/conversions/audio_to_stereo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@

(** Duplicate mono into stereo, drop channels when there are more than two. *)
class basic ~kind source =
object (self)

object
inherit Source.operator kind [source] ~name:"audio_to_stereo"

method stype = source#stype
Expand All @@ -48,7 +47,7 @@ object (self)
let layers = source#get frame ; Frame.get_content_layers frame in
(** Install the final stereo layer, and copy everything to it *)
let dst = Frame.content_of_type frame start stereo in
let rec aux { Frame. content = src ; start = pos ; length = l } =
let aux { Frame. content = src ; start = pos ; length = l } =
if pos >= start then begin
assert (src.Frame.video = [||] && src.Frame.midi = [||]) ;
match src.Frame.audio with
Expand Down
6 changes: 3 additions & 3 deletions src/conversions/drop.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end

let () =
let input = Lang.kind_type_of_kind_format ~fresh:1 Lang.any_fixed in
let {Frame.audio=audio;video=video;midi=midi} = Lang.of_frame_kind_t input in
let {Frame.audio=audio;video=_;midi=midi} = Lang.of_frame_kind_t input in
let output = Lang.frame_kind_t ~audio ~video:Lang.zero_t ~midi in
Lang.add_operator "drop_video"
~category:Lang.Conversions
Expand Down Expand Up @@ -101,7 +101,7 @@ end

let () =
let input = Lang.kind_type_of_kind_format ~fresh:1 Lang.any_fixed in
let {Frame.audio=audio;video=video;midi=midi} = Lang.of_frame_kind_t input in
let {Frame.audio=_;video=video;midi=midi} = Lang.of_frame_kind_t input in
let output = Lang.frame_kind_t ~audio:Lang.zero_t ~video ~midi in
Lang.add_operator "drop_audio"
~category:Lang.Conversions
Expand Down Expand Up @@ -148,7 +148,7 @@ end

let () =
let input = Lang.kind_type_of_kind_format ~fresh:1 Lang.any_fixed in
let {Frame.audio=audio;video=video;midi=midi} = Lang.of_frame_kind_t input in
let {Frame.audio=audio;video=video;midi=_} = Lang.of_frame_kind_t input in
let output = Lang.frame_kind_t ~audio ~video ~midi:Lang.zero_t in
Lang.add_operator "drop_midi"
~category:Lang.Conversions
Expand Down
4 changes: 2 additions & 2 deletions src/conversions/id.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
open Source

class id ~kind ?(name="id") (source:source) =
object (self)
inherit operator ~name kind [source] as super
object
inherit operator ~name kind [source]

method stype = source#stype
method remaining = source#remaining
Expand Down
6 changes: 3 additions & 3 deletions src/conversions/mean.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class mean ~kind source =
in
let channels = float channels in
object (self)
inherit operator kind [source] ~name:"mean" as super
inherit operator kind [source] ~name:"mean"

method stype = source#stype
method is_ready = source#is_ready
Expand Down Expand Up @@ -83,8 +83,8 @@ end
let () =
let in_kind = Lang.kind_type_of_kind_format ~fresh:1 Lang.any_fixed in
let out_kind =
let { Frame.audio=a;video=v;midi=m } = Lang.of_frame_kind_t in_kind in
Lang.frame_kind_t (Lang.succ_t Lang.zero_t) v m
let { Frame.audio=_;video=v;midi=m } = Lang.of_frame_kind_t in_kind in
Lang.frame_kind_t ~audio:(Lang.succ_t Lang.zero_t) ~video:v ~midi:m
in
Lang.add_operator "mean"
[ "", Lang.source_t in_kind, None, None ]
Expand Down
2 changes: 1 addition & 1 deletion src/conversions/mux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object (self)
while s#is_ready && Frame.is_partial frame do
s#get frame
done ;
let p,c = Frame.content frame pos in
let _,c = Frame.content frame pos in
let end_pos = Frame.position frame in
if inicon != c then
self#log#f 4 "Copy-avoiding optimization isn't working!" ;
Expand Down
4 changes: 2 additions & 2 deletions src/conversions/swap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
open Source

class swap ~kind (source:source) =
object (self)
inherit operator kind [source] ~name:"swap" as super
object
inherit operator kind [source] ~name:"swap"

method stype = source#stype
method is_ready = source#is_ready
Expand Down
2 changes: 1 addition & 1 deletion src/converters/audio_converter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct
(fun () ->
let preferred = preferred_conf#get in
match converters#get preferred with
| Some v ->
| Some _ ->
log#f 4 "Using preferred samplerate converter: %s." preferred;
| None ->
log#f 4 "Couldn't find preferred samplerate converter: %s."
Expand Down
10 changes: 5 additions & 5 deletions src/decoder/aac_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ let create_decoder input =
processed := !processed + Array.length data.(0)
with _ -> () end;
drop pos ;
let content,length =
let content,_ =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why resampler returns a length? It seems to me that it is the length of the first channel always so it can be computed if necessary (and I doubt it will be the case...)

resampler ~audio_src_rate:(float sample_freq) data
in
(* TODO assert (Array.length content.(0) = length) ? *)
Expand Down Expand Up @@ -179,7 +179,7 @@ let () =
"AAC"
~sdoc:"Use libfaad to decode AAC if MIME type or file extension \
is appropriate."
(fun ~metadata filename kind ->
(fun ~metadata:_ filename kind ->
(* Before doing anything, check that we are allowed to produce
* audio, and don't have to produce midi or video. Only then
* check that the file seems relevant for AAC decoding. *)
Expand Down Expand Up @@ -242,7 +242,7 @@ struct
let mp4 = Faad.Mp4.openfile ?seek:input.Decoder.lseek read in
let resampler = Rutils.create_audio () in
let track = Faad.Mp4.find_aac_track mp4 in
let sample_freq, chans = Faad.Mp4.init mp4 dec track in
let sample_freq, _ = Faad.Mp4.init mp4 dec track in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we check that we get the right number of chans or somehow use this information?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, after reading the code, it seems to me that the generator, which is fed with audio data, has some smarts to accept various audio content according to the frame type. Thus, I suspect that it's acceptable for the generator in some cases, e.g. audio of type 1+'a, to have audio layout change on the fly, in which case we don't need to check for the number of channels reported by the decoder and just let the generator handle the situation.

@dbaelde should be able to confirm if I'm on crack or what.. ^^

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi guys. I did a quick check, and it seems that we don't need to check the number of channels here. The resampler (from Rutils) supports varying number of channels, and in the end the decoder (created using Decoder.Buffered.file_decoder) makes sure that the number of channels actually does not change.

let nb_samples = Faad.Mp4.samples mp4 track in
let sample = ref 0 in
let pos = ref 0 in
Expand All @@ -254,7 +254,7 @@ struct
begin try
pos := !pos + (Array.length data.(0))
with _ -> () end;
let content,length =
let content,_ =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

resampler ~audio_src_rate:(float sample_freq) data
in
Generator.set_mode gen `Audio;
Expand Down Expand Up @@ -316,7 +316,7 @@ let () =
"MP4"
~sdoc:"Use libfaad to decode MP4 if MIME type or file extension \
is appropriate."
(fun ~metadata filename kind ->
(fun ~metadata:_ filename kind ->
(* Before doing anything, check that we are allowed to produce
* audio, and don't have to produce midi or video. Only then
* check that the file seems relevant for MP4 decoding. *)
Expand Down
6 changes: 2 additions & 4 deletions src/decoder/external_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

(** Decode files using an external decoder. *)

let log = Dtools.Log.make ["decoder";"external"]

let priority = Tutils.Blocking
let buf_size = 1024

Expand Down Expand Up @@ -189,7 +187,7 @@ let test_kind f filename =

let register_stdin name sdoc mimes test process =
Decoder.file_decoders#register name ~sdoc
(fun ~metadata filename kind ->
(fun ~metadata:_ filename kind ->
match test_kind test filename with
| None -> None
| Some out_kind ->
Expand Down Expand Up @@ -292,7 +290,7 @@ let external_input_oblivious process filename prebuf =

let register_oblivious name sdoc test process prebuf =
Decoder.file_decoders#register name ~sdoc
(fun ~metadata filename kind ->
(fun ~metadata:_ filename kind ->
match test_kind test filename with
| None -> None
| Some out_kind ->
Expand Down
8 changes: 4 additions & 4 deletions src/decoder/flac_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let create_decoder input =
in
let decoder = Flac.Decoder.create dummy_c in
let decoder,info,_ = Flac.Decoder.init decoder dummy_c in
let sample_freq,channels = info.Flac.Decoder.sample_rate,
let sample_freq,_ = info.Flac.Decoder.sample_rate,
info.Flac.Decoder.channels
in
let processed = ref Int64.zero in
Expand Down Expand Up @@ -98,7 +98,7 @@ let create_decoder input =
| _ -> 0
in
processed := Int64.add !processed (Int64.of_int len);
let content,length =
let content,_ =
resampler ~audio_src_rate:(float sample_freq) data
in
Generator.set_mode gen `Audio ;
Expand Down Expand Up @@ -162,7 +162,7 @@ let () =
"FLAC"
~sdoc:"Use libflac to decode any file \
if its MIME type or file extension is appropriate."
(fun ~metadata filename kind ->
(fun ~metadata:_ filename kind ->
if not (Decoder.test_file ~mimes:mime_types#get
~extensions:file_extensions#get
~log filename) then
Expand Down Expand Up @@ -222,7 +222,7 @@ let get_tags file =
let write = fun _ -> () in
let h = Flac.Decoder.File.create_from_fd write fd in
match h.Flac.Decoder.File.comments with
| Some (v,m) -> m
| Some (_,m) -> m
| None -> [])

let () = Request.mresolvers#register "FLAC" get_tags
Expand Down
9 changes: 3 additions & 6 deletions src/decoder/gstreamer_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

(** Decode files and streams using GStreamer. *)

open Dtools
open Stdlib

module GU = Gstreamer_utils
Expand All @@ -41,9 +40,7 @@ type gst =
(** Generic decoder. *)
(* TODO: we should share some code with Ogg_decoder... *)
module Make (Generator : Generator.S_Asio) = struct

let create_decoder ?(merge_tracks=false) source ~channels mode input =

let create_decoder ?(merge_tracks=false) _ ~channels mode input =
GU.init ();

let decode_audio = mode = `Both || mode = `Audio in
Expand Down Expand Up @@ -129,7 +126,7 @@ module Make (Generator : Generator.S_Asio) = struct
in
Gstreamer.App_src.on_need_data gst.src feed_data;

let rec decode buffer =
let decode buffer =
if not !started then
(
init ~reset:false buffer;
Expand Down Expand Up @@ -272,7 +269,7 @@ let get_type ~channels filename =
let () =
Decoder.file_decoders#register "GSTREAMER"
~sdoc:"Decode a file using GStreamer."
(fun ~metadata filename kind ->
(fun ~metadata:_ filename kind ->
if not (Decoder.test_file
~mimes:mime_types#get
~extensions:file_extensions#get
Expand Down
6 changes: 3 additions & 3 deletions src/decoder/mad_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ let create_decoder input =
decode =
(fun gen ->
let data = get_data () in
let sample_freq,channels,_ = get_info () in
let content,length =
let sample_freq,_,_ = get_info () in
let content,_ =
resampler ~audio_src_rate:(float sample_freq) data
in
Generator.set_mode gen `Audio ;
Expand Down Expand Up @@ -193,7 +193,7 @@ let () =
~plugin_aliases:["MP3"; "MP2"; "MP1"]
~sdoc:"Use libmad to decode any file \
if its MIME type or file extension is appropriate."
(fun ~metadata filename kind ->
(fun ~metadata:_ filename kind ->
(* Before doing anything, check that we are allowed to produce
* audio, and don't have to produce midi or video. Only then
* check that the file seems relevant for decoding. *)
Expand Down
8 changes: 4 additions & 4 deletions src/decoder/metadata_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ let file_deco filename =
let fill frame =
let pos = Frame.position frame in
let duration = Frame.seconds_of_master (size-pos) in
let rec aux t' =
let rec aux () =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think you need to keep this warning (because it says something useful: this piece of code is unfinished) or do some more modification. It may be okay to get rid of t' because the reference to t is used to keep track of time. I don't know why there is a reference, maybe to use it at the end after aux has returned.. but right now, the last update is useless because the ref is forgotten right after.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what last update you have in mind but after re-reading this code, it looks fine to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the code again. It didn't make sense at first, but now it does, and I believe that my previous comment was misleaded. The reference t keeps track of the time in the metadata stream, and lives through all calls of fill. I don't see any problem with this code. Thanks!

match !events with
| (ts,k,v)::tl ->
if ts < !t+.duration then
Expand All @@ -76,13 +76,13 @@ let file_deco filename =
Hashtbl.add meta k v ;
Frame.set_metadata frame pos meta ;
events := tl ;
aux pos
aux ()
else
Frame.add_break frame size
| [] -> Frame.add_break frame pos
in
ignore (Frame.content_of_type frame pos empty) ;
aux pos ;
aux () ;
t := !t +. Frame.seconds_of_master (Frame.position frame - pos) ;
-1 (* TODO remaining time *)
in
Expand All @@ -93,7 +93,7 @@ let file_deco filename =

let () =
Decoder.file_decoders#register "META"
(fun ~metadata filename kind ->
(fun ~metadata:_ filename kind ->
if Frame.type_has_kind empty kind then begin
ignore (parse_file filename) ;
Some (fun () -> file_deco filename)
Expand Down
2 changes: 1 addition & 1 deletion src/decoder/midi_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ let decoder ~channels file =

let () =
Decoder.file_decoders#register "MIDI"
(fun ~metadata filename kind ->
(fun ~metadata:_ filename kind ->
(* Any number of MIDI channel is acceptable as the decoder
* silently drops events on higher channels if needed.
* The number of MIDI channels is chosen at the beginning
Expand Down
2 changes: 1 addition & 1 deletion src/decoder/ogg_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ let file_extensions =
let () =
Decoder.file_decoders#register "OGG"
~sdoc:"Decode a file as OGG provided that libogg accepts it."
(fun ~metadata filename kind ->
(fun ~metadata:_ filename kind ->
(* First, test file extension and mime *)
if Decoder.test_file ~mimes:mime_types#get
~extensions:file_extensions#get
Expand Down
2 changes: 1 addition & 1 deletion src/decoder/raw_audio_decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module Make (Generator:Generator.S_Asio) = struct
Generator.put_audio gen content 0 length
in
(* TODO *)
let seek ticks = 0 in
let seek _ = 0 in
{ Decoder.
decode = decoder;
seek = seek }
Expand Down
Loading