Question

I am writing to a framebuffer located at "/dev/fb0". Everything works fine until I try to write again to the pipe using an OutputStream, which hangs the program. I have resolved this by closing the output stream and then recreating it, but this seems awfully slow and blunt.

Framebuffer.java

public class Framebuffer extends Autobuffer {
private FileOutputStream out = null;
private File pipe = null;

public Framebuffer() {
   super(320, 240);
}

public Framebuffer(File pipe) {
   super(320, 240);
   try {
      out = new FileOutputStream(pipe);
   } catch (FileNotFoundException e) {
   e.printStackTrace();
  }
 this.pipe = pipe;
 }

 public void sync() throws IOException {
   out.write(getBytes());
   out.close();
   out = new FileOutputStream(pipe);
 }
 }

Any ideas?

Thanks.

Was it helpful?

Solution

Firstly, unless something really weird is going on, "/dev/fb0" is a device file not a pipe. [This is a nitpick, but if you use the wrong terminology, 1) people won't understand you and 2) you will have difficulty searching for answers.]

Secondly, this looks like a weird way to interact with a framebuffer!!

I suspect that the problem is that you need to do the equivalent of a POSIX lseek call to set the stream position to zero each time you draw a frame. I've found two ways to do this:

OTHER TIPS

Changing the Output Stream to RandomAccessFile fixed all of my problems. I bet the stream wasn't working because it can't seek to position 0. Thanks to all who replied.

What if you flush your output with flush (from OutputStream)?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top