codemirror-lang-liquidsoap 0.2.9 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (418) hide show
  1. package/dist/cli.js +2 -2
  2. package/dist/index.js +2 -2
  3. package/package.json +4 -3
  4. package/src/cli.ts +0 -0
  5. package/src/liquidsoap.grammar +1 -1
  6. package/src/parser.js +1 -1
  7. package/tests/liquidsoap/.github/alpine/APKBUILD-minimal.in +1 -1
  8. package/tests/liquidsoap/.github/alpine/APKBUILD.in +1 -1
  9. package/tests/liquidsoap/.github/alpine/liquidsoap.pre-install +0 -0
  10. package/tests/liquidsoap/.github/debian/rules +1 -1
  11. package/tests/liquidsoap/.github/debian/rules-minimal +1 -1
  12. package/tests/liquidsoap/.github/opam/liquidsoap-core-windows.opam +4 -3
  13. package/tests/liquidsoap/.github/opam/packages/ffmpeg-av-windows/ffmpeg-av-windows.1.2.0/opam +38 -0
  14. package/tests/liquidsoap/.github/opam/packages/ffmpeg-avcodec-windows/ffmpeg-avcodec-windows.1.2.0/opam +37 -0
  15. package/tests/liquidsoap/.github/opam/packages/ffmpeg-avdevice-windows/ffmpeg-avdevice-windows.1.2.0/opam +37 -0
  16. package/tests/liquidsoap/.github/opam/packages/ffmpeg-avfilter-windows/ffmpeg-avfilter-windows.1.2.0/opam +37 -0
  17. package/tests/liquidsoap/.github/opam/packages/ffmpeg-avutil-windows/ffmpeg-avutil-windows.1.2.0/opam +37 -0
  18. package/tests/liquidsoap/.github/opam/packages/ffmpeg-swresample-windows/ffmpeg-swresample-windows.1.2.0/opam +38 -0
  19. package/tests/liquidsoap/.github/opam/packages/ffmpeg-swscale-windows/ffmpeg-swscale-windows.1.2.0/opam +37 -0
  20. package/tests/liquidsoap/.github/opam/packages/ffmpeg-windows/ffmpeg-windows.1.2.0/opam +35 -0
  21. package/tests/liquidsoap/.github/scripts/add-local-opam-packages.sh +0 -0
  22. package/tests/liquidsoap/.github/scripts/build-apk.sh +0 -0
  23. package/tests/liquidsoap/.github/scripts/build-deb.sh +0 -0
  24. package/tests/liquidsoap/.github/scripts/build-details.sh +1 -1
  25. package/tests/liquidsoap/.github/scripts/build-doc.sh +0 -0
  26. package/tests/liquidsoap/.github/scripts/build-docker-alpine.sh +0 -0
  27. package/tests/liquidsoap/.github/scripts/build-docker.sh +0 -0
  28. package/tests/liquidsoap/.github/scripts/build-posix.sh +16 -13
  29. package/tests/liquidsoap/.github/scripts/build-website.sh +0 -0
  30. package/tests/liquidsoap/.github/scripts/build-win32.sh +0 -0
  31. package/tests/liquidsoap/.github/scripts/checkout-deps.sh +0 -0
  32. package/tests/liquidsoap/.github/scripts/export-metrics.sh +0 -0
  33. package/tests/liquidsoap/.github/scripts/push-docker.sh +0 -0
  34. package/tests/liquidsoap/.github/scripts/stats-posix.sh +0 -0
  35. package/tests/liquidsoap/.github/scripts/test-posix.sh +0 -0
  36. package/tests/liquidsoap/.github/workflows/ci.yml +10 -1
  37. package/tests/liquidsoap/.pre-commit-config.yaml +1 -1
  38. package/tests/liquidsoap/CHANGES.md +101 -1
  39. package/tests/liquidsoap/README.md +1 -1
  40. package/tests/liquidsoap/ROADMAP.md +28 -26
  41. package/tests/liquidsoap/doc/content/cookbook.md +46 -3
  42. package/tests/liquidsoap/doc/content/database.md +126 -0
  43. package/tests/liquidsoap/doc/content/documentation.md +1 -0
  44. package/tests/liquidsoap/doc/content/encoding_formats.md +6 -7
  45. package/tests/liquidsoap/doc/content/ffmpeg_encoder.md +20 -0
  46. package/tests/liquidsoap/doc/content/hls_output.md +27 -2
  47. package/tests/liquidsoap/doc/content/index.md +1 -1
  48. package/tests/liquidsoap/doc/content/liq/basic-radio.liq +14 -6
  49. package/tests/liquidsoap/doc/content/liq/check +0 -0
  50. package/tests/liquidsoap/doc/content/liq/liquidsoap +0 -0
  51. package/tests/liquidsoap/doc/content/liq/medialib.sqlite.liq +4 -0
  52. package/tests/liquidsoap/doc/content/liq/on2-if2.liq +5 -2
  53. package/tests/liquidsoap/doc/content/liq/on2-initial.liq +10 -5
  54. package/tests/liquidsoap/doc/content/liq/on2-replaygain.liq +13 -4
  55. package/tests/liquidsoap/doc/content/liq/on2-volume.liq +4 -2
  56. package/tests/liquidsoap/doc/content/liq/playlists.liq +2 -1
  57. package/tests/liquidsoap/doc/content/liq/radiopi.liq +2 -6
  58. package/tests/liquidsoap/doc/content/liq/source-cue.liq +26 -0
  59. package/tests/liquidsoap/doc/content/liq/space_overhead.liq +0 -0
  60. package/tests/liquidsoap/doc/content/liq/split-cue.liq +7 -8
  61. package/tests/liquidsoap/doc/content/liq/sqlite.liq +120 -0
  62. package/tests/liquidsoap/doc/content/liq/video-in-video.liq +2 -0
  63. package/tests/liquidsoap/doc/content/migrating.md +12 -0
  64. package/tests/liquidsoap/doc/content/on2_part2.md +1 -1
  65. package/tests/liquidsoap/doc/content/playlist_parsers.md +2 -10
  66. package/tests/liquidsoap/doc/content/seek.md +1 -20
  67. package/tests/liquidsoap/doc/dune.inc +655 -0
  68. package/tests/liquidsoap/dune-project +8 -5
  69. package/tests/liquidsoap/liquidsoap +0 -0
  70. package/tests/liquidsoap/liquidsoap-core.opam +6 -4
  71. package/tests/liquidsoap/src/core/builtins/builtins_ffmpeg_bitstream_filters.ml +100 -128
  72. package/tests/liquidsoap/src/core/builtins/builtins_ffmpeg_decoder.ml +10 -11
  73. package/tests/liquidsoap/src/core/builtins/builtins_ffmpeg_encoder.ml +14 -15
  74. package/tests/liquidsoap/src/core/builtins/builtins_ffmpeg_filters.ml +33 -3
  75. package/tests/liquidsoap/src/core/builtins/builtins_files.ml +64 -12
  76. package/tests/liquidsoap/src/core/builtins/builtins_optionals.ml +0 -1
  77. package/tests/liquidsoap/src/core/builtins/builtins_prometheus.ml +4 -4
  78. package/tests/liquidsoap/src/core/builtins/builtins_request.ml +16 -1
  79. package/tests/liquidsoap/src/core/builtins/builtins_resolvers.ml +1 -1
  80. package/tests/liquidsoap/src/core/builtins/builtins_settings.ml +12 -2
  81. package/tests/liquidsoap/src/core/builtins/builtins_socket.ml +17 -4
  82. package/tests/liquidsoap/src/core/builtins/builtins_source.ml +17 -7
  83. package/tests/liquidsoap/src/core/builtins/builtins_sqlite.ml +362 -0
  84. package/tests/liquidsoap/src/core/builtins/builtins_ssl.ml +18 -9
  85. package/tests/liquidsoap/src/core/builtins/builtins_tls.ml +38 -27
  86. package/tests/liquidsoap/src/core/clock.ml +1 -1
  87. package/tests/liquidsoap/src/core/clock.mli +1 -1
  88. package/tests/liquidsoap/src/core/conversions/conversion.ml +4 -38
  89. package/tests/liquidsoap/src/core/conversions/mean.ml +12 -14
  90. package/tests/liquidsoap/src/core/conversions/stereo.ml +4 -4
  91. package/tests/liquidsoap/src/core/conversions/swap.ml +8 -23
  92. package/tests/liquidsoap/src/core/decoder/aac_decoder.ml +3 -3
  93. package/tests/liquidsoap/src/core/decoder/decoder.ml +134 -129
  94. package/tests/liquidsoap/src/core/decoder/decoder.mli +11 -4
  95. package/tests/liquidsoap/src/core/decoder/decoder_utils.ml +8 -9
  96. package/tests/liquidsoap/src/core/decoder/decoder_utils.mli +2 -2
  97. package/tests/liquidsoap/src/core/decoder/external_decoder.ml +7 -5
  98. package/tests/liquidsoap/src/core/decoder/ffmpeg_copy_decoder.ml +1 -1
  99. package/tests/liquidsoap/src/core/decoder/ffmpeg_decoder.ml +138 -60
  100. package/tests/liquidsoap/src/core/decoder/ffmpeg_decoder_common.ml +10 -0
  101. package/tests/liquidsoap/src/core/decoder/ffmpeg_internal_decoder.ml +1 -2
  102. package/tests/liquidsoap/src/core/decoder/ffmpeg_raw_decoder.ml +1 -1
  103. package/tests/liquidsoap/src/core/decoder/flac_metadata_plug.ml +3 -3
  104. package/tests/liquidsoap/src/core/decoder/gstreamer_decoder.ml +1 -2
  105. package/tests/liquidsoap/src/core/decoder/id3_plug.ml +3 -3
  106. package/tests/liquidsoap/src/core/decoder/image/sdlimage_decoder.ml +3 -3
  107. package/tests/liquidsoap/src/core/decoder/image_decoder.ml +25 -23
  108. package/tests/liquidsoap/src/core/decoder/image_plug.ml +3 -3
  109. package/tests/liquidsoap/src/core/decoder/liq_flac_decoder.ml +10 -11
  110. package/tests/liquidsoap/src/core/decoder/liq_ogg_decoder.ml +5 -5
  111. package/tests/liquidsoap/src/core/decoder/mad_decoder.ml +6 -7
  112. package/tests/liquidsoap/src/core/decoder/midi_decoder.ml +10 -10
  113. package/tests/liquidsoap/src/core/decoder/ogg_metadata_plug.ml +3 -3
  114. package/tests/liquidsoap/src/core/decoder/srt_decoder.ml +23 -15
  115. package/tests/liquidsoap/src/core/decoder/taglib_plug.ml +3 -3
  116. package/tests/liquidsoap/src/core/decoder/text/video_text_sdl.ml +12 -7
  117. package/tests/liquidsoap/src/core/decoder/video_plug.ml +3 -3
  118. package/tests/liquidsoap/src/core/dune +19 -22
  119. package/tests/liquidsoap/src/core/encoder/encoder.ml +1 -1
  120. package/tests/liquidsoap/src/core/encoder/encoder.mli +1 -1
  121. package/tests/liquidsoap/src/core/encoder/encoder_formats.ml +6 -0
  122. package/tests/liquidsoap/src/core/encoder/encoder_utils.ml +66 -0
  123. package/tests/liquidsoap/src/core/encoder/encoders/avi_encoder.ml +38 -39
  124. package/tests/liquidsoap/src/core/encoder/encoders/fdkaac_encoder.ml +1 -1
  125. package/tests/liquidsoap/src/core/encoder/encoders/ffmpeg_copy_encoder.ml +26 -24
  126. package/tests/liquidsoap/src/core/encoder/encoders/ffmpeg_encoder.ml +24 -6
  127. package/tests/liquidsoap/src/core/encoder/encoders/ffmpeg_encoder_common.ml +52 -45
  128. package/tests/liquidsoap/src/core/encoder/encoders/ffmpeg_internal_encoder.ml +55 -34
  129. package/tests/liquidsoap/src/core/encoder/encoders/gstreamer_encoder.ml +27 -22
  130. package/tests/liquidsoap/src/core/encoder/encoders/lame_encoder.ml +5 -4
  131. package/tests/liquidsoap/src/core/encoder/encoders/ogg_encoder.ml +14 -7
  132. package/tests/liquidsoap/src/core/encoder/encoders/shine_encoder.ml +4 -5
  133. package/tests/liquidsoap/src/core/encoder/formats/ffmpeg_format.ml +9 -0
  134. package/tests/liquidsoap/src/core/encoder/lang/lang_ffmpeg.ml +13 -10
  135. package/tests/liquidsoap/src/core/encoder/lang_encoder.ml +1 -1
  136. package/tests/liquidsoap/src/core/harbor/harbor.ml +7 -2
  137. package/tests/liquidsoap/src/core/harbor/harbor_base.ml +7 -3
  138. package/tests/liquidsoap/src/core/io/alsa_io.ml +8 -5
  139. package/tests/liquidsoap/src/core/io/ffmpeg_filter_io.ml +9 -14
  140. package/tests/liquidsoap/src/core/io/ffmpeg_io.ml +23 -24
  141. package/tests/liquidsoap/src/core/io/gstreamer_io.ml +24 -20
  142. package/tests/liquidsoap/src/core/io/oss_io.ml +7 -5
  143. package/tests/liquidsoap/src/core/io/portaudio_io.ml +7 -5
  144. package/tests/liquidsoap/src/core/io/pulseaudio_io.ml +8 -7
  145. package/tests/liquidsoap/src/core/io/srt_io.ml +115 -114
  146. package/tests/liquidsoap/src/core/io/udp_io.ml +6 -3
  147. package/tests/liquidsoap/src/core/lang.mli +3 -0
  148. package/tests/liquidsoap/src/core/lang_source.ml +23 -9
  149. package/tests/liquidsoap/src/core/ogg_formats/opus_encoder.ml +1 -1
  150. package/tests/liquidsoap/src/core/operators/accelerate.ml +10 -23
  151. package/tests/liquidsoap/src/core/operators/add.ml +131 -122
  152. package/tests/liquidsoap/src/core/operators/amplify.ml +36 -27
  153. package/tests/liquidsoap/src/core/operators/available.ml +20 -8
  154. package/tests/liquidsoap/src/core/operators/biquad_filter.ml +8 -8
  155. package/tests/liquidsoap/src/core/operators/chord.ml +7 -9
  156. package/tests/liquidsoap/src/core/operators/clip.ml +7 -7
  157. package/tests/liquidsoap/src/core/operators/comb.ml +7 -8
  158. package/tests/liquidsoap/src/core/operators/compand.ml +9 -9
  159. package/tests/liquidsoap/src/core/operators/compress.ml +15 -10
  160. package/tests/liquidsoap/src/core/operators/compress_exp.ml +8 -9
  161. package/tests/liquidsoap/src/core/operators/cross.ml +180 -247
  162. package/tests/liquidsoap/src/core/operators/defer.ml +8 -18
  163. package/tests/liquidsoap/src/core/operators/delay.ml +10 -18
  164. package/tests/liquidsoap/src/core/operators/delay_line.ml +9 -8
  165. package/tests/liquidsoap/src/core/operators/dtmf.ml +18 -16
  166. package/tests/liquidsoap/src/core/operators/dyn_op.ml +66 -63
  167. package/tests/liquidsoap/src/core/operators/echo.ml +8 -7
  168. package/tests/liquidsoap/src/core/operators/filter.ml +8 -8
  169. package/tests/liquidsoap/src/core/operators/filter_rc.ml +11 -10
  170. package/tests/liquidsoap/src/core/operators/fir_filter.ml +8 -7
  171. package/tests/liquidsoap/src/core/operators/flanger.ml +9 -8
  172. package/tests/liquidsoap/src/core/operators/frei0r_op.ml +113 -91
  173. package/tests/liquidsoap/src/core/operators/gate.ml +9 -8
  174. package/tests/liquidsoap/src/core/operators/iir_filter.ml +7 -7
  175. package/tests/liquidsoap/src/core/operators/insert_metadata.ml +29 -54
  176. package/tests/liquidsoap/src/core/operators/ladspa_op.ml +38 -36
  177. package/tests/liquidsoap/src/core/operators/lilv_op.ml +44 -44
  178. package/tests/liquidsoap/src/core/operators/lufs.ml +8 -8
  179. package/tests/liquidsoap/src/core/operators/map_metadata.ml +23 -20
  180. package/tests/liquidsoap/src/core/operators/map_op.ml +6 -7
  181. package/tests/liquidsoap/src/core/operators/max_duration.ml +21 -20
  182. package/tests/liquidsoap/src/core/operators/midi_routing.ml +13 -9
  183. package/tests/liquidsoap/src/core/operators/ms_stereo.ml +13 -15
  184. package/tests/liquidsoap/src/core/operators/muxer.ml +30 -101
  185. package/tests/liquidsoap/src/core/operators/noblank.ml +26 -48
  186. package/tests/liquidsoap/src/core/operators/normalize.ml +13 -9
  187. package/tests/liquidsoap/src/core/operators/on_end.ml +25 -12
  188. package/tests/liquidsoap/src/core/operators/on_frame.ml +9 -9
  189. package/tests/liquidsoap/src/core/operators/on_metadata.ml +9 -10
  190. package/tests/liquidsoap/src/core/operators/on_offset.ml +20 -13
  191. package/tests/liquidsoap/src/core/operators/on_track.ml +7 -10
  192. package/tests/liquidsoap/src/core/operators/pan.ml +7 -8
  193. package/tests/liquidsoap/src/core/operators/pipe.ml +14 -17
  194. package/tests/liquidsoap/src/core/operators/pitch.ml +7 -5
  195. package/tests/liquidsoap/src/core/operators/replaygain_op.ml +6 -6
  196. package/tests/liquidsoap/src/core/operators/resample.ml +7 -6
  197. package/tests/liquidsoap/src/core/operators/rms_smooth.ml +8 -8
  198. package/tests/liquidsoap/src/core/operators/sequence.ml +48 -58
  199. package/tests/liquidsoap/src/core/operators/soundtouch_op.ml +12 -12
  200. package/tests/liquidsoap/src/core/operators/st_bpm.ml +8 -7
  201. package/tests/liquidsoap/src/core/operators/stereotool_op.ml +5 -7
  202. package/tests/liquidsoap/src/core/operators/still_frame.ml +13 -10
  203. package/tests/liquidsoap/src/core/operators/switch.ml +128 -168
  204. package/tests/liquidsoap/src/core/operators/time_warp.ml +44 -103
  205. package/tests/liquidsoap/src/core/operators/track/merge_metadata.ml +31 -48
  206. package/tests/liquidsoap/src/core/operators/track_map.ml +6 -32
  207. package/tests/liquidsoap/src/core/operators/video_effects.ml +48 -13
  208. package/tests/liquidsoap/src/core/operators/video_fade.ml +69 -57
  209. package/tests/liquidsoap/src/core/operators/window_op.ml +8 -8
  210. package/tests/liquidsoap/src/core/outputs/graphics_out.ml +11 -8
  211. package/tests/liquidsoap/src/core/outputs/harbor_output.ml +3 -3
  212. package/tests/liquidsoap/src/core/outputs/hls_output.ml +203 -116
  213. package/tests/liquidsoap/src/core/outputs/icecast2.ml +31 -5
  214. package/tests/liquidsoap/src/core/outputs/output.ml +27 -31
  215. package/tests/liquidsoap/src/core/outputs/output.mli +4 -5
  216. package/tests/liquidsoap/src/core/outputs/pipe_output.ml +19 -8
  217. package/tests/liquidsoap/src/core/outputs/sdl_out.ml +12 -9
  218. package/tests/liquidsoap/src/core/playlist_parser.ml +2 -6
  219. package/tests/liquidsoap/src/core/request.ml +84 -36
  220. package/tests/liquidsoap/src/core/request.mli +11 -8
  221. package/tests/liquidsoap/src/core/source.ml +343 -181
  222. package/tests/liquidsoap/src/core/source.mli +147 -33
  223. package/tests/liquidsoap/src/core/sources/alsa_in.ml +4 -6
  224. package/tests/liquidsoap/src/core/sources/audio_gen.ml +23 -22
  225. package/tests/liquidsoap/src/core/sources/bjack_in.ml +7 -5
  226. package/tests/liquidsoap/src/core/sources/blank.ml +55 -36
  227. package/tests/liquidsoap/src/core/sources/debug_sources.ml +2 -2
  228. package/tests/liquidsoap/src/core/sources/external_input_video.ml +2 -3
  229. package/tests/liquidsoap/src/core/sources/generated.ml +25 -47
  230. package/tests/liquidsoap/src/core/sources/harbor_input.ml +7 -9
  231. package/tests/liquidsoap/src/core/sources/latest_metadata.ml +1 -2
  232. package/tests/liquidsoap/src/core/sources/noise.ml +38 -27
  233. package/tests/liquidsoap/src/core/sources/request_dynamic.ml +181 -198
  234. package/tests/liquidsoap/src/core/sources/synthesized.ml +36 -23
  235. package/tests/liquidsoap/src/core/sources/video_board.ml +8 -10
  236. package/tests/liquidsoap/src/core/sources/video_testsrc.ml +9 -11
  237. package/tests/liquidsoap/src/core/sources/video_text.ml +8 -11
  238. package/tests/liquidsoap/src/core/stream/aFrame.ml +0 -32
  239. package/tests/liquidsoap/src/core/stream/aFrame.mli +2 -46
  240. package/tests/liquidsoap/src/core/stream/content.ml +96 -11
  241. package/tests/liquidsoap/src/core/stream/content.mli +32 -22
  242. package/tests/liquidsoap/src/core/stream/content_audio.ml +8 -4
  243. package/tests/liquidsoap/src/core/stream/content_base.ml +24 -35
  244. package/tests/liquidsoap/src/core/stream/content_midi.ml +0 -1
  245. package/tests/liquidsoap/src/core/stream/content_pcm_base.ml +0 -1
  246. package/tests/liquidsoap/src/core/stream/content_timed.ml +15 -1
  247. package/tests/liquidsoap/src/core/stream/content_video.ml +91 -30
  248. package/tests/liquidsoap/src/core/stream/ffmpeg_content_base.ml +0 -49
  249. package/tests/liquidsoap/src/core/stream/ffmpeg_copy_content.ml +2 -1
  250. package/tests/liquidsoap/src/core/stream/ffmpeg_raw_content.ml +2 -1
  251. package/tests/liquidsoap/src/core/stream/frame.ml +67 -118
  252. package/tests/liquidsoap/src/core/stream/frame.mli +49 -43
  253. package/tests/liquidsoap/src/core/stream/frame_base.ml +20 -32
  254. package/tests/liquidsoap/src/core/stream/frame_settings.ml +13 -36
  255. package/tests/liquidsoap/src/core/stream/generator.ml +47 -140
  256. package/tests/liquidsoap/src/core/stream/generator.mli +6 -13
  257. package/tests/liquidsoap/src/core/stream/mFrame.ml +0 -12
  258. package/tests/liquidsoap/src/core/stream/mFrame.mli +0 -19
  259. package/tests/liquidsoap/src/core/stream/metadata_base.ml +75 -0
  260. package/tests/liquidsoap/src/core/stream/vFrame.ml +0 -16
  261. package/tests/liquidsoap/src/core/stream/vFrame.mli +1 -35
  262. package/tests/liquidsoap/src/core/synth/dssi_op.ml +19 -20
  263. package/tests/liquidsoap/src/core/synth/keyboard.ml +6 -10
  264. package/tests/liquidsoap/src/core/synth/keyboard_sdl.ml +5 -11
  265. package/tests/liquidsoap/src/core/synth/synth_op.ml +11 -10
  266. package/tests/liquidsoap/src/core/tools/http.ml +40 -6
  267. package/tests/liquidsoap/src/core/tools/http.mli +21 -3
  268. package/tests/liquidsoap/src/core/tools/liq_posix_time.ml +3 -1
  269. package/tests/liquidsoap/src/core/tools/producer_consumer.ml +7 -18
  270. package/tests/liquidsoap/src/core/tools/server.ml +1 -1
  271. package/tests/liquidsoap/src/core/tools/server_builtins.ml +1 -1
  272. package/tests/liquidsoap/src/core/tools/start_stop.ml +2 -6
  273. package/tests/liquidsoap/src/core/tools/tutils.ml +1 -1
  274. package/tests/liquidsoap/src/core/track.ml +1 -2
  275. package/tests/liquidsoap/src/core/visualization/midimeter.ml +7 -5
  276. package/tests/liquidsoap/src/core/visualization/video_volume.ml +55 -68
  277. package/tests/liquidsoap/src/core/visualization/vis_volume.ml +1 -1
  278. package/tests/liquidsoap/src/js/index.html +4 -4
  279. package/tests/liquidsoap/src/{core/builtins/builtins_magic.ml → lang/active_value.ml} +16 -12
  280. package/tests/liquidsoap/src/lang/active_value.mli +33 -0
  281. package/tests/liquidsoap/src/lang/builtins_math.ml +7 -6
  282. package/tests/liquidsoap/src/lang/dune +1 -0
  283. package/tests/liquidsoap/src/lang/environment.ml +3 -1
  284. package/tests/liquidsoap/src/lang/evaluation.ml +13 -2
  285. package/tests/liquidsoap/src/lang/lang.mli +3 -0
  286. package/tests/liquidsoap/src/lang/lang_core.ml +13 -6
  287. package/tests/liquidsoap/src/lang/lexer.ml +2 -0
  288. package/tests/liquidsoap/src/lang/methods.ml +1 -0
  289. package/tests/liquidsoap/src/lang/methods.mli +1 -0
  290. package/tests/liquidsoap/src/lang/modules.ml +1 -0
  291. package/tests/liquidsoap/src/lang/parser_helper.ml +10 -1
  292. package/tests/liquidsoap/src/lang/parser_helper.mli +8 -1
  293. package/tests/liquidsoap/src/lang/term/parsed_term.ml +2 -0
  294. package/tests/liquidsoap/src/lang/term/runtime_term.ml +6 -1
  295. package/tests/liquidsoap/src/lang/term/term_base.ml +128 -74
  296. package/tests/liquidsoap/src/lang/term/term_reducer.ml +69 -3
  297. package/tests/liquidsoap/src/lang/term.ml +0 -47
  298. package/tests/liquidsoap/src/lang/type.ml +17 -1
  299. package/tests/liquidsoap/src/lang/type.mli +1 -0
  300. package/tests/liquidsoap/src/lang/types/type_base.ml +1 -1
  301. package/tests/liquidsoap/src/lang/utils.ml +1 -0
  302. package/tests/liquidsoap/src/lang/value.ml +16 -2
  303. package/tests/liquidsoap/src/libs/error.liq +16 -0
  304. package/tests/liquidsoap/src/libs/extra/deprecations.liq +18 -0
  305. package/tests/liquidsoap/src/libs/extra/metadata.liq +101 -0
  306. package/tests/liquidsoap/src/libs/extra/openai.liq +152 -0
  307. package/tests/liquidsoap/src/libs/extra/server.liq +39 -25
  308. package/tests/liquidsoap/src/libs/extra/source.liq +188 -0
  309. package/tests/liquidsoap/src/libs/fades.liq +92 -46
  310. package/tests/liquidsoap/src/libs/file.liq +71 -5
  311. package/tests/liquidsoap/src/libs/medialib.liq +384 -2
  312. package/tests/liquidsoap/src/libs/metadata.liq +1 -9
  313. package/tests/liquidsoap/src/libs/playlist.liq +224 -141
  314. package/tests/liquidsoap/src/libs/request.liq +112 -84
  315. package/tests/liquidsoap/src/libs/server.liq +12 -0
  316. package/tests/liquidsoap/src/libs/source.liq +24 -3
  317. package/tests/liquidsoap/src/libs/sqlite.liq +164 -0
  318. package/tests/liquidsoap/src/libs/stdlib.liq +4 -0
  319. package/tests/liquidsoap/src/libs/string.liq +35 -1
  320. package/tests/liquidsoap/src/libs/utils.liq +8 -0
  321. package/tests/liquidsoap/src/libs/video.liq +2 -1
  322. package/tests/liquidsoap/src/runtime/build_config.ml +1 -1
  323. package/tests/liquidsoap/src/runtime/main.ml +1 -1
  324. package/tests/liquidsoap/src/tooling/parsed_json.ml +4 -0
  325. package/tests/liquidsoap/tests/core/content_test.ml +32 -20
  326. package/tests/liquidsoap/tests/core/decoder_test.ml +4 -4
  327. package/tests/liquidsoap/tests/core/ffmpeg_quality.ml +2 -0
  328. package/tests/liquidsoap/tests/core/frame_test.ml +0 -35
  329. package/tests/liquidsoap/tests/core/generator_test.ml +4 -4
  330. package/tests/liquidsoap/tests/core/more_types.ml +2 -0
  331. package/tests/liquidsoap/tests/core/output_encoded_test.ml +7 -5
  332. package/tests/liquidsoap/tests/core/output_test.ml +6 -11
  333. package/tests/liquidsoap/tests/core/stream_decoder_test.ml +3 -4
  334. package/tests/liquidsoap/tests/failures/ctype.liq +0 -0
  335. package/tests/liquidsoap/tests/failures/error.liq +0 -0
  336. package/tests/liquidsoap/tests/failures/record-invalid-member1.liq +0 -0
  337. package/tests/liquidsoap/tests/failures/record-invalid-member2.liq +0 -0
  338. package/tests/liquidsoap/tests/failures/ref.liq +0 -0
  339. package/tests/liquidsoap/tests/fixme/GH1170.liq +0 -0
  340. package/tests/liquidsoap/tests/fixme/cross2.liq +0 -0
  341. package/tests/liquidsoap/tests/fixme/cross3.liq +0 -0
  342. package/tests/liquidsoap/tests/fixme/sequence-1.liq +0 -0
  343. package/tests/liquidsoap/tests/language/bool.liq +1 -12
  344. package/tests/liquidsoap/tests/language/dune.inc +12 -0
  345. package/tests/liquidsoap/tests/language/file.liq +7 -2
  346. package/tests/liquidsoap/tests/language/functions.liq +2 -13
  347. package/tests/liquidsoap/tests/language/interactive.liq +5 -16
  348. package/tests/liquidsoap/tests/language/list.liq +73 -78
  349. package/tests/liquidsoap/tests/language/loop.liq +6 -18
  350. package/tests/liquidsoap/tests/language/mem_usage.liq +0 -1
  351. package/tests/liquidsoap/tests/language/metadata.liq +9 -13
  352. package/tests/liquidsoap/tests/language/null.liq +8 -12
  353. package/tests/liquidsoap/tests/language/number.liq +10 -0
  354. package/tests/liquidsoap/tests/language/pp.liq +8 -20
  355. package/tests/liquidsoap/tests/language/predicate.liq +6 -18
  356. package/tests/liquidsoap/tests/language/ref.liq +3 -15
  357. package/tests/liquidsoap/tests/language/regexp.liq +14 -25
  358. package/tests/liquidsoap/tests/language/sqlite.liq +96 -0
  359. package/tests/liquidsoap/tests/language/stdlib.liq +7 -20
  360. package/tests/liquidsoap/tests/language/string.liq +7 -0
  361. package/tests/liquidsoap/tests/media/dune.inc +39 -0
  362. package/tests/liquidsoap/tests/media/encoder_audio_only.liq.in +1 -1
  363. package/tests/liquidsoap/tests/media/encoder_audio_video.liq.in +1 -1
  364. package/tests/liquidsoap/tests/media/encoder_multitrack.liq.in +1 -1
  365. package/tests/liquidsoap/tests/media/encoder_video_only.liq.in +1 -1
  366. package/tests/liquidsoap/tests/media/ffmpeg_bitstream_filter.liq +94 -0
  367. package/tests/liquidsoap/tests/media/ffmpeg_complex_filter.liq +1 -1
  368. package/tests/liquidsoap/tests/media/ffmpeg_filter.liq +3 -9
  369. package/tests/liquidsoap/tests/media/ffmpeg_raw_hls.liq +15 -12
  370. package/tests/liquidsoap/tests/media/ffmpeg_transparency_filter.liq +3 -9
  371. package/tests/liquidsoap/tests/media/gen_dune.ml +1 -0
  372. package/tests/liquidsoap/tests/media/mk_encoder_test.sh +0 -0
  373. package/tests/liquidsoap/tests/media/mk_stream_test.sh +0 -0
  374. package/tests/liquidsoap/tests/media/multitrack.liq +21 -1
  375. package/tests/liquidsoap/tests/media/stream_audio.liq.in +0 -0
  376. package/tests/liquidsoap/tests/media/stream_video.liq.in +0 -0
  377. package/tests/liquidsoap/tests/performance/erathostenes.liq +0 -0
  378. package/tests/liquidsoap/tests/performance/memory.liq +0 -0
  379. package/tests/liquidsoap/tests/performance/small-record.liq +0 -0
  380. package/tests/liquidsoap/tests/regression/GH1327.liq +8 -0
  381. package/tests/liquidsoap/tests/regression/GH3316.liq +2 -0
  382. package/tests/liquidsoap/tests/regression/GH3645.liq +16 -0
  383. package/tests/liquidsoap/tests/regression/GH3675.liq +37 -0
  384. package/tests/liquidsoap/tests/regression/LS354-2.liq +11 -3
  385. package/tests/liquidsoap/tests/regression/dune.inc +45 -14
  386. package/tests/liquidsoap/tests/regression/track_sensitive.liq +17 -0
  387. package/tests/liquidsoap/tests/regression/unified-pcm-types.aac +0 -0
  388. package/tests/liquidsoap/tests/regression/unified-pcm-types.liq +3 -0
  389. package/tests/liquidsoap/tests/run_test.ml +7 -3
  390. package/tests/liquidsoap/tests/streams/195.liq +4 -1
  391. package/tests/liquidsoap/tests/streams/cross-override.liq +12 -4
  392. package/tests/liquidsoap/tests/streams/cross-persist-override.liq +12 -4
  393. package/tests/liquidsoap/tests/streams/cross.liq +1 -1
  394. package/tests/liquidsoap/tests/streams/crossfade.liq +11 -24
  395. package/tests/liquidsoap/tests/streams/cue-cut.liq +16 -0
  396. package/tests/liquidsoap/tests/streams/dtmf.liq +3 -0
  397. package/tests/liquidsoap/tests/streams/dtmf_pcm_s16.liq +4 -0
  398. package/tests/liquidsoap/tests/streams/dune.inc +145 -0
  399. package/tests/liquidsoap/tests/streams/fades-persistent-override.liq +7 -2
  400. package/tests/liquidsoap/tests/streams/hls_discontinuity.liq +68 -0
  401. package/tests/liquidsoap/tests/streams/hls_id3v2.liq +76 -4
  402. package/tests/liquidsoap/tests/streams/hls_large_frame.liq +31 -0
  403. package/tests/liquidsoap/tests/streams/merge_metadata.liq +2 -4
  404. package/tests/liquidsoap/tests/streams/no-cue-cut.liq +22 -0
  405. package/tests/liquidsoap/tests/streams/random.liq +4 -4
  406. package/tests/liquidsoap/tests/streams/rotate.liq +44 -21
  407. package/tests/liquidsoap/tests/streams/sharing.liq +5 -0
  408. package/tests/liquidsoap/tests/streams/source-cue.liq +134 -0
  409. package/tests/liquidsoap/tests/streams/srt_raw_pcm.liq +5 -0
  410. package/tests/liquidsoap/tests/test.liq +1 -2
  411. package/tests/run.sh +0 -0
  412. package/tests/liquidsoap/.github/opam/packages/duppy/duppy.0.9.3/opam +0 -37
  413. package/tests/liquidsoap/.github/opam/packages/ssl/ssl.0.7.0/opam +0 -40
  414. package/tests/liquidsoap/src/core/liqmagic.disabled.ml +0 -2
  415. package/tests/liquidsoap/src/core/liqmagic.enabled.ml +0 -3
  416. package/tests/liquidsoap/src/core/liqmagic.mli +0 -4
  417. package/tests/liquidsoap/src/core/operators/cuepoint.ml +0 -216
  418. package/tests/liquidsoap/tests/regression/GH3121.liq +0 -16
