Is there something wrong in this Kotlin class? It's supposed to take a 3gp file and decode it to raw data (i.e. something like a WAV file).

```
package com.example.alarma.utils.speechrecognizer

import android.media.MediaCodec
import android.media.MediaCodec.BUFFER_FLAG_END_OF_STREAM
import android.media.MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED
import android.media.MediaCodec.INFO_OUTPUT_FORMAT_CHANGED
import android.media.MediaExtractor
import android.media.MediaFormat
import android.media.MediaFormat.KEY_MIME
import java.nio.ByteBuffer


class AudioDecoder(private val callback: AudioCallback) {
    private var extractor: MediaExtractor? = null
    private var codec: MediaCodec? = null
    private var inputBuffers: Array<ByteBuffer>? = null
    private var outputBuffers: Array<ByteBuffer>? = null

    fun decodeAudio(filePath: String) = try {
        extractor = MediaExtractor().apply {
            setDataSource(filePath)
            (0 until trackCount)
                .map { Pair(it, getTrackFormat(it)) }
                .firstOrNull { (_, trackFormat) ->
                    trackFormat.getString(KEY_MIME)?.startsWith("audio/") == true
                }
            ?.let { (trackIndex, trackFormat) ->
                selectTrack(trackIndex)
                codec = MediaCodec.createDecoderByType(trackFormat.getString(KEY_MIME)!!).apply {
                    configure(trackFormat.apply {
                        setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, DECODE_INPUT_SIZE)
                    }, null, null, 0)
                    start()
                    this@AudioDecoder.inputBuffers = inputBuffers
                    this@AudioDecoder.outputBuffers = outputBuffers
                }
                var inputEOS = false
                var outputEOS = false
                while (!outputEOS) {
                    if (!inputEOS) {
                        val inputBufferId = this@AudioDecoder.codec?.dequeueInputBuffer(TIMEOUT_USEC) ?: break
                        val size = readSampleData(this@AudioDecoder.inputBuffers!![inputBufferId], 0)
                        if (size >= 0) {
                            this@AudioDecoder.codec?.queueInputBuffer(inputBufferId, 0, size, sampleTime, 0)
                        } else {
                            this@AudioDecoder.codec?.queueInputBuffer(inputBufferId, 0, 0, 0, BUFFER_FLAG_END_OF_STREAM)
                            inputEOS = true
                        }
                    }
                    val info = MediaCodec.BufferInfo()
                    val outputBufferId = this@AudioDecoder.codec?.dequeueOutputBuffer(info, TIMEOUT_USEC) ?: break
                    when {
                        outputBufferId >= 0 -> {
                            val buffer = this@AudioDecoder.outputBuffers?.get(outputBufferId)
                            val pcmData = ByteArray(info.size)
                            buffer?.get(pcmData)
                            this@AudioDecoder.callback.onAudioDataAvailable(pcmData)
                            this@AudioDecoder.codec?.releaseOutputBuffer(outputBufferId, false)
                            if (info.flags and BUFFER_FLAG_END_OF_STREAM != 0) {
                                outputEOS = true
                            }
                        }
                        outputBufferId == INFO_OUTPUT_BUFFERS_CHANGED -> this@AudioDecoder.outputBuffers = this@AudioDecoder.codec?.outputBuffers
                        outputBufferId == INFO_OUTPUT_FORMAT_CHANGED -> this@AudioDecoder.callback.onFormatChanged(this@AudioDecoder.codec?.outputFormat!!)
                    }
                }
            } ?: throw RuntimeException("No audio track found")
        }
    } catch (e: Exception) {
        callback.onAudioError(e)
    }

    fun release() {
        codec?.apply {
            stop()
            release()
        }
        extractor?.release()

        codec = null
        extractor = null
        inputBuffers = null
        outputBuffers = null
    }

    interface AudioCallback {
        fun onAudioDataAvailable(data: ByteArray)
        fun onAudioError(error: Exception)
        fun onFormatChanged(format: MediaFormat)
    }

    companion object {
        private const val DECODE_INPUT_SIZE = 524288 // 0.5MB
        private const val TIMEOUT_USEC = 10000L
    }
}
```