Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 84864
Collapse All | Expand All

(-)gst/gstqueue.c (-8 / +30 lines)
Lines 474-479 Link Here
474
static void
474
static void
475
gst_queue_locked_flush (GstQueue * queue)
475
gst_queue_locked_flush (GstQueue * queue)
476
{
476
{
477
  GST_CAT_LOG_OBJECT (queue_dataflow, queue, "Flushing contents...");
478
477
  while (!g_queue_is_empty (queue->queue)) {
479
  while (!g_queue_is_empty (queue->queue)) {
478
    GstData *data = g_queue_pop_head (queue->queue);
480
    GstData *data = g_queue_pop_head (queue->queue);
479
481
Lines 569-575 Link Here
569
571
570
  if (GST_IS_BUFFER (data))
572
  if (GST_IS_BUFFER (data))
571
    GST_CAT_LOG_OBJECT (queue_dataflow, queue,
573
    GST_CAT_LOG_OBJECT (queue_dataflow, queue,
572
        "adding buffer %p of size %d", data, GST_BUFFER_SIZE (data));
574
        "adding buffer %p of size %d and time %" GST_TIME_FORMAT,
575
        data, GST_BUFFER_SIZE (data),
576
        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (data)));
573
577
574
  /* We make space available if we're "full" according to whatever
578
  /* We make space available if we're "full" according to whatever
575
   * the user defined as "full". Note that this only applies to buffers.
579
   * the user defined as "full". Note that this only applies to buffers.
Lines 657-667 Link Here
657
            GstScheduler *sched;
661
            GstScheduler *sched;
658
662
659
            GST_CAT_DEBUG_OBJECT (queue_dataflow, queue, "interrupted");
663
            GST_CAT_DEBUG_OBJECT (queue_dataflow, queue, "interrupted");
660
            GST_QUEUE_MUTEX_UNLOCK;
661
            sched = gst_pad_get_scheduler (queue->sinkpad);
664
            sched = gst_pad_get_scheduler (queue->sinkpad);
662
            if (!sched || gst_scheduler_interrupt (sched, GST_ELEMENT (queue))) {
665
            if (!sched || gst_scheduler_interrupt (sched, GST_ELEMENT (queue))) {
663
              goto out_unref;
666
              goto ignore_interrupt;
664
            }
667
            }
668
            GST_QUEUE_MUTEX_UNLOCK;
665
            /* if we got here because we were unlocked after a
669
            /* if we got here because we were unlocked after a
666
             * flush, we don't need to add the buffer to the
670
             * flush, we don't need to add the buffer to the
667
             * queue again */
671
             * queue again */
Lines 693-698 Link Here
693
            }
697
            }
694
          }
698
          }
695
699
700
        ignore_interrupt:
696
          /* OK, we've got a serious issue here. Imagine the situation
701
          /* OK, we've got a serious issue here. Imagine the situation
697
           * where the puller (next element) is sending an event here,
702
           * where the puller (next element) is sending an event here,
698
           * so it cannot pull events from the queue, and we cannot
703
           * so it cannot pull events from the queue, and we cannot
Lines 701-709 Link Here
701
           * that, we handle pending upstream events here, too. */
706
           * that, we handle pending upstream events here, too. */
702
          gst_queue_handle_pending_events (queue);
707
          gst_queue_handle_pending_events (queue);
703
708
704
          STATUS (queue, "waiting for item_del signal from thread using qlock");
709
          if (!queue->interrupt) {
705
          g_cond_wait (queue->item_del, queue->qlock);
710
            STATUS (queue,
706
          STATUS (queue, "received item_del signal from thread using qlock");
711
                "waiting for item_del signal from thread using qlock");
712
            g_cond_wait (queue->item_del, queue->qlock);
713
            STATUS (queue, "received item_del signal from thread using qlock");
714
          } else {
715
            GST_CAT_DEBUG_OBJECT (queue_dataflow, queue,
716
                "Not waiting, just adding buffer, after interrupt (bad!)");
717
            break;
718
          }
707
        }
719
        }
708
720
709
        STATUS (queue, "post-full wait");
721
        STATUS (queue, "post-full wait");
Lines 848-853 Link Here
848
    queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
860
    queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
849
    if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
861
    if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
850
      queue->cur_level.time -= GST_BUFFER_DURATION (data);
862
      queue->cur_level.time -= GST_BUFFER_DURATION (data);
863
    GST_CAT_LOG_OBJECT (queue_dataflow, queue,
864
        "Got buffer of time %" GST_TIME_FORMAT,
865
        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (data)));
851
  }
866
  }
852
867
853
  /* Now that we're done, we can lose our own reference to
868
  /* Now that we're done, we can lose our own reference to
Lines 947-952 Link Here
947
        if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
962
        if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
948
          gst_queue_locked_flush (queue);
963
          gst_queue_locked_flush (queue);
949
        }
964
        }
965
        break;
950
      default:
966
      default:
951
        break;
967
        break;
952
    }
968
    }
Lines 974-983 Link Here
974
    /* FIXME: this code assumes that there's no discont in the queue */
990
    /* FIXME: this code assumes that there's no discont in the queue */
975
    switch (*fmt) {
991
    switch (*fmt) {
976
      case GST_FORMAT_BYTES:
992
      case GST_FORMAT_BYTES:
977
        *value -= queue->cur_level.bytes;
993
        if (*value >= queue->cur_level.bytes)
994
          *value -= queue->cur_level.bytes;
995
        else
996
          *value = 0;
978
        break;
997
        break;
979
      case GST_FORMAT_TIME:
998
      case GST_FORMAT_TIME:
980
        *value -= queue->cur_level.time;
999
        if (*value >= queue->cur_level.time)
1000
          *value -= queue->cur_level.time;
1001
        else
1002
          *value = 0;
981
        break;
1003
        break;
982
      default:
1004
      default:
983
        /* FIXME */
1005
        /* FIXME */

Return to bug 84864