@@ -29,9 +29,15 @@ open Source
29
29
  * to the current use of [sequence] in transitions. *)
30
30
  class sequence ?(merge = false) sources =
31
31
  let self_sync_type = Utils.self_sync_type sources in
32
+ let seq_sources = Atomic.make sources in
32
33
  object (self)
33
34
  inherit operator ~name:"sequence" sources
34
- val mutable seq_sources = sources
35
+
36
+ inherit
37
+ generate_from_multiple_sources
38
+ ~merge:(fun () -> merge && Atomic.get seq_sources <> [])
39
+ ~track_sensitive:(fun () -> true)
40
+ ()
35
41
 
36
42
  method self_sync =
37
43
  ( Lazy.force self_sync_type,
@@ -48,85 +54,69 @@ class sequence ?(merge = false) sources =
48
54
  method! private sleep =
49
55
  List.iter (fun s -> (s :> source)#leave (self :> source)) sources
50
56
 
51
- (** When head_ready is true, it must be that:
52
- * - (List.hd seq_sources)#is_ready
53
- * - or we have started playing a track of (List.hd sources)
54
- * and that track has not ended yet.
55
- * In case the head source becomes unavailable before its end of track,
56
- * head_ready keeps the sequence operator available, so that its #get_frame
57
- * can be called to properly end the track and cleanup the source if needed.
58
- * If instead the operator had become unavailable then source#get would have
59
- * inserted an end of track automatically instead of calling #get_frame. *)
60
- val mutable head_ready = false
61
-
62
- method private _is_ready ?frame () =
63
- head_ready || List.exists (fun s -> s#is_ready ?frame ()) seq_sources
57
+ (* We have to wait until at least one source is ready. *)
58
+ val mutable has_started = false
59
+
60
+ method private has_started =
61
+ match has_started with
62
+ | true -> true
63
+ | false ->
64
+ has_started <-
65
+ List.exists (fun s -> s#is_ready) (Atomic.get seq_sources);
66
+ has_started
67
+
68
+ method private get_source ~reselect () =
69
+ match (self#has_started, Atomic.get seq_sources) with
70
+ | _, [] -> None
71
+ | true, s :: rest ->
72
+ if
73
+ self#can_reselect
74
+ ~reselect:
75
+ (match reselect with `After_position _ -> `Force | v -> v)
76
+ s
77
+ then Some s
78
+ else (
79
+ self#log#info "Finished with %s" s#id;
80
+ (s :> source)#leave (self :> source);
81
+ Atomic.set seq_sources rest;
82
+ self#get_source ~reselect:`Ok ())
83
+ | _ -> None
64
84
 
65
85
  method remaining =
66
86
  if merge then (
67
87
  let ( + ) a b = if a < 0 || b < 0 then -1 else a + b in
68
- List.fold_left ( + ) 0 (List.map (fun s -> s#remaining) seq_sources))
69
- else (List.hd seq_sources)#remaining
88
+ List.fold_left ( + ) 0
89
+ (List.map (fun s -> s#remaining) (Atomic.get seq_sources)))
90
+ else (List.hd (Atomic.get seq_sources))#remaining
70
91
 
71
92
  method seek_source =
72
- match seq_sources with
93
+ match Atomic.get seq_sources with
73
94
  | s :: _ -> s#seek_source
74
95
  | _ -> (self :> Source.source)
75
96
 
76
97
  method abort_track =
77
98
  if merge then (
78
- match List.rev seq_sources with
99
+ match List.rev (Atomic.get seq_sources) with
79
100
  | [] -> assert false
80
- | hd :: _ -> seq_sources <- [hd]);
81
- match seq_sources with hd :: _ -> hd#abort_track | _ -> ()
82
-
83
- method private get_frame buf =
84
- if head_ready then (
85
- let hd = List.hd seq_sources in
86
- hd#get buf;
87
- if Frame.is_partial buf then (
88
- head_ready <- false;
89
- if List.length seq_sources > 1 then (
90
- seq_sources <- List.tl seq_sources;
91
- if merge && self#is_ready ~frame:buf () then (
92
- let pos = Frame.position buf in
93
- self#get_frame buf;
94
- Frame.set_breaks buf
95
- (Utils.remove_one (( = ) pos) (Frame.breaks buf))))))
96
- else (
97
- match seq_sources with
98
- | a :: (_ :: _ as tl) ->
99
- if a#is_ready ~frame:buf () then head_ready <- true
100
- else seq_sources <- tl;
101
- self#get_frame buf
102
- | [a] ->
103
- assert (a#is_ready ~frame:buf ());
104
-
105
- (* Our #is_ready ensures that. *)
106
- head_ready <- true;
107
- self#get_frame buf
108
- | [] -> assert false)
101
+ | hd :: _ -> Atomic.set seq_sources [hd]);
102
+ match Atomic.get seq_sources with hd :: _ -> hd#abort_track | _ -> ()
109
103
  end
110
104
 
111
105
  class merge_tracks source =
112
- object (self)
106
+ object
113
107
  inherit operator ~name:"sequence" [source]
114
108
  method stype = source#stype
115
- method private _is_ready = source#is_ready
109
+ method private can_generate_frame = source#is_ready
116
110
  method abort_track = source#abort_track
117
111
  method remaining = -1
118
112
  method self_sync = source#self_sync
119
113
  method seek_source = source#seek_source
120
114
 
121
- method private get_frame buf =
122
- source#get buf;
123
- if Frame.is_partial buf && source#is_ready ~frame:buf () then (
124
- self#log#info "End of track: merging.";
125
- self#get_frame buf;
126
- Frame.set_breaks buf
127
- (match Frame.breaks buf with
128
- | b :: _ :: l -> b :: l
129
- | _ -> assert false))
115
+ method private generate_frame =
116
+ let buf = source#get_frame in
117
+ Frame.set buf Frame.Fields.track_marks
118
+ (Content.make ~length:(Frame.position buf)
119
+ Content_timed.Track_marks.format)
130
120
  end
131
121
 
132
122
  let _ =
@@ -41,7 +41,7 @@ class soundtouch source_val rate tempo pitch =
41
41
  val mutable st = None
42
42
  method stype = source#stype
43
43
  method self_sync = source#self_sync
44
- method private _is_ready = source#is_ready
44
+ method private can_generate_frame = source#is_ready
45
45
  method seek_source = source#seek_source
46
46
  method remaining = -1
47
47
 
@@ -65,24 +65,24 @@ class soundtouch source_val rate tempo pitch =
65
65
  ignore (Soundtouch.get_samples_ni st buf 0 available);
66
66
  Generator.put self#buffer Frame.Fields.audio
67
67
  (Content.Audio.lift_data buf));
68
- if AFrame.is_partial databuf then Generator.add_track_mark self#buffer;
68
+ let gen_pos = Generator.length self#buffer in
69
+ List.iter
70
+ (fun pos -> Generator.add_track_mark ~pos:(pos + gen_pos) self#buffer)
71
+ (Frame.track_marks databuf);
69
72
 
70
- (* It's almost impossible to know where to add metadata,
71
- * b/c of tempo so we add then right here. *)
72
73
  List.iter
73
- (fun (_, m) -> Generator.add_metadata self#buffer m)
74
- (AFrame.get_all_metadata databuf)
74
+ (fun (pos, m) ->
75
+ Generator.add_metadata ~pos:(pos + gen_pos) self#buffer m)
76
+ (Frame.get_all_metadata databuf)
75
77
 
76
- method private get_frame buf =
78
+ method private generate_frame =
79
+ let size = Lazy.force Frame.size in
77
80
  consumer#set_output_enabled true;
78
- while
79
- Generator.length self#buffer < Lazy.force Frame.size
80
- && source#is_ready ~frame:self#buffer ()
81
- do
81
+ while Generator.length self#buffer < size && source#is_ready do
82
82
  self#child_tick
83
83
  done;
84
84
  consumer#set_output_enabled false;
85
- Generator.fill self#buffer buf
85
+ Generator.slice self#buffer size
86
86
 
87
87
  method! wake_up a =
88
88
  super#wake_up a;
@@ -26,7 +26,7 @@ class bpm (source : source) =
26
26
  object (self)
27
27
  inherit operator ~name:"bpm" [source] as super
28
28
  method stype = source#stype
29
- method private _is_ready = source#is_ready
29
+ method private can_generate_frame = source#is_ready
30
30
  method self_sync = source#self_sync
31
31
  method remaining = source#remaining
32
32
  method seek_source = source#seek_source
@@ -43,13 +43,14 @@ class bpm (source : source) =
43
43
  (Frame.Fields.find_opt Frame.Fields.audio self#content_type)))
44
44
  (Lazy.force Frame.audio_rate))
45
45
 
46
- method private get_frame buf =
46
+ method private generate_frame =
47
+ let buf =
48
+ Content.Audio.get_data (source#get_mutable_content Frame.Fields.audio)
49
+ in
47
50
  let bpm = Option.get bpm in
48
- let offset = AFrame.position buf in
49
- source#get buf;
50
- let len = AFrame.position buf - offset in
51
- let buf = AFrame.pcm buf in
52
- Soundtouch.BPM.put_samples_ni bpm buf offset len
51
+ let len = source#frame_audio_position in
52
+ Soundtouch.BPM.put_samples_ni bpm buf 0 len;
53
+ source#set_frame_data Frame.Fields.audio Content.Audio.lift_data buf
53
54
 
54
55
  method bpm =
55
56
  match bpm with Some bpm -> Soundtouch.BPM.get_bpm bpm | None -> 0.
@@ -75,18 +75,16 @@ class stereotool ~field ~handler source =
75
75
  method stype = source#stype
76
76
  method remaining = source#remaining
77
77
  method seek_source = source#seek_source
78
- method private _is_ready = source#is_ready
78
+ method private can_generate_frame = source#is_ready
79
79
  method abort_track = source#abort_track
80
80
  method self_sync = source#self_sync
81
81
 
82
- method private get_frame buf =
83
- let offset = AFrame.position buf in
84
- source#get buf;
85
- let position = AFrame.position buf in
86
- let b = Content.Audio.get_data (Frame.get buf field) in
82
+ method private generate_frame =
83
+ let b = Content.Audio.get_data (source#get_mutable_content field) in
87
84
  Stereotool.process
88
85
  ~samplerate:(Lazy.force Frame.audio_rate)
89
- handler b offset (position - offset)
86
+ handler b 0 source#frame_audio_position;
87
+ source#set_frame_data field Content.Audio.lift_data b
90
88
  end
91
89
 
92
90
  let _ =
@@ -33,7 +33,7 @@ class still_frame ~name (source : source) =
33
33
  method remaining = source#remaining
34
34
  method seek_source = source#seek_source
35
35
  method self_sync = source#self_sync
36
- method private _is_ready = source#is_ready
36
+ method private can_generate_frame = source#is_ready
37
37
  method abort_track = source#abort_track
38
38
  val mutable fname = None
39
39
 
@@ -44,15 +44,14 @@ class still_frame ~name (source : source) =
44
44
  .bmp"
45
45
  else fname <- Some f
46
46
 
47
- method private get_frame buf =
47
+ method private still buf =
48
48
  match fname with
49
- | None -> source#get buf
49
+ | None -> ()
50
50
  | Some f -> (
51
- let v = VFrame.get_content buf source in
52
- match v with
53
- | Some (v, off, _) ->
54
- let v = Content.Video.get_data v in
55
- let i = Video.Canvas.get v off in
51
+ let v = Content.Video.get_data (Frame.get buf Frame.Fields.video) in
52
+ match v.Content.Video.data with
53
+ | [] -> ()
54
+ | (_, i) :: _ ->
56
55
  let i =
57
56
  i |> Video.Canvas.Image.render |> Image.YUV420.to_RGBA32
58
57
  |> Image.RGBA32.to_BMP
@@ -60,8 +59,12 @@ class still_frame ~name (source : source) =
60
59
  let oc = open_out f in
61
60
  output_string oc i;
62
61
  close_out oc;
63
- fname <- None
64
- | None -> ())
62
+ fname <- None)
63
+
64
+ method private generate_frame =
65
+ let buf = source#get_frame in
66
+ self#still buf;
67
+ buf
65
68
  end
66
69
 
67
70
  let _ =
@@ -35,10 +35,41 @@ type child = { source : source; transition : transition }
35
35
  * or only at track limits (sensitive). *)
36
36
  type track_mode = Sensitive | Insensitive
37
37
 
38
- type selection = { child : child; effective_source : source }
38
+ type selection = {
39
+ predicate : Lang.value;
40
+ child : child;
41
+ effective_source : source;
42
+ }
39
43
 
40
- class virtual switch ~name ~override_meta ~transition_length
41
- ?(mode = fun () -> true) ?(replay_meta = true) (cases : child list) =
44
+ let satisfied f = Lang.to_bool (Lang.apply f [])
45
+
46
+ let trivially_true = function
47
+ | {
48
+ Lang.value =
49
+ Lang.Fun (_, _, { Term.term = `Ground (Term.Ground.Bool true); _ });
50
+ _;
51
+ } ->
52
+ true
53
+ | _ -> false
54
+
55
+ let pick_selection (p, _, s) = (p, s)
56
+
57
+ (** Like [List.find] but evaluates [f] on every element when [strict] is
58
+ [true]. *)
59
+ let find ?(strict = false) f l =
60
+ let rec aux = function
61
+ | x :: l ->
62
+ if f x then (
63
+ if strict then List.iter (fun x -> ignore (f x)) l;
64
+ x)
65
+ else aux l
66
+ | [] -> raise Not_found
67
+ in
68
+ aux l
69
+
70
+ class switch ~all_predicates ~override_meta ~transition_length ~replay_meta
71
+ ~track_sensitive children =
72
+ let cases = List.map (fun (_, _, s) -> s) children in
42
73
  let sources = ref (List.map (fun c -> c.source) cases) in
43
74
  let failed = ref false in
44
75
  let () =
@@ -52,7 +83,13 @@ class virtual switch ~name ~override_meta ~transition_length
52
83
  if !failed then lazy `Dynamic else Utils.self_sync_type !sources
53
84
  in
54
85
  object (self)
55
- inherit operator ~name (List.map (fun x -> x.source) cases)
86
+ inherit operator ~name:"switch" (List.map (fun x -> x.source) cases)
87
+
88
+ inherit
89
+ generate_from_multiple_sources
90
+ ~merge:(fun () -> false)
91
+ ~track_sensitive ()
92
+
56
93
  val mutable transition_length = transition_length
57
94
  val mutable selected : selection option = None
58
95
 
@@ -62,34 +99,30 @@ class virtual switch ~name ~override_meta ~transition_length
62
99
  | Some { child = { source }; effective_source } ->
63
100
  source != effective_source
64
101
 
65
- (** Indicates that the former child was left without having finished its
66
- * track, in which case the switch will artificially produce an EOT. *)
67
- val mutable need_eot = false
68
-
69
- (** The selection method should return None or Some c,
70
- * where c is a ready child. *)
71
- method virtual private select : child option
72
-
73
- (** Don't call #select directly but use #cached_select
74
- * to ensure consistency during one time tick between #is_ready and
75
- * #get_frame. We want to make sure that when a source is selected
76
- * during a #is_ready call, the same selection is returned during the
77
- * next #get_frame call. *)
78
- val mutable cached_selected = None
79
-
80
- method private cached_select =
81
- match cached_selected with
82
- | Some _ as c -> c
83
- | None ->
84
- cached_selected <- self#select;
85
- cached_selected
86
-
87
- initializer
88
- self#on_after_output (fun () ->
89
- (* Selection may have been triggered by a call to #is_ready, without
90
- * any call to #get_ready (in particular if #select returned None).
91
- * It is cleared here in order to get a chance to be re-computed later. *)
92
- cached_selected <- None)
102
+ method private select ~reselect () =
103
+ let may_reselect ~single s =
104
+ match selected with
105
+ | Some { child; effective_source } when child.source == s.source ->
106
+ (not single) && self#can_reselect ~reselect effective_source
107
+ | _ -> true
108
+ in
109
+ try
110
+ Some
111
+ (pick_selection
112
+ (find ~strict:all_predicates
113
+ (fun (d, single, s) ->
114
+ satisfied d && may_reselect ~single s && s.source#is_ready)
115
+ children))
116
+ with Not_found -> None
117
+
118
+ method stype =
119
+ if
120
+ List.exists
121
+ (fun (d, single, s) ->
122
+ s.source#stype = `Infallible && (not single) && trivially_true d)
123
+ children
124
+ then `Infallible
125
+ else `Fallible
93
126
 
94
127
  val mutable activation = []
95
128
 
@@ -110,37 +143,33 @@ class virtual switch ~name ~override_meta ~transition_length
110
143
  if self#is_selected_generated then
111
144
  (Option.get selected).effective_source#leave (self :> source)
112
145
 
113
- method private _is_ready ?frame:_ _ =
114
- need_eot || selected <> None || self#cached_select <> None
115
-
116
- (* This one is tricky. We do not want to call #cached_select as
117
- this requires some run-time info from underlying sources
118
- (mostly ctype to be set). The only case that matters if no
119
- sources are selected is to know if we are [`Static, false] for
120
- any caller such as [cross]. Since the source is not ready, we
121
- can return anything so we check if any source might be not
122
- self_sync in this case *)
123
- method self_sync =
124
- ( Lazy.force self_sync_type,
125
- match selected with
126
- | Some s -> snd s.effective_source#self_sync
127
- | None -> List.exists (fun c -> snd c.source#self_sync) cases )
128
-
129
- method private get_frame ab =
130
- (* Choose the next child to be played.
131
- * [forget] tells that the current child has finished its track,
132
- * in which case a transition does not make sense and would actually start
133
- * playing a next track (if available) on the left child. *)
134
- let reselect ?(forget = false) () =
135
- if not forget then need_eot <- true;
136
- match
137
- let c = self#cached_select in
138
- cached_selected <- None;
139
- c
140
- with
141
- | Some c -> (
142
- match selected with
143
- | None ->
146
+ method get_source ~reselect () =
147
+ match selected with
148
+ | Some s
149
+ when (track_sensitive () || satisfied s.predicate)
150
+ && self#can_reselect
151
+ ~reselect:
152
+ (* We want to force a re-select on each new track. *)
153
+ (match reselect with
154
+ | `After_position _ -> `Force
155
+ | v -> v)
156
+ s.effective_source ->
157
+ Some s.effective_source
158
+ | _ -> (
159
+ begin
160
+ match
161
+ ( selected,
162
+ self#select
163
+ (* If we've returned the same source, it should be accepted now. *)
164
+ ~reselect:(match reselect with `Force -> `Ok | v -> v)
165
+ () )
166
+ with
167
+ | None, None -> ()
168
+ | Some c, None ->
169
+ if c.child.source != c.effective_source then
170
+ c.effective_source#leave (self :> source);
171
+ selected <- None
172
+ | None, Some (predicate, c) ->
144
173
  self#log#important "Switch to %s." c.source#id;
145
174
  let new_source =
146
175
  (* Force insertion of old metadata if relevant.
@@ -158,18 +187,28 @@ class virtual switch ~name ~override_meta ~transition_length
158
187
  Typing.(new_source#frame_type <: self#frame_type);
159
188
  new_source#get_ready activation;
160
189
  selected <-
161
- Some { child = c; effective_source = new_source }
162
- | Some old_selection when old_selection.child.source != c.source
163
- ->
190
+ Some
191
+ { predicate; child = c; effective_source = new_source }
192
+ | Some old_selection, Some (_, c)
193
+ when old_selection.child.source == c.source ->
194
+ ()
195
+ | old_selection, Some (predicate, c) ->
196
+ let forget, old_source =
197
+ match old_selection with
198
+ | None -> (true, Debug_sources.empty ())
199
+ | Some old_selection ->
200
+ if
201
+ old_selection.effective_source
202
+ != old_selection.child.source
203
+ then
204
+ old_selection.effective_source#leave
205
+ (self :> source);
206
+ (false, old_selection.child.source)
207
+ in
164
208
  self#log#important "Switch to %s with%s transition."
165
209
  c.source#id
166
210
  (if forget then " forgetful" else "");
167
- old_selection.effective_source#leave (self :> source);
168
211
  Clock.collect_after (fun () ->
169
- let old_source =
170
- if forget then Debug_sources.empty ()
171
- else old_selection.child.source
172
- in
173
212
  let new_source =
174
213
  (* Force insertion of old metadata if relevant.
175
214
  * It can't be done in a static way: we need to start
@@ -203,42 +242,26 @@ class virtual switch ~name ~override_meta ~transition_length
203
242
  ~override_meta ~duration:transition_length s
204
243
  in
205
244
  Typing.(s#frame_type <: self#frame_type);
206
- new Sequence.sequence
207
- ~merge:true [s; new_source]
245
+ (new Sequence.sequence
246
+ ~merge:true [s; new_source]
247
+ :> Source.source)
208
248
  in
209
249
  Typing.(s#frame_type <: self#frame_type);
210
250
  Clock.unify ~pos:self#pos s#clock self#clock;
211
251
  s#get_ready activation;
212
- selected <- Some { child = c; effective_source = s })
213
- | _ ->
214
- (* We are staying on the same child,
215
- * don't start a new track. *)
216
- need_eot <- false)
217
- | None -> (
218
- match selected with
219
- | Some old_s ->
220
- old_s.effective_source#leave (self :> source);
221
- selected <- None
222
- | None -> ())
223
- in
224
- (* #select is called only when selected=None, and the cache is cleared
225
- * as soon as the new selection is set. *)
226
- assert (selected = None || cached_selected = None);
227
- if need_eot then (
228
- need_eot <- false;
229
- Frame.add_break ab (Frame.position ab))
230
- else (
231
- match selected with
232
- | None ->
233
- reselect ~forget:true ();
252
+ selected <-
253
+ Some { predicate; child = c; effective_source = s })
254
+ end;
255
+ match selected with
256
+ | Some s when s.effective_source#is_ready ->
257
+ Some s.effective_source
258
+ | _ -> None)
234
259
 
235
- (* Our #is_ready, and caching, ensure the following. *)
236
- assert (selected <> None);
237
- self#get_frame ab
238
- | Some s ->
239
- s.effective_source#get ab;
240
- if Frame.is_partial ab then reselect ~forget:true ()
241
- else if not (mode ()) then reselect ())
260
+ method self_sync =
261
+ ( Lazy.force self_sync_type,
262
+ match selected with
263
+ | Some s -> snd s.effective_source#self_sync
264
+ | None -> List.exists (fun c -> snd c.source#self_sync) cases )
242
265
 
243
266
  method remaining =
244
267
  match selected with None -> 0 | Some s -> s.effective_source#remaining
@@ -262,69 +285,6 @@ let default_transition =
262
285
  Liquidsoap_lang.Runtime.eval ~ignored:false ~ty:(Lang.univ_t ())
263
286
  "fun (_, y) -> y"
264
287
 
265
- (** Switch: switch according to user-defined predicates. *)
266
-
267
- let satisfied f = Lang.to_bool (Lang.apply f [])
268
-
269
- let trivially_true = function
270
- | {
271
- Lang.value =
272
- Lang.Fun (_, _, { Term.term = `Ground (Term.Ground.Bool true); _ });
273
- _;
274
- } ->
275
- true
276
- | _ -> false
277
-
278
- let third (_, _, s) = s
279
-
280
- (** Like [List.find] but evaluates [f] on every element when [strict] is
281
- [true]. *)
282
- let find ?(strict = false) f l =
283
- let rec aux = function
284
- | x :: l ->
285
- if f x then (
286
- if strict then List.iter (fun x -> ignore (f x)) l;
287
- x)
288
- else aux l
289
- | [] -> raise Not_found
290
- in
291
- aux l
292
-
293
- class lang_switch ~override_meta ~all_predicates ~transition_length mode
294
- ?replay_meta (children : (Lang.value * bool * child) list) =
295
- object
296
- inherit
297
- switch
298
- ~name:"switch" ~mode ~override_meta ~transition_length ?replay_meta
299
- (List.map third children)
300
-
301
- method private select =
302
- let selected s =
303
- match selected with
304
- | Some { child } when child.source == s.source -> true
305
- | _ -> false
306
- in
307
- try
308
- Some
309
- (third
310
- (find ~strict:all_predicates
311
- (fun (d, single, s) ->
312
- (* Check single constraints *)
313
- (if selected s then not single else true)
314
- && satisfied d && s.source#is_ready ())
315
- children))
316
- with Not_found -> None
317
-
318
- method stype =
319
- if
320
- List.exists
321
- (fun (d, single, s) ->
322
- s.source#stype = `Infallible && (not single) && trivially_true d)
323
- children
324
- then `Infallible
325
- else `Fallible
326
- end
327
-
328
288
  let _ =
329
289
  let return_t = Lang.frame_t (Lang.univ_t ()) Frame.Fields.empty in
330
290
  let pred_t = Lang.fun_t [] Lang.bool_t in
@@ -438,6 +398,6 @@ let _ =
438
398
  ( List.assoc "single" p,
439
399
  "there should be exactly one flag per children" ))
440
400
  in
441
- new lang_switch
442
- ~replay_meta ~override_meta ~all_predicates ~transition_length:tl ts
443
- children)
401
+ new switch
402
+ ~replay_meta ~override_meta ~all_predicates ~transition_length:tl
403
+ ~track_sensitive:ts children)