android - Merging two audio files takes more time on Nexus -


in project working on audio , call recording functionality. need merge 2 audio files. merging have written following code:

     try {         fileinputstream fistream1 = new fileinputstream(file1); // first         // source  file         fileinputstream fistream2 = new fileinputstream(file2);// second         // source file         sequenceinputstream sistream = new sequenceinputstream(fistream1, fistream2);          file audiodir = new file(environment.getexternalstoragedirectory(), constants.path_to_merged_audio);         if (!audiodir.exists()) {             audiodir.mkdirs();         }         fileoutputstream fostream = new fileoutputstream(audiodir + "/mergedfile.wav");// destinationfile          int temp;          while ((temp = sistream.read()) != -1) {             fostream.write(temp); // write file         }         fostream.close();         sistream.close();         fistream1.close();         fistream2.close();      } catch (exception e) {         e.printstacktrace();      }  } 

now, problem running code on note3 os 4.0.1 , working fine. when run same code on nexus4 os 5.0.1. takes 5-6 minutes, compared note3. search on dint found result. please me doing wrong or need implement api merging 2 audio files.

thanks

i giving answer own question. solved problem. in doubt error might hardware specific. issue way writing file.

           byte[] buf = new byte[1024];            try {              (int readnum; (readnum = sistream.read(buf)) != -1;)                  fostream.write(buf, 0, readnum);              } {              if(sistream!=null){                  sistream.close();              }           } 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -