Class: JACK::Port

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/jack/port.rb

Constant Summary collapse

FLAGS_IS_INPUT =
0x1
FLAGS_IS_OUTPUT =
0x2
FLAGS_IS_PHYSICAL =
0x4
FLAGS_CAN_MONITOR =
0x8
FLAGS_IS_TERMINAL =
0x10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier, client) ⇒ Port

Returns a new instance of Port.



31
32
33
34
35
36
37
38
39
# File 'lib/jack/port.rb', line 31

def initialize(identifier, client)
  @client = client
  
  if identifier.is_a? String
    @pointer = @client.port_by_name(identifier).pointer
  else
    @pointer = identifier
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



23
24
25
# File 'lib/jack/port.rb', line 23

def client
  @client
end

#pointerObject (readonly)

Returns the value of attribute pointer.



23
24
25
# File 'lib/jack/port.rb', line 23

def pointer
  @pointer
end

Instance Method Details

#can_monitor?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/jack/port.rb', line 75

def can_monitor?
  flags & FLAGS_CAN_MONITOR != 0
end

#connect(destination) ⇒ Object

Raises:

  • (ArgumentError)


49
50
51
52
53
54
# File 'lib/jack/port.rb', line 49

def connect(destination)
  raise ArgumentError, "You must pass JACK::Port or String to JACK::Port.connect" if not destination.is_a? Port and not destination.is_a? String
  destination = client.port_by_name(destination) if destination.is_a? String
  
  client.connect self, destination
end

#disconnect(destination) ⇒ Object

Raises:

  • (ArgumentError)


56
57
58
59
60
61
# File 'lib/jack/port.rb', line 56

def disconnect(destination)
  raise ArgumentError, "You must pass JACK::Port or String to JACK::Port.disconnect" if not destination.is_a? Port and not destination.is_a? String
  destination = client.port_by_name(destination) if destination.is_a? String
  
  client.disconnect self, destination
end

#flagsObject



45
46
47
# File 'lib/jack/port.rb', line 45

def flags
  jack_port_flags @pointer
end

#inspectObject



87
88
89
# File 'lib/jack/port.rb', line 87

def inspect
  "#<#{self.class} name=#{name}>"
end

#is_input?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/jack/port.rb', line 63

def is_input?
  flags & FLAGS_IS_INPUT != 0
end

#is_output?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/jack/port.rb', line 67

def is_output?
  flags & FLAGS_IS_OUTPUT != 0
end

#is_physical?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/jack/port.rb', line 71

def is_physical?
  flags & FLAGS_IS_PHYSICAL != 0
end

#is_terminal?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/jack/port.rb', line 79

def is_terminal?
  flags & FLAGS_IS_TERMINAL != 0
end

#nameObject



41
42
43
# File 'lib/jack/port.rb', line 41

def name
  jack_port_name @pointer
end

#to_sObject



83
84
85
# File 'lib/jack/port.rb', line 83

def to_s
  name
end