List of usage examples for org.apache.http.nio.entity ContentOutputStream flush
@Override public void flush() throws IOException
From source file:marytts.server.http.AudioStreamNHttpEntity.java
/** * Wait for the SharedOutputBuffer to become available, write audio data to it. *///from w w w . j a va 2s. c o m public void run() { this.logger = MaryUtils.getLogger(Thread.currentThread().getName()); // We must wait until produceContent() is called: while (out == null) { synchronized (mutex) { try { mutex.wait(); } catch (InterruptedException e) { } } } assert out != null; ContentOutputStream outStream = new ContentOutputStream(out); try { AudioSystem.write(audio, audioType, outStream); outStream.flush(); outStream.close(); logger.info("Finished writing output"); } catch (IOException ioe) { logger.info("Cannot write output, client seems to have disconnected. ", ioe); maryRequest.abort(); } }
From source file:marytts.tools.perceptiontest.AudioStreamNHttpEntity.java
/** * Wait for the SharedOutputBuffer to become available, write audio data to it. *//*from w w w. ja v a 2 s . c om*/ public void run() { this.logger = MaryUtils.getLogger(Thread.currentThread().getName()); // We must wait until produceContent() is called: while (out == null) { synchronized (mutex) { try { mutex.wait(); } catch (InterruptedException e) { } } } assert out != null; ContentOutputStream outStream = new ContentOutputStream(out); try { AudioSystem.write(audio, audioType, outStream); outStream.flush(); outStream.close(); logger.info("Finished writing output"); } catch (IOException ioe) { logger.info("Cannot write output, client seems to have disconnected. ", ioe); System.err.println("Cannot write output, client seems to have disconnected." + ioe); maryRequest.abort(); } }