Class: RbSDL2::Audio::AudioDevice

Inherits:
Object
  • Object
show all
Includes:
AudioSpecReader
Defined in:
lib/rb_sdl2/audio/audio_device.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(num, capture) ⇒ AudioDevice

Returns a new instance of AudioDevice.

Raises:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rb_sdl2/audio/audio_device.rb', line 10

def initialize(num, capture)
  is_capture = IS_CAPTURE.(capture)
  ptr = ::SDL.GetAudioDeviceName(num, is_capture)
  raise RbSDL2Error if ptr.null?

  spec = AudioSpec.new
  # GetAudioDeviceSpec は GetNumAudioDevices の最新の呼び出しを反映する。
  err = ::SDL.GetAudioDeviceSpec(num, is_capture, spec)
  raise RbSDL2Error if err != 0

  @capture = capture ? true : false
  @name = SDL.ptr_to_str(ptr)
  @spec = spec
end

Instance Attribute Details

#nameObject (readonly) Also known as: to_s

Returns the value of attribute name.



27
28
29
# File 'lib/rb_sdl2/audio/audio_device.rb', line 27

def name
  @name
end

#specObject (readonly)

Returns the value of attribute spec.



30
31
32
# File 'lib/rb_sdl2/audio/audio_device.rb', line 30

def spec
  @spec
end

Class Method Details

.devices(capture = false) ⇒ Object



5
6
7
# File 'lib/rb_sdl2/audio/audio_device.rb', line 5

def devices(capture = false)
  ::SDL.GetNumAudioDevices(IS_CAPTURE.(capture)).times.map { |num| new(num, capture) }
end

Instance Method Details

#capture?Boolean

Returns:

  • (Boolean)


25
# File 'lib/rb_sdl2/audio/audio_device.rb', line 25

def capture? = @capture

#unknown?Boolean

Returns:

  • (Boolean)


35
# File 'lib/rb_sdl2/audio/audio_device.rb', line 35

def unknown? = spec.unknown?