~ubuntu-branches/ubuntu/precise/gst-plugins-base0.10/precise-updates

« back to all changes in this revision

Viewing changes to gst-libs/gst/audio/gstbaseaudiosink.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2011-12-12 12:40:13 UTC
  • mfrom: (36.1.15 experimental)
  • Revision ID: package-import@ubuntu.com-20111212124013-onyadfb150d8c5dk
Tags: 0.10.35.2-2
* debian/libgstreamer-plugins-base.install:
  + Add license translations file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
#include <string.h>
36
36
 
 
37
/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
 
38
 * with newer GLib versions (>= 2.31.0) */
 
39
#define GLIB_DISABLE_DEPRECATION_WARNINGS
 
40
 
37
41
#include "gstbaseaudiosink.h"
38
42
 
39
43
GST_DEBUG_CATEGORY_STATIC (gst_base_audio_sink_debug);
58
62
  GstClockTime eos_time;
59
63
 
60
64
  gboolean do_time_offset;
61
 
  /* number of microseconds we alow timestamps or clock slaving to drift
 
65
  /* number of microseconds we allow clock slaving to drift
62
66
   * before resyncing */
63
67
  guint64 drift_tolerance;
 
68
 
 
69
  /* number of nanoseconds we allow timestamps to drift
 
70
   * before resyncing */
 
71
  GstClockTime alignment_threshold;
 
72
 
 
73
  /* time of the previous detected discont candidate */
 
74
  GstClockTime discont_time;
 
75
 
 
76
  /* number of nanoseconds to wait until creating a discontinuity */
 
77
  GstClockTime discont_wait;
64
78
};
65
79
 
66
80
/* BaseAudioSink signals and args */
79
93
/* FIXME, enable pull mode when clock slaving and trick modes are figured out */
80
94
#define DEFAULT_CAN_ACTIVATE_PULL FALSE
81
95
 
82
 
/* when timestamps or clock slaving drift for more than 40ms we resync. This is
 
96
/* when timestamps drift for more than 40ms we resync. This should
 
97
 * be anough to compensate for timestamp rounding errors. */
 
98
#define DEFAULT_ALIGNMENT_THRESHOLD   (40 * GST_MSECOND)
 
99
 
 
100
/* when clock slaving drift for more than 40ms we resync. This is
83
101
 * a reasonable default */
84
102
#define DEFAULT_DRIFT_TOLERANCE   ((40 * GST_MSECOND) / GST_USECOND)
85
103
 
 
104
/* allow for one second before resyncing to see if the timestamps drift will
 
105
 * fix itself, or is a permanent offset */
 
106
#define DEFAULT_DISCONT_WAIT        (1 * GST_SECOND)
 
107
 
86
108
enum
87
109
{
88
110
  PROP_0,
92
114
  PROP_PROVIDE_CLOCK,
93
115
  PROP_SLAVE_METHOD,
94
116
  PROP_CAN_ACTIVATE_PULL,
 
117
  PROP_ALIGNMENT_THRESHOLD,
95
118
  PROP_DRIFT_TOLERANCE,
 
119
  PROP_DISCONT_WAIT,
96
120
 
97
121
  PROP_LAST
98
122
};
216
240
  /**
217
241
   * GstBaseAudioSink:drift-tolerance
218
242
   *
219
 
   * Controls the amount of time in milliseconds that timestamps or clocks are allowed
 
243
   * Controls the amount of time in microseconds that clocks are allowed
220
244
   * to drift before resynchronisation happens.
221
245
   *
222
246
   * Since: 0.10.26
223
247
   */
