You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
implement AudioTrack.pause()
This commit is contained in:
@@ -213,6 +213,7 @@ JNIEXPORT void JNICALL Java_android_media_AudioTrack_native_1play(JNIEnv *env, j
|
|||||||
|
|
||||||
snd_async_add_pcm_handler(&pcm_callback, pcm_handle, periodic_update_callback, callback_data);
|
snd_async_add_pcm_handler(&pcm_callback, pcm_handle, periodic_update_callback, callback_data);
|
||||||
snd_pcm_start(pcm_handle);
|
snd_pcm_start(pcm_handle);
|
||||||
|
snd_pcm_pause(pcm_handle, FALSE);
|
||||||
/*--↑*/
|
/*--↑*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,3 +242,9 @@ JNIEXPORT jint JNICALL Java_android_media_AudioTrack_native_1write(JNIEnv *env,
|
|||||||
_RELEASE_BYTE_ARRAY_ELEMENTS(audioData, buffer);
|
_RELEASE_BYTE_ARRAY_ELEMENTS(audioData, buffer);
|
||||||
return frames_written;
|
return frames_written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_android_media_AudioTrack_native_1pause(JNIEnv *env, jobject this)
|
||||||
|
{
|
||||||
|
snd_pcm_t *pcm_handle = _PTR(_GET_LONG_FIELD(this, "pcm_handle"));
|
||||||
|
snd_pcm_pause(pcm_handle, TRUE);
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,6 +37,14 @@ JNIEXPORT jint JNICALL Java_android_media_AudioTrack_getMinBufferSize
|
|||||||
JNIEXPORT void JNICALL Java_android_media_AudioTrack_native_1play
|
JNIEXPORT void JNICALL Java_android_media_AudioTrack_native_1play
|
||||||
(JNIEnv *, jobject);
|
(JNIEnv *, jobject);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: android_media_AudioTrack
|
||||||
|
* Method: native_pause
|
||||||
|
* Signature: ()V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_android_media_AudioTrack_native_1pause
|
||||||
|
(JNIEnv *, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: android_media_AudioTrack
|
* Class: android_media_AudioTrack
|
||||||
* Method: native_write
|
* Method: native_write
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ public class AudioTrack {
|
|||||||
public void pause() {
|
public void pause() {
|
||||||
System.out.println("calling AudioTrack.pause()\n");
|
System.out.println("calling AudioTrack.pause()\n");
|
||||||
playbackState = PLAYSTATE_PAUSED;
|
playbackState = PLAYSTATE_PAUSED;
|
||||||
|
native_pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlaybackHeadPosition() {
|
public int getPlaybackHeadPosition() {
|
||||||
@@ -133,5 +134,6 @@ public class AudioTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public native void native_play();
|
public native void native_play();
|
||||||
|
public native void native_pause();
|
||||||
private native int native_write(byte[] audioData, int offsetInBytes, int sizeInBytes);
|
private native int native_write(byte[] audioData, int offsetInBytes, int sizeInBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user