Class: CoreAudio::AudioObject
- Inherits:
-
Object
- Object
- CoreAudio::AudioObject
- Defined in:
- lib/macos/core_audio/audio_object.rb
Direct Known Subclasses
Defined Under Namespace
Classes: PropertyAddress
Constant Summary collapse
- ObjectID =
FFI::Type::UINT32
- PropertyElement =
FFI::Type::UINT32
- PropertyScope =
FFI::Type::UINT32
- PropertySelector =
FFI::Type::UINT32
- PropertyScopeGlobal =
AudioHardwareBase.h: Basic Constants
'glob'- PropertyScopeInput =
'inpt'- PropertyScopeOutput =
'outp'- PropertyScopePlayThrough =
'ptru'- PropertyElementMaster =
0- PropertyBaseClass =
AudioHardwareBase.h: AudioObject Properties
'bcls'- PropertyClass =
'clas'- PropertyOwner =
'stdv'- PropertyName =
'lnam'- PropertyModelName =
'lmod'- PropertyManufacturer =
'lmak'- PropertyElementName =
'lchn'- PropertyElementCategoryName =
'lccn'- PropertyElementNumberName =
'lcnn'- PropertyOwnedObjects =
'ownd'- PropertyIdentify =
'iden'- PropertySerialNumber =
'snum'- PropertyFirmwareVersion =
'fwvn'- SystemObject =
AudioHardware.h: Basic Constants
1
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Convenience Attributes collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#device_name ⇒ String
The name of the device.
- #device_uid ⇒ Object
- #get_property(address) ⇒ FFI::MemoryPointer
-
#initialize(id) ⇒ AudioObject
constructor
A new instance of AudioObject.
-
#model_uid ⇒ String
A persistent identifier for the model of an AudioDevice.
- #set_property(address, buffer, qualifier = nil) ⇒ Object
-
#transport_type ⇒ String
The 4-character transport type identifier.
Constructor Details
#initialize(id) ⇒ AudioObject
Returns a new instance of AudioObject.
93 94 95 |
# File 'lib/macos/core_audio/audio_object.rb', line 93 def initialize(id) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
57 58 59 |
# File 'lib/macos/core_audio/audio_object.rb', line 57 def id @id end |
Class Method Details
.system ⇒ Object
89 90 91 |
# File 'lib/macos/core_audio/audio_object.rb', line 89 def self.system new(SystemObject) end |
Instance Method Details
#device_name ⇒ String
Returns the name of the device.
127 128 129 130 |
# File 'lib/macos/core_audio/audio_object.rb', line 127 def device_name address = PropertyAddress.global_master(PropertyName) get_string(address) end |
#device_uid ⇒ Object
132 133 134 135 |
# File 'lib/macos/core_audio/audio_object.rb', line 132 def device_uid address = PropertyAddress.global_master(AudioHardwareBase::AudioDevicePropertyDeviceUID) get_string(address) end |
#external? ⇒ Boolean
117 118 119 |
# File 'lib/macos/core_audio/audio_object.rb', line 117 def external? not internal? end |
#get_property(address) ⇒ FFI::MemoryPointer
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/macos/core_audio/audio_object.rb', line 98 def get_property(address) buffer_size = FFI::MemoryPointer.new(:uint32) status = CoreAudio.AudioObjectGetPropertyDataSize(id, address, 0, nil, buffer_size) raise('Could not get audio property size') unless 0 == status # buffer_size is now the size of the buffer to be passed to AudioObjectGetPropertyData() buffer = FFI::MemoryPointer.new(1, buffer_size.get_int32(0)) status = CoreAudio.AudioObjectGetPropertyData(id, address, 0, nil, buffer_size, buffer) raise('Could not get the audio property data') unless 0 == status buffer end |
#internal? ⇒ Boolean
121 122 123 |
# File 'lib/macos/core_audio/audio_object.rb', line 121 def internal? transport_type == 'bltn' end |
#model_uid ⇒ String
Returns a persistent identifier for the model of an AudioDevice.
138 139 140 141 |
# File 'lib/macos/core_audio/audio_object.rb', line 138 def model_uid address = PropertyAddress.global_master(AudioHardwareBase::AudioDevicePropertyModelUID) get_string(address) end |
#set_property(address, buffer, qualifier = nil) ⇒ Object
111 112 113 114 |
# File 'lib/macos/core_audio/audio_object.rb', line 111 def set_property(address, buffer, qualifier=nil) qualifier_size = qualifier.size rescue 0 CoreAudio.AudioObjectSetPropertyData(id, address, 0, nil, buffer.size, buffer) end |
#transport_type ⇒ String
Returns the 4-character transport type identifier.
144 145 146 147 148 |
# File 'lib/macos/core_audio/audio_object.rb', line 144 def transport_type address = PropertyAddress.global_master(AudioHardwareBase::AudioDevicePropertyTransportType) buffer = get_property(address) buffer.get_bytes(0, buffer.size).reverse end |