Opens the PortAudio streams with a valid framesPerBuffer value in order to make it possible to use the pseudo-blocking PortAudio stream interface implemented in r7982.

cusax-fix
Lyubomir Marinov 15 years ago
parent 03aeedfb4e
commit 4c84ef7b79

@ -145,7 +145,8 @@ protected void doConnect()
* override and be sure that there will be no request to close a connection
* if the connection has not been opened yet.
*/
protected synchronized void doDisconnect()
@Override
protected void doDisconnect()
{
try
{

@ -278,7 +278,7 @@ synchronized void setDeviceIndex(int deviceIndex)
inputParameters,
0 /* outputParameters */,
sampleRate,
PortAudio.FRAMES_PER_BUFFER_UNSPECIFIED,
framesPerBuffer,
PortAudio.STREAM_FLAGS_CLIP_OFF
| PortAudio.STREAM_FLAGS_DITHER_OFF,
null /* streamCallback */);

@ -376,6 +376,11 @@ public synchronized void open()
inputFormat.getSampleSizeInBits());
double sampleRate = inputFormat.getSampleRate();
framesPerBuffer
= (int)
((sampleRate * PortAudio.DEFAULT_MILLIS_PER_BUFFER)
/ (channels * 1000));
try
{
outputParameters
@ -390,7 +395,7 @@ public synchronized void open()
0 /* inputParameters */,
outputParameters,
sampleRate,
PortAudio.FRAMES_PER_BUFFER_UNSPECIFIED,
framesPerBuffer,
PortAudio.STREAM_FLAGS_CLIP_OFF
| PortAudio.STREAM_FLAGS_DITHER_OFF,
null /* streamCallback */);
@ -410,10 +415,6 @@ public synchronized void open()
if (stream == 0)
throw new ResourceUnavailableException("Pa_OpenStream");
framesPerBuffer
= (int)
((sampleRate * PortAudio.DEFAULT_MILLIS_PER_BUFFER)
/ (channels * 1000));
bytesPerBuffer
= PortAudio.Pa_GetSampleSize(sampleFormat)
* channels
@ -529,12 +530,9 @@ else if(gainControl.getDB() != 0)
}
}
PortAudio
.Pa_WriteStream(
PortAudio.Pa_WriteStream(
stream,
buffer,
offset,
framesPerBuffer,
buffer, offset, framesPerBuffer,
numberOfWrites);
int bytesWritten = numberOfWrites * bytesPerBuffer;

@ -361,10 +361,7 @@ public MediaDevice getDefaultDevice(MediaType mediaType)
}
if(device == null)
{
device = mediaService.getDefaultDevice(mediaType,
mediaUseCase);
}
device = mediaService.getDefaultDevice(mediaType, mediaUseCase);
if (MediaType.AUDIO.equals(mediaType))
{

Loading…
Cancel
Save