diff --git a/libretro/libretro.go b/libretro/libretro.go index 6b451bcf..5580f268 100644 --- a/libretro/libretro.go +++ b/libretro/libretro.go @@ -317,6 +317,14 @@ func (core *Core) APIVersion() uint { // Deinit takes care of the library global deinitialization func (core *Core) Deinit() { C.bridge_retro_deinit(core.symRetroDeinit) + environment = nil + videoRefresh = nil + audioSample = nil + audioSampleBatch = nil + inputPoll = nil + inputState = nil + log = nil + getTimeUsec = nil } // Run runs the game for one video frame. @@ -520,16 +528,22 @@ func coreAudioSampleBatch(buf unsafe.Pointer, frames C.size_t) C.size_t { if audioSampleBatch == nil { return 0 } - return C.size_t(audioSampleBatch(C.GoBytes(buf, C.int(4096)), int32(frames))) + return C.size_t(audioSampleBatch(C.GoBytes(buf, C.int(4*int(frames))), int32(frames))) } //export coreLog func coreLog(level C.enum_retro_log_level, msg *C.char) { + if log == nil { + return + } log(uint32(level), C.GoString(msg)) } //export coreGetTimeUsec func coreGetTimeUsec() C.uint64_t { + if getTimeUsec == nil { + return 0 + } return C.uint64_t(getTimeUsec()) }