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

jeremi.wojcicki jeremi.wojcicki at gmail.com
Wed Feb 21 09:09:39 UTC 2018


Nicolas Dufresne-5 wrote
> Le mardi 20 février 2018 à 12:16 -0700, jeremi.wojcicki a écrit :
>> To sum up, it seems that the lack of need-context message in bus sync
>> callback is the problem now. Any reason for that?
> 
> Have you compared your code against one of the tutorial ?

Hmm, I derived originally from tutorial-3 that I used some concepts from
sdlshare.c and sdlshare2.c for the fakesink and context sharing.

Anyhow, here is the current version of the code:

https://hastebin.com/onoyirarof.php

and as you can see the need-context message appears in the async handler (I
hope I am naming them right, but that's what I understood fro the GstBus
documentation).

2-21 10:00:26.546 19263-19331/com.oculus.vrcubeworldsv E/GST_log: Recieved
context[0x718BE080] and display[0x00000001] from renderer
02-21 10:00:26.565 19263-19377/com.oculus.vrcubeworldsv I/GST_log: Starting
gstreamer pipeline
02-21 10:00:26.565 19263-19377/com.oculus.vrcubeworldsv I/GST_log: Creating
pipeline in CustomData at 0x735d084420
02-21 10:00:26.565 19263-19377/com.oculus.vrcubeworldsv I/GST_log: Creating
new main loop
02-21 10:00:26.565 19263-19377/com.oculus.vrcubeworldsv I/GST_log: Building
pipeline
02-21 10:00:26.569 19263-19377/com.oculus.vrcubeworldsv I/GST_log: glupload
display ok
02-21 10:00:26.569 19263-19377/com.oculus.vrcubeworldsv I/GST_log: glupload
wrapped context ok
02-21 10:00:26.574 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.574 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.574 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.574 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.574 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.574 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
stream-status message
02-21 10:00:26.574 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.574 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.574 19263-19385/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.574 19263-19385/com.oculus.vrcubeworldsv I/GST_log: > Got
stream-status message
02-21 10:00:26.575 19263-19385/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.575 19263-19385/com.oculus.vrcubeworldsv I/GST_log: > Got
stream-start message
02-21 10:00:26.630 19263-19385/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.630 19263-19385/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.630 19263-19385/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.630 19263-19385/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.630 19263-19385/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.630 19263-19385/com.oculus.vrcubeworldsv I/GST_log: > Got
async-done message
02-21 10:00:26.630 19263-19377/com.oculus.vrcubeworldsv I/GST_log: Entering
main loop... (CustomData:0x735d084420)
02-21 10:00:26.630 19263-19377/com.oculus.vrcubeworldsv I/GST_log: Semaphore
post
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
new-clock message
02-21 10:00:26.631 19263-19385/com.oculus.vrcubeworldsv I/GST_log: Got a
buffer at fakesink
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > sync
handler called
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log:
Playing...
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > async
handler called
02-21 10:00:26.631 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > async
handler called
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
need-context message
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: Element
gluploadelement0 asks for context. We give => 0x718be080 0x00000001
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: got need
context gst.gl.GLDisplay
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > async
handler called
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
have-context message
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: Received
'got context' message
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > async
handler called
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
need-context message
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: Element
gluploadelement0 asks for context. We give => 0x718be080 0x00000001
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: got need
context gst.gl.app_context
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > async
handler called
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > async
handler called
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > async
handler called
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > async
handler called
02-21 10:00:26.632 19263-19377/com.oculus.vrcubeworldsv I/GST_log: > Got
state-changed message
02-21 10:00:27.631 19263-19385/com.oculus.vrcubeworldsv I/GST_log: Got a
buffer at fakesink
02-21 10:00:28.632 19263-19385/com.oculus.vrcubeworldsv I/GST_log: Got a
buffer at fakesink
02-21 10:00:29.631 19263-19385/com.oculus.vrcubeworldsv I/GST_log: Got a
buffer at fakesink
02-21 10:00:30.631 19263-19385/com.oculus.vrcubeworldsv I/GST_log: Got a
buffer at fakesink

Maybe the problem is not really in it. It is possible to set the context
just upon element creation, right? Maybe it would be better to focus on this
solution. Now I have this kind of code that sets it in the callback,
depending on the message:

        case GST_MESSAGE_NEED_CONTEXT:
        {

            // we got gl_display and gl_context and starting of the main
loop

            GstElement *element = GST_ELEMENT (message->src);
            const gchar *name = gst_element_get_name(element);

            LOG_INFO("Element %s asks for context. We give => 0x%08x
0x%08x", name, data->egl_context, data->egl_display);

            const gchar *context_type;

            gst_message_parse_context_type (message, &context_type);
            LOG_INFO("got need context %s\n", context_type);

            if (g_strcmp0 (context_type, GST_GL_DISPLAY_CONTEXT_TYPE) == 0)
{
                GstContext *display_context =
                        gst_context_new (GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
                gst_context_set_gl_display (display_context,
data->gst_display);
                gst_element_set_context (GST_ELEMENT (message->src),
display_context);
                return TRUE;
            } else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0)
{
                GstContext *app_context = gst_context_new
("gst.gl.app_context", TRUE);
                GstStructure *s = gst_context_writable_structure
(app_context);
                gst_structure_set (s, "context", GST_GL_TYPE_CONTEXT,
data->gst_context, NULL);
                gst_element_set_context (GST_ELEMENT (message->src),
app_context);
                return TRUE;
            }
            break;

        }

Is it good enough to set the context right in the beginning (in the
app_function)?




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


More information about the gstreamer-devel mailing list