为什么Android SDL_SetVideoMode在未被主线程调用时崩溃?

时间:2013-05-31 09:00:39

标签: android sdl

我面临着一个我无法解决的奇怪问题。 我在android上使用SDL来显示由ffmpeg解码的帧。 如果SDL渲染器直接在主要功能中创建,然后初始化,则没有问题

05-31 09:24:11.442: V/SDL(11376): pixel format RGB_565
05-31 09:24:11.442: I/SDL(11376): SDL_Android_Init()
05-31 09:24:11.442: I/Main(11376): Entering main
05-31 09:24:13.817: I/SDLRenderer(11376): Entering SDLRenderer::init
05-31 09:24:13.817: I/SDLRenderer(11376): SDLRenderer::init -> About to create screen with w=704 h=480
05-31 09:24:13.817: I/SDL(11376): [STUB] GL_LoadLibrary
05-31 09:24:13.822: V/SDL(11376): Starting up OpenGL ES 2.0
05-31 09:24:13.827: D/libEGL(11376): loaded /system/lib/egl/libEGL_mali.so
05-31 09:24:13.832: D/libEGL(11376): loaded /system/lib/egl/libGLESv1_CM_mali.so
05-31 09:24:13.832: D/libEGL(11376): loaded /system/lib/egl/libGLESv2_mali.so
05-31 09:24:13.837: D/(11376): Device driver API match
05-31 09:24:13.837: D/(11376): Device driver API version: 10
05-31 09:24:13.837: D/(11376): User space API version: 10 
05-31 09:24:13.837: D/(11376): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Fri May  4 10:32:42 KST 2012 
05-31 09:24:13.862: I/SDL(11376): [STUB] GL_SetSwapInterval
05-31 09:24:13.862: I/SDL(11376): [STUB] GL_GetSwapInterval
05-31 09:24:13.932: I/SDLRenderer(11376): SDLRenderer::init -> screen created with w=704 h=480
05-31 09:24:13.932: I/SDLRenderer(11376): SDLRenderer::init -> About to create YUV Overlay with SDL_YV12_OVERLAY and w=704 h=480
05-31 09:24:13.932: I/SDLRenderer(11376): SDLRenderer::init -> YUV Overlay created with SDL_YV12_OVERLAY and w=704 h=480

但是如果在main函数中,我创建了一个执行上一个作业的线程(创建渲染器并初始化它)它会崩溃..

05-31 10:33:04.462: V/SDL(23043): pixel format RGB_565
05-31 10:33:04.462: I/SDL(23043): SDL_Android_Init()
05-31 10:33:04.462: I/Main(23043): Entering main
05-31 10:33:05.882: I/Main(23043): Main: About to create thread DecodeVideo
05-31 10:33:05.882: I/Main(23043): Starting DecodeVideo
05-31 10:33:06.457: I/SDLRenderer(23043): Entering SDLRenderer::init
05-31 10:33:06.462: I/SDLRenderer(23043): SDLRenderer::init -> About to create screen with w=704 h=480
05-31 10:33:06.462: I/SDL(23043): [STUB] GL_LoadLibrary
05-31 10:33:06.462: A/libc(23043): Fatal signal 11 (SIGSEGV) at 0x00000364 (code=1)

有人知道是否有特别的事要做才能解决这个问题? 谢谢。 ZBB

1 个答案:

答案 0 :(得分:1)

来自documentation

*注3:应在应用程序的主线程中调用此函数。 *