如果是一个TextureView的"消费端和QUOT;关闭? [英] When Is a TextureView's "Consumer Side" Closed?

查看:170
本文介绍了如果是一个TextureView的"消费端和QUOT;关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个谷歌官方的样本为摄像​​机2 API从的遭受的:// github上。 COM / googlesamples / Android的Camera2Basic /问题/ 10>同 BufferQueue已被放弃问题如图中:

One of the official Google samples for the Camera2 API suffers from the same BufferQueue has been abandoned problem as is seen in:

  • <一个href="http://stackoverflow.com/questions/22486762/what-can-i-do-when-the-bufferqueue-has-been-abandoned">What我可以做的时候BufferQueue已被放弃?
  • <一个href="http://stackoverflow.com/questions/30111951/android-logcat-shows-bufferqueueprocedure-solved">Android LogCat中显示BufferQueueProcedure,解决
  • What can I do when the BufferQueue has been abandoned?
  • Android LogCat shows BufferQueueProcedure, solved

具体而言,示例应用程序从的onPause调用 closeCamera()办法()片段,其中 closeCamera()电话关闭() CameraCaptureSession ,然后关闭() CameraDevice ,然后关闭()的ImageReader (用于实际拍照)。在关闭() CameraDevice 是,当上述 BufferQueue的一些事件已经出现在LogCat中抛弃消息,虽然我只得到了消息,一些安卓5.1的硬件(的Nexus 4和Nexus 7 2013年),而不是别人(的Nexus 5和Nexus 6)。

Specifically, the sample app calls a closeCamera() method from onPause() of a fragment, where closeCamera() calls close() on the CameraCaptureSession, then close() on the CameraDevice, then close() on the ImageReader (used for actual picture-taking). After the close() on CameraDevice is when a few occurrences of the aforementioned BufferQueue has been abandoned message appears in LogCat, though I only get the message on some Android 5.1 hardware (Nexus 4 and Nexus 7 2013) and not others (Nexus 5 and Nexus 6).

在此法登的评论是:

如果消费者方面正在进入的onPause(),该消息将有望之前关闭。

If the consumer side is shut down before entering onPause(), the messages would be expected.

在将 TextureView 的消费端将被关闭,为什么呢?

When will TextureView's "consumer side" will be shut down, and why then?

谷歌的样品code不主动做任何事情来关闭 TextureView ,我可以看到。而且,因为 TextureView 停顿了一下,我本来期望的消费者方将不会受到任何影响的时候,仍然可以看到的onPause (),但也许以后在的onStop()

Google's sample code does not proactively do anything to shut down the TextureView that I can see. And, since the TextureView could still be visible when paused, I would have expected that the "consumer side" would not be affected at the time of onPause(), but perhaps later in onStop().

虽然我知道这消息(尽管是一个错误)是良性的,我试图找出如何摆脱它,如果没有其他原因,而不是prevent我被要求一次又一次,为什么我的code正在记录此错误。我希望通过了解更多关于这个消费者面,我可以找出如何更好地整理东西的时候用户退出摄像机2,采用活动或片段,并避免此错误。

While I realize that this message (despite being an error) is benign, I'm trying to figure out how to get rid of it, if for no other reason than to prevent my being asked time and again why code of mine is logging this error. I am hoping that by understanding more about this "consumer side", I can figure out how better to tidy things up when the user exits a Camera2-using activity or fragment and avoid this error.

推荐答案

您等待相机onClosed状态回调方法被调用,在退出之前的onPause?

Are you waiting for the camera's onClosed state callback method to be invoked, before exiting onPause?

在此之前,回调火灾,相机可能还有尚未完成的工作要做,并接近的定义()是在关闭设备之前完成了所有悬而未决的拍摄请求。这可以调用close()。

Until that callback fires, the camera may still have pending work to do, and the definition of close() is to finish up all pending capture requests before shutting down the device. This can be sped up by calling abortCapture() before calling close().

某些设备(如N5和N6)当前块的密切()调用,这样,当它返回时,所有挂起的工作就完成了,但是这是一个实现细节,我认为我们的样本无意中依赖于今天。

Some devices (like the N5 and N6) currently block the close() call so that when it returns, all the pending work is done, but this is an implementation detail that I think our sample inadvertently relies on today.

不过,我们一般要允许应用程序调用close()离开的onPause()立即,避免挂在UI线程等待相机硬件关机。但是,这还不是今天的现实。

However, we generally want to allow apps to call close() and leave onPause() immediately, to avoid hanging the UI thread on waiting for the camera hardware to shut down. But this isn't yet reality today.

在换言之,靠近()被认为是异步的,并且不是对所有设备。但是,我们希望它可以为你射后不理它,所以需要在摄像装置的侧面加以解决这些错误消息(当重复请求的目标消失了中间的操作不是垃圾邮件日志)。

In other words, close() is supposed to be asynchronous, and isn't on all devices. But we'd like it to be possible for you to fire and forget it, so these error messages need to be addressed on the camera device's side (not spam the log when the repeating request target goes away mid-operation).

另一个原因只是调用close()和退出的onPause()今日不推荐的是,它会从$打开在p $ pvent其他应用程序 相机在他们的onResume()调用,哪一个摄像头应用程序之间切换时,会造成虚假的错误。

The other reason just calling close() and exiting onPause() isn't recommended today is that it will prevent other apps from opening the camera in their onResume() calls, which will cause spurious errors when switching between camera apps.

总结一下:

现在:等待<一href="http://developer.android.com/reference/android/hardware/camera2/CameraDevice.StateCallback.html#onClosed(android.hardware.camera2.CameraDevice)"相对=nofollow> CameraDevice.StateCallback#onClosed 调用CameraDevice#收盘后退出的onPause()之前被调用()。

For now: Wait for CameraDevice.StateCallback#onClosed to be invoked before exiting onPause() after calling CameraDevice#close().

在未来的某个时刻:将安全只是调用close()和退出的onPause;该框架将适当允许下一个应用程序来连接,而不是垃圾邮件的日志。很抱歉,这不是今天的样子!

At some future point: Will be safe to just call close() and exit onPause; the framework will properly allow the next app to connect and not spam your log. Sorry this isn't the state today!

这篇关于如果是一个TextureView的&QUOT;消费端和QUOT;关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