Bug 修復

今天調試屏幕與視頻的同時旋轉測試出錯了:

10-18 11:31:42.663: E/SurfaceTextureClient(16812): dequeueBuffer: ISurfaceTexture::requestBuffer failed: -19
10-18 11:31:42.663: E/[EGL-ERROR](16812): void __egl_platform_dequeue_buffer(egl_surface*):1258: failed to dequeue buffer from native window (0x65ca03b0); err = -19, buf = 0x0
10-18 11:31:42.733: E/TestRotate(16812): create surfaceview for mediaplayer1
10-18 11:31:42.733: D/AndroidRuntime(16812): Shutting down VM
10-18 11:31:42.733: W/dalvikvm(16812): threadid=1: thread exiting with uncaught exception (group=0x4128b300)
10-18 11:31:42.773: E/AndroidRuntime(16812): FATAL EXCEPTION: main
10-18 11:31:42.773: E/AndroidRuntime(16812): java.lang.IllegalArgumentException: The surface has been released
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.media.MediaPlayer._setVideoSurface(Native Method)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.media.MediaPlayer.setDisplay(MediaPlayer.java:668)
10-18 11:31:42.773: E/AndroidRuntime(16812): at com.starnet.DisplayOutput.TestRotate.surfaceCreated(TestRotate.java:246)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.SurfaceView.updateWindow(SurfaceView.java:623)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.SurfaceView.setFrame(SurfaceView.java:298)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.View.layout(View.java:13770)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.View.layout(View.java:13772)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.ViewGroup.layout(ViewGroup.java:4365)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.View.layout(View.java:13772)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.ViewGroup.layout(ViewGroup.java:4365)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.View.layout(View.java:13772)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.ViewGroup.layout(ViewGroup.java:4365)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.View.layout(View.java:13772)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.ViewGroup.layout(ViewGroup.java:4365)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1875)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1696)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1007)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4221)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.Choreographer.doFrame(Choreographer.java:525)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.os.Handler.handleCallback(Handler.java:615)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.os.Handler.dispatchMessage(Handler.java:92)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.os.Looper.loop(Looper.java:137)
10-18 11:31:42.773: E/AndroidRuntime(16812): at android.app.ActivityThread.main(ActivityThread.java:4745)
10-18 11:31:42.773: E/AndroidRuntime(16812): at java.lang.reflect.Method.invokeNative(Native Method)
10-18 11:31:42.773: E/AndroidRuntime(16812): at java.lang.reflect.Method.invoke(Method.java:511)
10-18 11:31:42.773: E/AndroidRuntime(16812): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-18 11:31:42.773: E/AndroidRuntime(16812): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-18 11:31:42.773: E/AndroidRuntime(16812): at dalvik.system.NativeStart.main(Native Method)


其中AndroidManifest.xml:

<activity  android:name="com.starnet.DisplayOutput.TestRotate"
            android:configChanges="orientation|keyboardHidden|screenSize" >
</activity>


java旋轉方法:

class TestThread extends Thread{
        @Override  
        public void run() {           
int orientation = getRequestedOrientation();
System.out.println("____rotateflage   __"+orientation);
try{
Thread.currentThread();
Thread.sleep(1000);
}
catch(InterruptedException ie){}
if(pointer==4 && rotateflage){
if (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
else if(orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
else if(orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT )
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
else if(orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE )
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
}
if(pointer==4 && rotateflage){
Message msgRo = new Message();    
if(countRotate<3){
msgRo.what=VEDIOROTATEOK;
}else {
msgRo.what = NESTOPTION3;
rotateflage=false;
}
TestRotate.this.myHandler.sendMessage(msgRo);  
}
}
    }

主要是myHandler發送 NESTOPTION3 消息去跳到下一個UI後出錯。

之後改爲:

class TestThread extends Thread{
        @Override  
        public void run() {           
int orientation = getRequestedOrientation();
System.out.println("____rotateflage   __"+orientation);
try{
Thread.currentThread();
Thread.sleep(1000);
}
catch(InterruptedException ie){}
if(pointer==4 && rotateflage){
if (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
else if(orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
else if(orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT )
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
else if(orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE )
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
}
try{
Thread.currentThread();
Thread.sleep(2000);
}

catch(InterruptedException ie){}
if(pointer==4 && rotateflage){
Message msgRo = new Message();    
if(countRotate<3){
msgRo.what=VEDIOROTATEOK;
}else {
msgRo.what=NESTOPTION3;
rotateflage=false;
}
TestRotate.this.myHandler.sendMessage(msgRo);
}
}
    }就OK無措了。

自己猜測是旋屏後馬上跳到別界面出錯,應該sleep會二再跳到其它UI。(菜鳥不要誤人子弟。我是菜鳥)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章