eglglessink: start()/stop() is called in READY<->NULL in basesink

But this should be called in PAUSED<->READY.
This commit is contained in:
Sebastian Dröge 2012-10-16 11:51:13 +02:00
parent d2dcecfc8a
commit 1f0bf75075

View file

@ -383,8 +383,6 @@ static GstStateChangeReturn gst_eglglessink_change_state (GstElement * element,
static GstFlowReturn gst_eglglessink_show_frame (GstVideoSink * vsink,
GstBuffer * buf);
static gboolean gst_eglglessink_setcaps (GstBaseSink * bsink, GstCaps * caps);
static gboolean gst_eglglessink_start (GstBaseSink * sink);
static gboolean gst_eglglessink_stop (GstBaseSink * sink);
static GstFlowReturn gst_eglglessink_buffer_alloc (GstBaseSink * sink,
guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
static GstCaps *gst_eglglessink_getcaps (GstBaseSink * bsink);
@ -1068,11 +1066,9 @@ HANDLE_ERROR:
return FALSE;
}
gboolean
gst_eglglessink_start (GstBaseSink * sink)
static gboolean
gst_eglglessink_start (GstEglGlesSink * eglglessink)
{
GstEglGlesSink *eglglessink = GST_EGLGLESSINK (sink);
if (!eglglessink->egl_started) {
GST_ERROR_OBJECT (eglglessink, "EGL uninitialized. Bailing out");
goto HANDLE_ERROR;
@ -1095,11 +1091,9 @@ HANDLE_ERROR:
return FALSE;
}
gboolean
gst_eglglessink_stop (GstBaseSink * sink)
static gboolean
gst_eglglessink_stop (GstEglGlesSink * eglglessink)
{
GstEglGlesSink *eglglessink = GST_EGLGLESSINK (sink);
/* EGL/GLES2 cleanup */
if (!gst_eglglessink_context_make_current (eglglessink, TRUE, FALSE))
return FALSE;
@ -2488,6 +2482,36 @@ gst_eglglessink_wipe_fmt (gpointer data)
g_free (format);
}
static gboolean
gst_eglglessink_open (GstEglGlesSink * eglglessink)
{
if (!egl_init (eglglessink)) {
return FALSE;
}
return TRUE;
}
static gboolean
gst_eglglessink_close (GstEglGlesSink * eglglessink)
{
g_mutex_lock (eglglessink->flow_lock);
if (eglglessink->eglglesctx->display) {
eglTerminate (eglglessink->eglglesctx->display);
eglglessink->eglglesctx->display = NULL;
}
eglglessink->selected_fmt = NULL;
g_list_free_full (eglglessink->supported_fmts, gst_eglglessink_wipe_fmt);
eglglessink->supported_fmts = NULL;
gst_caps_unref (eglglessink->sinkcaps);
eglglessink->sinkcaps = NULL;
eglglessink->egl_started = FALSE;
g_mutex_unlock (eglglessink->flow_lock);
return TRUE;
}
static GstStateChangeReturn
gst_eglglessink_change_state (GstElement * element, GstStateChange transition)
{
@ -2496,9 +2520,17 @@ gst_eglglessink_change_state (GstElement * element, GstStateChange transition)
eglglessink = GST_EGLGLESSINK (element);
GST_ERROR_OBJECT (eglglessink, "Changing state %d -> %d", GST_STATE_TRANSITION_CURRENT (transition), GST_STATE_TRANSITION_NEXT (transition));
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
if (!egl_init (eglglessink)) {
if (!gst_eglglessink_open (eglglessink)) {
ret = GST_STATE_CHANGE_FAILURE;
goto done;
}
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
if (!gst_eglglessink_start (eglglessink)) {
ret = GST_STATE_CHANGE_FAILURE;
goto done;
}
@ -2513,19 +2545,16 @@ gst_eglglessink_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_READY_TO_NULL:
g_mutex_lock (eglglessink->flow_lock);
if (eglglessink->eglglesctx->display) {
eglTerminate (eglglessink->eglglesctx->display);
eglglessink->eglglesctx->display = NULL;
if (!gst_eglglessink_close (eglglessink)) {
ret = GST_STATE_CHANGE_FAILURE;
goto done;
}
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
if (!gst_eglglessink_stop (eglglessink)) {
ret = GST_STATE_CHANGE_FAILURE;
goto done;
}
eglglessink->selected_fmt = NULL;
g_list_free_full (eglglessink->supported_fmts, gst_eglglessink_wipe_fmt);
eglglessink->supported_fmts = NULL;
gst_caps_unref (eglglessink->sinkcaps);
eglglessink->sinkcaps = NULL;
eglglessink->egl_started = FALSE;
g_mutex_unlock (eglglessink->flow_lock);
break;
default:
break;
@ -2640,8 +2669,6 @@ gst_eglglessink_class_init (GstEglGlesSinkClass * klass)
gstelement_class->change_state = gst_eglglessink_change_state;
gstbasesink_class->start = gst_eglglessink_start;
gstbasesink_class->stop = gst_eglglessink_stop;
gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_eglglessink_setcaps);
gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_eglglessink_getcaps);
gstbasesink_class->buffer_alloc = GST_DEBUG_FUNCPTR