package com.kofax.mobile.sdk.k; import com.kofax.kmc.kui.uicontrols.PreviewCallbackListener; import com.kofax.kmc.kui.uicontrols.PreviewFrameEvent; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /* loaded from: classes3.dex */ class l { private final a GI; public l(PreviewCallbackListener previewCallbackListener) { this.GI = new a(previewCallbackListener); } public void b(com.kofax.mobile.sdk._internal.camera.f fVar) { this.GI.b(fVar); } public void stopListening() { this.GI.stopListening(); } /* loaded from: classes3.dex */ static class a implements PreviewCallbackListener { private final PreviewCallbackListener GK; private final Lock GJ = new ReentrantLock(true); private com.kofax.mobile.sdk._internal.camera.f GL = null; public a(PreviewCallbackListener previewCallbackListener) { if (previewCallbackListener == null) { throw new IllegalArgumentException(); } this.GK = previewCallbackListener; } public void b(com.kofax.mobile.sdk._internal.camera.f fVar) { this.GJ.lock(); try { if (this.GL != null) { throw new IllegalStateException(); } fVar.addPreviewCallbackListener(this); this.GL = fVar; } finally { this.GJ.unlock(); } } public void stopListening() { this.GJ.lock(); try { this.GL.removePreviewCallbackListener(this); this.GL = null; } finally { this.GJ.unlock(); } } @Override // com.kofax.kmc.kui.uicontrols.PreviewCallbackListener public void onPreviewFrame(PreviewFrameEvent previewFrameEvent) { if (this.GJ.tryLock()) { try { if (this.GL != null) { this.GK.onPreviewFrame(previewFrameEvent); } } finally { this.GJ.unlock(); } } } } }