Trying to Convert a VB.net Example to Go (Record Audio)

blov · · 856 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>So i have this small tut online that i am copying to Go the best i can. <a href="http://www.visual-basic-tutorials.com/MicRecord.php" rel="nofollow">http://www.visual-basic-tutorials.com/MicRecord.php</a></p> <p>I am trying to use Windows own winmm.dll to do this in as few lines of code as i can. When i run i get &#34;exit status 3221225477&#34; I have no idea what the means, Also i <em>think</em> this should be working as its basically the same as the VB.net version.</p> <p>Here is the code i have; package main</p> <pre><code>import ( &#34;fmt&#34; &#34;syscall&#34; &#34;time&#34; &#34;unsafe&#34; ) var ( winmm = syscall.MustLoadDLL(&#34;winmm.dll&#34;) mciSendString = winmm.MustFindProc(&#34;mciSendStringA&#34;) ) func MCIWorker(lpstrCommand string, lpstrReturnString string, uReturnLength int, hwndCallback int) error { _, _, err := syscall.Syscall(mciSendString.Addr(), uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpstrCommand))), uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpstrReturnString))), uintptr(uReturnLength), uintptr(hwndCallback)) return err } func main() { fmt.Println(&#34;New&#34;, MCIWorker(&#34;open new Type waveaudio Alias recsound&#34;, &#34;&#34;, 0, 0)) fmt.Println(&#34;Record&#34;, MCIWorker(&#34;record recsound&#34;, &#34;&#34;, 0, 0)) time.Sleep(10 * time.Second) fmt.Println(&#34;Save&#34;, MCIWorker(&#34;save recsound c:\\mic.wav&#34;, &#34;&#34;, 0, 0)) fmt.Println(&#34;Close&#34;, MCIWorker(&#34;close recsound&#34;, &#34;&#34;, 0, 0)) } </code></pre> <hr/>**评论:**<br/><br/>mortonpe: <pre><p>Checkout <a href="http://stackoverflow.com/questions/10306272/apache-crashing-parent-child-process-exited-with-status-3221225477-restarti" rel="nofollow">http://stackoverflow.com/questions/10306272/apache-crashing-parent-child-process-exited-with-status-3221225477-restarti</a></p> <p>Summary: something is access memory which is not allocated. Something is up with one of the unsafe address, probably either null, the wrong data type, not sides correctly</p></pre>SaturnsVoid: <pre><p>Thanks i will look into the API a bit more and see if i can work it out.</p></pre>SaturnsVoid: <pre><p>Alright i needed to call it instead, now just trying to figure out how to get it to listen to the default mic...</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

856 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传