LVC (videolan) 播放高清节目采用OMX解码时,重新进入播放会导致surface 出错,造成采用软解卡顿的问题,错误信息如下:
10-28 04:25:25.069 E/BufferQueueProducer( 1465): <span style="color:#FF0000;">[SurfaceView] connect(P): already connected (cur=2 req=3)</span>
10-28 04:25:25.069 E/MediaCodec( 4912): <span style="color:#FF0000;">native_window_api_connect returned an error: Invalid argument (-22)</span>
10-28 04:25:25.070 E/MediaCodec( 4912): configure failed with err 0xffffffea, resetting...
出现这个问题的原因是播放切换推出时,surfaceView仍然 被占用,导致第二次进去时出错,解决的方法是
重新构建SurfaceView:
gSurfaceView.setVisibility(ViewStub.GONE)
gSurfaceView.setVisibility(ViewStub.VISIBLE);
播放前重新attachViews 给AWindow;实现代码如下:
if(gSurfaceView.getVisibility() != View.GONE)
{
gSurfaceView.setVisibility(View.GONE);
}
if(gSurfaceView.getVisibility() != View.VISIBLE)
{
gSurfaceView.setVisibility(View.VISIBLE);
}
IVLCVout vout = mVlcPlayer.getVLCVout();
vout.setVideoView(gSurfaceView);
if(vout.areViewsAttached())
{
vout.detachViews();
}
vout.attachViews();
可能某些版本会出现类似的问题,所以正常播放并不需要调用类似的方法,期望下个版本没有这个问题。