Skip to content

Commit

Permalink
Removed libs, obj, more work on JNI interface to libpulse
Browse files Browse the repository at this point in the history
  • Loading branch information
hchapman committed Apr 24, 2012
1 parent 335c966 commit c943883
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 260 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
gen
bin
obj
libs
.classpath
72 changes: 59 additions & 13 deletions jni/pulse.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,89 @@

#include <pulse/pulseaudio.h>

typedef struct jni_cb_info {
JNIEnv *jenv;
jobject jobject;
void *data;
} jni_cb_info ;

static void context_state_cb(pa_context* c, void* userdata) {
dlog(0, "%d", pa_context_get_state(c));
jni_cb_info *data = (jni_cb_info*)userdata;
JNIEnv *jenv = data->jenv;
jobject jobj = data->jobject;
// jclass cls = (*jenv)->GetObjectClass(jenv, jobj);
}

static void sink_info_cb(pa_context* c, const pa_sink_info *i,
int eol, void *userdata) {
dlog(0, "Sup bro", NULL);
dlog(0, i->description);
pa_threaded_mainloop *ma;

ma = userdata;
assert(ma);
//ma = userdata->data;
//assert(ma);

pa_threaded_mainloop_signal(ma, 0);
//pa_threaded_mainloop_signal(ma, 0);
}

JNIEXPORT jlong JNICALL Java_com_harrcharr_reverb_pulse_Mainloop_JNINew(
JNIEXPORT jlong JNICALL
Java_com_harrcharr_reverb_pulse_Mainloop_JNINew(
JNIEnv *jenv, jclass jcls) {
pa_threaded_mainloop *m = pa_threaded_mainloop_new();

return m;
}

JNIEXPORT void JNICALL Java_com_harrcharr_reverb_pulse_Mainloop_JNIStart(
JNIEXPORT void JNICALL
Java_com_harrcharr_reverb_pulse_Mainloop_JNIStart(
JNIEnv *jenv, jclass jcls, jlong ptr_m) {
pa_threaded_mainloop_start((pa_threaded_mainloop*)ptr_m);
}

JNIEXPORT jlong JNICALL Java_com_harrcharr_reverb_pulse_Context_JNICreate(
JNIEnv *jenv, jclass jcls, pa_threaded_mainloop *m) {
pa_context* context_ptr_from_jobject(JNIEnv *env, jobject obj) {
jclass cls = (*env)->GetObjectClass(env, obj);
jfieldID fid;
jlong ptr;
fid = (*env)->GetFieldID(env, cls, "pContext", "J");
if (fid == 0) {
return;
}
ptr = (*env)->GetLongField(env, obj, fid);
return (pa_context*)ptr;
}

void context_ptr_to_jobject(JNIEnv *env, jobject obj, pa_context *c) {
jclass cls = (*env)->GetObjectClass(env, obj);
jfieldID fid;
fid = (*env)->GetFieldID(env, cls, "pContext", "J");
if (fid == 0) {
return;
}
(*env)->SetLongField(env, obj, fid, (long)c);
}

JNIEXPORT void JNICALL
Java_com_harrcharr_reverb_pulse_Context_JNICreate(
JNIEnv *jenv, jobject jobj, pa_threaded_mainloop *m) {
dlog(0, "%d", m);
pa_mainloop_api *api = pa_threaded_mainloop_get_api(m);
pa_context *c = pa_context_new(api, "primary");

dlog(0, "hello from c!");
jni_cb_info userdata = {jenv, jobj, NULL};
pa_context_set_state_callback(c, context_state_cb, &userdata);

dlog(0, "hello from c!");
dlog(0, "%d", c);

return c;
context_ptr_to_jobject(jenv, jobj, c);
}

JNIEXPORT jint JNICALL Java_com_harrcharr_reverb_pulse_Context_JNIConnect(
JNIEnv *jenv, jclass jcls, jlong ptr_context, jstring server) {
JNIEXPORT jint JNICALL
Java_com_harrcharr_reverb_pulse_Context_JNIConnect(
JNIEnv *jenv, jobject jobj,jstring server) {
// pa_threaded_mainloop *m = (pa_threaded_mainloop*)ptr_mainloop;
pa_context *c = (pa_context*)ptr_context;
pa_context *c = context_ptr_from_jobject(jenv, jobj);

dlog(0, "%d", c);

Expand All @@ -70,7 +112,11 @@ JNIEXPORT jint JNICALL Java_com_harrcharr_reverb_pulse_Context_JNIConnect(
dlog(0, pa_context_get_server(c));

while(pa_context_is_pending(c) != 0) {
dlog(0, "%i", pa_context_get_state(c));
// dlog(0, "%i", pa_context_get_state(c));
}

while(pa_context_get_state(c) != PA_CONTEXT_READY) {
// dlog(0, "%i", pa_context_get_state(c));
}

dlog(0, "holy shit");
Expand Down
Binary file removed libs/armeabi/libjson.so
Binary file not shown.
Binary file removed libs/armeabi/libpulse.so
Binary file not shown.
Binary file removed libs/armeabi/libpulse_interface.so
Binary file not shown.
Binary file removed libs/armeabi/libpulsecommon-UNKNOWN.UNKNOWN.so
Binary file not shown.
Binary file removed libs/armeabi/libsndfile.so
Binary file not shown.
Binary file removed obj/local/armeabi/libcrypto.so
Binary file not shown.
Binary file removed obj/local/armeabi/libjson.so
Binary file not shown.
Binary file removed obj/local/armeabi/libpulse.so
Binary file not shown.
Binary file removed obj/local/armeabi/libpulse_interface.so
Binary file not shown.
Binary file removed obj/local/armeabi/libpulsecommon-UNKNOWN.UNKNOWN.so
Binary file not shown.
Binary file removed obj/local/armeabi/librtmp.a
Binary file not shown.
Binary file removed obj/local/armeabi/librtmp_interface.so
Binary file not shown.
Binary file removed obj/local/armeabi/libsndfile.so
Binary file not shown.
Binary file removed obj/local/armeabi/libssl.so
Binary file not shown.
Binary file removed obj/local/armeabi/objs/pulse_interface/pulse.o
Binary file not shown.
242 changes: 0 additions & 242 deletions obj/local/armeabi/objs/pulse_interface/pulse.o.d

This file was deleted.

13 changes: 8 additions & 5 deletions src/com/harrcharr/reverb/pulse/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ public class Context {
long pContext;

public Context(Mainloop m) {
pContext = Context.JNICreate(m.getPointer());
JNICreate(m.getPointer());
}

public void connect(String servername) {
Context.JNIConnect(pContext, servername);
JNIConnect(servername);
}

public long getPointer() {
return pContext;
}

private final static native long JNICreate(long ptr_mainloop);
private final static native long JNIConnect(
long ptr_context, String server);
public void callback() {
System.out.println("ho!");
}

private final native void JNICreate(long ptr_mainloop);
private final native int JNIConnect(String server);
}

0 comments on commit c943883

Please sign in to comment.