当前位置:网站首页>Golang appelle sdl2, lit l'audio PCM et signale une erreur lors de l'exécution externe du Code.
Golang appelle sdl2, lit l'audio PCM et signale une erreur lors de l'exécution externe du Code.
2022-06-22 06:51:00 【Une question par jour pour les constructeurs d'échafaudages de 】
golangAppelezsdl2,JouerpcmAudio,Erreur signaléesignal arrived during external code execution.
win10 x64Test suivant réussi,Le succès n'est pas garanti sous d'autres systèmes d'exploitation.
Ce qui est adopté estsyscallComment,Non, pas du tout.cgoComment.
Voir adresse
Ingo1.16.15Après compilation et exécution,L'erreur suivante sera signalée.Remplacer pargo1.18Ne vous trompez pas..
Exception 0xc0000005 0x0 0xc000442000 0x7ff96da8db50
PC=0x7ff96da8db50
signal arrived during external code execution
syscall.Syscall6(0x7ff96daa7440, 0x4, 0x20d6354a0a0, 0xc000442000, 0x1000, 0x10, 0x0, 0x0, 0x0, 0x0, …)
D:/Program Files/Go/go1.16.15/src/runtime/syscall_windows.go:347 +0xf2
syscall.(*Proc).Call(0xc000599b40, 0xc0001207c0, 0x4, 0x4, 0x20, 0xa6ffa0, 0x20d6354a001, 0xc0001207c0)
D:/Program Files/Go/go1.16.15/src/syscall/dll_windows.go:188 +0x385
syscall.(*LazyProc).Call(0xc00007fc50, 0xc0001207c0, 0x4, 0x4, 0x3, 0x3, 0x20d6354a0a0, 0x0)
D:/Program Files/Go/go1.16.15/src/syscall/dll_windows.go:339 +0x78
github.com/moonfdd/sdl2-go/sdl.SDL_MixAudio(0x20d6354a0a0, 0xc000442000, 0x1000001000)
D:/mysetup/gopath/src/sdl2-go/sdl/SDL_audio.go:1185 +0xf1
main.fill_audio_pcm(0xc00010ff48, 0x20d6354a0a0, 0x1000, 0x0)
D:/mysetup/gopath/src/sdl2-go/examples/a06-sdl-pcm/main1.go:33 +0x125
goroutine 1 [chan receive]:
main.main()
D:/mysetup/gopath/src/sdl2-go/examples/a06-sdl-pcm/main1.go:66 +0x288
rax 0x20d6354a0a0
rbx 0xc0000086e0
rcx 0x20d6354a0a0
rdi 0xecaa4c3000
rsi 0xc0000439c0
rbp 0xc000043960
rsp 0xecabbffb50
r8 0x8010
r9 0x20d6354b0a0
r10 0x10
r11 0x4
r12 0xa7b800
r13 0x0
r14 0x0
r15 0x2030001
rip 0x7ff96da8db50
rflags 0x10206
cs 0x33
fs 0x53
gs 0x2b
golangLes codes sont les suivants::
package main
import (
"fmt"
"github.com/moonfdd/sdl2-go/sdl"
"github.com/moonfdd/sdl2-go/sdlcommon"
"io/ioutil"
"sync"
"syscall"
"unsafe"
)
var o sync.Once
// Fonction de rappel du périphérique audio
func fill_audio_pcm(udata sdlcommon.FVoidP, stream *sdlcommon.FUint8T, len1 sdlcommon.FInt) uintptr {
info := (*Info)(unsafe.Pointer(udata))
if info.isStop {
return 0
}
if info.Start >= info.Len {
info.isStop = true
o.Do(func() {
ch <- struct{
}{
}
})
return 0
}
sdl.SDL_memset(uintptr(unsafe.Pointer(stream)), 0, uint64(len1))
if len1 > int32(info.Len-info.Start) {
fmt.Println("Pas assezlen", len1, info.Len-info.Start)
len1 = int32(info.Len - info.Start)
}
sdl.SDL_MixAudio(stream, &info.Data[info.Start], uint32(len1), sdl.SDL_MIX_MAXVOLUME/8)
info.Start += int(len1)
return 0
}
var ch = make(chan struct{
}, 1)
func main() {
sdlcommon.SetSDL2Path("SDL2.dll")
var spec sdl.SDL_AudioSpec
sdl.SDL_Init(sdl.SDL_INIT_AUDIO)
spec.Freq = 44100
spec.Format = sdl.AUDIO_S16SYS // Format du point d'échantillonnage
spec.Channels = 2 // 2Accès
spec.Silence = 0
spec.Userdata = uintptr(0)
spec.Samples = 1024 // 23.2ms -> 46.4ms Nombre d'échantillons par lecture , Combien de fois un rappel et samples
spec.Callback = syscall.NewCallback(fill_audio_pcm) // Fonction de rappel
fileData, err := ioutil.ReadFile("44100_16bit_2ch.pcm")
if err != nil {
fmt.Println("Impossible de lire le fichier", err)
return
}
info := new(Info)
info.Data = fileData
info.Len = len(fileData)
spec.Userdata = uintptr(unsafe.Pointer(info))
if sdl.SDL_OpenAudio(&spec, nil) != 0 {
fmt.Println(" Impossible d'ouvrir le périphérique audio ")
return
}
sdl.SDL_PauseAudio(0)
<-ch
fmt.Println("Fermer")
sdl.SDL_CloseAudio()
sdl.SDL_Quit()
}
type Info struct {
Data []byte
Len int
Start int
isStop bool
}
Les résultats sont les suivants:
边栏推荐
- vue连接mysql数据库失败
- Neuron+eKuiper 实现工业物联网数据采集、清理与反控
- -Bash: telnet: command not found solution
- Introduction to 51 single chip microcomputer - 8x8 dot matrix LED
- The song of cactus - marching into to C live broadcast (1)
- import keras时遇到的错误 TypeError: Descriptors cannot not be created directly. If this call came from a _
- Dijin introduces digi connectcore voice control software for connectcore system module
- [5g NR] RRC connection reconstruction analysis
- JDBC query result set, which is converted into a table
- Tp6 links to sqlserver, PHP links to sqlserver, and Linux offline installation and deployment
猜你喜欢

