Class: ALSA::PCM::SwParameters

Inherits:
Object
  • Object
show all
Defined in:
lib/alsa/pcm/sw_parameters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device = nil) ⇒ SwParameters

Returns a new instance of SwParameters.



6
7
8
9
10
11
12
13
# File 'lib/alsa/pcm/sw_parameters.rb', line 6

def initialize(device = nil)
  sw_params_pointer = FFI::MemoryPointer.new :pointer

  ALSA::PCM::Native::sw_params_malloc sw_params_pointer        
  self.handle = sw_params_pointer.read_pointer

  self.device = device if device
end

Instance Attribute Details

#deviceObject

Returns the value of attribute device.



4
5
6
# File 'lib/alsa/pcm/sw_parameters.rb', line 4

def device
  @device
end

#handleObject

Returns the value of attribute handle.



4
5
6
# File 'lib/alsa/pcm/sw_parameters.rb', line 4

def handle
  @handle
end

Instance Method Details

#avail_minObject Also known as: available_minimum



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/alsa/pcm/sw_parameters.rb', line 33

def avail_min
  value = nil
  ALSA::try_to "get period time" do
    value_pointer = FFI::MemoryPointer.new(:int)
    error_code = ALSA::PCM::Native::sw_params_get_avail_min self.handle, value_pointer
    value = value_pointer.read_int
    value_pointer.free
    error_code
  end
  value
end

#avail_min=(avail_min) ⇒ Object Also known as: available_minimum=



26
27
28
29
30
# File 'lib/alsa/pcm/sw_parameters.rb', line 26

def avail_min=(avail_min)
  ALSA::try_to "set avail_min (#{avail_min})" do
    ALSA::PCM::Native::sw_params_set_avail_min self.device.handle, self.handle, avail_min
  end
end

#current_for_deviceObject



19
20
21
22
23
24
# File 'lib/alsa/pcm/sw_parameters.rb', line 19

def current_for_device
  ALSA::try_to "retrieve current hardware parameters" do
    ALSA::PCM::Native::sw_params_current device.handle, self.handle
  end
  self
end

#freeObject



46
47
48
49
50
# File 'lib/alsa/pcm/sw_parameters.rb', line 46

def free
  ALSA::try_to "unallocate sw_params" do
    ALSA::PCM::Native::sw_params_free self.handle
  end
end

#update_attributes(attributes) ⇒ Object



15
16
17
# File 'lib/alsa/pcm/sw_parameters.rb', line 15

def update_attributes(attributes)
  attributes.each_pair { |name, value| send("#{name}=", value) }
end