Media Codec dequeueOutputBuffer IllegalStateException
<p>I try to decode a mp3 audio data stream with Android Media Codec. 
With a sample rate of 44100 the decoding works fine, but the latency is too big. So I set the sample rate to 16000, but now the decoder doesn't work anymore. I get an Illegal State Exception at dequeueOutputBuffer. </p>

<p>This is the part of the code where the problem might be:</p>

<pre><code>                        bufferInfo = new MediaCodec.BufferInfo();
                        outputBufferIndex = decoder.dequeueOutputBuffer(bufferInfo, -1);


                        while (outputBufferIndex &gt;= 0) {



                            outputBuffer = decoder.getOutputBuffer(outputBufferIndex);

                            outputBuffer.position(bufferInfo.offset);
                            outputBuffer.limit(bufferInfo.offset + bufferInfo.size);

                            outData = new byte[bufferInfo.size];
                            outputBuffer.get(outData);

                            track.write(outData, 0, outData.length);

                            decoder.releaseOutputBuffer(outputBufferIndex, false);
                            outputBufferIndex = decoder.dequeueOutputBuffer(bufferInfo, -1);


                        }
</code></pre>

<p>I also tried to set the timeout of dequeueOutputBuffer to 0 but this doesn't change anything.</p>

<p>This is the error I receive: </p>

<pre><code>E/SoftMP3: mp3 decoder returned error 1
E/ACodec: [OMX.google.mp3.decoder] ERROR(0x80001001)
E/ACodec: signalError(omxError 0x80001001, internalError -2147483648)
E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 6
E/AndroidRuntime: FATAL EXCEPTION: Thread-79054
    Process: com.example.jonas.audio_client, PID: 26394
    java.lang.IllegalStateException
       at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
       at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:1107) 
</code></pre>

<p>If I print the Audio Format that the Extractor gets, I see that the Sample-Rate is set to 16000.</p>

<pre><code>D/Format:: {bitrate=32000, mime=audio/mpeg, durationUs=6509000, channel-count=1, sample-rate=16000, bit-rate=32000}
</code></pre>

<p>Thanks for any help!</p>