Monday, 1 October 2018

FileOutputStream max_allowed_dequeued_buffers 3

When I'm trying to use FileOutputStream to write data to a file, I get this error and I do not know what to do with it. Here is the class where the error comes from. Adding the rest of the program to show what calls process would be too long to fit here.

public class WriterProcessor implements AudioProcessor {
    File output;
    TarsosDSPAudioFormat audioFormat;
    FileOutputStream fos;

    /**
     *
     * @param audioFormat which this processor is attached to
     * @param output randomaccessfile of the output file
     */
    public WriterProcessor(TarsosDSPAudioFormat audioFormat,File output){
        this.output=output;
        this.audioFormat=audioFormat;
        deleteFile();
        openFileStream();
    }
    @Override
    public boolean process(AudioEvent audioEvent) {
        writeIntoOutputfile(audioEvent.getByteBuffer());
        return true;
    }

    @Override
    public void processingFinished() {
        try {
            fos.close();
        } catch (IOException ex) {
        }

        try {
            System.out.println("Buffer size: " + audioFormat.getFrameSize());
            byte[] bytes = new byte[audioFormat.getFrameSize()];


            RandomAccessFile raf = new RandomAccessFile(output.getPath(), "wr");
            raf.read(bytes, 0 ,audioFormat.getFrameSize());


        } catch (Exception ex){

        }
    }


    /**
     * Writes data into file
     * @param data
     */
    private void writeIntoOutputfile(byte[] data) {
        try {
            fos.write(data);
        } catch (IOException ioe) {
            Log.w("Audio processor", "failed writing debug data to file");
            throw new RuntimeException(ioe);
        }
    }

    private void openFileStream() {
        fos = null;
        try {
            fos = new FileOutputStream(output, false);
        } catch (FileNotFoundException e) {
            Log.e("AudioRecorder", e.getMessage());
        }
    }

    private void deleteFile(){
        if (output.exists()) {
            output.delete();
        }
    }

}

Method process() calls out the writeIntoOutputFile() and usually this error comes from IOException.

09-28 13:54:24.564 19533-19731/ E/[EGL-ERROR]: void __egl_platform_dequeue_buffer(egl_surface*):1851: failed to dequeue buffer from native window 0x98965808; err = -19, buf = 0x0,max_allowed_dequeued_buffers 3
09-28 13:54:24.569 19533-19731/com.starmenew.com E/CameraDeviceGLThread-1: Received exception on GL render thread: 
    java.lang.IllegalStateException: makeCurrent: EGL error: 0x300d
        at android.hardware.camera2.legacy.SurfaceTextureRenderer.checkEglError(SurfaceTextureRenderer.java:544)
        at android.hardware.camera2.legacy.SurfaceTextureRenderer.makeCurrent(SurfaceTextureRenderer.java:525)
        at android.hardware.camera2.legacy.SurfaceTextureRenderer.drawIntoSurfaces(SurfaceTextureRenderer.java:745)
        at android.hardware.camera2.legacy.GLThreadManager$1.handleMessage(GLThreadManager.java:105)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:203)
        at android.os.HandlerThread.run(HandlerThread.java:61)

Maybe there is a way to free up a dequed buffer or I do not really understand this error.



from FileOutputStream max_allowed_dequeued_buffers 3

No comments:

Post a Comment