mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Introduce internal/jni
This commit is contained in:
parent
dd210a3ed1
commit
6a74ea5b30
@ -183,6 +183,8 @@ import "C"
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/jni"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Player struct {
|
type Player struct {
|
||||||
@ -205,7 +207,7 @@ func NewPlayer(sampleRate, channelNum, bytesPerSample int) (*Player, error) {
|
|||||||
chErr: make(chan error),
|
chErr: make(chan error),
|
||||||
chBuffer: make(chan []byte),
|
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)
|
audioTrack := C.jobject(nil)
|
||||||
bufferSize := C.int(0)
|
bufferSize := C.int(0)
|
||||||
if msg := C.initAudioTrack(C.uintptr_t(vm), C.uintptr_t(env), C.jobject(ctx),
|
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)
|
msg := (*C.char)(nil)
|
||||||
switch p.bytesPerSample {
|
switch p.bytesPerSample {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// and editted.
|
// and editted.
|
||||||
// This file is licensed under the 3-clause BSD license.
|
// This file is licensed under the 3-clause BSD license.
|
||||||
|
|
||||||
package driver
|
package jni
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
@ -69,7 +69,7 @@ import (
|
|||||||
"unsafe"
|
"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)
|
errch := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
Loading…
Reference in New Issue
Block a user