# ByteBufferAllocator

# ByteBufferAllocator

Artifact:[androidx.media3:media3-muxer](https://developer.android.com/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/muxer/ByteBufferAllocator.java+class:androidx.media3.muxer.ByteBufferAllocator)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/muxer/ByteBufferAllocator "View this page in Java")

<br />

```
@UnstableApi
interface ByteBufferAllocator
```

<br />

*** ** * ** ***

A memory allocator for[ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html).

## Summary

|                                                       ### Constants                                                        |
|----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| `const `[ByteBufferAllocator](https://developer.android.com/reference/kotlin/androidx/media3/muxer/ByteBufferAllocator)`!` | [DEFAULT](https://developer.android.com/reference/kotlin/androidx/media3/muxer/ByteBufferAllocator#DEFAULT()) Default implementation. |

|                               ### Public functions                                |
|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html)`!` | [allocate](https://developer.android.com/reference/kotlin/androidx/media3/muxer/ByteBufferAllocator#allocate(int))`(capacity: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Allocates and returns a new[ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html). |

## Constants

### DEFAULT

```
const val DEFAULT: ByteBufferAllocator!
```

Default implementation.  

## Public functions

### allocate

```
fun allocate(capacity: Int): ByteBuffer!
```

Allocates and returns a new[ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html).  

|                                       Parameters                                        |
|-----------------------------------------------------------------------------------------|--------------------------------------|
| `capacity: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The new buffer's capacity, in bytes. |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|----------------------------------------|
| [java.lang.IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | If the`capacity`is a negative integer. |