SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia.portaudio.streams
Class OutputPortAudioStream

java.lang.Object
  extended by net.java.sip.communicator.impl.neomedia.portaudio.streams.OutputPortAudioStream

public class OutputPortAudioStream
extends Object

The output stream that opens and writes to the PortAudio stream.

Author:
Damian Minkov, Lubomir Marinov

Constructor Summary
OutputPortAudioStream(int deviceIndex, double sampleRate, int channels)
          Creates output stream.
OutputPortAudioStream(int deviceIndex, double sampleRate, int channels, long sampleFormat)
          Creates output stream.
 
Method Summary
 void close()
          Closes this OutputPortAudioStream and prepares it to be garbage collected.
(package private)  Object getCloseSyncObject()
          Return the object we have used to synchronize Pa_CloseStream.
 int getDeviceIndex()
          The index of the device that we use.
 long getStream()
          The pointer of the PortAudio stream.
 void start()
          Starts the stream operation
 void stop()
          Stops the stream operation.
 void write(byte[] buffer, int offset, int length)
          Writes a specific byte buffer of audio samples into the native PortAudio stream represented by this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputPortAudioStream

public OutputPortAudioStream(int deviceIndex,
                             double sampleRate,
                             int channels)
                      throws PortAudioException
Creates output stream.

Parameters:
deviceIndex - the index of the device to use.
sampleRate - the sample rate.
channels - the channels to serve.
Throws:
PortAudioException - if stream fails to open.

OutputPortAudioStream

public OutputPortAudioStream(int deviceIndex,
                             double sampleRate,
                             int channels,
                             long sampleFormat)
                      throws PortAudioException
Creates output stream.

Parameters:
deviceIndex - the index of the device to use.
sampleRate - the sample rate.
channels - the channels to serve.
sampleFormat - the sample format to use.
Throws:
PortAudioException - if stream fails to open.
Method Detail

close

public void close()
           throws PortAudioException
Closes this OutputPortAudioStream and prepares it to be garbage collected.

Throws:
PortAudioException - if anything wrong happens while closing this OutputPortAudioStream

write

public void write(byte[] buffer,
                  int offset,
                  int length)
           throws PortAudioException
Writes a specific byte buffer of audio samples into the native PortAudio stream represented by this instance.

Splits the specified buffer and performs multiple writes with PortAudioManager.getFramesPerBuffer() number of frames at a time. If any bytes from the specified buffer remain unwritten, they are retained for the next write to be prepended to its buffer.

Parameters:
buffer - the byte buffer to the written into the native PortAudio stream represented by this instance
offset - the offset in buffer at which the audio samples to be written begin
length - the length of the audio samples in buffer to be written
Throws:
PortAudioException - if anything goes wrong while writing

start

public void start()
           throws PortAudioException
Starts the stream operation

Throws:
PortAudioException

stop

public void stop()
          throws PortAudioException
Stops the stream operation.

Throws:
PortAudioException

getDeviceIndex

public int getDeviceIndex()
The index of the device that we use.

Returns:
the deviceIndex

getStream

public long getStream()
The pointer of the PortAudio stream.

Returns:
the stream pointer.

getCloseSyncObject

Object getCloseSyncObject()
Return the object we have used to synchronize Pa_CloseStream.

Returns:
the closeSyncObject the sync object.

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.