示例#1
0
//export onInputQueueDestroyed
func onInputQueueDestroyed(act *C.ANativeActivity, queue unsafe.Pointer) {
	defer func() {
		handleCallbackError(act, recover())
	}()
	Debugf("onInputQueueDestroy...\n")

	C.ALooper_wake(looper)

	internalEvent <- inputQueueDestroyedEvent{
		unsafe.Pointer(act),
		queue,
	}

	Debugf("onInputQueueDestroy done\n")
}
示例#2
0
文件: android.go 项目: 2722/lantern
func runInputQueue(vm, jniEnv, ctx uintptr) error {
	env := (*C.JNIEnv)(unsafe.Pointer(jniEnv)) // not a Go heap pointer

	// Android loopers select on OS file descriptors, not Go channels, so we
	// translate the inputQueue channel to an ALooper_wake call.
	l := C.ALooper_prepare(C.ALOOPER_PREPARE_ALLOW_NON_CALLBACKS)
	pending := make(chan *C.AInputQueue, 1)
	go func() {
		for q := range inputQueue {
			pending <- q
			C.ALooper_wake(l)
		}
	}()

	var q *C.AInputQueue
	for {
		if C.ALooper_pollAll(-1, nil, nil, nil) == C.ALOOPER_POLL_WAKE {
			select {
			default:
			case p := <-pending:
				if q != nil {
					processEvents(env, q)
					C.AInputQueue_detachLooper(q)
				}
				q = p
				if q != nil {
					C.AInputQueue_attachLooper(q, l, 0, nil, nil)
				}
				inputQueueDone <- struct{}{}
			}
		}
		if q != nil {
			processEvents(env, q)
		}
	}
}
示例#3
0
func (m *mainLoop) wakeAndAck() {
	C.ALooper_wake(m.looper)
	<-m.ack
}