~ubuntu-branches/ubuntu/trusty/liquidsoap/trusty

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(*****************************************************************************

  Liquidsoap, a programmable audio stream generator.
  Copyright 2003-2011 Savonet team

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details, fully stated in the COPYING
  file at the root of the liquidsoap distribution.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 *****************************************************************************)

  (** Alsa related settings *)

(** ALSA should be quiet *)
let () = Alsa.no_stderr_report ()

(** Error translator *)
let error_translator e =
   match e with
     | Alsa.Buffer_xrun
     | Alsa.Bad_state
     | Alsa.Suspended
     | Alsa.IO_error
     | Alsa.Device_busy
     | Alsa.Invalid_argument
     | Alsa.Device_removed
     | Alsa.Interrupted
     | Alsa.Unknown_error _ ->
       raise (Utils.Translation
         (Printf.sprintf "Alsa error: %s" (Alsa.string_of_error e)))
     | _ -> ()

let () = Utils.register_error_translator error_translator

let conf =
  Dtools.Conf.void ~p:(Configure.conf#plug "alsa")
    "ALSA configuration"
let conf_buffer_length =
  Dtools.Conf.int ~p:(conf#plug "buffer_length") ~d:1
    "Buffer size, in frames"
    ~comments:[
      "This is only used for buffered ALSA I/O, and affects latency."
    ]
let periods =
  Dtools.Conf.int ~p:(conf#plug "periods") ~d:0
    "Number of periods"
    ~comments:[
      "Set to 0 to disable this setting and use ALSA's default."
    ]
let alsa_buffer =
  Dtools.Conf.int ~p:(conf#plug "alsa_buffer") ~d:0
    "Alsa internal buffer size"
    ~comments:[
      "This setting is only used in buffered alsa I/O, and affects latency.";
      "Set to 0 to disable this setting and use ALSA's default."
    ]

(** A dedicated clock for all ALSA I/O operators, to make sure other
  * blocking I/O inteferes with them. In the future, we might even want
  * to have different clocks for different ALSA devices. *)
let get_clock = Tutils.lazy_cell (fun () -> new Clock.self_sync "alsa")