/hg/icedtea6: PR1050: Stream objects not garbage collected
omajid at icedtea.classpath.org
omajid at icedtea.classpath.org
Thu Jun 28 10:31:35 PDT 2012
changeset f8a29d2a4ca4 in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=f8a29d2a4ca4
author: Omair Majid <omajid at redhat.com>
date: Thu Jun 28 13:27:42 2012 -0400
PR1050: Stream objects not garbage collected
2012-06-28 Omair Majid <omajid at redhat.com>
* NEWS: Update with fix.
* pulseaudio/src/java/org/classpath/icedtea/pulseaudio/Stream.java:
Add new member variable contextPointer.
* pulseaudio/src/native/org_classpath_icedtea_pulseaudio_Stream.c
(Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1new):
Save j_context as contextPointer.
(Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1unref):
Delete the global ref and dellocate the java context.
(cork_callback): Don't check userdata. It is NULL.
(Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1cork):
Dont allocate and pass a java_context to pa_stream_cork. It is not needed.
* pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java
(testOpenCloseLotsOfTimes): New method.
diffstat:
ChangeLog | 17 ++++++++
NEWS | 2 +
pulseaudio/src/java/org/classpath/icedtea/pulseaudio/Stream.java | 3 +
pulseaudio/src/native/org_classpath_icedtea_pulseaudio_Stream.c | 21 +++++----
pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java | 13 ++++++
5 files changed, 47 insertions(+), 9 deletions(-)
diffs (136 lines):
diff -r 7f4c7b5567f3 -r f8a29d2a4ca4 ChangeLog
--- a/ChangeLog Wed Jun 27 16:19:49 2012 -0400
+++ b/ChangeLog Thu Jun 28 13:27:42 2012 -0400
@@ -1,3 +1,20 @@
+2012-06-28 Omair Majid <omajid at redhat.com>
+
+ PR1050: Stream objects not garbage collected
+ * NEWS: Update with fix.
+ * pulseaudio/src/java/org/classpath/icedtea/pulseaudio/Stream.java:
+ Add new member variable contextPointer.
+ * pulseaudio/src/native/org_classpath_icedtea_pulseaudio_Stream.c
+ (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1new):
+ Save j_context as contextPointer.
+ (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1unref):
+ Delete the global ref and dellocate the java context.
+ (cork_callback): Don't check userdata. It is NULL.
+ (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1cork):
+ Dont allocate and pass a java_context to pa_stream_cork. It is not needed.
+ * pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java
+ (testOpenCloseLotsOfTimes): New method.
+
2012-06-26 Omair Majid <omajid at redhat.com>
* test/tapset/jstaptest.pl (get_arch_dir): Fix dir for x86.
diff -r 7f4c7b5567f3 -r f8a29d2a4ca4 NEWS
--- a/NEWS Wed Jun 27 16:19:49 2012 -0400
+++ b/NEWS Thu Jun 28 13:27:42 2012 -0400
@@ -18,6 +18,8 @@
- S6761072: new krb5 tests fail on multiple platforms
- S6883983: JarVerifier dependency on sun.security.pkcs should be removed
- S4465490: Suspicious about double-check locking idiom being used in the code
+* Bug fixes
+ - PR1050: Stream objects not garbage collected
New in release 1.11.3 (2012-06-12):
diff -r 7f4c7b5567f3 -r f8a29d2a4ca4 pulseaudio/src/java/org/classpath/icedtea/pulseaudio/Stream.java
--- a/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/Stream.java Wed Jun 27 16:19:49 2012 -0400
+++ b/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/Stream.java Thu Jun 28 13:27:42 2012 -0400
@@ -160,7 +160,10 @@
public static final String DEFAULT_DEVICE = null;
+ // stores a pointer to pa_stream
private byte[] streamPointer;
+ // stores a pointer to the java_context/this object for callbacks
+ private byte[] contextPointer;
static {
SecurityWrapper.loadNativeLibrary();
diff -r 7f4c7b5567f3 -r f8a29d2a4ca4 pulseaudio/src/native/org_classpath_icedtea_pulseaudio_Stream.c
--- a/pulseaudio/src/native/org_classpath_icedtea_pulseaudio_Stream.c Wed Jun 27 16:19:49 2012 -0400
+++ b/pulseaudio/src/native/org_classpath_icedtea_pulseaudio_Stream.c Thu Jun 28 13:27:42 2012 -0400
@@ -313,6 +313,8 @@
j_context->env = env;
j_context->obj = (*env)->NewGlobalRef(env, obj);
+ setJavaPointer(env, obj, CONTEXT_POINTER, j_context);
+
pa_context* context = convertJavaPointerToNative(env, contextPointer);
assert(context);
@@ -352,7 +354,7 @@
(*env)->ReleaseStringUTFChars(env, nameString,name);
}
- setJavaPointer(env, obj, "streamPointer", stream);
+ setJavaPointer(env, obj, STREAM_POINTER, stream);
/*
*
@@ -380,10 +382,17 @@
*/
JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1unref
(JNIEnv* env, jobject obj) {
+
+ java_context* j_context = getJavaPointer(env, obj, CONTEXT_POINTER);
+ assert(j_context);
+ (*env)->DeleteGlobalRef(env, j_context->obj);
+ free(j_context);
+ setJavaPointer(env, obj, CONTEXT_POINTER, NULL);
+
pa_stream* stream = getJavaPointer(env, obj, STREAM_POINTER);
assert(stream);
pa_stream_unref(stream);
- setJavaPointer(env, obj, "streamPointer", NULL);
+ setJavaPointer(env, obj, STREAM_POINTER, NULL);
}
/*
@@ -696,9 +705,7 @@
static void cork_callback(pa_stream* stream, int success, void* userdata) {
- java_context* context = userdata;
assert(stream);
- assert(context);
JNIEnv* env = pulse_thread_env;
assert(env);
notifyWaitingOperations(env);
@@ -718,11 +725,7 @@
(JNIEnv* env, jobject obj, jint yes) {
pa_stream* stream = (pa_stream*)getJavaPointer(env, obj, STREAM_POINTER);
assert(stream);
- java_context* j_context = malloc(sizeof(java_context));
- assert(j_context);
- j_context->env = env;
- j_context->obj = (*env)->NewGlobalRef(env, obj);
- pa_operation* operation = pa_stream_cork(stream, yes, cork_callback, j_context);
+ pa_operation* operation = pa_stream_cork(stream, yes, cork_callback, NULL);
assert(operation);
return convertNativePointerToJava(env, operation);
}
diff -r 7f4c7b5567f3 -r f8a29d2a4ca4 pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java
--- a/pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java Wed Jun 27 16:19:49 2012 -0400
+++ b/pulseaudio/unittests/org/classpath/icedtea/pulseaudio/PulseAudioClipTest.java Thu Jun 28 13:27:42 2012 -0400
@@ -115,6 +115,19 @@
clip.close();
}
+ @Test
+ public void testOpenCloseLotsOfTimes() throws LineUnavailableException,
+ UnsupportedAudioFileException, IOException {
+ File soundFile = new File("testsounds/startup.wav");
+ AudioInputStream audioInputStream = AudioSystem
+ .getAudioInputStream(soundFile);
+ for (int i = 0; i < 1000; i++) {
+ Clip clip = (Clip) mixer.getLine(new Line.Info(Clip.class));
+ clip.open(audioInputStream);
+ clip.close();
+ }
+ }
+
@Test
public void testLoop4Times() throws LineUnavailableException, IOException,
UnsupportedAudioFileException {
More information about the distro-pkg-dev
mailing list