android - MP3 decoding failed using mediacodec without mediaextractor -


i trying decode mp3 in android using omx.google.mp3.decoder , play using audiotrack gets failed returning i/omxclient( 3506): using client-side omx mux. i/sw ( 3506): codec ==== codec name:omx.google.mp3.decoder i/sw ( 3506): type supported codec:audio/mpeg i/sw ( 3506): encoder:false e/omxnodeinstance( 3506): omx_getextensionindex failed i/swaudioplayer( 3506): decoder ready: true e/softmp3 ( 3506): mp3 decoder returned error 2 e/acodec ( 3506): [omx.google.mp3.decoder] error(0x80001001) e/mediacodec( 3506): codec reported error. (omx error 0x80001001, internalerror -2147483648) e/swaudioplayer( 3506): exception in audio play java.lang.illegalstateexception

here decoder setup code (tried using playbufsize 4kb 64kb no luck in decoding mp3)

    private static mediacodecinfo getcodecinfo(string mimetype) {     string info = "";     int numcodecs = mediacodeclist.getcodeccount();     (int = 0; < numcodecs; i++) {         mediacodecinfo codecinfo = mediacodeclist.getcodecinfoat(i);         string[] types = codecinfo.getsupportedtypes();         (int j = 0; j < types.length; j++) {             if (types[j].equalsignorecase(mimetype)) {                 info += "codec name:" + codecinfo.getname() + "\n";                 info += "type supported codec:" + types[j] + "\n";                 info += "is encoder:" + codecinfo.isencoder() + "\n";                 codeccapabilities codeccapabilities = codecinfo.getcapabilitiesfortype(types[j]);                 log.i("sw","codec ==== "+ info);                 for(final codecprofilelevel codecprofilelevel : codeccapabilities.profilelevels) {                     log.i("sw","codec level "+codecprofilelevel.level);                              log.i("sw","codec profile "+codecprofilelevel.profile);                 }                 return codecinfo;             }         }     }     return null; }  private boolean setdecoder() throws ioexception {     string mimetype = "audio/mpeg";     int rate = 48000;     decoder = mediacodec.createdecoderbytype(mimetype);     mcodecinfo = getcodecinfo(mimetype);     if(mcodecinfo != null) {         mediaformat format = new mediaformat();         format.setstring(mediaformat.key_mime, mimetype);         format.setinteger(mediaformat.key_channel_count, 2);         format.setinteger(mediaformat.key_sample_rate, rate);         format.setinteger(mediaformat.key_bit_rate, 320 * 1024); /* 320 kbps */         format.setinteger(mediaformat.key_max_input_size, playbufsize);          decoder.configure(format, null, null, 0);         return true;     }     return false; }` 

mp3 data received in buffer server (streaming mp3 data android android)

public void play_audio() {     inputbuffers = decoder.getinputbuffers();     outputbuffers = decoder.getoutputbuffers();     inputbufferindex = decoder.dequeueinputbuffer(-1);     try {         if (inputbufferindex >= 0)         {             inputbuffer = inputbuffers[inputbufferindex];             inputbuffer.clear();             inputbuffer.put(playdata);             decoder.queueinputbuffer(inputbufferindex, 0, playdata.length, 0, 0);         }          bufferinfo = new mediacodec.bufferinfo();         outputbufferindex = decoder.dequeueoutputbuffer(bufferinfo, 0);          log.i("swa","outputbufferindex "+outputbufferindex);          while (outputbufferindex >= 0)         {             outputbuffer = outputbuffers[outputbufferindex];              outputbuffer.position(bufferinfo.offset);             outputbuffer.limit(bufferinfo.offset + bufferinfo.size);              log.i("swa","bufferinfo.offset "+bufferinfo.offset);             log.i("swa","bufferinfo.size "+bufferinfo.size);              outdata = new byte[bufferinfo.size];             outputbuffer.get(outdata);              log.i("swa", outdata.length + " bytes decoded");              audiotrack.write(outdata, 0, outdata.length);              decoder.releaseoutputbuffer(outputbufferindex, false);             outputbufferindex = decoder.dequeueoutputbuffer(bufferinfo, 0);         }     }     catch (exception e)     {         log.e("swaudioplayer","exception in audio play "+e);     } } 

i have used buffer size 4kb 64kb (size of received mp3 data received in playdata byte array) still getting mp3 decoder error.getting error @ decoder.queueinputbuffer(inputbufferindex, 0, playdata.length, 0, 0); how resolve it? need skip mp3 header before decoding?

the number 2 in "mp3 decoder returned error 2" seems mean unsupported_free_bitrate. judging referenced softmp3 source code seems mp3 has "free bit rate" and/or reserved frequency, not supported softmp3.

that should rare. i'd find more bad data fed decoder (especially since "free bit rate" happens number 0 in mp3 standard).

i notice dequeinputbuffer() called once. think problem should called every lap; see synchronous processing using buffer arrays.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -