我正在OUYA设备上测试我的视频播放器,它几乎立即崩溃并出现“尺寸过大”错误(请参阅下面的logcat转储)。如果有人知道解决方法或设置最大尺寸的方法,我将不胜感激。
D/MySurface(2651): surfaceCreated W/InputDispatcher(319): Attempted to unregister already unregistered input channel '41daf688 tv.ouya.console.wallpaper.OozeService (server)' I/WindowState(319): WIN DEATH: Window{41daf688 tv.ouya.console.wallpaper.OozeService paused=false} I/WindowManager(319): WINDOW DIED Window{41daf688 tv.ouya.console.wallpaper.OozeService paused=false} E/SurfaceFlinger(109): dimensions too large 2560 x 1472 E/SurfaceFlinger(109): createNormalSurfaceLocked() failed (Invalid argument) W/WindowStateAnimator(319): OutOfResourcesException creating surface I/WindowManager(319): Out of memory for surface! Looking for leaks... W/WindowManager(319): No leaked surfaces; killing applicatons! W/ActivityManager(319): Killing processes Free memory at adjustment 0 W/ActivityManager(319): Killing ProcessRecord{41d9cae8 2651:example.android.player/u0a37} (adj 0): Free memory W/WindowManager(319): Looks like we have reclaimed some memory, clearing surface for retry. W/WindowManager(319): Due to memory failure, waiting a bit for next layout
我已经尝试通过这篇文章改变决议,但没有取得任何成功:http://forums.ouya.tv/discussion/2170/setting-resolution-not-working
答案 0 :(得分:0)
我找到了一个解决方法,使用Surface回调,其宽度和高度预设为max:
@Override public void surfaceCreated(SurfaceHolder holder) { Rect rect = holder.getSurfaceFrame(); if (rect.width() > maxWidth || rect.height() > maxHeight) { holder.setFixedSize(maxWidth, maxHeight); } }