Skip to content

Commit

Permalink
fixed userData accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
theaidem committed May 7, 2016
1 parent 4c29ed6 commit 9afdc11
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lowlevel/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,8 @@ func (c *Channel) Get3DDistanceFilter() (bool, float64, float64, error) {

// Sets a user value that can be retrieved with "Channel.UserData".
func (c *Channel) SetUserData(userdata interface{}) error {
res := C.FMOD_Channel_SetUserData(c.cptr, unsafe.Pointer(&userdata))
data := *(*[]*C.char)(unsafe.Pointer(&userdata))
res := C.FMOD_Channel_SetUserData(c.cptr, unsafe.Pointer(&data))
return errs[res]
}

Expand Down
3 changes: 2 additions & 1 deletion lowlevel/channel_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@ func (c *ChannelGroup) Get3DDistanceFilter() (bool, float64, float64, error) {

// Sets a user value that can be retrieved with "ChannelGroup.UserData".
func (c *ChannelGroup) SetUserData(userdata interface{}) error {
res := C.FMOD_ChannelGroup_SetUserData(c.cptr, unsafe.Pointer(&userdata))
data := *(*[]*C.char)(unsafe.Pointer(&userdata))
res := C.FMOD_ChannelGroup_SetUserData(c.cptr, unsafe.Pointer(&data))
return errs[res]
}

Expand Down
3 changes: 2 additions & 1 deletion lowlevel/dsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ func (d *DSP) Idle() (bool, error) {
// It can be useful if an FMOD callback passes an object of this type as a parameter, and the user does not know which object it is (if many of these types of objects exist).
// Using "DSP.UserData" would help in the identification of the object.
func (d *DSP) SetUserData(userdata interface{}) error {
res := C.FMOD_DSP_SetUserData(d.cptr, unsafe.Pointer(&userdata))
data := *(*[]*C.char)(unsafe.Pointer(&userdata))
res := C.FMOD_DSP_SetUserData(d.cptr, unsafe.Pointer(&data))
return errs[res]
}

Expand Down
3 changes: 2 additions & 1 deletion lowlevel/dsp_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ func (d *DspConnection) Type() (DSPConnectionType, error) {
// Sets a user value that the DSPConnection object will store internally. Can be retrieved with "DSPConnection.UserData".
// This function is primarily used in case the user wishes to 'attach' data to an FMOD object.
func (d *DspConnection) SetUserData(userdata interface{}) error {
res := C.FMOD_DSPConnection_SetUserData(d.cptr, unsafe.Pointer(&userdata))
data := *(*[]*C.char)(unsafe.Pointer(&userdata))
res := C.FMOD_DSPConnection_SetUserData(d.cptr, unsafe.Pointer(&data))
return errs[res]
}

Expand Down
3 changes: 2 additions & 1 deletion lowlevel/geometry.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ func (g *Geometry) Save(data *interface{}, datasize *C.int) error {
*/

func (g *Geometry) SetUserData(userdata interface{}) error {
res := C.FMOD_Geometry_SetUserData(g.cptr, unsafe.Pointer(&userdata))
data := *(*[]*C.char)(unsafe.Pointer(&userdata))
res := C.FMOD_Geometry_SetUserData(g.cptr, unsafe.Pointer(&data))
return errs[res]
}

Expand Down
3 changes: 2 additions & 1 deletion lowlevel/reverb3d.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ func (r *Reverb3D) IsActive() (bool, error) {
// It can be useful if an FMOD callback passes an object of this type as a parameter,
// and the user does not know which object it is (if many of these types of objects exist). Using Reverb::getUserData would help in the identification of the object.
func (r *Reverb3D) SetUserData(userdata interface{}) error {
res := C.FMOD_Reverb3D_SetUserData(r.cptr, unsafe.Pointer(&userdata))
data := *(*[]*C.char)(unsafe.Pointer(&userdata))
res := C.FMOD_Reverb3D_SetUserData(r.cptr, unsafe.Pointer(&data))
return errs[res]
}

Expand Down
5 changes: 3 additions & 2 deletions lowlevel/sound.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (s *Sound) Get3DCustomRolloff() (*Vector, int, error) {
var points = NewVector()
var cpoints *C.FMOD_VECTOR = points.toCp()
var numpoints C.int
res := C.FMOD_Sound_Get3DCustomRolloff(s.cptr, &cpoints, &numpoints)
res := C.FMOD_Sound_Get3DCustomRolloff(s.cptr, unsafe.Pointer(&cpoints), &numpoints)
if cpoints != nil {
points.fromC(*cpoints)
}
Expand Down Expand Up @@ -516,7 +516,8 @@ func (s *Sound) MusicSpeed() (float64, error) {
// It can be useful if an FMOD callback passes an object of this type as a parameter, and the user does not know which object it is
// (if many of these types of objects exist). Using "Sound.UserData" would help in the identification of the object.
func (s *Sound) SetUserData(userdata interface{}) error {
res := C.FMOD_Sound_SetUserData(s.cptr, unsafe.Pointer(&userdata))
data := *(*[]*C.char)(unsafe.Pointer(&userdata))
res := C.FMOD_Sound_SetUserData(s.cptr, unsafe.Pointer(&data))
return errs[res]
}

Expand Down
3 changes: 2 additions & 1 deletion lowlevel/sound_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ func (s *SoundGroup) NumPlaying() (int, error) {
// It can be useful if an FMOD callback passes an object of this type as a parameter, and the user does not know which object it is (if many of these types of objects exist).
// Using "SoundGroup.UserData" would help in the identification of the object.
func (s *SoundGroup) SetUserData(userdata interface{}) error {
res := C.FMOD_SoundGroup_SetUserData(s.cptr, unsafe.Pointer(&userdata))
data := *(*[]*C.char)(unsafe.Pointer(&userdata))
res := C.FMOD_SoundGroup_SetUserData(s.cptr, unsafe.Pointer(&data))
return errs[res]
}

Expand Down
1 change: 1 addition & 0 deletions lowlevel/sound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ func TestSoundUserData(t *testing.T) {
}

userData := "TestData"

err = censor.SetUserData(userData)
if err != nil {
t.Fatal(err)
Expand Down
3 changes: 2 additions & 1 deletion lowlevel/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,8 @@ func (s *System) NetworkTimeout() (int, error) {
// It can be useful if an FMOD callback passes an object of this type as a parameter, and the user does not know which object it is (if many of these types of objects exist).
// Using "System.UserData" would help in the identification of the object.
func (s *System) SetUserData(userdata interface{}) error {
res := C.FMOD_System_SetUserData(s.cptr, unsafe.Pointer(&userdata))
data := *(*[]*C.char)(unsafe.Pointer(&userdata))
res := C.FMOD_System_SetUserData(s.cptr, unsafe.Pointer(&data))
return errs[res]
}

Expand Down

0 comments on commit 9afdc11

Please sign in to comment.