Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/docs/plugins/scanobj-build.stamp b/docs/plugins/scanobj-build.stamp
- deleted file mode 100644
- index e69de29..0000000
- diff --git a/sys/decklink/gstdecklinksink.cpp b/sys/decklink/gstdecklinksink.cpp
- index 257277d..657cf4e 100644
- --- a/sys/decklink/gstdecklinksink.cpp
- +++ b/sys/decklink/gstdecklinksink.cpp
- @@ -696,24 +696,76 @@ gst_decklink_sink_audiosink_chain (GstPad * pad, GstObject * parent,
- {
- GstDecklinkSink *decklinksink;
- GstFlowReturn ret;
- -
- + GstClockTime timestamp, duration;
- + GstClockTime running_time;
- + GstClockTime running_time_duration;
- + GstClock *clock;
- + GstClockID clock_id;
- + GstClockTime base_time;
- decklinksink = GST_DECKLINK_SINK (parent);
- if (decklinksink->stop)
- return GST_FLOW_FLUSHING;
- - g_mutex_lock (&decklinksink->audio_mutex);
- + timestamp = GST_BUFFER_TIMESTAMP (buffer);
- + duration = GST_BUFFER_DURATION (buffer);
- + if (duration == GST_CLOCK_TIME_NONE) {
- + duration = gst_util_uint64_scale_int (GST_SECOND, gst_buffer_get_size (buffer), 2 * 2 *48000);
- + GST_WARNING_OBJECT (decklinksink, "no audio duration, setting it to %lu",
- + duration);
- + }
- +
- + running_time =
- + gst_segment_to_running_time (&decklinksink->audio_segment,
- + GST_FORMAT_TIME, timestamp);
- + running_time_duration =
- + gst_segment_to_running_time (&decklinksink->audio_segment,
- + GST_FORMAT_TIME, timestamp + duration) - running_time;
- +
- + clock = gst_element_get_clock (GST_ELEMENT (decklinksink));
- + base_time = gst_element_get_base_time (GST_ELEMENT (decklinksink));
- + if (clock) {
- + if (base_time != GST_CLOCK_TIME_NONE) {
- + GstClockTime clock_time = gst_clock_get_time (clock);
- +
- + if (base_time + running_time + running_time_duration <
- + gst_clock_get_time (clock)) {
- + GST_WARNING_OBJECT (decklinksink,
- + "Dropping too late frame: %" GST_TIME_FORMAT " < %" GST_TIME_FORMAT,
- + GST_TIME_ARGS (running_time + running_time_duration),
- + GST_TIME_ARGS (clock_time - base_time));
- + gst_object_unref (clock);
- + //flow_ret = GST_FLOW_OK;
- + goto out;
- + }
- +
- + if (base_time + running_time > gst_clock_get_time(clock) ) {
- + clock_id = gst_clock_new_single_shot_id (clock, base_time + running_time);
- + GST_WARNING_OBJECT (decklinksink,
- + "waiting for clock: %" GST_TIME_FORMAT " -> %" GST_TIME_FORMAT,
- + GST_TIME_ARGS (clock_time), GST_TIME_ARGS (base_time + running_time));
- + gst_clock_id_wait (clock_id, NULL);
- + //GST_LOG_OBJECT (decklinksink, "finished waiting for clock");
- + gst_clock_id_unref (clock_id);
- + }
- + }
- +
- + gst_object_unref (clock);
- + }
- +
- /* FIXME: This is not correct as it assumes that the decklink clock
- * has the exact same value as the pipeline clock at any time. Not
- * only the same rate!
- */
- - while (!decklinksink->stop &&
- - gst_adapter_available (decklinksink->audio_adapter) > 1600 * 4 * 2) {
- - g_cond_wait (&decklinksink->audio_cond, &decklinksink->audio_mutex);
- - }
- + //while (!decklinksink->stop &&
- + // gst_adapter_available (decklinksink->audio_adapter) > 1600 * 4 * 2) {
- + //g_cond_wait (&decklinksink->audio_cond, &decklinksink->audio_mutex);
- + //}
- + g_mutex_lock (&decklinksink->audio_mutex);
- gst_adapter_push (decklinksink->audio_adapter, buffer);
- g_mutex_unlock (&decklinksink->audio_mutex);
- +out:
- ret = GST_FLOW_OK;
- return ret;
- }
- @@ -795,6 +847,13 @@ Output::RenderAudioSamples (bool preroll)
- {
- uint32_t samplesWritten;
- HRESULT ret;
- + GstClockTime timestamp, duration;
- + GstClockTime running_time;
- + GstClockTime running_time_duration;
- + GstClock *clock;
- + GstClockID clock_id;
- + GstClockTime base_time;
- + guint64 dist;
- // guint64 samplesToWrite;
- @@ -806,18 +865,67 @@ Output::RenderAudioSamples (bool preroll)
- gconstpointer data;
- int n;
- +
- g_mutex_lock (&decklinksink->audio_mutex);
- n = gst_adapter_available (decklinksink->audio_adapter);
- if (n > 0) {
- data = gst_adapter_map (decklinksink->audio_adapter, n);
- + clock = gst_element_get_clock (GST_ELEMENT (decklinksink));
- + base_time = gst_element_get_base_time (GST_ELEMENT (decklinksink));
- + timestamp = gst_adapter_prev_pts (decklinksink->audio_adapter, &dist);
- +
- + if (timestamp == GST_CLOCK_TIME_NONE) {
- + GST_WARNING_OBJECT (decklinksink,
- + "No timestamp for audio adapter");
- + }
- +
- + running_time =
- + gst_segment_to_running_time (&decklinksink->audio_segment,
- + GST_FORMAT_TIME, timestamp);
- + duration = gst_util_uint64_scale_int (GST_SECOND, 48000, 1);
- +
- + running_time_duration =
- + gst_segment_to_running_time (&decklinksink->audio_segment,
- + GST_FORMAT_TIME, timestamp + duration) - running_time;
- +
- + if (clock) {
- + if (base_time != GST_CLOCK_TIME_NONE) {
- + GstClockTime clock_time = gst_clock_get_time (clock);
- +
- + if (base_time + running_time + running_time_duration <
- + gst_clock_get_time (clock)) {
- + GST_WARNING_OBJECT (decklinksink,
- + "Dropping too late frame (avail=%d, dist=%lu dropping=%ld) : %" GST_TIME_FORMAT " < %" GST_TIME_FORMAT,
- + n, dist, (gint64)n - (gint64)dist,
- + GST_TIME_ARGS (running_time + running_time_duration),
- + GST_TIME_ARGS (clock_time - base_time));
- + gst_object_unref (clock);
- + gst_adapter_flush (decklinksink->audio_adapter, n - dist);
- + return S_OK;
- + }
- +
- + if (base_time + running_time > gst_clock_get_time(clock) ) {
- + clock_id = gst_clock_new_single_shot_id (clock, base_time + running_time);
- + GST_LOG_OBJECT (decklinksink,
- + "waiting for clock: %" GST_TIME_FORMAT " -> %" GST_TIME_FORMAT,
- + GST_TIME_ARGS (clock_time), GST_TIME_ARGS (base_time + running_time));
- + gst_clock_id_wait (clock_id, NULL);
- + GST_LOG_OBJECT (decklinksink, "finished waiting for clock");
- + gst_clock_id_unref (clock_id);
- + }
- + }
- +
- + gst_object_unref (clock);
- + }
- +
- /* FIXME: This is not correct. We assume here that the decklink
- * clock runs at the same rate as the pipeline clock and that
- * the input stream has no discontinuities at all
- */
- ret = decklinksink->output->ScheduleAudioSamples ((void *) data, n / 4,
- - 0, 0, &samplesWritten);
- + running_time, GST_SECOND, &samplesWritten);
- gst_adapter_unmap (decklinksink->audio_adapter);
- gst_adapter_flush (decklinksink->audio_adapter, samplesWritten * 4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement