File tree Expand file tree Collapse file tree 3 files changed +33
-2
lines changed
stdlib/public/SDK/CoreAudio Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 1
1
add_swift_library (swiftCoreAudio IS_SDK_OVERLAY
2
2
CoreAudio.swift
3
+ ../../../public/core/WriteBackMutableSlice.swift
3
4
4
5
TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR
5
6
SWIFT_MODULE_DEPENDS Dispatch
Original file line number Diff line number Diff line change @@ -128,7 +128,11 @@ public struct UnsafeMutableAudioBufferListPointer {
128
128
129
129
// FIXME: swift-3-indexing-model: conform to RandomAccessCollection
130
130
// and update the test to reflect the change.
131
- extension UnsafeMutableAudioBufferListPointer : MutableCollection {
131
+ extension UnsafeMutableAudioBufferListPointer
132
+ : MutableCollection , RandomAccessCollection {
133
+
134
+ public typealias Index = Int
135
+
132
136
/// Always zero, which is the index of the first `AudioBuffer`.
133
137
public var startIndex : Int {
134
138
return 0
@@ -152,5 +156,21 @@ extension UnsafeMutableAudioBufferListPointer : MutableCollection {
152
156
( _audioBuffersPointer + index) . pointee = newValue
153
157
}
154
158
}
159
+
160
+ public subscript( bounds: Range < Int > )
161
+ -> MutableRandomAccessSlice < UnsafeMutableAudioBufferListPointer > {
162
+ get {
163
+ return MutableRandomAccessSlice ( base: self , bounds: bounds)
164
+ }
165
+ set {
166
+ _writeBackMutableSlice ( & self , bounds: bounds, slice: newValue)
167
+ }
168
+ }
169
+
170
+ public typealias Indices = CountableRange < Int >
171
+
172
+ public var indices : Indices {
173
+ return startIndex..< endIndex
174
+ }
155
175
}
156
176
Original file line number Diff line number Diff line change @@ -159,6 +159,16 @@ CoreAudioTestSuite.test("AudioBufferList.allocate(maximumBuffers: Int)/trap/over
159
159
AudioBufferList . allocate ( maximumBuffers: Int . max)
160
160
}
161
161
162
+ CoreAudioTestSuite . test ( " UnsafeMutableAudioBufferListPointer/AssociatedTypes " ) {
163
+ typealias Subject = UnsafeMutableAudioBufferListPointer
164
+ expectRandomAccessCollectionAssociatedTypes (
165
+ collectionType: Subject . self,
166
+ iteratorType: IndexingIterator< Subject> . self ,
167
+ subSequenceType: MutableRandomAccessSlice< Subject> . self ,
168
+ indexType: Int . self,
169
+ indexDistanceType: Int . self,
170
+ indicesType: CountableRange< Int> . self )
171
+ }
162
172
163
173
CoreAudioTestSuite . test (
164
174
" UnsafeMutableAudioBufferListPointer.init(_: UnsafeMutablePointer<AudioBufferList>), " +
@@ -284,7 +294,7 @@ CoreAudioTestSuite.test("UnsafeMutableAudioBufferListPointer/Collection") {
284
294
}
285
295
286
296
// FIXME: use checkMutableRandomAccessCollection, when we have that function.
287
- checkForwardCollection ( expected, ablPtrWrapper)
297
+ checkRandomAccessCollection ( expected, ablPtrWrapper)
288
298
free ( ablPtrWrapper. unsafeMutablePointer)
289
299
}
290
300
You can’t perform that action at this time.
0 commit comments