cleanup
This commit is contained in:
parent
23108dcc09
commit
5a1e05db6a
|
@ -78,15 +78,20 @@ BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
|
||||||
* @param path path to try to load dll
|
* @param path path to try to load dll
|
||||||
*/
|
*/
|
||||||
void fmod_create(JNIEnv *env, char* path) {
|
void fmod_create(JNIEnv *env, char* path) {
|
||||||
|
// try to create an instance using the supplied path
|
||||||
fmod_instance = FMOD_CreateInstance(path);
|
fmod_instance = FMOD_CreateInstance(path);
|
||||||
|
|
||||||
|
// if we got one, we need to locate and cache jni stuff used for callbacks
|
||||||
if (fmod_instance != NULL) {
|
if (fmod_instance != NULL) {
|
||||||
|
|
||||||
|
// fmusic specific callbacks
|
||||||
fmusic = env->FindClass("org/lwjgl/fmod3/FMusic");
|
fmusic = env->FindClass("org/lwjgl/fmod3/FMusic");
|
||||||
music_instcallback = env->GetStaticMethodID(fmusic, "music_instcallback", "(JI)V");
|
music_instcallback = env->GetStaticMethodID(fmusic, "music_instcallback", "(JI)V");
|
||||||
music_ordercallback = env->GetStaticMethodID(fmusic, "music_ordercallback", "(JI)V");
|
music_ordercallback = env->GetStaticMethodID(fmusic, "music_ordercallback", "(JI)V");
|
||||||
music_rowcallback = env->GetStaticMethodID(fmusic, "music_rowcallback", "(JI)V");
|
music_rowcallback = env->GetStaticMethodID(fmusic, "music_rowcallback", "(JI)V");
|
||||||
music_zxxcallback = env->GetStaticMethodID(fmusic, "music_zxxcallback", "(JI)V");
|
music_zxxcallback = env->GetStaticMethodID(fmusic, "music_zxxcallback", "(JI)V");
|
||||||
|
|
||||||
|
// fsound specefic callbacks
|
||||||
fsound = env->FindClass("org/lwjgl/fmod3/FSound");
|
fsound = env->FindClass("org/lwjgl/fmod3/FSound");
|
||||||
sound_dspcallback = env->GetStaticMethodID(fsound, "dsp_callback", "(JLjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;I)Ljava/nio/ByteBuffer;");
|
sound_dspcallback = env->GetStaticMethodID(fsound, "dsp_callback", "(JLjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;I)Ljava/nio/ByteBuffer;");
|
||||||
sound_stream_endcallback = env->GetStaticMethodID(fsound, "end_callback", "(J)V");
|
sound_stream_endcallback = env->GetStaticMethodID(fsound, "end_callback", "(J)V");
|
||||||
|
@ -94,7 +99,8 @@ void fmod_create(JNIEnv *env, char* path) {
|
||||||
sound_stream_callback = env->GetStaticMethodID(fsound, "stream_callback", "(JLjava/nio/ByteBuffer;I)V");
|
sound_stream_callback = env->GetStaticMethodID(fsound, "stream_callback", "(JLjava/nio/ByteBuffer;I)V");
|
||||||
sound_metadata_callback = env->GetStaticMethodID(fsound, "meta_callback", "(JLjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V");
|
sound_metadata_callback = env->GetStaticMethodID(fsound, "meta_callback", "(JLjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V");
|
||||||
|
|
||||||
// cache some data
|
// we need the size of the mix buffer, so we start out by caching it and
|
||||||
|
// update it accordingly on changes
|
||||||
switch(fmod_instance->FSOUND_GetMixer()) {
|
switch(fmod_instance->FSOUND_GetMixer()) {
|
||||||
case FSOUND_MIXER_AUTODETECT:
|
case FSOUND_MIXER_AUTODETECT:
|
||||||
case FSOUND_MIXER_BLENDMODE:
|
case FSOUND_MIXER_BLENDMODE:
|
||||||
|
|
|
@ -39,19 +39,23 @@
|
||||||
#include "fmoddyn.h"
|
#include "fmoddyn.h"
|
||||||
#include "fmod_errors.h"
|
#include "fmod_errors.h"
|
||||||
|
|
||||||
|
// Called to create an FMOD instance
|
||||||
void fmod_create(JNIEnv *env, char*);
|
void fmod_create(JNIEnv *env, char*);
|
||||||
|
|
||||||
|
// Called to destroy our FMOD instance
|
||||||
void fmod_destroy();
|
void fmod_destroy();
|
||||||
|
|
||||||
extern void attachMixerThread();
|
// Actual FMOD instance to invoke methods on
|
||||||
extern void attachStreamThread();
|
|
||||||
extern FMOD_INSTANCE * fmod_instance;
|
extern FMOD_INSTANCE * fmod_instance;
|
||||||
|
|
||||||
// Setup for callback. The callbacks don't have access to a JNIEnv pointer, so we have to provide
|
// Setup for callback. The callbacks don't have access to a JNIEnv pointer, so we have to provide
|
||||||
// one. Unfortunately we cannot cache one, since JNIEnv er thread local copies. We can however
|
// one. Unfortunately we cannot cache one, since JNIEnv are thread local copies. We can however
|
||||||
// aquire one, using AttachCurrent<ThreadAsDaemon>. However we need a VM instance for that.
|
// aquire one, using AttachCurrent<ThreadAsDaemon>. However we need a VM instance for that.
|
||||||
// so we supply 1 VM instance for use by threads (in common_tools) (VM instances are shared across threads), and
|
// so we supply 1 VM instance for use by threads (in common_tools) (VM instances are shared across threads), and
|
||||||
// 1 JNIEnv pointer per thread. At this time, 2 threads have been identified - the Stream thread
|
// 1 JNIEnv pointer per thread. At this time, 2 threads have been identified - the Stream thread
|
||||||
// and the mixer thread.
|
// and the Mixer thread.
|
||||||
|
extern void attachMixerThread();
|
||||||
|
extern void attachStreamThread();
|
||||||
extern JNIEnv *mixer_jnienv;
|
extern JNIEnv *mixer_jnienv;
|
||||||
extern JNIEnv *stream_jnienv;
|
extern JNIEnv *stream_jnienv;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue