播放框架 - GL渲染

1、WallpaperGLThread
2、GLMediaDisplay
3、GLRenderer
4、GLImageRenderer
5、GLVideoRenderer

问题:

  • 从GL渲染切回正常渲染,会播放失败(即使刷新Surface,也被GL绑定,依赖解决)

播放框架 - GLVideoRenderer

OpenGL 从零开始写一个Android平台下的全景视频播放器
TextureView+SurfaceTexture+OpenGL ES来播放视频

存在问题:
1、视频这边 setRenderer 后没有触发 WallpaperGLThread 的 onDrawFrame,图片可以(已经解决)
2、视频播放会不停的闪烁(已经解决)
3、视频播放图像颠倒(已经解决)
4、视频播放会卡住渲染线程(已经解决)

备注1:

问题4: 
"Thread-174" sysTid=11176 
  #00 pc 000205b8 /system/lib/libc.so (__ioctl+8) 
  #01 pc 0002cf27 /system/lib/libc.so (ioctl+14) 
  #02 pc 0001d3ed /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+140) 
  #03 pc 0001d8d7 /system/lib/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+42) 
  #04 pc 0001dadf /system/lib/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+118) 
  #05 pc 00019791 /system/lib/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+30) 
  #06 pc 0002bc09 /system/lib/libgui.so 
  #07 pc 00030373 /system/lib/libgui.so (android::Surface::dequeueBuffer(ANativeWindowBuffer**, int*)+98) 
  #08 pc 0002f9b9 /system/lib/libgui.so (android::Surface::hook_dequeueBuffer(ANativeWindow*, ANativeWindowBuffer**, int*)+10) 
  #09 pc 00018cec /system/lib/egl/libGLES_mali.so 
  #10 pc 0019afb8 /system/lib/egl/libGLES_mali.so 
  #11 pc 0019bd68 /system/lib/egl/libGLES_mali.so (eglSwapBuffers+1260) 
  #12 pc 0000f709 /system/lib/libEGL.so (eglSwapBuffers+280) 
  #13 pc 0004f2cf /system/lib/libandroid_runtime.so 
  #14 pc 0001db8c /system/lib/libdvm.so (dvmPlatformInvoke+112) 
  #15 pc 0004e033 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398) 
  #16 pc 00000834 /dev/ashmem/dalvik-jit-code-cache (deleted)

备注2:

