changeset in /hg/pulseaudio: 2008-09-03 Omair Majid <omajid at redh...

Omair Majid omajid at redhat.com
Wed Sep 3 07:59:35 PDT 2008


changeset b191c8f8cb2d in /hg/pulseaudio
details: http://icedtea.classpath.org/hg/pulseaudio?cmd=changeset;node=b191c8f8cb2d
description:
	2008-09-03 Omair Majid <omajid at redhat.com>

	    * src/java/org/classpath/icedtea/pulseaudio/Eventloop.java
	    (nativeUpdateTargetPortNameList): Changed return type to long.
	    (nativeUpdateSourcePortNameList): Likewise.
	    * src/native/org_classpath_icedtea_pulseaudio_Eventloop.c
	    (sink_list_success_cb): Added asserts to fail nosily on error.
	    (source_list_success_cb): Likewise.
	    (context_change_callback): Likewise.
	    (poll_function): Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateTargetPortNameList):
	    Changed return type to jlong from jint. Added asserts.
	    (Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateSourcePortNameList):
	    Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_EventLoop_native_1shutdown): Set
	    pointer to NULL on cleanup.
	    (Java_org_classpath_icedtea_pulseaudio_EventLoop_native_1set_1sink_1volume):
	    Added asserts.
	    * src/native/org_classpath_icedtea_pulseaudio_Operation.c
	    (Java_org_classpath_icedtea_pulseaudio_Operation_native_1ref): Added
	    asserts.
	    (Java_org_classpath_icedtea_pulseaudio_Operation_native_1unref): Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_Operation_native_1get_1state):
	    Likewise.
	    * src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c
	    (source_callback): Added asserts.
	    (get_source_volume_callback): Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_PulseAudioSourcePort_native_1updateVolumeInfo):
	    Added checks for error conditions and asserts.
	    (Java_org_classpath_icedtea_pulseaudio_PulseAudioSourcePort_native_1setVolume):
	    Likewise.
	    * src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c
	    (get_sink_volume_callback): Added asserts.
	    (Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetPort_native_1updateVolumeInfo):
	    Added asserts and checks for errors.
	    (Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetPort_native_1setVolume):
	    Likewise.
	    * src/native/org_classpath_icedtea_pulseaudio_Stream.c
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1read):
	    Added asserts.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1peek):
	    Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1drop):
	    Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1writable_1size):
	    Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1readable_1size):
	    Likewise.
	    (drain_callback): Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1drain):
	    Likewise.
	    (cork_callback): Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1cork):
	    Likewise.
	    (flush_callback): Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1flush):
	    Likewise.
	    (trigger_callback): Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1trigger):
	    Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1set_1name):
	    Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1get_1sample_1spec):
	    Added code for error checking and asserts.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1get_1buffer_1attr):
	    Adde asserts.
	    (set_buffer_attr_callback): Likewise.
	    (update_sample_rate_callback): Likewise.
	    (Java_org_classpath_icedtea_pulseaudio_Stream_native_1setVolume):
	    Likewise.

diffstat:

6 files changed, 193 insertions(+), 60 deletions(-)
src/java/org/classpath/icedtea/pulseaudio/EventLoop.java           |    6 
src/native/org_classpath_icedtea_pulseaudio_EventLoop.c            |   90 ++++++----
src/native/org_classpath_icedtea_pulseaudio_Operation.c            |    3 
src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c |   50 ++++-
src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c |   51 +++++
src/native/org_classpath_icedtea_pulseaudio_Stream.c               |   53 ++++-

diffs (truncated from 606 to 500 lines):

diff -r 52c81c12f7d0 -r b191c8f8cb2d src/java/org/classpath/icedtea/pulseaudio/EventLoop.java
--- a/src/java/org/classpath/icedtea/pulseaudio/EventLoop.java	Tue Sep 02 17:23:01 2008 -0400
+++ b/src/java/org/classpath/icedtea/pulseaudio/EventLoop.java	Wed Sep 03 10:47:27 2008 -0400
@@ -244,9 +244,9 @@ public class EventLoop implements Runnab
 		return mainloopPointer;
 	}
 
