I think I found reason for these opengles_display() errors:
05-06 19:49:17.393 18505 18555 D Baresip vidisp: eglSwapBuffers() returned error 12301
05-06 19:49:17.657 18505 18555 D Baresip vidisp: eglSwapBuffers() returned error 12301
...
They occur only when call_connect() is called with disabled video stream
and video is started later during the call by video_start_display().
The reason for the errors is that opengles_alloc() and subsequent
opengles_display() functions are executed on different threads. I added
some pthread_self() debug a found it out:
05-07 14:29:38.270 14543 14543 D Baresip Lib: allocating new call for ua 515980318608 on thread 519961038544
05-07 14:29:38.273 14543 14543 D Baresip Lib: connecting call 515979876880 to
sip:te...@test.tutpro.com on thread 519961038544
05-07 14:29:44.354 14543 14599 D Baresip Lib:
b...@test.tutpro.com: Call established:
sip:te...@test.tutpro.com
05-07 14:29:56.053 14543 14543 D Baresip Lib: video_start_display on thread 519961038544
05-07 14:29:56.563 14543 14543 D Baresip vidisp: At opengles_alloc() on thread 519961038544
05-07 14:29:57.645 14543 14598 D Baresip vidisp: At opengles_display() on thread 515871628624
05-07 14:29:57.651 14543 14598 D Baresip vidisp: eglSwapBuffers() returned error EGL_BAD_SURFACE
05-07 14:29:57.897 14543 14598 D Baresip vidisp: At opengles_display() on thread 515871628624
05-07 14:29:57.903 14543 14598 D Baresip vidisp: eglSwapBuffers() returned error EGL_BAD_SURFACE
...
As you can see, all call related API functions and opengles_alloc() are
on the same thread 519961038544, but opengles_display() calls are on
thread 515871628624. It is not possible for the opengles_display()
calls to work, because the OpenGL context must be created on the same
thread that is used for rendering the frames. Now the context is
created by opengles_alloc() on a different thread.
When video is enabled already at call_connect(), both opengles_alloc()
and opengles_display() are executed on the same thread and everything
works OK:
05-07 14:51:48.725 14878 14928 D Baresip vidisp: At opengles_alloc() on thread 515871575376
...
05-07 14:51:49.901 14878 14928 D Baresip vidisp: At opengles_display() on thread 515871575376
So, looks like I found the explanation, but how to fix the issue, i.e.,
how to make sure that the same thread is used for both alloc and
display?
-- Juha