首次用DBeaver连接mysql报错

Introduction to 51 Single Chip Microcomputer -- minimum system of single chip microcomputer

实训渗透靶场02|3星vh-lll靶机|vulnhub靶场Node1

Event preview edgex developer summit @ Nanjing station is coming!

Tableau 连接mysql详细教程

圣杯布局和双飞翼布局的区别
![[php] composer installation](/img/37/7adaca01b95085b42a116bc6b08165.png)
[php] composer installation

Blog add mailbox private message shortcut

Single cell literature learning (Part3) -- dstg: deconvoluting spatial transcription data through graph based AI

Qt development simple Bluetooth debugging assistant (low power Bluetooth)
随机推荐
[write CPU by yourself] implementation of exception related instructions
【openairinterface5g】项目目录结构
EMC solutions
Single cell paper record (part6) -- space: spatial gene enhancement using scrna seq
【5G NR】UE注册管理状态
[M32] single chip microcomputer SVN setting ignore file
Introduction to 51 single chip microcomputer - 8x8 dot matrix LED
Single cell literature learning (Part3) -- dstg: deconvoluting spatial transcription data through graph based AI
College entrance examination is a post station on the journey of life
Which is the best agency mode or decoration mode
MySQL Niuke brush questions
C语言——深入理解数组
【OpenAirInterface5g】RRC NR解析(一)
ForkJoinPool
What exactly is the open source office of a large factory like?
iframe框架,,原生js路由
Literature record (part106) -- graph auto-encoder via neighborhood Wasserstein reconstruction
首次用DBeaver连接mysql报错
Data security practice guide - data collection security management
Chrome 安装 driver