224
248
  g_object_class_install_property (gobject_class, PROP_DRIFT_TOLERANCE,
225
249
      g_param_spec_int64 ("drift-tolerance", "Drift Tolerance",
226
 
          "Tolerance for timestamp and clock drift in microseconds", 1,
 
250
          "Tolerance for clock drift in microseconds", 1,
227
251
          G_MAXINT64, DEFAULT_DRIFT_TOLERANCE,
228
252
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
253
  /**
 
254
   * GstBaseAudioSink:alignment_threshold
 
255
   *
 
256
   * Controls the amount of time in nanoseconds that timestamps are allowed
 
257
   * to drift from their ideal time before choosing not to align them.
 
258
   *
 
259
   * Since: 0.10.36
 
260
   */
 
261
  g_object_class_install_property (gobject_class, PROP_ALIGNMENT_THRESHOLD,
 
262
      g_param_spec_uint64 ("alignment-threshold", "Alignment Threshold",
 
263
          "Timestamp alignment threshold in nanoseconds", 1,
 
264
          G_MAXUINT64 - 1, DEFAULT_ALIGNMENT_THRESHOLD,
 
265
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
266
 
 
267
  /**
 
268
   * GstBaseAudioSink:discont-wait
 
269
   *
 
270
   * A window of time in nanoseconds to wait before creating a discontinuity as
 
271
   * a result of breaching the drift-tolerance.
 
272
   *
 
273
   * Since: 0.10.36
 
274
   */
 
275
  g_object_class_install_property (gobject_class, PROP_DISCONT_WAIT,
 
276
      g_param_spec_uint64 ("discont-wait", "Discont Wait",
 
277
          "Window of time in nanoseconds to wait before "
 
278
          "creating a discontinuity", 0,
 
279
          G_MAXUINT64 - 1, DEFAULT_DISCONT_WAIT,
 
280
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
229
281
 
230
282
  gstelement_class->change_state =
231
283
      GST_DEBUG_FUNCPTR (gst_base_audio_sink_change_state);
266
318
  baseaudiosink->provide_clock = DEFAULT_PROVIDE_CLOCK;
267
319
  baseaudiosink->priv->slave_method = DEFAULT_SLAVE_METHOD;
268
320
  baseaudiosink->priv->drift_tolerance = DEFAULT_DRIFT_TOLERANCE;
 
321
  baseaudiosink->priv->alignment_threshold = DEFAULT_ALIGNMENT_THRESHOLD;
 
322
  baseaudiosink->priv->discont_wait = DEFAULT_DISCONT_WAIT;
269
323
 
270
324
  baseaudiosink->provided_clock = gst_audio_clock_new ("GstAudioSinkClock",
271
325
      (GstAudioClockGetTimeFunc) gst_base_audio_sink_get_time, baseaudiosink);
292
346
  if (feature) {
293
347
    if (strcmp (gst_plugin_feature_get_name (feature), "pulsesink") == 0) {
294
348
      if (!gst_plugin_feature_check_version (feature, 0, 10, 17)) {
295
 
        /* we're dealing with an old pulsesink, we need to disable time corection */
 
349
        /* we're dealing with an old pulsesink, we need to disable time correction */
296
350
        GST_DEBUG ("disable time offset");
297
351
        baseaudiosink->priv->do_time_offset = FALSE;
298
352
      }
415
469
      if ((res =
416
470
              gst_base_sink_query_latency (GST_BASE_SINK_CAST (basesink), &live,
417
471
                  &us_live, &min_l, &max_l))) {
418
 
        GstClockTime min_latency, max_latency;
 
472
        GstClockTime base_latency, min_latency, max_latency;
419
473
 
420
474
        /* we and upstream are both live, adjust the min_latency */
421
475
        if (live && us_live) {
434
488
 
435
489
          basesink->priv->us_latency = min_l;
436
490
 
437
 
          min_latency =
 
491
          base_latency =
438
492
              gst_util_uint64_scale_int (spec->seglatency * spec->segsize,
439
493
              GST_SECOND, spec->rate * spec->bytes_per_sample);
440
494
          GST_OBJECT_UNLOCK (basesink);
441
495
 
442
496
          /* we cannot go lower than the buffer size and the min peer latency */
443
 
          min_latency = min_latency + min_l;
 
497
          min_latency = base_latency + min_l;
444
498
          /* the max latency is the max of the peer, we can delay an infinite
445
499
           * amount of time. */
446
 
          max_latency = min_latency + (max_l == -1 ? 0 : max_l);
 
500
          max_latency = (max_l == -1) ? -1 : (base_latency + max_l);
447
501
 
448
502
          GST_DEBUG_OBJECT (basesink,
449
503
              "peer min %" GST_TIME_FORMAT ", our min latency: %"
450
504
              GST_TIME_FORMAT, GST_TIME_ARGS (min_l),
451
505
              GST_TIME_ARGS (min_latency));
 
506
          GST_DEBUG_OBJECT (basesink,
 
507
              "peer max %" GST_TIME_FORMAT ", our max latency: %"
 
508
              GST_TIME_FORMAT, GST_TIME_ARGS (max_l),
 
509
              GST_TIME_ARGS (max_latency));
452
510
        } else {
453
511
          GST_DEBUG_OBJECT (basesink,
454
512
              "peer or we are not live, don't care about latency");
655
713
  return result;
656
714
}
657
715
 
 
716
/**
 
717
 * gst_base_audio_sink_set_alignment_threshold:
 
718
 * @sink: a #GstBaseAudioSink
 
719
 * @alignment_threshold: the new alignment threshold in nanoseconds
 
720
 *
 
721
 * Controls the sink's alignment threshold.
 
722
 *
 
723
 * Since: 0.10.36
 
724
 */
 
725
void
 
726
gst_base_audio_sink_set_alignment_threshold (GstBaseAudioSink * sink,
 
727
    GstClockTime alignment_threshold)
 
728
{
 
729
  g_return_if_fail (GST_IS_BASE_AUDIO_SINK (sink));
 
730
 
 
731
  GST_OBJECT_LOCK (sink);
 
732
  sink->priv->alignment_threshold = alignment_threshold;
 
733
  GST_OBJECT_UNLOCK (sink);
 
734
}
 
735
 
 
736
/**
 
737
 * gst_base_audio_sink_get_alignment_threshold
 
738
 * @sink: a #GstBaseAudioSink
 
739
 *
 
740
 * Get the current alignment threshold, in nanoseconds, used by @sink.
 
741
 *
 
742
 * Returns: The current alignment threshold used by @sink.
 
743
 *
 
744
 * Since: 0.10.36
 
745
 */
 
746
GstClockTime
 
747
gst_base_audio_sink_get_alignment_threshold (GstBaseAudioSink * sink)
 
748
{
 
749
  gint64 result;
 
750
 
 
751
  g_return_val_if_fail (GST_IS_BASE_AUDIO_SINK (sink), -1);
 
752
 
 
753
  GST_OBJECT_LOCK (sink);
 
754
  result = sink->priv->alignment_threshold;
 
755
  GST_OBJECT_UNLOCK (sink);
 
756
 
 
757
  return result;
 
758
}
 
759
 
 
760
/**
 
761
 * gst_base_audio_sink_set_discont_wait:
 
762
 * @sink: a #GstBaseAudioSink
 
763
 * @discont_wait: the new discont wait in nanoseconds
 
764
 *
 
765
 * Controls how long the sink will wait before creating a discontinuity.
 
766
 *
 
767
 * Since: 0.10.36
 
768
 */
 
769
void
 
770
gst_base_audio_sink_set_discont_wait (GstBaseAudioSink * sink,
 
771
    GstClockTime discont_wait)
 
772
{
 
773
  g_return_if_fail (GST_IS_BASE_AUDIO_SINK (sink));
 
774
 
 
775
  GST_OBJECT_LOCK (sink);
 
776
  sink->priv->discont_wait = discont_wait;
 
777
  GST_OBJECT_UNLOCK (sink);
 
778
}
 
779
 
 
780
/**
 
781
 * gst_base_audio_sink_get_discont_wait
 
782
 * @sink: a #GstBaseAudioSink
 
783
 *
 
784
 * Get the current discont wait, in nanoseconds, used by @sink.
 
785
 *
 
786
 * Returns: The current discont wait used by @sink.
 
787
 *
 
788
 * Since: 0.10.36
 
789
 */
 
790
GstClockTime
 
791
gst_base_audio_sink_get_discont_wait (GstBaseAudioSink * sink)
 
792
{
 
793
  GstClockTime result;
 
794
 
 
795
  g_return_val_if_fail (GST_IS_BASE_AUDIO_SINK (sink), -1);
 
796
 
 
797
  GST_OBJECT_LOCK (sink);
 
798
  result = sink->priv->discont_wait;
 
799
  GST_OBJECT_UNLOCK (sink);
 
800
 
 
801
  return result;
 
802
}
 
803
 
658
804
static void
659
805
gst_base_audio_sink_set_property (GObject * object, guint prop_id,
660
806
    const GValue * value, GParamSpec * pspec)
682
828
    case PROP_DRIFT_TOLERANCE:
683
829
      gst_base_audio_sink_set_drift_tolerance (sink, g_value_get_int64 (value));
684
830
      break;
 
831
    case PROP_ALIGNMENT_THRESHOLD:
 
832
      gst_base_audio_sink_set_alignment_threshold (sink,
 
833
          g_value_get_uint64 (value));
 
834
      break;
 
835
    case PROP_DISCONT_WAIT:
 
836
      gst_base_audio_sink_set_discont_wait (sink, g_value_get_uint64 (value));
 
837
      break;
685
838
    default:
686
839
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
687
840
      break;
715
868
    case PROP_DRIFT_TOLERANCE:
716
869
      g_value_set_int64 (value, gst_base_audio_sink_get_drift_tolerance (sink));
717
870
      break;
 
871
    case PROP_ALIGNMENT_THRESHOLD:
 
872
      g_value_set_uint64 (value,
 
873
          gst_base_audio_sink_get_alignment_threshold (sink));
 
874
      break;
 
875
    case PROP_DISCONT_WAIT:
 
876
      g_value_set_uint64 (value, gst_base_audio_sink_get_discont_wait (sink));
 
877
      break;
718
878
    default:
719
879
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
720
880
      break;
727
887
  GstBaseAudioSink *sink = GST_BASE_AUDIO_SINK (bsink);
728
888
  GstRingBufferSpec *spec;
729
889
  GstClockTime now;
 
890
  GstClockTime crate_num, crate_denom;
730
891
 
731
892
  if (!sink->ringbuffer)
732
893
    return FALSE;
765
926
    gst_ring_buffer_activate (sink->ringbuffer, TRUE);
766
927
  }
767
928
 
 
929
  /* due to possible changes in the spec file we should recalibrate the clock */
 
930
  gst_clock_get_calibration (sink->provided_clock, NULL, NULL,
 
931
      &crate_num, &crate_denom);
 
932
  gst_clock_set_calibration (sink->provided_clock,
 
933
      gst_clock_get_internal_time (sink->provided_clock), now, crate_num,
 
934
      crate_denom);
 
935
 
768
936
  /* calculate actual latency and buffer times.
769
937
   * FIXME: In 0.11, store the latency_time internally in ns */
770
938
  spec->latency_time = gst_util_uint64_scale (spec->segsize,
876
1044
      sink->priv->avg_skew = -1;
877
1045
      sink->next_sample = -1;
878
1046
      sink->priv->eos_time = -1;
 
1047
      sink->priv->discont_time = -1;
879
1048
      if (sink->ringbuffer)
880
1049
        gst_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
881
1050
      break;
1297
1466
  sink->priv->avg_skew = -1;
1298
1467
  sink->next_sample = -1;
1299
1468
  sink->priv->eos_time = -1;
 
1469
  sink->priv->discont_time = -1;
1300
1470
 
1301
1471
  return GST_FLOW_OK;
1302
1472
 
1320
1490
}
1321
1491
 
1322
1492
static gint64
1323
 
gst_base_audio_sink_get_alignment (GstBaseAudioSink * sink, GstClockTime sample_offset)
 
1493
gst_base_audio_sink_get_alignment (GstBaseAudioSink * sink,
 
1494
    GstClockTime sample_offset)
1324
1495
{
1325
1496
  GstRingBuffer *ringbuf = sink->ringbuffer;
1326
1497
  gint64 align;
1327
 
  gint64 diff;
1328
 
  gint64 maxdrift;
 
1498
  gint64 sample_diff;
 
1499
  gint64 max_sample_diff;
1329
1500
  gint segdone = g_atomic_int_get (&ringbuf->segdone) - ringbuf->segbase;
1330
1501
  gint64 samples_done = segdone * ringbuf->samples_per_seg;
1331
1502
  gint64 headroom = sample_offset - samples_done;
1332
1503
  gboolean allow_align = TRUE;
 
1504
  gboolean discont = FALSE;
1333
1505
 
1334
1506
  /* now try to align the sample to the previous one, first see how big the
1335
1507
   * difference is. */
1336
1508
  if (sample_offset >= sink->next_sample)
1337
 
    diff = sample_offset - sink->next_sample;
 
1509
    sample_diff = sample_offset - sink->next_sample;
1338
1510
  else
1339
 
    diff = sink->next_sample - sample_offset;
 
1511
    sample_diff = sink->next_sample - sample_offset;
1340
1512
 
1341
 
  /* calculate the max allowed drift in units of samples. By default this is
1342
 
   * 20ms and should be anough to compensate for timestamp rounding errors. */
1343
 
  maxdrift = (ringbuf->spec.rate * sink->priv->drift_tolerance) / GST_MSECOND;
 
1513
  /* calculate the max allowed drift in units of samples. */
 
1514
  max_sample_diff = gst_util_uint64_scale_int (sink->priv->alignment_threshold,
 
1515
      ringbuf->spec.rate, GST_SECOND);
1344
1516
 
1345
1517
  /* calc align with previous sample */
1346
1518
  align = sink->next_sample - sample_offset;
1347
1519
 
1348
1520
  /* don't align if it means writing behind the read-segment */
1349
 
  if (diff > headroom && align < 0)
 
1521
  if (sample_diff > headroom && align < 0)
1350
1522
    allow_align = FALSE;
1351
1523
 
1352
 
  if (G_LIKELY (diff < maxdrift && allow_align)) {
 
1524
  if (G_UNLIKELY (sample_diff >= max_sample_diff)) {
 
1525
    /* wait before deciding to make a discontinuity */
 
1526
    if (sink->priv->discont_wait > 0) {
 
1527
      GstClockTime time = gst_util_uint64_scale_int (sample_offset,
 
1528
          GST_SECOND, ringbuf->spec.rate);
 
1529
      if (sink->priv->discont_time == -1) {
 
1530
        /* discont candidate */
 
1531
        sink->priv->discont_time = time;
 
1532
      } else if (time - sink->priv->discont_time >= sink->priv->discont_wait) {
 
1533
        /* discont_wait expired, discontinuity detected */
 
1534
        discont = TRUE;
 
1535
        sink->priv->discont_time = -1;
 
1536
      }
 
1537
    } else {
 
1538
      discont = TRUE;
 
1539
    }
 
1540
  } else if (G_UNLIKELY (sink->priv->discont_time != -1)) {
 
1541
    /* we have had a discont, but are now back on track! */
 
1542
    sink->priv->discont_time = -1;
 
1543
  }
 
1544
 
 
1545
  if (G_LIKELY (!discont && allow_align)) {
1353
1546
    GST_DEBUG_OBJECT (sink,
1354
1547
        "align with prev sample, ABS (%" G_GINT64_FORMAT ") < %"
1355
 
        G_GINT64_FORMAT, align, maxdrift);
 
1548
        G_GINT64_FORMAT, align, max_sample_diff);
1356
1549
  } else {
 
1550
    gint64 diff_s G_GNUC_UNUSED;
 
1551
 
1357
1552
    /* calculate sample diff in seconds for error message */
1358
 
    gint64 diff_s = gst_util_uint64_scale_int (diff, GST_SECOND, ringbuf->spec.rate);
 
1553
    diff_s =
 
1554
        gst_util_uint64_scale_int (sample_diff, GST_SECOND, ringbuf->spec.rate);
 
1555
 
1359
1556
    /* timestamps drifted apart from previous samples too much, we need to
1360
1557
     * resync. We log this as an element warning. */
1361
1558
    GST_WARNING_OBJECT (sink,
1362
1559
        "Unexpected discontinuity in audio timestamps of "
1363
1560
        "%s%" GST_TIME_FORMAT ", resyncing",
1364
 
        sample_offset > sink->next_sample ? "+" : "-",
1365
 
        GST_TIME_ARGS (diff_s));
 
1561
        sample_offset > sink->next_sample ? "+" : "-", GST_TIME_ARGS (diff_s));
1366
1562
    align = 0;
1367
1563
  }
1368
1564
 
1375
1571
  guint64 in_offset;
1376
1572
  GstClockTime time, stop, render_start, render_stop, sample_offset;
1377
1573
  GstClockTimeDiff sync_offset, ts_offset;
 
1574
  GstBaseAudioSinkClass *bclass;
1378
1575
  GstBaseAudioSink *sink;
1379
1576
  GstRingBuffer *ringbuf;
1380
1577
  gint64 diff, align, ctime, cstop;
1390
1587
  GstFlowReturn ret;
1391
1588
  GstSegment clip_seg;
1392
1589
  gint64 time_offset;
 
1590
  GstBuffer *out = NULL;
1393
1591
 
1394
1592
  sink = GST_BASE_AUDIO_SINK (bsink);
 
1593
  bclass = GST_BASE_AUDIO_SINK_GET_CLASS (sink);
1395
1594
 
1396
1595
  ringbuf = sink->ringbuffer;
1397
1596
 
1415
1614
    GST_OBJECT_UNLOCK (sink);
1416
1615
  }
1417
1616
 
 
1617
  /* Before we go on, let's see if we need to payload the data. If yes, we also
 
1618
   * need to unref the output buffer before leaving. */
 
1619
  if (bclass->payload) {
 
1620
    out = bclass->payload (sink, buf);
 
1621
 
 
1622
    if (!out)
 
1623
      goto payload_failed;
 
1624
 
 
1625
    buf = out;
 
1626
  }
 
1627
 
1418
1628
  bps = ringbuf->spec.bytes_per_sample;
1419
1629
 
1420
1630
  size = GST_BUFFER_SIZE (buf);
1591
1801
      render_stop = 0;
1592
1802
  }
1593
1803
 
 
1804
  /* in some clock slaving cases, all late samples end up at 0 first,
 
1805
   * and subsequent ones align with that until threshold exceeded,
 
1806
   * and then sync back to 0 and so on, so avoid that altogether */
 
1807
  if (G_UNLIKELY (render_start == 0 && render_stop == 0))
 
1808
    goto too_late;
 
1809
 
1594
1810
  /* and bring the time to the rate corrected offset in the buffer */
1595
1811
  render_start = gst_util_uint64_scale_int (render_start,
1596
1812
      ringbuf->spec.rate, GST_SECOND);
1697
1913
    gst_ring_buffer_start (ringbuf);
1698
1914
  }
1699
1915
 
1700
 
  return GST_FLOW_OK;
 
1916
  ret = GST_FLOW_OK;
 
1917
 
 
1918
done:
 
1919
  if (out)
 
1920
    gst_buffer_unref (out);
 
1921
 
 
1922
  return ret;
1701
1923
 
1702
1924
  /* SPECIAL cases */
1703
1925
out_of_segment:
1706
1928
        "dropping sample out of segment time %" GST_TIME_FORMAT ", start %"
1707
1929
        GST_TIME_FORMAT, GST_TIME_ARGS (time),
1708
1930
        GST_TIME_ARGS (bsink->segment.start));
 
1931
    ret = GST_FLOW_OK;
 
1932
    goto done;
 
1933
  }
 
1934
too_late:
 
1935
  {
 
1936
    GST_DEBUG_OBJECT (sink, "dropping late sample");
1709
1937
    return GST_FLOW_OK;
1710
1938
  }
1711
1939
  /* ERRORS */
 
1940
payload_failed:
 
1941
  {
 
1942
    GST_ELEMENT_ERROR (sink, STREAM, FORMAT, (NULL), ("failed to payload."));
 
1943
    ret = GST_FLOW_ERROR;
 
1944
    goto done;
 
1945
  }
1712
1946
wrong_state:
1713
1947
  {
1714
1948
    GST_DEBUG_OBJECT (sink, "ringbuffer not negotiated");
1715
1949
    GST_ELEMENT_ERROR (sink, STREAM, FORMAT, (NULL), ("sink not negotiated."));
1716
 
    return GST_FLOW_NOT_NEGOTIATED;
 
1950
    ret = GST_FLOW_NOT_NEGOTIATED;
 
1951
    goto done;
1717
1952
  }
1718
1953
wrong_size:
1719
1954
  {
1720
1955
    GST_DEBUG_OBJECT (sink, "wrong size");
1721
1956
    GST_ELEMENT_ERROR (sink, STREAM, WRONG_TYPE,
1722
1957
        (NULL), ("sink received buffer of wrong size."));
1723
 
    return GST_FLOW_ERROR;
 
1958
    ret = GST_FLOW_ERROR;
 
1959
    goto done;
1724
1960
  }
1725
1961
stopping:
1726
1962
  {
1727
1963
    GST_DEBUG_OBJECT (sink, "preroll got interrupted: %d (%s)", ret,
1728
1964
        gst_flow_get_name (ret));
1729
 
    return ret;
 
1965
    goto done;
1730
1966
  }
1731
1967
sync_latency_failed:
1732
1968
  {
1733
1969
    GST_DEBUG_OBJECT (sink, "failed waiting for latency");
1734
 
    return ret;
 
1970
    goto done;
1735
1971
  }
1736
1972
}
1737
1973
 
1887
2123
  sink->priv->sync_latency = TRUE;
1888
2124
  gst_ring_buffer_may_start (sink->ringbuffer, TRUE);
1889
2125
  if (basesink->pad_mode == GST_ACTIVATE_PULL) {
1890
 
    /* we always start the ringbuffer in pull mode immediatly */
 
2126
    /* we always start the ringbuffer in pull mode immediately */
1891
2127
    gst_ring_buffer_start (sink->ringbuffer);
1892
2128
  }
1893
2129
 
1914
2150
      sink->next_sample = -1;
1915
2151
      sink->priv->last_align = -1;
1916
2152
      sink->priv->eos_time = -1;
 
2153
      sink->priv->discont_time = -1;
1917
2154
      gst_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
1918
2155
      gst_ring_buffer_may_start (sink->ringbuffer, FALSE);
1919
2156
 
1940
2177
      gst_ring_buffer_may_start (sink->ringbuffer, TRUE);
1941
2178
      if (GST_BASE_SINK_CAST (sink)->pad_mode == GST_ACTIVATE_PULL ||
1942
2179
          g_atomic_int_get (&sink->abidata.ABI.eos_rendering) || eos) {
1943
 
        /* we always start the ringbuffer in pull mode immediatly */
 
2180
        /* we always start the ringbuffer in pull mode immediately */
1944
2181
        /* sync rendering on eos needs running clock,
1945
2182
         * and others need running clock when finished rendering eos */
1946
2183
        gst_ring_buffer_start (sink->ringbuffer);
2008
2245
  /* ERRORS */
2009
2246
open_failed:
2010
2247
  {
2011
 
    /* subclass must post a meaningfull error message */
 
2248
    /* subclass must post a meaningful error message */
2012
2249
    GST_DEBUG_OBJECT (sink, "open failed");
2013
2250
    return GST_STATE_CHANGE_FAILURE;
2014
2251
  }