mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
Introduce internal/jni
This commit is contained in:
parent
dd210a3ed1
commit
6a74ea5b30
@ -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:
|
||||
|
@ -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()
|
Loading…
Reference in New Issue
Block a user