resindvd: Manage timed still sequences better

Make timed still frames work better by extending the current segment
when needed, and restarting the still sequence with the correct
remaining duration when the wait it interrupted by activation of a
highlight NAV packet.
This commit is contained in:
Jan Schmidt 2009-05-11 14:17:42 +01:00
parent 79f653fde8
commit 4204b644ef
2 changed files with 54 additions and 20 deletions

View file

@ -590,6 +590,12 @@ rsn_dvdsrc_do_still (resinDvdSrc * src, int duration)
if (src->in_still_state == FALSE) { if (src->in_still_state == FALSE) {
GST_DEBUG_OBJECT (src, "**** Start STILL FRAME. Duration %d ****", GST_DEBUG_OBJECT (src, "**** Start STILL FRAME. Duration %d ****",
duration); duration);
if (duration == 255)
src->still_time_remaining = GST_CLOCK_TIME_NONE;
else
src->still_time_remaining = GST_SECOND * duration;
/* Send a close-segment event, and a dvd-still start /* Send a close-segment event, and a dvd-still start
* event, then sleep */ * event, then sleep */
s = gst_structure_new ("application/x-gst-dvd", s = gst_structure_new ("application/x-gst-dvd",
@ -622,7 +628,9 @@ rsn_dvdsrc_do_still (resinDvdSrc * src, int duration)
src->in_still_state = TRUE; src->in_still_state = TRUE;
} else { } else {
GST_DEBUG_OBJECT (src, "Re-entering still wait"); GST_DEBUG_OBJECT (src,
"Re-entering still wait with %" GST_TIME_FORMAT " remaining",
GST_TIME_ARGS (src->still_time_remaining));
g_mutex_lock (src->branch_lock); g_mutex_lock (src->branch_lock);
} }
@ -659,10 +667,11 @@ rsn_dvdsrc_do_still (resinDvdSrc * src, int duration)
GTimeVal end_time; GTimeVal end_time;
gboolean was_signalled; gboolean was_signalled;
if (src->still_time_remaining > 0) {
g_get_current_time (&end_time); g_get_current_time (&end_time);
g_time_val_add (&end_time, duration * G_USEC_PER_SEC); g_time_val_add (&end_time, src->still_time_remaining / GST_USECOND);
/* FIXME: Implement timed stills by sleeping on the clock, possibly /* Implement timed stills by sleeping, possibly
* in multiple steps if we get paused/unpaused */ * in multiple steps if we get paused/unpaused */
g_mutex_unlock (src->dvd_lock); g_mutex_unlock (src->dvd_lock);
GST_LOG_OBJECT (src, "cond_timed_wait still for %d sec", duration); GST_LOG_OBJECT (src, "cond_timed_wait still for %d sec", duration);
@ -675,11 +684,26 @@ rsn_dvdsrc_do_still (resinDvdSrc * src, int duration)
if (was_signalled) { if (was_signalled) {
/* Signalled - must be flushing */ /* Signalled - must be flushing */
GTimeVal cur_time;
GstClockTimeDiff remain;
g_get_current_time (&cur_time);
remain =
(end_time.tv_sec - cur_time.tv_sec) * GST_SECOND +
(end_time.tv_usec - cur_time.tv_usec) * GST_USECOND;
if (remain < 0)
src->still_time_remaining = 0;
else
src->still_time_remaining = remain;
GST_LOG_OBJECT (src, GST_LOG_OBJECT (src,
"cond_timed_wait still over. Signalled, branching = %d", "cond_timed_wait still aborted by signal with %" GST_TIME_FORMAT
src->branching); " remaining. branching = %d",
GST_TIME_ARGS (src->still_time_remaining), src->branching);
return TRUE; return TRUE;
} }
}
/* Else timed out, end the still */ /* Else timed out, end the still */
GST_DEBUG_OBJECT (src, GST_DEBUG_OBJECT (src,
@ -690,12 +714,17 @@ rsn_dvdsrc_do_still (resinDvdSrc * src, int duration)
} }
/* Tell downstream the still is over. /* Tell downstream the still is over.
* Later: We'll only do this if the still isn't interrupted: */ * We only do this if the still isn't interrupted: */
s = gst_structure_new ("application/x-gst-dvd", s = gst_structure_new ("application/x-gst-dvd",
"event", G_TYPE_STRING, "dvd-still", "event", G_TYPE_STRING, "dvd-still",
"still-state", G_TYPE_BOOLEAN, FALSE, NULL); "still-state", G_TYPE_BOOLEAN, FALSE, NULL);
still_event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, s); still_event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, s);
/* If the segment was too short in a timed still, it may need extending */
if (segment->last_stop < segment->start + GST_SECOND * duration)
gst_segment_set_last_stop (segment, GST_FORMAT_TIME,
segment->start + (GST_SECOND * duration));
g_mutex_unlock (src->dvd_lock); g_mutex_unlock (src->dvd_lock);
gst_pad_push_event (GST_BASE_SRC_PAD (src), still_event); gst_pad_push_event (GST_BASE_SRC_PAD (src), still_event);
g_mutex_lock (src->dvd_lock); g_mutex_lock (src->dvd_lock);
@ -2040,9 +2069,11 @@ rsn_dvdsrc_activate_nav_block (resinDvdSrc * src, GstBuffer * nav_buf)
/* highlight might change, let's check */ /* highlight might change, let's check */
rsn_dvdsrc_update_highlight (src); rsn_dvdsrc_update_highlight (src);
if (src->highlight_event) if (src->highlight_event && src->in_still_state) {
GST_LOG_OBJECT (src, "Signalling still condition due to highlight change");
g_cond_broadcast (src->still_cond); g_cond_broadcast (src->still_cond);
} }
}
static void static void
rsn_dvdsrc_clear_nav_blocks (resinDvdSrc * src) rsn_dvdsrc_clear_nav_blocks (resinDvdSrc * src)

View file

@ -90,6 +90,9 @@ struct _resinDvdSrc
gboolean was_mouse_over; gboolean was_mouse_over;
/* Remaining time to wait in a timed still: */
GstClockTime still_time_remaining;
GstBuffer *alloc_buf; GstBuffer *alloc_buf;
GstBuffer *next_buf; GstBuffer *next_buf;
/* TRUE if the next_buf is a nav block that needs enqueueing */ /* TRUE if the next_buf is a nav block that needs enqueueing */