Mercurial > hg > pulseaudio
changeset 34:a22db30b1290
added flush() and drain() to SourceDataLine
committer: Ioana Ivan <iivan@redhat.com>
author | Ioana Ivan <iivan@redhat.com> |
---|---|
date | Fri, 01 Aug 2008 12:07:21 -0400 |
parents | 3e7111680ba6 |
children | 127841aeb6e9 |
files | src/org/openjdk/sound/PulseAudioMixer.java src/org/openjdk/sound/PulseAudioSourceDataLine.java src/org_openjdk_sound_PulseAudioSourceDataLine.c src/org_openjdk_sound_PulseAudioSourceDataLine.h |
diffstat | 4 files changed, 58 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/openjdk/sound/PulseAudioMixer.java Fri Aug 01 11:27:40 2008 -0400 +++ b/src/org/openjdk/sound/PulseAudioMixer.java Fri Aug 01 12:07:21 2008 -0400 @@ -363,6 +363,7 @@ line.write(abData, 0, bytesRead); } } + line.flush(); selectedMixer.close();
--- a/src/org/openjdk/sound/PulseAudioSourceDataLine.java Fri Aug 01 11:27:40 2008 -0400 +++ b/src/org/openjdk/sound/PulseAudioSourceDataLine.java Fri Aug 01 12:07:21 2008 -0400 @@ -44,8 +44,10 @@ private native void native_write(byte[] data, int length); private native int native_get_writable_size(); + + private native int native_getOperationState(int operationState); - private native void native_flush(); + private native int native_flush(); private native void native_start(); @@ -53,7 +55,7 @@ private native void native_resume(); - private native void native_drain(); + private native int native_drain(); private native void native_close(); @@ -287,13 +289,34 @@ @Override public void drain() { - // TODO Auto-generated method stub + int operationPointer; + int operationState; + synchronized (eventLoop.threadLock) { + operationPointer = native_drain(); + operationState = native_getOperationState(operationPointer); + } + while(operationState != 1) { + synchronized (eventLoop.threadLock) { + operationState = native_getOperationState(operationPointer); + } + } } @Override public void flush() { - // TODO Auto-generated method stub + int operationPointer; + int operationState; + synchronized (eventLoop.threadLock) { + operationPointer = native_flush(); + operationState = native_getOperationState(operationPointer); + } + while(operationState != 1) { + synchronized (eventLoop.threadLock) { + operationState = native_getOperationState(operationPointer); + } + } + }
--- a/src/org_openjdk_sound_PulseAudioSourceDataLine.c Fri Aug 01 11:27:40 2008 -0400 +++ b/src/org_openjdk_sound_PulseAudioSourceDataLine.c Fri Aug 01 12:07:21 2008 -0400 @@ -172,9 +172,22 @@ * Method: native_flush * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1flush +JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1flush (JNIEnv* env, jobject obj) { + pa_stream *stream = getJavaIntField(env, obj, "streamPointer"); + pa_operation *o = pa_stream_flush(stream, NULL, NULL); + return o; + + +} + +JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1getOperationState(JNIEnv *env, jobject obj, jint operation) { + + + return pa_operation_get_state((pa_operation *) operation); + + } /* @@ -218,9 +231,11 @@ * Method: native_drain * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1drain +JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1drain (JNIEnv* env, jobject obj) { - + pa_stream *stream = getJavaIntField(env, obj, "streamPointer"); + pa_operation *o = pa_stream_drain(stream, NULL, NULL); + return o; } /*
--- a/src/org_openjdk_sound_PulseAudioSourceDataLine.h Fri Aug 01 11:27:40 2008 -0400 +++ b/src/org_openjdk_sound_PulseAudioSourceDataLine.h Fri Aug 01 12:07:21 2008 -0400 @@ -35,10 +35,18 @@ /* * Class: org_openjdk_sound_PulseAudioSourceDataLine + * Method: native_getOperationState + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1getOperationState + (JNIEnv *, jobject, jint); + +/* + * Class: org_openjdk_sound_PulseAudioSourceDataLine * Method: native_flush - * Signature: ()V + * Signature: ()I */ -JNIEXPORT void JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1flush +JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1flush (JNIEnv *, jobject); /* @@ -68,9 +76,9 @@ /* * Class: org_openjdk_sound_PulseAudioSourceDataLine * Method: native_drain - * Signature: ()V + * Signature: ()I */ -JNIEXPORT void JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1drain +JNIEXPORT jint JNICALL Java_org_openjdk_sound_PulseAudioSourceDataLine_native_1drain (JNIEnv *, jobject); /*