Skip ptr checks from go for handle value

This commit is contained in:
DataHoarder 2022-07-28 14:43:34 +02:00
parent 1413086e90
commit 0d9c44a7e8
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
2 changed files with 11 additions and 3 deletions

6
decoder.c Normal file
View file

@ -0,0 +1,6 @@
#include <vorbis/vorbisfile.h>
int handle_ov_open_callbacks(uintptr_t datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks) {
return ov_open_callbacks((void*)datasource, vf, initial, ibytes, callbacks);
}

View file

@ -13,6 +13,8 @@ size_t cgoReadCallback(void *ptr, size_t size, size_t nmemb, void *datasource);
int cgoSeekCallback(void *datasource, ogg_int64_t offset, int whence);
long cgoTellCallback(void *datasource);
int cgoCloseCallback(void *datasource);
int handle_ov_open_callbacks(uintptr_t datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
*/
import "C"
import (
@ -38,7 +40,7 @@ func NewDecoder(reader io.Reader) (*Decoder, error) {
d.file = (*C.OggVorbis_File)(unsafe.Pointer(&d.mem[0]))
d.handle = cgo.NewHandle(d)
if ret := C.ov_open_callbacks(unsafe.Pointer(d.handle), d.file, nil, 0, C.ov_callbacks{
if ret := C.handle_ov_open_callbacks(C.uintptr_t(d.handle), d.file, nil, 0, C.ov_callbacks{
read_func: C.vorbisfile_read_func(C.cgoReadCallback),
seek_func: nil,
close_func: nil,
@ -72,7 +74,7 @@ func NewSeekerDecoder(reader io.ReadSeeker) (*Decoder, error) {
d.file = (*C.OggVorbis_File)(unsafe.Pointer(&d.mem[0]))
d.handle = cgo.NewHandle(d)
if ret := C.ov_open_callbacks(unsafe.Pointer(d.handle), d.file, nil, 0, C.ov_callbacks{
if ret := C.handle_ov_open_callbacks(C.uintptr_t(d.handle), d.file, nil, 0, C.ov_callbacks{
read_func: C.vorbisfile_read_func(C.cgoReadCallback),
seek_func: C.vorbisfile_seek_func(C.cgoSeekCallback),
close_func: nil,
@ -106,7 +108,7 @@ func NewSeekCloserDecoder(reader io.ReadSeekCloser) (*Decoder, error) {
d.file = (*C.OggVorbis_File)(unsafe.Pointer(&d.mem[0]))
d.handle = cgo.NewHandle(d)
if ret := C.ov_open_callbacks(unsafe.Pointer(d.handle), d.file, nil, 0, C.ov_callbacks{
if ret := C.handle_ov_open_callbacks(C.uintptr_t(d.handle), d.file, nil, 0, C.ov_callbacks{
read_func: C.vorbisfile_read_func(C.cgoReadCallback),
seek_func: C.vorbisfile_seek_func(C.cgoSeekCallback),
close_func: C.vorbisfile_close_func(C.cgoCloseCallback),