Problem with context sharing (glupload) with an OVR thread (Oculus Mobile SDK)

jeremi.wojcicki jeremi.wojcicki at gmail.com
Tue Feb 20 19:16:11 UTC 2018


Matthew Waters wrote
> This code looks good assuming that this callback is from the sync bus
> handler and not the async bus handler and that data->gst_context holds a
> valid GstGLContext.

It is quite likely that the problem was the async bus call that I used,
which was defined in this way:

// setting bus callbacks
guint bus_watch_id;
bus = gst_pipeline_get_bus (GST_PIPELINE (data->pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_callback, data);
gst_object_unref (bus);

This callback was called twice for my glupload element, asking
“gst.gl.app_context” and "gst.gl.GLDisplay". After your suggestion I deleted
the previous implementation and substituted it with the sync call (taken “as
is” from sdlshare2.c):

/* Set the pipeline to READY, so it can already accept a window handle, if
we have one */
gst_element_set_state(data->pipeline, GST_STATE_READY);

bus = gst_pipeline_get_bus (GST_PIPELINE (data->pipeline));
gst_bus_add_signal_watch (bus);

gst_bus_enable_sync_message_emission (bus);
g_signal_connect (bus, "message::error",   G_CALLBACK (end_stream_cb),
data->main_loop);
g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb),
data->main_loop);
g_signal_connect (bus, "message::eos",     G_CALLBACK (end_stream_cb),
data->main_loop);
g_signal_connect (bus, "sync-message",     G_CALLBACK (bus_callback), 
data);

Now the problem is that the sync message is called several times with
“state-changed” message, but never with “need-context” message, so I do not
actaully have the chance to share my context…

02-20 20:02:07.931 9331-9353/com.oculus.vrcubeworldsv E/GST_log: Recieved
context[0x5D081680] and display[0x00000001] from renderer
02-20 20:02:07.966 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Starting
gstreamer pipeline
02-20 20:02:07.966 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Creating
pipeline in CustomData at 0x735d082420
02-20 20:02:07.966 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Creating
new main loop
02-20 20:02:07.966 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Building
pipeline
02-20 20:02:07.978 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Checking
errors
02-20 20:02:07.980 9331-9376/com.oculus.vrcubeworldsv I/GST_log: glupload
display ok
02-20 20:02:07.980 9331-9376/com.oculus.vrcubeworldsv I/GST_log: glupload
wrapped context ok
02-20 20:02:07.983 9331-9376/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:07.983 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Got
state-changed message
02-20 20:02:07.983 9331-9376/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:07.983 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Got
state-changed message
02-20 20:02:07.984 9331-9376/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:07.984 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Got
stream-status message
02-20 20:02:07.985 9331-9376/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:07.985 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Got
state-changed message
02-20 20:02:07.985 9331-9385/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:07.985 9331-9385/com.oculus.vrcubeworldsv I/GST_log: Got
stream-status message
02-20 20:02:07.985 9331-9385/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:07.985 9331-9385/com.oculus.vrcubeworldsv I/GST_log: Got
stream-start message
02-20 20:02:08.023 9331-9385/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:08.023 9331-9385/com.oculus.vrcubeworldsv I/GST_log: Got
state-changed message
02-20 20:02:08.024 9331-9385/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:08.024 9331-9385/com.oculus.vrcubeworldsv I/GST_log: Got
state-changed message
02-20 20:02:08.024 9331-9385/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:08.024 9331-9385/com.oculus.vrcubeworldsv I/GST_log: Got
async-done message
02-20 20:02:08.024 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Entering
main loop... (CustomData:0x735d082420)
02-20 20:02:08.024 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Semaphore
post
02-20 20:02:08.024 9331-9376/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:08.024 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Got
new-clock message
02-20 20:02:08.025 9331-9385/com.oculus.vrcubeworldsv I/GST_log: Got a
buffer at fakesink
02-20 20:02:08.025 9331-9376/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:08.025 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Got
state-changed message
02-20 20:02:08.025 9331-9376/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:08.025 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Got
state-changed message
02-20 20:02:08.026 9331-9376/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:08.026 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Got
state-changed message
02-20 20:02:08.026 9331-9376/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:08.026 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Got
state-changed message
02-20 20:02:08.027 9331-9376/com.oculus.vrcubeworldsv E/GST_log: ==========>
BUS SYNC !!!!
02-20 20:02:08.027 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Got
state-changed message
02-20 20:02:08.027 9331-9376/com.oculus.vrcubeworldsv I/GST_log: Playing...
02-20 20:02:09.025 9331-9385/com.oculus.vrcubeworldsv I/GST_log: Got a
buffer at fakesink
02-20 20:02:10.026 9331-9385/com.oculus.vrcubeworldsv I/GST_log: Got a
buffer at fakesink
02-20 20:02:11.025 9331-9385/com.oculus.vrcubeworldsv I/GST_log: Got a
buffer at fakesink

Speaking of the validity of the GstGlContext, data->egl_display and
data->egl_context are EGLContext and EGLDisplay, respectively, which are
passed from the renderer. I wrap them in this way, so I think I’m ok here:
    // get GStreamer display from the native OpenGL EGL vars
    data->gst_display =
gst_gl_display_egl_new_with_egl_display(data->egl_display);

    if(data->gst_display == NULL){
        LOG_ERROR("glupload display fail");
    } else {
        LOG_INFO("glupload display ok");
    }

    data->gst_context = gst_gl_context_new_wrapped( data->gst_display,
(guintptr)data->egl_context,
                                                    GST_GL_PLATFORM_EGL,
GST_GL_API_GLES2);
    if(data->gst_context == NULL){
        LOG_ERROR("glupload wrapped context fail");
    } else {
        LOG_INFO("glupload wrapped context ok");
    }

To sum up, it seems that the lack of need-context message in bus sync
callback is the problem now. Any reason for that?

Thanks,
Jeremi

PS. Soon I will add the full debug logs




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list