Trying to fix linux32 binary, add functions to get device latency. Change in defualt latency when creating inputstream. Add clipOff and ditherOff flags on opening output stream from renderer.

cusax-fix
Damian Minkov 17 years ago
parent 23105e0c4f
commit acfc7db2b6

Binary file not shown.

@ -9,8 +9,8 @@ CPPFLAGS=-DJNI_IMPLEMENTATION \
-Wall -Wreturn-type \
-I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux \
-I$(PORTAUDIO_HOME)/include
LDFLAGS=-shared -fPIC
LIBS=-L$(PORTAUDIO_HOME)/lib/.libs -static -lportaudio
LDFLAGS=-shared
LIBS=-L$(PORTAUDIO_HOME)/lib/.libs -lasound -lm -lpthread -ljack -static -lportaudio
$(TARGET): net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio.c net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio.h
$(CC) $(CPPFLAGS) $< $(LDFLAGS) -o $@ $(LIBS)

@ -292,6 +292,34 @@ Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_PaDeviceI
return ((PaDeviceInfo *) deviceInfo)->hostApi;
}
JNIEXPORT jdouble JNICALL
Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_PaDeviceInfo_1getDefaultLowInputLatency
(JNIEnv *env, jclass clazz, jlong deviceInfo)
{
return ((PaDeviceInfo *) deviceInfo)->defaultLowInputLatency;
}
JNIEXPORT jdouble JNICALL
Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_PaDeviceInfo_1getDefaultLowOutputLatency
(JNIEnv *env, jclass clazz, jlong deviceInfo)
{
return ((PaDeviceInfo *) deviceInfo)->defaultLowOutputLatency;
}
JNIEXPORT jdouble JNICALL
Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_PaDeviceInfo_1getDefaultHighInputLatency
(JNIEnv *env, jclass clazz, jlong deviceInfo)
{
return ((PaDeviceInfo *) deviceInfo)->defaultHighInputLatency;
}
JNIEXPORT jdouble JNICALL
Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_PaDeviceInfo_1getDefaultHighOutputLatency
(JNIEnv *env, jclass clazz, jlong deviceInfo)
{
return ((PaDeviceInfo *) deviceInfo)->defaultHighOutputLatency;
}
JNIEXPORT jlong JNICALL
Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_Pa_1GetHostApiInfo
(JNIEnv *env , jclass clazz, jint hostApiIndex)
@ -352,7 +380,7 @@ Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_PaStreamP
streamParameters->device = deviceIndex;
streamParameters->channelCount = channelCount;
streamParameters->sampleFormat = sampleFormat;
streamParameters->suggestedLatency = 0,4;
streamParameters->suggestedLatency = 0;
streamParameters->hostApiSpecificStreamInfo = NULL;
}
return (jlong) streamParameters;
@ -367,8 +395,13 @@ PortAudio_fixInputParametersSuggestedLatency(
PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo(inputParameters->device);
if (deviceInfo)
inputParameters->suggestedLatency
= deviceInfo->defaultHighInputLatency;
{
// default latency of 100ms seems ok
// to use portaudio on all systems
inputParameters->suggestedLatency
= 0.1; //= deviceInfo->defaultLowInputLatency;
}
}
return inputParameters;
}
@ -383,7 +416,7 @@ PortAudio_fixOutputParametersSuggestedLatency(
if (deviceInfo)
outputParameters->suggestedLatency
= deviceInfo->defaultHighOutputLatency;
= deviceInfo->defaultLowOutputLatency;
}
return outputParameters;
}

