changeset in /hg/pulseaudio: 2008-08-19 Omair Majid <omajid at redh...

Omair Majid omajid at redhat.com
Wed Aug 27 09:05:26 PDT 2008


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

	* .hgignore: Ignore *.orig files too now.

	* src/java/org/classpath/icedtea/pulseaudio/StreamBufferAttributes.java: New
	class. Forgot to add this last time.
	* src/java/org/classpath/icedtea/pulseaudio/StreamSampleSpecification.java:
	Liksewise.

	* src/native/Makefile.am: Removed obsolete compilation of TargetDataLine.c
	* src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.c:
	Removed obsolete file

diffstat:

5 files changed, 78 insertions(+), 239 deletions(-)
.hgignore                                                                |    1 
src/java/org/classpath/icedtea/pulseaudio/StreamBufferAttributes.java    |   43 +
src/java/org/classpath/icedtea/pulseaudio/StreamSampleSpecification.java |   34 +
src/native/Makefile.am                                                   |    2 
src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.c   |  237 ----------

diffs (350 lines):

diff -r 0ab3515d5074 -r 675a5044aecb .hgignore
--- a/.hgignore	Tue Aug 19 17:04:11 2008 -0400
+++ b/.hgignore	Tue Aug 19 17:29:25 2008 -0400
@@ -6,6 +6,7 @@ syntax: glob
 *~
 org_classpath_icedtea_*.h
 *.log
