@@ -34,9 +34,9 @@ class SafeCloseImageReaderProxy implements ImageReaderProxy {
34
34
private final Object mLock = new Object ();
35
35
36
36
@ GuardedBy ("mLock" )
37
- private volatile int mOutstandingImages = 0 ;
37
+ private int mOutstandingImages = 0 ;
38
38
@ GuardedBy ("mLock" )
39
- private volatile boolean mIsClosed = false ;
39
+ private boolean mIsClosed = false ;
40
40
41
41
// The wrapped instance of ImageReaderProxy
42
42
@ GuardedBy ("mLock" )
@@ -46,7 +46,7 @@ class SafeCloseImageReaderProxy implements ImageReaderProxy {
46
46
private final Surface mSurface ;
47
47
48
48
// Called after images are closed to check if the ImageReaderProxy should be closed
49
- private ForwardingImageProxy .OnImageCloseListener mImageCloseListener = (image ) -> {
49
+ private final ForwardingImageProxy .OnImageCloseListener mImageCloseListener = (image ) -> {
50
50
synchronized (mLock ) {
51
51
mOutstandingImages --;
52
52
if (mIsClosed && mOutstandingImages == 0 ) {
@@ -97,16 +97,14 @@ public void close() {
97
97
@ GuardedBy ("mLock" )
98
98
@ Nullable
99
99
private ImageProxy wrapImageProxy (@ Nullable ImageProxy imageProxy ) {
100
- synchronized (mLock ) {
101
- if (imageProxy != null ) {
102
- mOutstandingImages ++;
103
- SingleCloseImageProxy singleCloseImageProxy =
104
- new SingleCloseImageProxy (imageProxy );
105
- singleCloseImageProxy .addOnImageCloseListener (mImageCloseListener );
106
- return singleCloseImageProxy ;
107
- } else {
108
- return null ;
109
- }
100
+ if (imageProxy != null ) {
101
+ mOutstandingImages ++;
102
+ SingleCloseImageProxy singleCloseImageProxy =
103
+ new SingleCloseImageProxy (imageProxy );
104
+ singleCloseImageProxy .addOnImageCloseListener (mImageCloseListener );
105
+ return singleCloseImageProxy ;
106
+ } else {
107
+ return null ;
110
108
}
111
109
}
112
110
@@ -117,7 +115,6 @@ private ImageProxy wrapImageProxy(@Nullable ImageProxy imageProxy) {
117
115
* <p>Once this has been called, no more additional ImageProxy can be acquired from the
118
116
* {@link SafeCloseImageReaderProxy}.
119
117
*/
120
- @ GuardedBy ("mLock" )
121
118
void safeClose () {
122
119
synchronized (mLock ) {
123
120
mIsClosed = true ;
0 commit comments