@@ -26,22 +26,20 @@ func getProperties(
26
26
let result = MIDIObjectGetProperties ( ref, & props, deep)
27
27
28
28
guard result == noErr else {
29
- props? . release ( )
30
29
throw MIDIIOError . osStatus ( result)
31
30
}
32
31
33
32
guard let unwrappedProps = props? . takeRetainedValue ( ) else {
34
- props? . release ( )
35
33
throw MIDIIOError . readError (
36
34
" Got nil while reading MIDIEndpointRef property list. "
37
35
)
38
36
}
39
37
40
38
// "takeRetainedValue() is the right choice here because it is the caller's responsibility to
41
39
// release the string.
42
- // This is different from the usual Core Foundation memory management rules, but documented in
43
- // the MIDI Services Reference"
44
- // -- https://stackoverflow.com/a/27171498/2805570
40
+ // This is different from the usual Core Foundation memory management rules, but documented in
41
+ // the MIDI Services Reference. "
42
+ // -- https://stackoverflow.com/a/27171498/2805570
45
43
46
44
return unwrappedProps
47
45
}
@@ -55,29 +53,27 @@ func getProperties(
55
53
///
56
54
/// - Throws: ``MIDIIOError``
57
55
func getDictionary(
58
- forProperty: CFString ,
56
+ forProperty property : CFString ,
59
57
of ref: CoreMIDI . MIDIObjectRef
60
58
) throws -> NSDictionary {
61
59
var dict : Unmanaged < CFDictionary > ?
62
- let result = MIDIObjectGetDictionaryProperty ( ref, forProperty , & dict)
60
+ let result = MIDIObjectGetDictionaryProperty ( ref, property , & dict)
63
61
64
62
guard result == noErr else {
65
- dict? . release ( )
66
63
throw MIDIIOError . osStatus ( result)
67
64
}
68
65
69
66
guard let unwrappedDict = dict? . takeRetainedValue ( ) else {
70
- dict? . release ( )
71
67
throw MIDIIOError . readError (
72
68
" Got nil while reading MIDIEndpointRef property list. "
73
69
)
74
70
}
75
71
76
72
// "takeRetainedValue() is the right choice here because it is the caller's responsibility to
77
73
// release the string.
78
- // This is different from the usual Core Foundation memory management rules, but documented in
79
- // the MIDI Services Reference"
80
- // -- https://stackoverflow.com/a/27171498/2805570
74
+ // This is different from the usual Core Foundation memory management rules, but documented in
75
+ // the MIDI Services Reference. "
76
+ // -- https://stackoverflow.com/a/27171498/2805570
81
77
82
78
return unwrappedDict as NSDictionary
83
79
}
@@ -91,29 +87,27 @@ func getDictionary(
91
87
///
92
88
/// - Throws: ``MIDIIOError``
93
89
func getString(
94
- forProperty: CFString ,
90
+ forProperty property : CFString ,
95
91
of ref: CoreMIDI . MIDIObjectRef
96
92
) throws -> String {
97
93
var val : Unmanaged < CFString > ?
98
- let result = MIDIObjectGetStringProperty ( ref, forProperty , & val)
94
+ let result = MIDIObjectGetStringProperty ( ref, property , & val)
99
95
100
96
guard result == noErr else {
101
- val? . release ( )
102
97
throw MIDIIOError . osStatus ( result)
103
98
}
104
99
105
100
guard let unwrappedVal = val? . takeRetainedValue ( ) else {
106
- val? . release ( )
107
101
throw MIDIIOError . readError (
108
- " Got nil while reading MIDIEndpointRef property value \( ( forProperty as String ) . quoted) "
102
+ " Got nil while reading MIDIEndpointRef property value \( ( property as String ) . quoted) "
109
103
)
110
104
}
111
105
112
106
// "takeRetainedValue() is the right choice here because it is the caller's responsibility to
113
107
// release the string.
114
- // This is different from the usual Core Foundation memory management rules, but documented in
115
- // the MIDI Services Reference"
116
- // -- https://stackoverflow.com/a/27171498/2805570
108
+ // This is different from the usual Core Foundation memory management rules, but documented in
109
+ // the MIDI Services Reference. "
110
+ // -- https://stackoverflow.com/a/27171498/2805570
117
111
118
112
return unwrappedVal as String
119
113
}
@@ -123,11 +117,12 @@ func getString(
123
117
///
124
118
/// - Parameter forProperty: a `CoreMIDI.Property` constant
125
119
func getInteger(
126
- forProperty: CFString ,
120
+ forProperty property : CFString ,
127
121
of ref: CoreMIDI . MIDIObjectRef
128
122
) -> Int32 {
129
123
var val : Int32 = 0
130
- _ = MIDIObjectGetIntegerProperty ( ref, forProperty, & val)
124
+ // TODO: handle OSStatus errors?
125
+ _ = MIDIObjectGetIntegerProperty ( ref, property, & val)
131
126
return val
132
127
}
133
128
0 commit comments