package androidx.media3.extractor;

import androidx.annotation.GuardedBy;
import androidx.annotation.Nullable;
import java.lang.reflect.Constructor;
import java.util.concurrent.atomic.AtomicBoolean;

/* JADX INFO: loaded from: classes.dex */
public final class t {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final s f3466a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final AtomicBoolean f3467b = new AtomicBoolean(false);

    @Nullable
    @GuardedBy("extensionLoaded")
    private Constructor<? extends y> extractorConstructor;

    public t(androidx.core.view.n nVar) {
        this.f3466a = nVar;
    }

    @Nullable
    private Constructor<? extends y> maybeLoadExtractorConstructor() {
        synchronized (this.f3467b) {
            if (this.f3467b.get()) {
                return this.extractorConstructor;
            }
            try {
                return ((androidx.core.view.n) this.f3466a).getConstructor();
            } catch (ClassNotFoundException unused) {
                this.f3467b.set(true);
                return this.extractorConstructor;
            } catch (Exception e10) {
                throw new RuntimeException("Error instantiating extension", e10);
            }
        }
    }

    @Nullable
    public y getExtractor(Object... objArr) {
        Constructor<? extends y> constructorMaybeLoadExtractorConstructor = maybeLoadExtractorConstructor();
        if (constructorMaybeLoadExtractorConstructor == null) {
            return null;
        }
        try {
            return constructorMaybeLoadExtractorConstructor.newInstance(objArr);
        } catch (Exception e10) {
            throw new IllegalStateException("Unexpected error creating extractor", e10);
        }
    }
}
