IdlingMediaCodecAdapterFactory


@UnstableApi
class IdlingMediaCodecAdapterFactory : MediaCodecAdapter.Factory


A MediaCodecAdapter.Factory which can idle all the async queueing and callback threads used in async MediaCodec mode.

This helps ensure that buffers are reliably queued and dequeued from MediaCodec as the playback thread advances in tests. Without this, the queueing and callback threads run freely and often make little progress before the test completes, leading to flakiness and unpredictable results.

Summary

Public constructors

Constructs an instance with no automatic idling.

Constructs an instance which automatically idles the async threads using clock.

Public functions

MediaCodecAdapter!

Creates a MediaCodecAdapter instance.

Unit

Calls idle on all created queueing and callback threads with a non-null looper.

Inherited Constants

From androidx.media3.exoplayer.mediacodec.MediaCodecAdapter.Factory
const MediaCodecAdapter.Factory!

This property is deprecated.

Use getDefault instead.

Inherited functions

From androidx.media3.exoplayer.mediacodec.MediaCodecAdapter.Factory
java-static MediaCodecAdapter.Factory!
getDefault(context: Context!)

Returns the default factory that should be used in most cases.

Public constructors

IdlingMediaCodecAdapterFactory

IdlingMediaCodecAdapterFactory(context: Context!)

Constructs an instance with no automatic idling. The async threads can be manually idled with idleQueueingAndCallbackThreads.

Parameters
context: Context!

A Context.

IdlingMediaCodecAdapterFactory

IdlingMediaCodecAdapterFactory(context: Context!, clock: Clock!)

Constructs an instance which automatically idles the async threads using clock.

The async threads can also be manually idled with idleQueueingAndCallbackThreads.

Parameters
context: Context!

A Context.

clock: Clock!

A clock to schedule the idling operations with.

Public functions

createAdapter

fun createAdapter(configuration: MediaCodecAdapter.Configuration!): MediaCodecAdapter!

Creates a MediaCodecAdapter instance.

idleQueueingAndCallbackThreads

fun idleQueueingAndCallbackThreads(): Unit

Calls idle on all created queueing and callback threads with a non-null looper.