Class: RbSDL2::Audio::AudioDevice
- Inherits:
-
Object
- Object
- RbSDL2::Audio::AudioDevice
- Includes:
- AudioSpecReader
- Defined in:
- lib/rb_sdl2/audio/audio_device.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Class Method Summary collapse
Instance Method Summary collapse
- #capture? ⇒ Boolean
-
#initialize(num, capture) ⇒ AudioDevice
constructor
A new instance of AudioDevice.
- #unknown? ⇒ Boolean
Constructor Details
#initialize(num, capture) ⇒ AudioDevice
Returns a new instance of AudioDevice.
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
#name ⇒ Object (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 |
#spec ⇒ Object (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
25 |
# File 'lib/rb_sdl2/audio/audio_device.rb', line 25 def capture? = @capture |
#unknown? ⇒ Boolean
35 |
# File 'lib/rb_sdl2/audio/audio_device.rb', line 35 def unknown? = spec.unknown? |