package androidx.media3.decoder.midi;

import android.content.Context;
import android.os.Handler;
import androidx.annotation.Nullable;
import androidx.media3.common.Format;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.decoder.CryptoConfig;
import androidx.media3.exoplayer.audio.AudioRendererEventListener;
import androidx.media3.exoplayer.audio.AudioSink;
import androidx.media3.exoplayer.audio.DecoderAudioRenderer;

/* JADX INFO: loaded from: classes.dex */
@UnstableApi
public final class MidiRenderer extends DecoderAudioRenderer<MidiDecoder> {
    private final Context context;

    @Deprecated
    public MidiRenderer(Context context) {
        this.context = context.getApplicationContext();
    }

    public String getName() {
        return "MidiRenderer";
    }

    protected int supportsFormatInternal(Format format) {
        if ("audio/x-exoplayer-midi".equals(format.sampleMimeType)) {
            return !sinkSupportsFormat(MidiDecoder.getDecoderOutputFormat()) ? 1 : 4;
        }
        return 0;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public MidiDecoder createDecoder(Format format, @Nullable CryptoConfig cryptoConfig) throws MidiDecoderException {
        return new MidiDecoder(this.context);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public Format getOutputFormat(MidiDecoder midiDecoder) {
        return MidiDecoder.getDecoderOutputFormat();
    }

    public MidiRenderer(Context context, @Nullable Handler handler, @Nullable AudioRendererEventListener audioRendererEventListener, AudioSink audioSink) {
        super(handler, audioRendererEventListener, audioSink);
        this.context = context.getApplicationContext();
    }
}
