Mercurial > hg > pulseaudio
changeset 76:c7d9beb92d3d
2008-08-15 Omair Majid <omajid@redhat.com>
* build.xml: removed javah tasks for SourceDataLine and Clip
* src/native/Makefile.am: removed PulseAudio{Clip,SourceDataLine}.{c,h}
as files to build
* src/native/org_classpath_icedtea_pulseaudio_PulseAudioClip.c: removed
* src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine.c:
removed
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Fri, 15 Aug 2008 10:37:25 -0400 |
parents | a2034200b782 |
children | 2e3dd470d097 |
files | build.xml src/native/Makefile.am src/native/org_classpath_icedtea_pulseaudio_PulseAudioClip.c src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine.c |
diffstat | 4 files changed, 0 insertions(+), 359 deletions(-) [+] |
line wrap: on
line diff
--- a/build.xml Fri Aug 15 10:26:12 2008 -0400 +++ b/build.xml Fri Aug 15 10:37:25 2008 -0400 @@ -37,8 +37,6 @@ <javah classpath="${classdir}" destdir="${headerdir}" verbose="no" force="yes"> <class name="org.classpath.icedtea.pulseaudio.EventLoop"/> <class name="org.classpath.icedtea.pulseaudio.Operation"/> - <class name="org.classpath.icedtea.pulseaudio.PulseAudioSourceDataLine"/> - <class name="org.classpath.icedtea.pulseaudio.PulseAudioClip"/> <class name="org.classpath.icedtea.pulseaudio.Stream"/> <class name="org.classpath.icedtea.pulseaudio.PulseAudioStreamVolumeControl"/> </javah>
--- a/src/native/Makefile.am Fri Aug 15 10:26:12 2008 -0400 +++ b/src/native/Makefile.am Fri Aug 15 10:37:25 2008 -0400 @@ -5,14 +5,10 @@ jni-common.h \ org_classpath_icedtea_pulseaudio_EventLoop.c \ org_classpath_icedtea_pulseaudio_EventLoop.h \ - org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine.c \ - org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine.h \ org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.c \ org_classpath_icedtea_pulseaudio_PulseAudioStreamVolumeControl.h \ org_classpath_icedtea_pulseaudio_Operation.h \ org_classpath_icedtea_pulseaudio_Operation.c \ - org_classpath_icedtea_pulseaudio_PulseAudioClip.c \ - org_classpath_icedtea_pulseaudio_PulseAudioClip.h \ org_classpath_icedtea_pulseaudio_Stream.c \ org_classpath_icedtea_pulseaudio_Stream.h
--- a/src/native/org_classpath_icedtea_pulseaudio_PulseAudioClip.c Fri Aug 15 10:26:12 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* org_classpath_icedtea_pulseaudio_PulseAudioClip.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 "org_classpath_icedtea_pulseaudio_PulseAudioClip.h" - -#include "jni-common.h" - -/* - * Class: org_classpath_icedtea_pulseaudio_PulseAudioClip - * Method: native_open - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioClip_native_1open -(JNIEnv* env, jobject obj) { - -} - -/* - * Class: org_classpath_icedtea_pulseaudio_PulseAudioClip - * Method: native_close - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioClip_native_1close -(JNIEnv* env, jobject obj) { - -} -
--- a/src/native/org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine.c Fri Aug 15 10:26:12 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,292 +0,0 @@ -/* org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine.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 <string.h> -#include <unistd.h> -#include <fcntl.h> -#include <jni.h> -#include <pulse/pulseaudio.h> - -#include "org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine.h" -#include "jni-common.h" - -/* defined in EventLoop.c */ -extern JNIEnv* pulse_thread_env; - -static void stream_drain_complete_callback(pa_stream* stream, int success, - void* userdata) { - assert(stream); - assert(success != 0); - - pa_stream_disconnect(stream); -} - -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_PulseAudioSourceDataLine_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_write - * Signature: ([BII)V - */ -JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine_native_1write -(JNIEnv* env, jobject obj, jbyteArray data, jint offset, jint data_length) { - - pa_stream* stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer"); - jbyte* data_buffer = (*env)->GetByteArrayElements(env, data, NULL); - jbyte* buffer_start = data_buffer + offset; - pa_stream_write(stream, buffer_start, data_length, NULL, 0, PA_SEEK_RELATIVE); - (*env)->ReleaseByteArrayElements(env, data, data_buffer, 0); - -} - -/* - * Class: org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine - * Method: native_get_writable_size - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine_native_1get_1writable_1size -(JNIEnv* env, jobject obj) { - - pa_stream *stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer"); - assert(stream); - int available = pa_stream_writable_size(stream); - return available; -} - -/* - * Class: org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine - * Method: native_flush - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine_native_1flush -(JNIEnv* env, jobject obj) -{ - pa_stream *stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer"); - pa_operation *o = pa_stream_flush(stream, NULL, NULL); - return convertPointerToJavaLong(o); - -} - -/* - * Class: org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine - * Method: native_start - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine_native_1start -(JNIEnv *env, jobject obj) { - pa_stream *stream = (pa_stream*)getJavaPointer(env, obj, "streamPointer"); - assert(stream); - pa_stream_connect_playback(stream, NULL, NULL, 0, NULL, NULL); - -} - -/* - * Class: org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine - * Method: native_pause - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine_native_1pause -(JNIEnv* env, jobject obj) { - -} - -/* - * Class: org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine - * Method: native_resume - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine_native_1resume -(JNIEnv* env, jobject obj) { - -} - -/* - * Class: org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine - * Method: native_drain - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine_native_1drain -(JNIEnv* env, jobject obj) { - pa_stream *stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer"); - assert(stream); - pa_operation *o = pa_stream_drain(stream, NULL, NULL); - return convertPointerToJavaLong(o); -} - -/* - * Class: org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine - * Method: native_close - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_classpath_icedtea_pulseaudio_PulseAudioSourceDataLine_native_1close -(JNIEnv* env, jobject obj) { - - pa_stream* stream = (pa_stream*) getJavaPointer(env, obj, "streamPointer"); - assert(stream); - pa_operation *o = pa_stream_drain(stream, stream_drain_complete_callback, NULL); - if (o == NULL) { - pa_stream_disconnect(stream); - } else { - pa_operation_unref(o); - } - -} -