Exemple #1
0
func initAL() {
	err := mobileinit.RunOnJVM(func(vm, env, ctx uintptr) error {
		C.al_init(C.uintptr_t(vm), C.uintptr_t(env), C.jobject(ctx), &alHandle)
		if alHandle == nil {
			return errors.New("al: cannot load libopenal.so")
		}
		return nil
	})
	if err != nil {
		log.Fatalf("al: %v", err)
	}

	alEnableFunc = C.LPALENABLE(fn("alEnable"))
	alDisableFunc = C.LPALDISABLE(fn("alDisable"))
	alIsEnabledFunc = C.LPALISENABLED(fn("alIsEnabled"))
	alGetIntegerFunc = C.LPALGETINTEGER(fn("alGetInteger"))
	alGetIntegervFunc = C.LPALGETINTEGERV(fn("alGetIntegerv"))
	alGetFloatFunc = C.LPALGETFLOAT(fn("alGetFloat"))
	alGetFloatvFunc = C.LPALGETFLOATV(fn("alGetFloatv"))
	alGetBooleanFunc = C.LPALGETBOOLEAN(fn("alGetBoolean"))
	alGetBooleanvFunc = C.LPALGETBOOLEANV(fn("alGetBooleanv"))
	alGetStringFunc = C.LPALGETSTRING(fn("alGetString"))
	alDistanceModelFunc = C.LPALDISTANCEMODEL(fn("alDistanceModel"))
	alDopplerFactorFunc = C.LPALDOPPLERFACTOR(fn("alDopplerFactor"))
	alDopplerVelocityFunc = C.LPALDOPPLERVELOCITY(fn("alDopplerVelocity"))
	alSpeedOfSoundFunc = C.LPALSPEEDOFSOUND(fn("alSpeedOfSound"))
	alGetErrorFunc = C.LPALGETERROR(fn("alGetError"))
	alGenSourcesFunc = C.LPALGENSOURCES(fn("alGenSources"))
	alSourcePlayvFunc = C.LPALSOURCEPLAYV(fn("alSourcePlayv"))
	alSourcePausevFunc = C.LPALSOURCEPAUSEV(fn("alSourcePausev"))
	alSourceStopvFunc = C.LPALSOURCESTOPV(fn("alSourceStopv"))
	alSourceRewindvFunc = C.LPALSOURCEREWINDV(fn("alSourceRewindv"))
	alDeleteSourcesFunc = C.LPALDELETESOURCES(fn("alDeleteSources"))
	alGetSourceiFunc = C.LPALGETSOURCEI(fn("alGetSourcei"))
	alGetSourcefFunc = C.LPALGETSOURCEF(fn("alGetSourcef"))
	alGetSourcefvFunc = C.LPALGETSOURCEFV(fn("alGetSourcefv"))
	alSourceiFunc = C.LPALSOURCEI(fn("alSourcei"))
	alSourcefFunc = C.LPALSOURCEF(fn("alSourcef"))
	alSourcefvFunc = C.LPALSOURCEFV(fn("alSourcefv"))
	alSourceQueueBuffersFunc = C.LPALSOURCEQUEUEBUFFERS(fn("alSourceQueueBuffers"))
	alSourceUnqueueBuffersFunc = C.LPALSOURCEUNQUEUEBUFFERS(fn("alSourceUnqueueBuffers"))
	alGetListenerfFunc = C.LPALGETLISTENERF(fn("alGetListenerf"))
	alGetListenerfvFunc = C.LPALGETLISTENERFV(fn("alGetListenerfv"))
	alListenerfFunc = C.LPALLISTENERF(fn("alListenerf"))
	alListenerfvFunc = C.LPALLISTENERFV(fn("alListenerfv"))
	alGenBuffersFunc = C.LPALGENBUFFERS(fn("alGenBuffers"))
	alDeleteBuffersFunc = C.LPALDELETEBUFFERS(fn("alDeleteBuffers"))
	alGetBufferiFunc = C.LPALGETBUFFERI(fn("alGetBufferi"))
	alBufferDataFunc = C.LPALBUFFERDATA(fn("alBufferData"))
	alIsBufferFunc = C.LPALISBUFFER(fn("alIsBuffer"))

	alcGetErrorFunc = C.LPALCGETERROR(fn("alcGetError"))
	alcOpenDeviceFunc = C.LPALCOPENDEVICE(fn("alcOpenDevice"))
	alcCloseDeviceFunc = C.LPALCCLOSEDEVICE(fn("alcCloseDevice"))
	alcCreateContextFunc = C.LPALCCREATECONTEXT(fn("alcCreateContext"))
	alcMakeContextCurrentFunc = C.LPALCMAKECONTEXTCURRENT(fn("alcMakeContextCurrent"))
	alcDestroyContextFunc = C.LPALCDESTROYCONTEXT(fn("alcDestroyContext"))
}
Exemple #2
0
func initAL() {
	ctx := app.Context{}
	switch C.al_init(ctx.JavaVM(), ctx.AndroidContext(), &alHandle) {
	case C.AL_INIT_RESULT_OK:
		// No-op.
	case C.AL_INIT_RESULT_CANNOT_ATTACH_JVM:
		log.Fatal("al: cannot attach JVM")
	case C.AL_INIT_RESULT_BAD_JNI_VERSION:
		log.Fatal("al: bad JNI version")
	case C.AL_INIT_RESULT_CANNOT_LOAD_SO:
		log.Fatal("al: cannot load libopenal.so")
	default:
		log.Fatal("al: cannot initialize OpenAL library")
	}

	alEnableFunc = C.LPALENABLE(fn("alEnable"))
	alDisableFunc = C.LPALDISABLE(fn("alDisable"))
	alIsEnabledFunc = C.LPALISENABLED(fn("alIsEnabled"))
	alGetIntegerFunc = C.LPALGETINTEGER(fn("alGetInteger"))
	alGetFloatFunc = C.LPALGETFLOAT(fn("alGetFloat"))
	alGetStringFunc = C.LPALGETSTRING(fn("alGetString"))
	alDistanceModelFunc = C.LPALDISTANCEMODEL(fn("alDistanceModel"))
	alDopplerFactorFunc = C.LPALDOPPLERFACTOR(fn("alDopplerFactor"))
	alDopplerVelocityFunc = C.LPALDOPPLERVELOCITY(fn("alDopplerVelocity"))
	alSpeedOfSoundFunc = C.LPALSPEEDOFSOUND(fn("alSpeedOfSound"))
	alGetErrorFunc = C.LPALGETERROR(fn("alGetError"))
	alGenSourcesFunc = C.LPALGENSOURCES(fn("alGenSources"))
	alSourcePlayvFunc = C.LPALSOURCEPLAYV(fn("alSourcePlayv"))
	alSourcePausevFunc = C.LPALSOURCEPAUSEV(fn("alSourcePausev"))
	alSourceStopvFunc = C.LPALSOURCESTOPV(fn("alSourceStopv"))
	alSourceRewindvFunc = C.LPALSOURCEREWINDV(fn("alSourceRewindv"))
	alDeleteSourcesFunc = C.LPALDELETESOURCES(fn("alDeleteSources"))
	alGetSourceiFunc = C.LPALGETSOURCEI(fn("alGetSourcei"))
	alGetSourcefFunc = C.LPALGETSOURCEF(fn("alGetSourcef"))
	alGetSourcefvFunc = C.LPALGETSOURCEFV(fn("alGetSourcefv"))
	alSourceiFunc = C.LPALSOURCEI(fn("alSourcei"))
	alSourcefFunc = C.LPALSOURCEF(fn("alSourcef"))
	alSourcefvFunc = C.LPALSOURCEFV(fn("alSourcefv"))
	alSourceQueueBuffersFunc = C.LPALSOURCEQUEUEBUFFERS(fn("alSourceQueueBuffers"))
	alSourceUnqueueBuffersFunc = C.LPALSOURCEUNQUEUEBUFFERS(fn("alSourceUnqueueBuffers"))
	alGetListenerfFunc = C.LPALGETLISTENERF(fn("alGetListenerf"))
	alGetListenerfvFunc = C.LPALGETLISTENERFV(fn("alGetListenerfv"))
	alListenerfFunc = C.LPALLISTENERF(fn("alListenerf"))
	alListenerfvFunc = C.LPALLISTENERFV(fn("alListenerfv"))
	alGenBuffersFunc = C.LPALGENBUFFERS(fn("alGenBuffers"))
	alDeleteBuffersFunc = C.LPALDELETEBUFFERS(fn("alDeleteBuffers"))
	alGetBufferiFunc = C.LPALGETBUFFERI(fn("alGetBufferi"))
	alBufferDataFunc = C.LPALBUFFERDATA(fn("alBufferData"))
	alIsBufferFunc = C.LPALISBUFFER(fn("alIsBuffer"))

	alcGetErrorFunc = C.LPALCGETERROR(fn("alcGetError"))
	alcOpenDeviceFunc = C.LPALCOPENDEVICE(fn("alcOpenDevice"))
	alcCloseDeviceFunc = C.LPALCCLOSEDEVICE(fn("alcCloseDevice"))
	alcCreateContextFunc = C.LPALCCREATECONTEXT(fn("alcCreateContext"))
	alcMakeContextCurrentFunc = C.LPALCMAKECONTEXTCURRENT(fn("alcMakeContextCurrent"))
	alcDestroyContextFunc = C.LPALCDESTROYCONTEXT(fn("alcDestroyContext"))
}