-	private native int nativeUpdateTargetPortNameList();
-
-	private native int nativeUpdateSourcePortNameList();
+	private native long nativeUpdateTargetPortNameList();
+
+	private native long nativeUpdateSourcePortNameList();
 
 	protected synchronized List<String> updateTargetPortNameList() {
 		targetPortNameList = new ArrayList<String>();
diff -r 52c81c12f7d0 -r b191c8f8cb2d src/native/org_classpath_icedtea_pulseaudio_EventLoop.c
--- a/src/native/org_classpath_icedtea_pulseaudio_EventLoop.c	Tue Sep 02 17:23:01 2008 -0400
+++ b/src/native/org_classpath_icedtea_pulseaudio_EventLoop.c	Wed Sep 03 10:47:27 2008 -0400
@@ -49,27 +49,43 @@ static java_context_t* java_context = NU
 
 JNIEnv* pulse_thread_env = NULL;
 
-void sink_list_success_cb(pa_context *context, const pa_sink_info *i, int eol, void *userdata) {
-	
+void sink_list_success_cb(pa_context *context, const pa_sink_info *i, int eol,
+		void *userdata) {
+
 	if (eol == 0) {
-		jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env, java_context->obj);
+		jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env,
+				java_context->obj);
+		assert(cls);
 		jstring name = (*pulse_thread_env)->NewStringUTF(pulse_thread_env, i->name);
-		jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, "sink_callback", "(Ljava/lang/String;)V");
-		(*pulse_thread_env)->CallVoidMethod(pulse_thread_env, java_context->obj, mid1, name) ;
-	} else {
+		assert(name);
+		jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls,
+				"sink_callback", "(Ljava/lang/String;)V");
+		assert(mid1);
+		(*pulse_thread_env)->CallVoidMethod(pulse_thread_env,
+				java_context->obj, mid1, name) ;
+	} else {
+		assert(pulse_thread_env);
 		notifyWaitingOperations(pulse_thread_env);
 	}
 
 }
 
-void source_list_success_cb(pa_context *context, const pa_source_info *i, int eol, void *userdata) {
-	
+void source_list_success_cb(pa_context *context, const pa_source_info *i,
+		int eol, void *userdata) {
+
 	if (eol == 0) {
-		jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env, java_context->obj);
+		jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env,
+				java_context->obj);
+		assert(cls);
 		jstring name = (*pulse_thread_env)->NewStringUTF(pulse_thread_env, i->name);
-		jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, "source_callback", "(Ljava/lang/String;)V");
-		(*pulse_thread_env)->CallVoidMethod(pulse_thread_env, java_context->obj, mid1, name) ;
-	} else {
+		assert(name);
+		jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls,
+				"source_callback", "(Ljava/lang/String;)V");
+		assert(mid1);
+		(*pulse_thread_env)->CallVoidMethod(pulse_thread_env,
+				java_context->obj, mid1, name) ;
+	} else {
+		assert(pulse_thread_env);
 		notifyWaitingOperations(pulse_thread_env);
 	}
 
