mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
audio/vorbis: Refactoring: Use uintptr to calc a pointer value with an offset
This commit is contained in:
parent
2475fd32a8
commit
4492c0dad0
@ -5488,10 +5488,6 @@ int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, in
|
|||||||
|
|
||||||
#endif // STB_VORBIS_HEADER_ONLY
|
#endif // STB_VORBIS_HEADER_ONLY
|
||||||
|
|
||||||
static inline short shortValue(short* data, int i) {
|
|
||||||
return data[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
@ -5547,8 +5543,9 @@ type decoded struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *decoded) at(offset int) C.short {
|
func (d *decoded) at(offset int) C.short {
|
||||||
// return *(*C.short)(unsafe.Pointer(uintptr(unsafe.Pointer(d.data)) + uintptr(offset)))
|
const sizeOfShort = 2
|
||||||
return C.shortValue(d.data, C.int(offset))
|
p := uintptr(unsafe.Pointer(d.data))
|
||||||
|
return *(*C.short)(unsafe.Pointer(p + uintptr(offset*sizeOfShort)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *decoded) Read(b []byte) (int, error) {
|
func (d *decoded) Read(b []byte) (int, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user