Mercurial > hg > pulseaudio
changeset 39:92e04ec1b947
fixed merge problems
committer: Omair Majid <omajid@redhat.com>
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Fri, 01 Aug 2008 13:02:00 -0400 |
parents | 177bc55c9384 (current diff) 127841aeb6e9 (diff) |
children | 6c22ddefdbfa |
files | src/org/openjdk/sound/PulseAudioMixer.java src/org/openjdk/sound/PulseAudioSourceDataLine.java src/org_openjdk_sound_PulseAudioMixer.h src/org_openjdk_sound_PulseAudioSourceDataLine.c unittests/org/openjdk/sound/PulseSourceDataLineTest.java |
diffstat | 5 files changed, 64 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/openjdk/sound/PulseAudioMixer.java Fri Aug 01 12:58:52 2008 -0400 +++ b/src/org/openjdk/sound/PulseAudioMixer.java Fri Aug 01 13:02:00 2008 -0400 @@ -369,6 +369,7 @@ } System.out.println("about to close"); + line.flush(); selectedMixer.close(); }
--- a/src/org/openjdk/sound/PulseAudioSourceDataLine.java Fri Aug 01 12:58:52 2008 -0400 +++ b/src/org/openjdk/sound/PulseAudioSourceDataLine.java Fri Aug 01 13:02:00 2008 -0400 @@ -44,8 +44,11 @@ private native void native_write(byte[] data, int offset, 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 +56,8 @@ private native void native_resume(); - private native void native_drain(); + + private native int native_drain(); private native void native_close(); @@ -282,15 +286,34 @@ @Override public void drain() { - // TODO: double check this - native_drain(); + 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: double check this - native_flush(); + 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 12:58:52 2008 -0400 +++ b/src/org_openjdk_sound_PulseAudioSourceDataLine.c Fri Aug 01 13:02:00 2008 -0400 @@ -169,9 +169,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); + + } /* @@ -213,9 +226,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 12:58:52 2008 -0400 +++ b/src/org_openjdk_sound_PulseAudioSourceDataLine.h Fri Aug 01 13:02:00 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); /*
--- a/unittests/org/openjdk/sound/PulseSourceDataLineTest.java Fri Aug 01 12:58:52 2008 -0400 +++ b/unittests/org/openjdk/sound/PulseSourceDataLineTest.java Fri Aug 01 13:02:00 2008 -0400 @@ -9,6 +9,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.junit.Assert; public class PulseSourceDataLineTest { @@ -19,6 +20,8 @@ @Before public void setUp() throws Exception { + + } @Test @@ -26,7 +29,7 @@ PulseAudioMixer mixer = PulseAudioMixer.getInstance(); mixer.open(); PulseAudioSourceDataLine line = (PulseAudioSourceDataLine) mixer.getLine(new Line.Info(PulseAudioSourceDataLine.class)); - + Assert.assertNotNull(line); } @After