@@ -85,20 +101,13 @@ static void context_change_callback(pa_c
 
 	//	printf("context state changed to %d\n", pa_context_get_state(context));
 
-	/* Call the 'update' method in java
+	/* Call the EventLoop.update method in java
 	 * to handle all java-side events
 	 */
 	jclass cls = (*env)->GetObjectClass(env, obj);
-	if (cls == NULL) {
-		printf("unable to get class of object");
-		return;
-	}
+	assert(cls);
 	jmethodID mid = (*env)->GetMethodID(env, cls, "update", "(I)V");
-	if (mid == NULL) {
-		printf("unable to get callback method\n");
-		return;
-
-	}
+	assert(mid);
 	(*env)->CallVoidMethod(env, obj, mid, pa_context_get_state(context));
 	return;
 
@@ -108,6 +117,7 @@ static int poll_function(struct pollfd *
 		void *userdata) {
 
 	JNIEnv* env = pulse_thread_env;
+	assert(env);
 	jobject lockObject = getLockObject(env);
 
 	(*env)->MonitorExit(env, lockObject);
@@ -213,17 +223,21 @@ JNIEXPORT jint JNICALL Java_org_classpat
 
 }
 
-JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateTargetPortNameList(JNIEnv *env, jobject obj) {
-	pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer");
+JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateTargetPortNameList(JNIEnv *env, jobject obj) {
+	pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer");
+	assert(context);
 	pa_operation *o = pa_context_get_sink_info_list(context, sink_list_success_cb, NULL);
-  	return (jint) o;
- }
- 
- JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateSourcePortNameList(JNIEnv *env, jobject obj) {
-	pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer");
+	assert(o);
+	return convertPointerToJavaLong(o);
+}
+
+JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_EventLoop_nativeUpdateSourcePortNameList(JNIEnv *env, jobject obj) {
+	pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer");
+	assert(context);
 	pa_operation *o = pa_context_get_source_info_list(context, source_list_success_cb, NULL);
-  	return (jint) o;
- }
+	assert(o);
+	return convertPointerToJavaLong(o);
+}
 
 static void context_drain_complete_callback(pa_context* context, void* userdata) {
 	pa_context_disconnect(context);
@@ -257,6 +271,7 @@ JNIEXPORT void JNICALL Java_org_classpat
 	(*env)->DeleteGlobalRef(env, java_context->obj);
 
 	free(java_context);
+	java_context = NULL;
 
 	setJavaPointer(env, obj, "mainloopPointer", NULL);
 	setJavaPointer(env, obj, "contextPointer", NULL);
@@ -272,7 +287,6 @@ static void sink_input_volume_change_com
 	assert(userdata);
 	free(userdata);
 	assert(success);
-	printf("volume change complete\n");
 
 }
 
@@ -280,7 +294,6 @@ static void sink_input_change_volume(pa_
 		const pa_sink_input_info* i, int eol, void* userdata) {
 	assert(c);
 
-	// end of list ?
 	if (eol) {
 		return;
 	}
@@ -317,10 +330,17 @@ static void sink_input_change_volume(pa_
  */
 JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_EventLoop_native_1set_1sink_1volume
 (JNIEnv* env, jobject obj, jlong streamPointer, jint volume) {
+
+	pa_stream* stream = (pa_stream*) convertJavaLongToPointer(streamPointer);
+	assert(stream);
+	pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer");
+	assert(context);
+
 	int* new_volume = malloc(sizeof(int));
 	*new_volume = volume;
-	int stream_id = pa_stream_get_index((pa_stream*) convertJavaLongToPointer(streamPointer));
-	pa_context_get_sink_input_info((pa_context*) getJavaPointer(env, obj,"contextPointer") ,stream_id,sink_input_change_volume, new_volume);
+
+	int stream_id = pa_stream_get_index(stream);
+	pa_context_get_sink_input_info(context, stream_id,sink_input_change_volume, new_volume);
 	return;
 }
 
diff -r 52c81c12f7d0 -r b191c8f8cb2d src/native/org_classpath_icedtea_pulseaudio_Operation.c
--- a/src/native/org_classpath_icedtea_pulseaudio_Operation.c	Tue Sep 02 17:23:01 2008 -0400
+++ b/src/native/org_classpath_icedtea_pulseaudio_Operation.c	Wed Sep 03 10:47:27 2008 -0400
@@ -49,6 +49,7 @@ JNIEXPORT void JNICALL Java_org_classpat
 (JNIEnv* env, jobject obj) {
 
 	pa_operation* operation = (pa_operation*) getJavaPointer(env, obj, "operationPointer");
+	assert(operation);
 	pa_operation_ref(operation);
 
 }
@@ -62,6 +63,7 @@ JNIEXPORT void JNICALL Java_org_classpat
 (JNIEnv* env, jobject obj) {
 
 	pa_operation* operation = (pa_operation*) getJavaPointer(env, obj, "operationPointer");
+	assert(operation);
 	pa_operation_unref(operation);
 
 }
@@ -75,6 +77,7 @@ JNIEXPORT jint JNICALL Java_org_classpat
 (JNIEnv *env, jobject obj) {
 
 	pa_operation* operation = (pa_operation*) getJavaPointer(env, obj, "operationPointer");
+	assert(operation);
 	int state = pa_operation_get_state(operation);
 	return state;
 }
diff -r 52c81c12f7d0 -r b191c8f8cb2d src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c
--- a/src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c	Tue Sep 02 17:23:01 2008 -0400
+++ b/src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.c	Wed Sep 03 10:47:27 2008 -0400
@@ -1,4 +1,3 @@
-
 #include "org_classpath_icedtea_pulseaudio_PulseAudioSourcePort.h"
 #include "jni-common.h"
 #include <pulse/pulseaudio.h>
@@ -12,43 +11,80 @@ extern JNIEnv* pulse_thread_env;
 extern JNIEnv* pulse_thread_env;
 
 void source_callback(pa_context *context, int success, void *userdata) {
+	assert(context);
+	assert(pulse_thread_env);
 	notifyWaitingOperations(pulse_thread_env);
 }
 
-void get_source_volume_callback(pa_context *context, const pa_source_info *i, int eol, void *userdata) {
-	if(eol == 0) {
-		printf("%s\n", i->name); 
+void get_source_volume_callback(pa_context *context, const pa_source_info *i,
+		int eol, void *userdata) {
+	assert(context);
+	assert(pulse_thread_env);
+	
+	if (eol == 0) {
+		// printf("%s\n", i->name); 
 		jobject obj = (jobject) userdata;
+		assert(obj);
 		jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env, obj);
-		jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, "update_channels_and_volume", "(IF)V");
-		(*pulse_thread_env)->CallVoidMethod(pulse_thread_env, obj, mid1, (int) (i->volume).channels, (float) (i->volume).values[0]) ;
+		assert(cls);
+		jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls,
+				"update_channels_and_volume", "(IF)V");
+		assert(mid1);
+		(*pulse_thread_env)->CallVoidMethod(pulse_thread_env, obj, mid1,
+				(int) (i->volume).channels, (float) (i->volume).values[0]) ;
 	} else {
 		notifyWaitingOperations(pulse_thread_env);
 	}
 }
-	
+
 JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourcePort_native_1updateVolumeInfo(JNIEnv *env, jobject obj) {
 	jclass cls = (*env)->GetObjectClass(env, obj);
+	assert(cls);
 	jfieldID fid = (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;");
+	assert(fid);
 	jstring jstr = (*env)->GetObjectField(env, obj, fid);
+	assert(jstr);
 	const char *name = (*env)->GetStringUTFChars(env, jstr, NULL);
+	if (name == NULL) {
+		return convertPointerToJavaLong(NULL);	// oome
+	}
+	
 	pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer");
+	assert(context);
 	obj = (*env)->NewGlobalRef(env, obj);
 	pa_operation *o = pa_context_get_source_info_by_name (context, (char*) name, get_source_volume_callback, obj);
+	assert(o);
 	return convertPointerToJavaLong(o);
 }
 
 JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourcePort_native_1setVolume(JNIEnv *env, jobject obj, jfloat value) {
 	jclass cls = (*env)->GetObjectClass(env, obj);
+	assert(cls);
+	
 	jfieldID fid = (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;");
+	assert(fid);
+	
 	jstring jstr = (*env)->GetObjectField(env, obj, fid);
+	assert(jstr);
+	
 	const char *name = (*env)->GetStringUTFChars(env, jstr, NULL);
+	if (name == NULL) {
+		return convertPointerToJavaLong(NULL); 	// oome
+	}
+	
 	pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer");
+	assert(context);
+	
 	obj = (*env)->NewGlobalRef(env, obj);
 	fid = (*env)->GetFieldID(env, cls, "channels", "I");
+	assert(fid);
+	
 	jint channels = (*env)->GetIntField(env, obj, fid);
 	pa_cvolume cv;
+	
 	pa_operation *o = pa_context_set_source_volume_by_name (context, (char*) name,pa_cvolume_set(&cv, channels, value), source_callback, obj);
+	assert(o);
+	
 	return convertPointerToJavaLong(o);
 }
 
diff -r 52c81c12f7d0 -r b191c8f8cb2d src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c
--- a/src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c	Tue Sep 02 17:23:01 2008 -0400
+++ b/src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetPort.c	Wed Sep 03 10:47:27 2008 -0400
@@ -15,41 +15,80 @@ void sink_callback(pa_context *context, 
 	notifyWaitingOperations(pulse_thread_env);
 }
 
-void get_sink_volume_callback(pa_context *context, const pa_sink_info *i, int eol, void *userdata) {
-	if(eol == 0) {
-		printf("%s\n", i->name); 
+void get_sink_volume_callback(pa_context *context, const pa_sink_info *i,
+		int eol, void *userdata) {
+	assert(context);
+	assert(pulse_thread_env);
+
+	if (eol == 0) {
+		// printf("%s\n", i->name); 
 		jobject obj = (jobject) userdata;
+		assert(obj);
 		jclass cls = (*pulse_thread_env)->GetObjectClass(pulse_thread_env, obj);
-		jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls, "update_channels_and_volume", "(IF)V");
-		(*pulse_thread_env)->CallVoidMethod(pulse_thread_env, obj, mid1, (int) (i->volume).channels, (float) (i->volume).values[0]) ;
+		assert(cls);
+		jmethodID mid1 = (*pulse_thread_env)->GetMethodID(pulse_thread_env, cls,
+				"update_channels_and_volume", "(IF)V");
+		assert(mid1);
+		(*pulse_thread_env)->CallVoidMethod(pulse_thread_env, obj, mid1,
+				(int) (i->volume).channels, (float) (i->volume).values[0]) ;
 	} else {
 		notifyWaitingOperations(pulse_thread_env);
 	}
-	
 
 }
 
 JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetPort_native_1updateVolumeInfo(JNIEnv *env, jobject obj) {
 	jclass cls = (*env)->GetObjectClass(env, obj);
+	assert(cls);
+	
 	jfieldID fid = (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;");
+	assert(fid);
+	
 	jstring jstr = (*env)->GetObjectField(env, obj, fid);
+	assert(jstr);
+	
 	const char *name = (*env)->GetStringUTFChars(env, jstr, NULL);
+	if (name == NULL) {
+		return convertPointerToJavaLong(NULL);	// oome
+	}
+	
 	pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer");
+	assert(context);
+	
 	obj = (*env)->NewGlobalRef(env, obj);
+	
 	pa_operation *o = pa_context_get_sink_info_by_name (context, (char*) name, get_sink_volume_callback, obj);
+	assert(o);
+	
 	return convertPointerToJavaLong(o);
 }
 
 JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetPort_native_1setVolume(JNIEnv *env, jobject obj, jfloat value) {
 	jclass cls = (*env)->GetObjectClass(env, obj);
+	assert(cls);
+	
 	jfieldID fid = (*env)->GetFieldID(env, cls, "name", "Ljava/lang/String;");
+	assert(fid);
+	
 	jstring jstr = (*env)->GetObjectField(env, obj, fid);
+	assert(jstr);
+	
 	const char *name = (*env)->GetStringUTFChars(env, jstr, NULL);
+	if (name == NULL) {
+		return convertPointerToJavaLong(NULL);	// return oome
+	}
+	
 	pa_context* context = (pa_context*) getJavaPointer(env, obj, "contextPointer");
+	assert(context);
+	
 	obj = (*env)->NewGlobalRef(env, obj);
 	fid = (*env)->GetFieldID(env, cls, "channels", "I");
+	assert(fid);
+	
 	jint channels = (*env)->GetIntField(env, obj, fid);
 	pa_cvolume cv;
 	pa_operation *o = pa_context_set_sink_volume_by_name (context, (char*) name,pa_cvolume_set(&cv, channels, value), sink_callback, obj);
+	assert(o);
+	
 	return convertPointerToJavaLong(o);
 }
diff -r 52c81c12f7d0 -r b191c8f8cb2d src/native/org_classpath_icedtea_pulseaudio_Stream.c
--- a/src/native/org_classpath_icedtea_pulseaudio_Stream.c	Tue Sep 02 17:23:01 2008 -0400
+++ b/src/native/org_classpath_icedtea_pulseaudio_Stream.c	Wed Sep 03 10:47:27 2008 -0400
@@ -11,12 +11,11 @@ typedef struct java_context {
 
 extern JNIEnv* pulse_thread_env;
 
-static void set_sink_input_volume_callback(pa_context* context, int success,void* userdata) {
+static void set_sink_input_volume_callback(pa_context* context, int success,
+		void* userdata) {
 	notifyWaitingOperations(pulse_thread_env);
 
 }
-
-
 
 const char* getStringFromFormat(pa_sample_format_t format) {
 
@@ -499,6 +498,7 @@ JNIEXPORT jint JNICALL Java_org_classpat
 JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1read
 (JNIEnv *env, jobject obj, jbyteArray array, jint length, jint offset) {
 	pa_stream *stream = getJavaPointer(env, obj, "streamPointer");
+	assert(stream);
 	const void *read_data = NULL;
 	size_t read_length = 0;
 	pa_stream_peek(stream, &read_data, &read_length);
@@ -520,6 +520,7 @@ JNIEXPORT jbyteArray JNICALL Java_org_cl
 (JNIEnv* env, jobject obj) {
 
 	pa_stream* stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer");
+	assert(stream);
 	const void* startLocation;
 	size_t count;
 
@@ -546,6 +547,7 @@ JNIEXPORT jint JNICALL Java_org_classpat
 JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1drop
 (JNIEnv* env, jobject obj) {
 	pa_stream* stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer");
+	assert(stream);
 	return pa_stream_drop(stream);
 }
 
@@ -557,6 +559,7 @@ JNIEXPORT jint JNICALL Java_org_classpat
 JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1writable_1size
 (JNIEnv* env, jobject obj) {
 	pa_stream* stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer");
+	assert(stream);
 	size_t size = pa_stream_writable_size(stream);
 	return size;
 
@@ -570,6 +573,7 @@ JNIEXPORT jint JNICALL Java_org_classpat
 JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1readable_1size
 (JNIEnv* env, jobject obj) {
 	pa_stream* stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer");
+	assert(stream);
 	return pa_stream_readable_size(stream);
 }
 
@@ -577,6 +581,7 @@ static void drain_callback(pa_stream* st
 
 	assert(success);
 	JNIEnv* env = pulse_thread_env;
+	assert(env);
 	notifyWaitingOperations(env);
 
 }
@@ -589,13 +594,16 @@ JNIEXPORT jlong JNICALL Java_org_classpa
 JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1drain
 (JNIEnv* env, jobject obj) {
 	pa_stream* stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer");
+	assert(stream);
 	pa_operation* operation = pa_stream_drain(stream, drain_callback, NULL);
+	assert(operation);
 	return convertPointerToJavaLong(operation);
 }
 
 static void cork_callback(pa_stream* stream, int success, void* userdata) {
 	assert(success);
 	JNIEnv* env = pulse_thread_env;
+	assert(env);
 	notifyWaitingOperations(env);
 
 }
@@ -608,13 +616,16 @@ JNIEXPORT jlong JNICALL Java_org_classpa
 JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1cork
 (JNIEnv* env, jobject obj, jint yes) {
 	pa_stream* stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer");
+	assert(stream);
 	pa_operation* operation = pa_stream_cork(stream, yes, cork_callback, NULL);
+	assert(operation);
 	return convertPointerToJavaLong(operation);
 }
 
 static void flush_callback(pa_stream* stream, int success, void* userdata) {
 	assert(success);
 	JNIEnv* env = pulse_thread_env;
+	assert(env);
 	notifyWaitingOperations(env);
 
 }
@@ -627,13 +638,16 @@ JNIEXPORT jlong JNICALL Java_org_classpa
 JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_Stream_native_1pa_1stream_1flush
 (JNIEnv* env, jobject obj) {
 	pa_stream* stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer");
+	assert(stream);
 	pa_operation* operation = pa_stream_flush(stream, flush_callback, NULL);



More information about the distro-pkg-dev mailing list