Class: FMOD::Handle Abstract

Inherits:
Fiddle::Pointer
  • Object
show all
Includes:
Core, Fiddle
Defined in:
lib/fmod/handle.rb

Overview

This class is abstract.

The superclass for all core FMOD classes.

Contains a reference handle to an unmanaged object, and as such it is crucial to call #release on any derived class to prevent memory leaks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address) ⇒ Handle

Returns a new instance of Handle.

Parameters:

  • address (Pointer, Integer, String)

    The address of a native FMOD pointer.



18
19
20
21
# File 'lib/fmod/handle.rb', line 18

def initialize(address)
  address = address.unpack1('J') if address.is_a?(String)
  super(address.to_i)
end

Instance Attribute Details

#user_dataPointer

Returns a user value stored within the object.

Returns:

  • (Pointer)

    a user value stored within the object.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fmod/handle.rb', line 44

def user_data
  pointer = int_ptr
  case self
  when ChannelControl
    FMOD.invoke(:ChannelGroup_GetUserData, self, pointer)
  when Dsp
    FMOD.invoke(:DSP_GetUserData, self, pointer)
  when DspConnection
    FMOD.invoke(:DSPConnection_GetUserData, self, pointer)
  when Geometry
    FMOD.invoke(:Geometry_GetUserData, self, pointer)
  when Reverb3D
    FMOD.invoke(:Reverb3D_GetUserData, self, pointer)
  when Sound
    FMOD.invoke(:Sound_GetUserData, self, pointer)
  when SoundGroup
    FMOD.invoke(:SoundGroup_GetUserData, self, pointer)
  when System
    FMOD.invoke(:System_GetUserData, self, pointer)
  end
  Pointer.new(pointer.unpack1('J'))
end

Instance Method Details

#int_ptrString

Returns an empty string buffer the size of the platforms pointer size.

Returns:

  • (String)

    an empty string buffer the size of the platforms pointer size.



98
99
100
# File 'lib/fmod/handle.rb', line 98

def int_ptr
  "\0" * SIZEOF_INTPTR_T
end

#releasevoid Also known as: dispose

This method returns an undefined value.

Releases the native handle. Failure to call this function may result in memory leaks.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fmod/handle.rb', line 27

def release
  case self
  when Sound then FMOD.invoke(:Sound_Release, self)
  when Dsp then FMOD.invoke(:DSP_Release, self)
  when ChannelGroup then FMOD.invoke(:ChannelGroup_Release, self)
  when Geometry then FMOD.invoke(:Geometry_Release, self)
  when Reverb3D then FMOD.invoke(:Reverb3D_Release, self)
  when SoundGroup then FMOD.invoke(:SoundGroup_Release, self)
  when System then FMOD.invoke(:System_Release, self)
  end
end

#to_sString

Returns the string representation of the object.

Returns:

  • (String)

    the string representation of the object.



91
92
93
# File 'lib/fmod/handle.rb', line 91

def to_s
  inspect # TODO
end