Reputation: 1396
I have an audio player with uses an PipedOutputStream for buffering the input of the data and a PipedInput for the actual playing. Sometimes the player pauses, but there is still data to buffer. If the buffer is now full, the writing-thread will block indefinitely.
Is there a fast alternative, which supports a timeout on write or another solution?
Upvotes: 0
Views: 1473
Reputation: 46
There is spf4j which contains alternative implementation for PipedInput/OuputStream. I have been experiencing same issue and resolved with it.
The root cause of the problem is that the pipedinputstream checks the liveness of writer (the thread calling write from pipiedoutputstream) in read method everytime. So the writer finishes early, then read would throw exception and finish read loop with unread data remaining
Upvotes: 1