Introduce internal/jni

This commit is contained in:
Hajime Hoshi 2016-05-28 02:40:13 +09:00
parent dd210a3ed1
commit 6a74ea5b30
2 changed files with 6 additions and 4 deletions

View File

@ -183,6 +183,8 @@ import "C"
import (
"errors"
"unsafe"
"github.com/hajimehoshi/ebiten/internal/jni"
)
type Player struct {
@ -205,7 +207,7 @@ func NewPlayer(sampleRate, channelNum, bytesPerSample int) (*Player, error) {
chErr: make(chan error),
chBuffer: make(chan []byte),
}
if err := runOnJVM(func(vm, env, ctx uintptr) error {
if err := jni.RunOnJVM(func(vm, env, ctx uintptr) error {
audioTrack := C.jobject(nil)
bufferSize := C.int(0)
if msg := C.initAudioTrack(C.uintptr_t(vm), C.uintptr_t(env), C.jobject(ctx),
@ -233,7 +235,7 @@ func (p *Player) loop() {
}
}
if err := runOnJVM(func(vm, env, ctx uintptr) error {
if err := jni.RunOnJVM(func(vm, env, ctx uintptr) error {
msg := (*C.char)(nil)
switch p.bytesPerSample {
case 1:

View File

@ -4,7 +4,7 @@
// and editted.
// This file is licensed under the 3-clause BSD license.
package driver
package jni
/*
#include <jni.h>
@ -69,7 +69,7 @@ import (
"unsafe"
)
func runOnJVM(fn func(vm, env, ctx uintptr) error) error {
func RunOnJVM(fn func(vm, env, ctx uintptr) error) error {
errch := make(chan error)
go func() {
runtime.LockOSThread()