+ Layer 0xb7cf9d48 (SurfaceView) 
  Region transparentRegion (this=0xb7cf9eac, count=1) 
    [ 0, 0, 0, 0] 
  Region visibleRegion (this=0xb7cf9d50, count=1) 
    [320, 160, 960, 560] 
      layerStack= 0, z= 11000, pos=(320,160), size=( 640, 400), crop=( 0, 0, -1, -1), isOpaque=1, invalidate=0, alpha=0xff, flags=0x00000000, tr=[1.00, 0.00][0.00, 1.00] 
      client=0xb7c93ae0 
      format= 4, activeBuffer=[ 640x 400: 640, 2], queued-frames=3, mRefreshPending=0 
            mTexName=7 mCurrentTexture=0 
            mCurrentCrop=[0,0,0,0] mCurrentTransform=0 
            mAbandoned=0 
            -BufferQueue mMaxAcquiredBufferCount=1, mDequeueBufferCannotBlock=0, default-size=[640x400], default-format=4, transform-hint=00, FIFO(2)={01:0xb7c6a0f0 crop=[0,0,0,0], xform=0x00, time=0x2812b520203, scale=FREEZE 
02:0xb7c3e238 crop=[0,0,0,0], xform=0x00, time=0x2812c5454df, scale=FREEZE 

            >[00:0xb7c6a070] state=ACQUIRED, 0xb7cb4c20 [ 640x 400: 640, 2] 
             [01:0xb7c6a0f0] state=QUEUED , 0xb7c3e670 [ 640x 400: 640, 2] 
             [02:0xb7c3e238] state=QUEUED , 0xb7c6a170 [ 640x 400: 640, 2] 

备注3:

问题1: 
是因为没有resize SurfaceView,Render 线程还在等待 

06-21 15:56:58.219 23906 23946 D WallpaperGLThread: <init> surfaceCreated 
06-21 15:56:58.219 23906 23946 I GLThread: surfaceCreated tid=228 
06-21 15:56:58.219 23906 23949 I GLThread: starting tid=228 
06-21 15:56:58.229 23906 23946 D WallpaperGLThread: setRenderer com.pptv.wallpaperplayer.media.GLVideoRenderer@42316b50 
06-21 15:56:58.229 23906 23949 I GLThread: waiting tid=228 mHaveEglContext: false mHaveEglSurface: false mFinishedCreatingEglSurface: false mPaused: false mHasSurface: true mSurfaceIsBad: false mWaitingForSurface: false mWidth: 0 mHeight: 0 mRequestRender: true mRenderMode: 1 
备注4:

问题1: 
需要调整 WallpaperSurfaceView,在 surfaceCreated 时,也调用 surfaceChanged

备注5:

问题2: 

Pano正常的Surface: 
+ Layer 0xb872a720 (SurfaceView) 
  Region transparentRegion (this=0xb872a884, count=1) 
    [ 0, 0, 0, 0] 
  Region visibleRegion (this=0xb872a728, count=1) 
    [ 0, 0, 1280, 720] 
      layerStack= 0, z= 21020, pos=(0,0), size=(1280, 720), crop=( 0, 0,1280, 720), isOpaque=1, invalidate=0, alpha=0xff, flags=0x00000000, tr=[1.00, 0.00][0.00, 1.00] 
      client=0xb8755030 
      format= 4, activeBuffer=[1280x 720:1280, 2], queued-frames=0, mRefreshPending=0 
            mTexName=14 mCurrentTexture=1 
            mCurrentCrop=[0,0,0,0] mCurrentTransform=0 
            mAbandoned=0 
            -BufferQueue mMaxAcquiredBufferCount=1, mDequeueBufferCannotBlock=0, default-size=[1280x720], default-format=4, transform-hint=00, FIFO(0)={} 
             [00:0xb8773bd0] state=FREE , 0xb864e138 [1280x 720:1280, 2] 
            >[01:0xb8712ab0] state=ACQUIRED, 0xb878f1c0 [1280x 720:1280, 2] 
             [02:0xb8773b50] state=DEQUEUED, 0xb8790448 [1280x 720:1280, 2] 

WPP不正常的Surface: 
+ Layer 0xb86f9700 (SurfaceView) 
  Region transparentRegion (this=0xb86f9864, count=1) 
    [ 0, 0, 0, 0] 
  Region visibleRegion (this=0xb86f9708, count=1) 
    [ 0, 0, 1280, 720] 
      layerStack= 0, z= 11000, pos=(0,0), size=(1280, 720), crop=( 0, 0, -1, -1), isOpaque=1, invalidate=0, alpha=0xff, flags=0x00000000, tr=[1.00, 0.00][0.00, 1.00] 
      client=0xb873cc68 
      format= 4, activeBuffer=[1280x 720:1280, 2], queued-frames=2, mRefreshPending=0 
            mTexName=14 mCurrentTexture=1 
            mCurrentCrop=[0,0,0,0] mCurrentTransform=0 
            mAbandoned=0 
            -BufferQueue mMaxAcquiredBufferCount=1, mDequeueBufferCannotBlock=0, default-size=[1280x720], default-format=4, transform-hint=00, FIFO(2)={02:0xb86ed5c8 crop=[0,0,0,0], xform=0x00, time=0x183eb016a3c15, scale=FREEZE 
00:0xb8743060 crop=[0,0,0,0], xform=0x00, time=0x183eb02791211, scale=FREEZE 

             [00:0xb8743060] state=QUEUED , 0xb87747e0 [1280x 720:1280, 2] 
            >[01:0xb8787cd8] state=ACQUIRED, 0xb86ed530 [1280x 720:1280, 2] 
             [02:0xb86ed5c8] state=QUEUED , 0xb86a13d0 [1280x 720:1280, 2] 

备注6:

问题4:进一步分析 SurfaceFlinger 进程,好像卡在: 

"Binder_1" sysTid=1205 
  #00 pc 00021934 /system/lib/libc.so (__futex_syscall3+8) 
  #01 pc 0000ef64 /system/lib/libc.so (__pthread_cond_timedwait_relative+48) 
  #02 pc 0000efc4 /system/lib/libc.so (__pthread_cond_timedwait+64) 
  #03 pc 00026855 /system/lib/libgui.so (android::BufferQueue::dequeueBuffer(int*, android::sp<android::Fence>*, bool, unsigned int, unsigned int, unsigned int, unsigned int)+692) 
  #04 pc 0002b8ef /system/lib/libgui.so (android::BnGraphicBufferProducer::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+262) 
  #05 pc 00019225 /system/lib/libbinder.so (android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+60) 
  #06 pc 0001d799 /system/lib/libbinder.so (android::IPCThreadState::executeCommand(int)+508) 
  #07 pc 0001db17 /system/lib/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+38) 
  #08 pc 0001db8d /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+48) 
  #09 pc 00021a49 /system/lib/libbinder.so 
  #10 pc 0000ea01 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+216) 
  #11 pc 0000e533 /system/lib/libutils.so 
  #12 pc 0000d208 /system/lib/libc.so (__thread_entry+72) 
  #13 pc 0000d3a4 /system/lib/libc.so (pthread_create+240)

备注7:

dequeueBuffer 失败:(这个是wpp service 进程的输出,可能是 surfacetexture dequeueBuffer 被调用时失败) 

06-28 14:25:13.008 14112 14133 E BufferQueue: [unnamed-14112-0] dequeueBuffer: would block! returning an error instead. 
06-28 14:25:13.128 14112 14122 E BufferQueue: [unnamed-14112-0] dequeueBuffer: would block! returning an error instead. 
06-28 14:25:13.138 14112 14134 E BufferQueue: [unnamed-14112-0] dequeueBuffer: would block! returning an error instead. 

相关代码: 
            if (tryAgain) { 
                // return an error if we're in "cannot block" mode (producer and consumer 
                // are controlled by the application) -- however, the consumer is allowed 
                // to acquire briefly an extra buffer (which could cause us to have to wait here) 
                // and that's okay because we know the wait will be brief (it happens 
                // if we dequeue a buffer while the consumer has acquired one but not released 
                // the old one yet -- for e.g.: see GLConsumer::updateTexImage()). 
                if (mDequeueBufferCannotBlock && (acquiredCount <= mMaxAcquiredBufferCount)) { 
                    ST_LOGE("dequeueBuffer: would block! returning an error instead."); 
                    return WOULD_BLOCK; 
                } 
                mDequeueCondition.wait(mMutex); 
            } 

备注8:

06-28 14:58:20.868 21903 22016 D GLVideoRenderer: draw 
06-28 14:58:20.888 21903 22016 D GLVideoRenderer: draw 
06-28 14:58:20.948 21903 22016 D GLVideoRenderer: draw 
06-28 14:58:21.008 21903 22016 D GLVideoRenderer: draw 
06-28 14:58:21.028 21903 22016 D GLVideoRenderer: draw 

"Thread-1271" sysTid=22016 
  #00 pc 000205bc /system/lib/libc.so (__ioctl+12) 
  #01 pc 0002cf27 /system/lib/libc.so (ioctl+14) 
  #02 pc 0001d3ed /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+140) 
  #03 pc 0001d8d7 /system/lib/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+42) 
  #04 pc 0001dadf /system/lib/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+118) 
  #05 pc 00019791 /system/lib/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+30) 
  #06 pc 0002b377 /system/lib/libgui.so 
  #07 pc 00030721 /system/lib/libgui.so (android::Surface::queueBuffer(ANativeWindowBuffer*, int)+220) 
  #08 pc 0002f9d5 /system/lib/libgui.so (android::Surface::hook_queueBuffer(ANativeWindow*, ANativeWindowBuffer*, int)+10) 
  #09 pc 0001823c /system/lib/egl/libGLES_mali.so 
  #10 pc 0019b710 /system/lib/egl/libGLES_mali.so 
  #11 pc 0019bf88 /system/lib/egl/libGLES_mali.so (eglSwapBuffers+1804) 
  #12 pc 0000f709 /system/lib/libEGL.so (eglSwapBuffers+280) 
  #13 pc 0004f2cf /system/lib/libandroid_runtime.so 
  #14 pc 0001db8c /system/lib/libdvm.so (dvmPlatformInvoke+112) 
  #15 pc 0004e033 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398) 
  #16 pc 00000834 /dev/ashmem/dalvik-jit-code-cache (deleted) 


"GLThread 1271" prio=5 tid=20 SUSPENDED 
  | group="main" sCount=1 dsCount=0 obj=0x4208cfd0 self=0x5a5f2898 
  | sysTid=22016 nice=0 sched=0/0 cgrp=apps handle=1514666160 
  | state=S schedstat=( 0 0 0 ) utm=420 stm=202 core=0 
  #00 pc 00021934 /system/lib/libc.so (__futex_syscall3+8) 
  #01 pc 0000ef64 /system/lib/libc.so (__pthread_cond_timedwait_relative+48) 
  #02 pc 0000efc4 /system/lib/libc.so (__pthread_cond_timedwait+64) 
  #03 pc 0005359b /system/lib/libdvm.so 
  #04 pc 00053b61 /system/lib/libdvm.so (dvmChangeStatus(Thread*, ThreadStatus)+34) 
  #05 pc 0004e03b /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+406) 
  #06 pc 00000834 /dev/ashmem/dalvik-jit-code-cache (deleted) 
  at com.google.android.gles_jni.EGLImpl.eglSwapBuffers(Native Method) 
  at android.opengl.GLSurfaceView$EglHelper.swap(GLSurfaceView.java:1140) 
  at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1526) 
  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) 

