<!--
{
  "availability" : [
    "iOS: 8.0.0 - 18.0.0",
    "iPadOS: 8.0.0 - 18.0.0",
    "macCatalyst: 13.1.0 - 18.0.0",
    "macOS: 10.8.0 - 15.0.0",
    "tvOS: 10.2.0 - 18.0.0",
    "visionOS: 1.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVSampleBufferDisplayLayer/requestMediaDataWhenReady(on:using:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVSampleBufferDisplayLayer(im)requestMediaDataWhenReadyOnQueue:usingBlock:"
  },
  "title" : "requestMediaDataWhenReady(on:using:)"
}
-->

# requestMediaDataWhenReady(on:using:)

Instructs the target to invoke a client-supplied block repeatedly, at its convenience, in order to gather sample buffers for display.

```
func requestMediaDataWhenReady(on queue: dispatch_queue_t, using block: @escaping @Sendable () -> Void)
```

## Parameters

`queue`

The dispatch queue.

`block`

The block that provides media data.

## Discussion

Apple discourages the use of this symbol in iOS 17, tvOS 17, and macOS 14 and later. Use [`requestMediaDataWhenReady(on:using:)`](/documentation/AVFoundation/AVQueuedSampleBufferRendering/requestMediaDataWhenReady(on:using:)) on the [`sampleBufferRenderer`](/documentation/AVFoundation/AVSampleBufferDisplayLayer/sampleBufferRenderer) instead.

The block is expected to call the [`enqueue(_:)`](/documentation/AVFoundation/AVSampleBufferDisplayLayer/enqueue(_:)) in order to provide media data for decompression (if necessary) and rendering while the [`isReadyForMoreMediaData`](/documentation/AVFoundation/AVSampleBufferDisplayLayer/isReadyForMoreMediaData) property remains <doc://com.apple.documentation/documentation/Swift/true>, or until it can provide no additional media. When the layer has decoded enough media data that it is ready for additional media data, it will invoke the block again.

By allowing the display layer to determine when to invoke the block, the implementation of incremental I/O operations is simplified when supplying synchronized media data during rendering.

If this function is called multiple times, only the last call is effective.

You invoke the [`stopRequestingMediaData()`](/documentation/AVFoundation/AVSampleBufferDisplayLayer/stopRequestingMediaData()) method to cancel this request.

Each call to `requestMediaDataWhenReadyOnQueue:usingBlock:` must be balanced with a corresponding call to [`stopRequestingMediaData()`](/documentation/AVFoundation/AVSampleBufferDisplayLayer/stopRequestingMediaData()).

Releasing the receiver instance without a call to [`stopRequestingMediaData()`](/documentation/AVFoundation/AVSampleBufferDisplayLayer/stopRequestingMediaData()) will result in undefined behavior.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)