mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-06 14:32:31 +00:00
decklinkvideosink: Only start if both sinks are set to PLAYING already
Not only if the video sink is set to PLAYING so far. Also give more useful debug output about why we don't start, and don't start if already started. Also refactor the function to early-return instead of having a huge if-else block over the whole function. https://bugzilla.gnome.org/show_bug.cgi?id=790114
This commit is contained in:
parent
a38cf7d8a9
commit
011649790d
1 changed files with 111 additions and 89 deletions
|
@ -845,13 +845,41 @@ gst_decklink_video_sink_start_scheduled_playback (GstElement * element)
|
|||
GstClockTime start_time;
|
||||
HRESULT res;
|
||||
bool active;
|
||||
|
||||
if (self->output->video_enabled && (!self->output->audiosink
|
||||
|| self->output->audio_enabled)
|
||||
&& (GST_STATE (self) == GST_STATE_PLAYING
|
||||
|| GST_STATE_PENDING (self) == GST_STATE_PLAYING)) {
|
||||
GstClock *clock = NULL;
|
||||
|
||||
// Check if we're already started
|
||||
if (self->output->started) {
|
||||
GST_DEBUG_OBJECT (self, "Already started");
|
||||
return;
|
||||
}
|
||||
// Check if we're ready to start:
|
||||
// we need video and audio enabled, if there is audio
|
||||
// and both of the two elements need to be set to PLAYING already
|
||||
if (!self->output->video_enabled) {
|
||||
GST_DEBUG_OBJECT (self,
|
||||
"Not starting scheduled playback yet: video not enabled yet!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->output->audiosink && !self->output->audio_enabled) {
|
||||
GST_DEBUG_OBJECT (self,
|
||||
"Not starting scheduled playback yet: "
|
||||
"have audio but not enabled yet!");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((GST_STATE (self) != GST_STATE_PLAYING
|
||||
&& GST_STATE_PENDING (self) != GST_STATE_PLAYING)
|
||||
|| (self->output->audiosink &&
|
||||
GST_STATE (self->output->audiosink) != GST_STATE_PLAYING
|
||||
&& GST_STATE_PENDING (self->output->audiosink) !=
|
||||
GST_STATE_PLAYING)) {
|
||||
GST_DEBUG_OBJECT (self,
|
||||
"Not starting scheduled playback yet: "
|
||||
"Elements are not set to PLAYING yet");
|
||||
return;
|
||||
}
|
||||
|
||||
clock = gst_element_get_clock (element);
|
||||
if (!clock) {
|
||||
GST_ELEMENT_ERROR (self, STREAM, FAILED, (NULL),
|
||||
|
@ -877,8 +905,7 @@ gst_decklink_video_sink_start_scheduled_playback (GstElement * element)
|
|||
//
|
||||
// We can't use the normal base time for the external clock
|
||||
// because we might go to PLAYING later than the pipeline
|
||||
self->internal_base_time =
|
||||
gst_clock_get_internal_time (self->output->clock);
|
||||
self->internal_base_time = gst_clock_get_internal_time (self->output->clock);
|
||||
self->external_base_time = gst_clock_get_internal_time (clock);
|
||||
|
||||
gst_decklink_video_sink_convert_to_internal_clock (self, &start_time, NULL);
|
||||
|
@ -905,7 +932,6 @@ gst_decklink_video_sink_start_scheduled_playback (GstElement * element)
|
|||
gst_object_unref (clock);
|
||||
return;
|
||||
}
|
||||
|
||||
// Wait until scheduled playback actually stopped
|
||||
do {
|
||||
g_cond_wait (&self->output->cond, &self->output->lock);
|
||||
|
@ -936,14 +962,10 @@ gst_decklink_video_sink_start_scheduled_playback (GstElement * element)
|
|||
|
||||
// Sample the clocks again to get the most accurate values
|
||||
// after we started scheduled playback
|
||||
self->internal_base_time =
|
||||
gst_clock_get_internal_time (self->output->clock);
|
||||
self->internal_base_time = gst_clock_get_internal_time (self->output->clock);
|
||||
self->external_base_time = gst_clock_get_internal_time (clock);
|
||||
g_mutex_lock (&self->output->lock);
|
||||
gst_object_unref (clock);
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (self, "Not starting scheduled playback yet");
|
||||
}
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
|
|
Loading…
Reference in a new issue