备注9:

"Binder_5" sysTid=1653 
  #00 pc 00021934 /system/lib/libc.so (__futex_syscall3+8) 
  #01 pc 0000e70c /system/lib/libc.so 
  #02 pc 000242e7 /system/lib/libgui.so 
  #03 pc 00027dab /system/lib/libgui.so (android::ConsumerBase::onFrameAvailable()+14) 
  #04 pc 0002629b /system/lib/libgui.so (android::BufferQueue::ProxyConsumerListener::onFrameAvailable()+20) 
  #05 pc 000274c1 /system/lib/libgui.so (android::BufferQueue::queueBuffer(int, android::IGraphicBufferProducer::QueueBufferInput const&, android::IGraphicBufferProducer::QueueBufferOutput*)+896) 
  #06 pc 0002b96d /system/lib/libgui.so (android::BnGraphicBufferProducer::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+388) 
  #07 pc 00019225 /system/lib/libbinder.so (android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+60) 
  #08 pc 0001d799 /system/lib/libbinder.so (android::IPCThreadState::executeCommand(int)+508) 
  #09 pc 0001db17 /system/lib/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+38) 
  #10 pc 0001db8d /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+48) 
  #11 pc 00021a49 /system/lib/libbinder.so 
  #12 pc 0000ea01 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+216) 
  #13 pc 0000e533 /system/lib/libutils.so 
  #14 pc 0000d208 /system/lib/libc.so (__thread_entry+72) 
  #15 pc 0000d3a4 /system/lib/libc.so (pthread_create+240) 

备注10:

瞎猫碰上死耗子,原来是必须先调用 glClear ,然后才能 updateTexImage

备注11:

不使用 SurfaceTexture 的 TransformMatrix,图像就不会颠倒

备注12:

 1085 0 21% S 26 163172K 11904K fg system /system/bin/surfaceflinger 
12628 1 13% S 31 476960K 42664K fg system com.pptv.wallpaperplayer:player 
 1105 1 9% S 44 690832K 10860K fg root /applications/bin/tvos 
12559 0 7% S 31 494384K 57744K fg system com.pptv.wallpaperplayer.service 
 1088 1 7% S 28 328312K 17700K fg root /system/bin/mediaserver 

备注13:

问题2: 
因为GL刷新频率超过帧率,有时候调用了 onDrawFrame,但是没有画图,但是 gl 不知道,还在 swap,就显示老的画面了,导致画面抖动。

播放框架 - GLImageRenderer

存在问题:
1、切换比例时,会闪烁(已经解决)

备注1:

比例调整时,原因未知,但是如果不调整Surface大小,只调整glViewPort,是不会闪烁的。

猜你喜欢

转载自blog.csdn.net/luansxx/article/details/89429507
今日推荐