+*.orig
 bin/*
 lib/*
 Makefile
diff -r 0ab3515d5074 -r 675a5044aecb src/java/org/classpath/icedtea/pulseaudio/StreamBufferAttributes.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/org/classpath/icedtea/pulseaudio/StreamBufferAttributes.java	Tue Aug 19 17:29:25 2008 -0400
@@ -0,0 +1,43 @@
+package org.classpath.icedtea.pulseaudio;
+
+public class StreamBufferAttributes {
+
+	public static final int SANE_DEFAULT = -1;
+
+	private int maxLength;
+	private int targetLength;
+	private int preBuffering;
+	private int minimumRequest;
+	private int fragmentSize;
+
+	public StreamBufferAttributes(int maxLength, int targetLength,
+			int preBuffering, int minimumRequest, int fragmentSize) {
+		this.maxLength = maxLength;
+		this.targetLength = targetLength;
+		this.preBuffering = preBuffering;
+		this.minimumRequest = minimumRequest;
+		this.fragmentSize = fragmentSize;
+	}
+
+	public int getMaxLength() {
+		return maxLength;
+	}
+
+	public int getTargetLength() {
+		return targetLength;
+	}
+
+	public int getPreBuffering() {
+		return preBuffering;
+	}
+
+	public int getMinimumRequest() {
+		return minimumRequest;
+	}
+
+	public int getFragmentSize() {
+		return fragmentSize;
+	}
+
+}
+
diff -r 0ab3515d5074 -r 675a5044aecb src/java/org/classpath/icedtea/pulseaudio/StreamSampleSpecification.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/org/classpath/icedtea/pulseaudio/StreamSampleSpecification.java	Tue Aug 19 17:29:25 2008 -0400
@@ -0,0 +1,34 @@
+package org.classpath.icedtea.pulseaudio;
+
+import org.classpath.icedtea.pulseaudio.Stream.Format;
+
+
+public class StreamSampleSpecification {
+	private Format format;
+	private int rate;
+	private int channels;
+
+	public StreamSampleSpecification(Format format, int rate, int channels) {
+		this.format = format;
+		this.rate = rate;
+		this.channels = channels;
+	}
+	
+	public StreamSampleSpecification(String format, int rate, int channels) {
+		this.format = Format.valueOf(format);
+		this.rate = rate;
+		this.channels = channels;
+	}
+
+	public Format getFormat() {
+		return format;
+	}
+
+	public int getRate() {
+		return rate;
+	}
+
+	public int getChannels() {
+		return channels;
+	}
+}
\ No newline at end of file
diff -r 0ab3515d5074 -r 675a5044aecb src/native/Makefile.am
--- a/src/native/Makefile.am	Tue Aug 19 17:04:11 2008 -0400
+++ b/src/native/Makefile.am	Tue Aug 19 17:29:25 2008 -0400
@@ -5,8 +5,6 @@ libpulse_java_la_SOURCES = \
 	jni-common.h \
 	org_classpath_icedtea_pulseaudio_EventLoop.c \
 	org_classpath_icedtea_pulseaudio_EventLoop.h \
-	org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.c \
-	org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.h \
 	org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.c \
 	org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.h \
 	org_classpath_icedtea_pulseaudio_Operation.h \
diff -r 0ab3515d5074 -r 675a5044aecb src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.c
--- a/src/native/org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.c	Tue Aug 19 17:04:11 2008 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,237 +0,0 @@
-/* org_org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.c
-   Copyright (C) 2008 Red Hat, Inc.
-
-This file is part of IcedTea.
-
-IcedTea is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 2.
-
-IcedTea is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with IcedTea; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version.
-*/
-
-
-
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <jni.h>
-#include <pulse/pulseaudio.h>
-#include <string.h>
-
-#include "org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine.h"
-#include "jni-common.h"
-
-/* defined in EventLoop.c */
-extern JNIEnv* pulse_thread_env;
-
-/*static void stream_read_cb(pa_stream* stream, size_t length, void* userdata) {
-	pa_threaded_mainloop *mainloop = userdata;
-	pa_threaded_mainloop_signal(mainloop, 0);
-}
-
-static void stream_operation_complete_cb(pa_stream* stream, int success,
-		void* userdata) {
-	pa_threaded_mainloop *mainloop = userdata;
-	pa_threaded_mainloop_signal(mainloop, 0);
-}*/
-
-static void stream_state_change_callback(pa_stream* stream, void* userdata) {
-	assert(stream);
-	assert(userdata);
-
-	//	printf("entering stream_state_change_callback\n");
-
-	java_context_t* java_context = (java_context_t*)userdata;
-	JNIEnv* env;
-
-	/* needed so we can create a stream from another thread
-	 */
-	if (pa_stream_get_state(stream) == PA_STREAM_CREATING) {
-		env = java_context->env;
-	} else {
-		env = pulse_thread_env;
-	}
-
-	jobject obj = java_context->obj;
-
-	// printf("stream state changed to %d\n", pa_stream_get_state(stream));
-
-	/* Call the '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;
-	}
-	jmethodID mid = (*env)->GetMethodID(env, cls, "update", "(I)V");
-	if (mid == NULL) {
-		printf("unable to get callback method\n");
-		return;
-
-	}
-	//printf("calling update on java\n");
-	(*env)->CallVoidMethod(env, obj, mid, pa_stream_get_state(stream));
-
-	//printf("returning form stream_state_change_callback\n");
-	return;
-
-}
-
-/*
- * Class:     org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine
- * Method:    native_open
- * Signature: (JLjava/lang/String;Ljava/lang/String;III)V
- */
-JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine_native_1open
-(JNIEnv* env, jobject obj, jlong contextPointer, jstring name, jstring encodingString, jint sampleRate, jint channels, jint bufferSize) {
-
-	//TODO: Need to deal with the buffer size. Currently ignored
-
-	//	printf("entering native_open\n");
-	java_context_t* java_context = malloc(sizeof(java_context));
-	java_context->env = env;
-	java_context->obj = (*env)->NewGlobalRef(env, obj);
-
-	pa_context* context = (pa_context*) convertJavaLongToPointer(contextPointer);
-	assert(context != NULL);
-
-	pa_sample_spec sample_spec;
-
-	const char *encoding = (*env)->GetStringUTFChars(env, encodingString, NULL);
-
-	if (strcmp(encoding, "PA_SAMPLE_U8") == 0) {
-		sample_spec.format = PA_SAMPLE_U8;
-	} else if (strcmp(encoding, "PA_SAMPLE_ALAW") == 0) {
-		sample_spec.format = PA_SAMPLE_ALAW;
-	} else if (strcmp(encoding, "PA_SAMPLE_ULAW;") == 0) {
-		sample_spec.format = PA_SAMPLE_ULAW;
-	} else if (strcmp(encoding, "PA_SAMPLE_S16BE") == 0) {
-		sample_spec.format = PA_SAMPLE_S16BE;
-	} else if (strcmp(encoding, "PA_SAMPLE_S16LE") == 0) {
-		sample_spec.format = PA_SAMPLE_S16LE;
-	} else if (strcmp(encoding, "PA_SAMPLE_S32BE") == 0) {
-		sample_spec.format = PA_SAMPLE_S32BE;
-	} else if (strcmp(encoding, "PA_SAMPLE_S32LE") == 0) {
-		sample_spec.format = PA_SAMPLE_S32LE;
-	} else {
-		printf("error in open: encoding is : %s\n", encoding);
-		throwByName(env, "java/lang/IllegalArgumentException", "Invalid format");
-		/* clean up */
-		free(java_context);
-		(*env)->DeleteGlobalRef(env, obj);
-		(*env)->ReleaseStringUTFChars(env, encodingString, encoding);
-		return;
-	}
-
-	sample_spec.rate = sampleRate;
-	sample_spec.channels = channels;
-
-	printf("sample_spec.rate = %d\n", sample_spec.rate);
-	printf("sample_spec.channels = %d\n", sample_spec.channels);
-
-	if ( !pa_sample_spec_valid(&sample_spec)) {
-		printf("error: invalid format\n");
-		throwByName(env, "java/lang/IllegalArgumentException", "Invalid format");
-		/* clean up */
-		free(java_context);
-		(*env)->DeleteGlobalRef(env, obj);
-		(*env)->ReleaseStringUTFChars(env, encodingString, encoding);
-		return;
-	}
-
-	(*env)->ReleaseStringUTFChars(env, encodingString, encoding);
-
-	/* obtain the server from the caller */
-	const char* stream_name = NULL;
-	stream_name = (*env)->GetStringUTFChars(env, name, NULL);
-	if (stream_name == NULL) {
-		return; /* OutOfMemoryError */
-	}
-	//	printf("About to create stream: %s\n", stream_name);
-	pa_stream* stream = pa_stream_new(context, stream_name, &sample_spec, NULL);
-	assert(stream != NULL);
-	(*env)->ReleaseStringUTFChars(env, name, stream_name);
-
-	pa_stream_set_state_callback(stream, stream_state_change_callback, java_context);
-
-	//	printf("seeting stream pointer: %d\n", (int)stream);
-	setJavaPointer(env, obj, "streamPointer", stream);
-	//	printf("returning from native_open\n");
-
-}
-
-/*
- * Class:     org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine
- * Method:    native_start
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine_native_1start
-(JNIEnv *env, jobject obj) {
-	pa_stream *stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer");
-	assert(stream);
-	pa_stream_connect_record(stream, NULL, NULL, 0);
-
-}
-
-
-JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine_native_1get_1readable_1size
-(JNIEnv* env, jobject obj) {
-
-
-
-	pa_stream *stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer");
-	assert(stream);
-	int available = pa_stream_readable_size(stream);
-	return available;
-}
-
-JNIEXPORT int JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine_native_1read
-  (JNIEnv *env, jobject obj, jbyteArray array, jint length,  jint offset) {
-	pa_stream *stream = getJavaPointer(env, obj, "streamPointer");
-	const void *read_data = NULL;
-	size_t  read_length = 0;
-	pa_stream_peek(stream, &read_data, &read_length);
-	if (length < read_length) {
-		read_length = length;
-	}
-
-	(*env)->SetByteArrayRegion(env, array, offset, read_length, read_data);
-	pa_stream_drop(stream);
-	return read_length;
-}
-
-JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioTargetDataLine_native_1close
-(JNIEnv* env, jobject obj) {
-	pa_stream* stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer");
-	pa_stream_disconnect(stream);
-
-
-}
-



More information about the distro-pkg-dev mailing list