@ -167,6 +167,38 @@ JNIEXPORT jdouble JNICALL Java_net_java_sip_communicator_impl_media_protocol_por
JNIEXPORT jint JNICALL Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_PaDeviceInfo_1getHostApi
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio
* Method: PaDeviceInfo_getDefaultLowInputLatency
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_PaDeviceInfo_1getDefaultLowInputLatency
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio
* Method: PaDeviceInfo_getDefaultLowOutputLatency
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_PaDeviceInfo_1getDefaultLowOutputLatency
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio
* Method: PaDeviceInfo_getDefaultHighInputLatency
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_PaDeviceInfo_1getDefaultHighInputLatency
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio
* Method: PaDeviceInfo_getDefaultHighOutputLatency
* Signature: (J)D
*/
JNIEXPORT jdouble JNICALL Java_net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio_PaDeviceInfo_1getDefaultHighOutputLatency
(JNIEnv *, jclass, jlong);
/*
* Class: net_java_sip_communicator_impl_media_protocol_portaudio_PortAudio
* Method: Pa_GetHostApiInfo

@ -36,6 +36,40 @@ public final class PortAudio
*/
public static final long STREAM_FLAGS_NO_FLAG = 0;
/**
* Disable default clipping of out of range samples.
*/
public static final long STREAM_FLAGS_CLIP_OFF = 0x00000001;
/**
* Disable default dithering.
*/
public static final long STREAM_FLAGS_DITHER_OFF = 0x00000002;
/**
* Flag requests that where possible a full duplex stream will not discard
* overflowed input samples without calling the stream callback.
* This flag is only valid for full duplex callback streams and only when
* used in combination with the paFramesPerBufferUnspecified (0)
* framesPerBuffer parameter. Using this flag incorrectly results in a
* paInvalidFlag error being returned from
* Pa_OpenStream and Pa_OpenDefaultStream.
*/
public static final long STREAM_FLAGS_NEVER_DROP_INPUT = 0x00000004;
/**
* Call the stream callback to fill initial output buffers, rather than
* the default behavior of priming the buffers with zeros (silence).
* This flag has no effect for input-only and blocking read/write streams.
*/
public static final long
STREAM_FLAGS_PRIME_OUTPUT_BUFFERS_USING_STREAM_CALLBACK = 0x00000008;
/**
* A mask specifying the platform specific bits.
*/
public static final long STREAM_FLAGS_PLATFORM_SPECIFIC_FLAGS = 0xFFFF0000;
private static boolean initialized;
/**
@ -256,6 +290,34 @@ public static native boolean Pa_IsFormatSupported(
*/
public static native int PaDeviceInfo_getHostApi(long deviceInfo);
/**
* Returns defaultLowInputLatency for the device.
* @param deviceInfo device info pointer.
* @return defaultLowInputLatency for the device.
*/
public static native double PaDeviceInfo_getDefaultLowInputLatency(long deviceInfo);
/**
* Returns defaultLowOutputLatency for the device.
* @param deviceInfo device info pointer.
* @return defaultLowOutputLatency for the device.
*/
public static native double PaDeviceInfo_getDefaultLowOutputLatency(long deviceInfo);
/**
* Returns defaultHighInputLatency for the device.
* @param deviceInfo device info pointer.
* @return defaultHighInputLatency for the device.
*/
public static native double PaDeviceInfo_getDefaultHighInputLatency(long deviceInfo);
/**
* Returns defaultHighOutputLatency for the device.
* @param deviceInfo device info pointer.
* @return defaultHighOutputLatency for the device.
*/
public static native double PaDeviceInfo_getDefaultHighOutputLatency(long deviceInfo);
/**
* Retrieve a pointer to a structure containing information
* about a specific host Api.

@ -160,20 +160,9 @@ public void open()
{
if (stream == 0)
{
long streamParameters
= PortAudio.PaStreamParameters_new(
deviceIndex,
audioFormat.getChannels(),
PortAudio.SAMPLE_FORMAT_INT16);
stream
= PortAudio.Pa_OpenStream(
0,
streamParameters,
audioFormat.getSampleRate(),
PortAudio.FRAMES_PER_BUFFER_UNSPECIFIED,
PortAudio.STREAM_FLAGS_NO_FLAG,
null);
// lets try three times to open the device
// and wait 250 ms. between retries.
stream = openStreamRetring(3, 250);
}
}
catch (PortAudioException e)
@ -182,6 +171,50 @@ public void open()
}
}
/**
* When opening the device notifications maybe running so we will retry
* opening the device.
* @param numOfRetries the number of tries to open the requested device.
* @param interval the interval to wait between retries in miliseconds.
* @return the stream pointer.
* @throws PortAudioException the exception to be thrown if device
* fail to open and after the last try.
*/
private long openStreamRetring(int numOfRetries, int interval)
throws PortAudioException
{
for(int i = 0; i < numOfRetries; i++)
{
try
{
long streamParameters
= PortAudio.PaStreamParameters_new(
deviceIndex,
audioFormat.getChannels(),
PortAudio.SAMPLE_FORMAT_INT16);
return PortAudio.Pa_OpenStream(
0,
streamParameters,
audioFormat.getSampleRate(),
PortAudio.FRAMES_PER_BUFFER_UNSPECIFIED,
PortAudio.STREAM_FLAGS_CLIP_OFF
| PortAudio.STREAM_FLAGS_DITHER_OFF,
null);
}
catch (PortAudioException e)
{
if(i == numOfRetries - 1)
throw e;
else
try
{Thread.sleep(interval);}catch(InterruptedException ex){}
}
}
return 0;
}
/**
* Closes the plug-in.
*/

Loading…
Cancel
Save