Disable framesPerBuffer workaround to test linux32 fix inside portaudio. Return suggested latency to be low latency value comming from sound device. New util class for portaudio. Fix problem in renderer now respect sample size in bits when opening files.

cusax-fix
Damian Minkov 17 years ago
parent e9dcc64abc
commit 830a31af7e

Binary file not shown.

@ -390,20 +390,17 @@ static PaStreamParameters *
PortAudio_fixInputParametersSuggestedLatency(
PaStreamParameters *inputParameters)
{
if (inputParameters && (0 == inputParameters->suggestedLatency))
{
PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo(inputParameters->device);
if (inputParameters && (0 == inputParameters->suggestedLatency))
{
PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo(inputParameters->device);
if (deviceInfo)
if (deviceInfo)
{
// default latency of 100ms seems ok
// to use portaudio on all systems
inputParameters->suggestedLatency
= 0.1; //= deviceInfo->defaultLowInputLatency;
= deviceInfo->defaultLowInputLatency;
}
}
return inputParameters;
}
return inputParameters;
}
static PaStreamParameters *

@ -61,7 +61,7 @@ public class PortAudioAuto
new CaptureDeviceInfo(
PortAudio.PaDeviceInfo_getName(deviceInfo),
new MediaLocator(
PortAudioStream.LOCATOR_PREFIX + deviceIndex),
PortAudioUtils.LOCATOR_PREFIX + deviceIndex),
PortAudioStream.getFormats());
if(maxInputChannels > 0)

@ -111,7 +111,7 @@ public void run()
if (portAudioStream == 0)
{
int deviceIndex =
PortAudioStream.getDeviceIndexFromLocator(
PortAudioUtils.getDeviceIndexFromLocator(
audioNotifier.getDeviceConfiguration().
getAudioNotifyDevice().getLocator());
long devInfo = PortAudio.Pa_GetDeviceInfo(deviceIndex);
@ -129,7 +129,8 @@ public void run()
= PortAudio.PaStreamParameters_new(
deviceIndex,
outChannels,
PortAudio.SAMPLE_FORMAT_INT16);
PortAudioUtils.getPortAudioSampleFormat(
audioStreamFormat.getSampleSizeInBits()));
// check if file samplerate is supported
// if it is use it and not resample
if(!PortAudio.Pa_IsFormatSupported(

@ -30,6 +30,36 @@ public final class PortAudio
*/
public static final long SAMPLE_FORMAT_INT16 = 0x00000008;
/**
* A type used to specify one or more sample formats.
* The format paFloat32.
*/
public static final long SAMPLE_FORMAT_FLOAT32 = 0x00000001;
/**
* A type used to specify one or more sample formats.
* The format paInt32.
*/
public static final long SAMPLE_FORMAT_INT32 = 0x00000002;
/**
* A type used to specify one or more sample formats.
* The format paInt24.
*/
public static final long SAMPLE_FORMAT_INT24 = 0x00000004;
/**
* A type used to specify one or more sample formats.
* The format paInt8.
*/
public static final long SAMPLE_FORMAT_INT8 = 0x00000010;
/**
* A type used to specify one or more sample formats.
* The format paUInt8.
*/
public static final long SAMPLE_FORMAT_UINT8 = 0x00000020;
/**
* Flags used to control the behavior of a stream.
* They are passed as parameters to Pa_OpenStream or Pa_OpenDefaultStream.

@ -24,11 +24,6 @@ public class PortAudioStream
private static final Logger logger =
Logger.getLogger(PortAudioStream.class);
/**
* The locator prefix used when creating or parsing <tt>MediaLocator</tt>s.
*/
public static final String LOCATOR_PREFIX = "portaudio:#";
/**
* The indicator which determines whether
* <tt>PortAudioStream#read(Buffer)</tt> will try to workaround a crash
@ -55,8 +50,8 @@ public class PortAudioStream
{
String osName = System.getProperty("os.name");
USE_FRAMES_PER_BUFFER_WORKAROUND
= (osName != null) && osName.contains("Linux");
USE_FRAMES_PER_BUFFER_WORKAROUND = false;
// = (osName != null) && osName.contains("Linux");
}
private Control[] controls = new Control[0];
@ -75,7 +70,7 @@ public class PortAudioStream
*/
public PortAudioStream(MediaLocator locator)
{
this.deviceIndex = getDeviceIndexFromLocator(locator);
this.deviceIndex = PortAudioUtils.getDeviceIndexFromLocator(locator);
}
/**
@ -272,7 +267,7 @@ public synchronized void read(Buffer buffer)
}
PortAudio.Pa_ReadStream(stream, bytebuff, readAvailableFrames);
buffer.setTimeStamp(System.nanoTime());
buffer.setData(bytebuff);
buffer.setSequenceNumber(seqNo);
@ -289,15 +284,4 @@ public synchronized void read(Buffer buffer)
throw ioe;
}
}
/**
* Extracts the device index from the locator.
* @param locator the locator containing the device index.
* @return the extracted device index.
*/
public static int getDeviceIndexFromLocator(MediaLocator locator)
{
return Integer.parseInt(locator.toExternalForm().replace(
PortAudioStream.LOCATOR_PREFIX, ""));
}
}

@ -0,0 +1,49 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.media.protocol.portaudio;
import javax.media.*;
/**
* Common used util methods concerning PortAudio.
* @author Damian Minkov
*/
public class PortAudioUtils
{
/**
* The locator prefix used when creating or parsing <tt>MediaLocator</tt>s.
*/
public static final String LOCATOR_PREFIX = "portaudio:#";
/**
* Extracts the device index from the locator.
* @param locator the locator containing the device index.
* @return the extracted device index.
*/
public static int getDeviceIndexFromLocator(MediaLocator locator)
{
return Integer.parseInt(locator.toExternalForm().replace(
LOCATOR_PREFIX, ""));
}
/**
* Returns the PortAudio sample format.
* @param sampleSizeInBits the size in bits.
* @return the portaudio sampleformat.
*/
public static long getPortAudioSampleFormat(int sampleSizeInBits)
{
switch(sampleSizeInBits)
{
case 8 : return PortAudio.SAMPLE_FORMAT_INT8;
case 16 : return PortAudio.SAMPLE_FORMAT_INT16;
case 24 : return PortAudio.SAMPLE_FORMAT_INT24;
case 32 : return PortAudio.SAMPLE_FORMAT_INT32;
default : return PortAudio.SAMPLE_FORMAT_INT16;
}
}
}

@ -43,8 +43,6 @@ public class PortAudioRenderer
boolean started = false;
// private final Object bufferSync = new Object();
private static int deviceIndex = -1;
private static int frameSize;
@ -274,7 +272,7 @@ public Object getControl(String controlType)
*/
public static void setDevice(MediaLocator locator)
{
deviceIndex = PortAudioStream.getDeviceIndexFromLocator(locator);
deviceIndex = PortAudioUtils.getDeviceIndexFromLocator(locator);
long device = PortAudio.Pa_GetDeviceInfo(deviceIndex);
int outputChannels = 1;

@ -50,7 +50,7 @@ public class PortAudioAuto
new CaptureDeviceInfo(
PortAudio.PaDeviceInfo_getName(deviceInfo),
new MediaLocator(
PortAudioStream.LOCATOR_PREFIX + deviceIndex),
PortAudioUtils.LOCATOR_PREFIX + deviceIndex),
PortAudioStream.getFormats());
if(maxInputChannels > 0)

Loading…
Cancel
Save