title: Access element given structure UnsafeMutablePointer
body: <p>In C, I have the following code to allocate a AudioBufferList with the appropriate size and then populate it with relevant data. </p>
  
  <pre><code>AudioObjectPropertyScope scope = mIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
  AudioObjectPropertyAddress address = { kAudioDevicePropertyStreamConfiguration, scope, 0 };
  UInt32 propertySize;
  __Verify_noErr(
    AudioObjectGetPropertyDataSize(mID, &amp;address, 0, NULL, &amp;propertySize)
  );
  AudioBufferList *bufferList = (AudioBufferList *) malloc(propertySize);
  __Verify_noErr(
    AudioObjectGetPropertyData(mID, &amp;address, 0, NULL, &amp;propertySize, bufferList)
  );
  </code></pre>
  
  <p>Then, I can access struct element :</p>
  
  <pre><code>UInt32 result { 0 };
  for(UInt32 i = 0; i &lt; bufferList-&gt;mNumberBuffers; ++i)
  {
    result += bufferList-&gt;mBuffers[i].mNumberChannels;
  }
  free(bufferList)
  </code></pre>
  
  <p><strong>How can I replicate this behavior in Swift, given the fact that I use the same framework, i.e. AudioToolbox?</strong> </p>
  
  <p>I have tried the following but I can't access the <code>mNumberBuffers</code> </p>
  
  <pre><code>let scope: AudioObjectPropertyScope = scope ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput
  var address: AudioObjectPropertyAddress = AudioObjectPropertyAddress(mSelector: kAudioDevicePropertyStreamConfiguration, mScope: scope, mElement: 0)
  var size: UInt32 = 0
  CheckError(
    AudioObjectGetPropertyDataSize(mID, &amp;address, 0, nil, &amp;size),
    "Couldn't get stream configuration data size."
  )
  var bufferList = UnsafeMutableRawPointer.allocate(bytes: Int(size), alignedTo: MemoryLayout&lt;AudioBufferList&gt;.alignment).assumingMemoryBound(to: AudioBufferList.self)
  CheckError(
    AudioObjectGetPropertyData(mID, &amp;address, 0, nil, &amp;size, bufferList),
    "Couldn't get device's stream configuration"
  )
  </code></pre>