Skip to content
Browse files

Emit end_of_stream on stop.

  • Loading branch information...
1 parent ef50490 commit c16ee1e6b38b887bce84152bb126cf2ca6bac5a9 @smimram smimram committed
Showing with 17 additions and 11 deletions.
  1. +13 −11 src/encoder/gstreamer_encoder.ml
  2. +4 −0 src/tools/utils.ml
View
24 src/encoder/gstreamer_encoder.ml
@@ -37,21 +37,21 @@ type gst =
let encoder id ext =
GU.init ();
- let channels =
- Encoder.GStreamer.audio_channels ext
- in
+ let channels = Encoder.GStreamer.audio_channels ext in
let mutex = Mutex.create () in
+ (* Here "samples" are the number of buffers available in the GStreamer
+ appsink *)
let samples = ref 0 in
let decr_samples =
- Tutils.mutexify mutex (fun () ->
- decr samples)
+ Tutils.mutexify mutex
+ (fun () -> decr samples)
in
let incr_samples =
- Tutils.mutexify mutex (fun () ->
- incr samples)
+ Tutils.mutexify mutex
+ (fun () -> incr samples)
in
let on_sample () =
- incr_samples();
+ incr_samples ()
in
let gst =
@@ -108,6 +108,8 @@ let encoder id ext =
let stop gst () =
let ans = ref "" in
+ Utils.maydo Gstreamer.App_src.end_of_stream gst.audio_src;
+ Utils.maydo Gstreamer.App_src.end_of_stream gst.video_src;
ignore (Gstreamer.Element.set_state gst.bin Gstreamer.Element.State_null);
ignore (Gstreamer.Element.get_state gst.bin);
while !samples > 0 do
@@ -131,12 +133,12 @@ let encoder id ext =
let nanolen = Int64.of_float (Frame.seconds_of_master len *. nano) in
let videochans = if gst.video_src <> None then 1 else 0 in
let content =
- Frame.content_of_type frame start
+ Frame.content_of_type frame start
{Frame.
audio = channels;
video = videochans;
- midi = 0
- }
+ midi = 0;
+ }
in
if channels > 0 then
begin
View
4 src/tools/utils.ml
@@ -28,6 +28,10 @@ let maybe f = function
| Some x -> Some (f x)
| None -> None
+let maydo f = function
+ | Some x -> f x
+ | None -> ()
+
let some_or none = function
| Some x -> x
| None -> none

0 comments on commit c16ee1e

Please sign in to comment.
Something went wrong with that request. Please try again.