DefaultAllocator.smali
.class public final Lcom/google/android/exoplayer2/upstream/DefaultAllocator;
.super Ljava/lang/Object;
.source "DefaultAllocator.java"
# interfaces
.implements Lcom/google/android/exoplayer2/upstream/Allocator;
# static fields
.field private static final AVAILABLE_EXTRA_CAPACITY:I = 0x64
# instance fields
.field private allocatedCount:I
.field private availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
.field private availableCount:I
.field private final individualAllocationSize:I
.field private final initialAllocationBlock:[B
.field private final singleAllocationReleaseHolder:[Lcom/google/android/exoplayer2/upstream/Allocation;
.field private targetBufferSize:I
.field private final trimOnReset:Z
# direct methods
.method public constructor <init>(ZI)V
.registers 4
const/4 v0, 0x0
.line 47
invoke-direct {p0, p1, p2, v0}, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;-><init>(ZII)V
return-void
.end method
.method public constructor <init>(ZII)V
.registers 9
.line 61
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const/4 v0, 0x0
const/4 v1, 0x1
if-lez p2, :cond_9
const/4 v2, 0x1
goto :goto_a
:cond_9
const/4 v2, 0x0
.line 62
:goto_a
invoke-static {v2}, Lcom/google/android/exoplayer2/util/Assertions;->checkArgument(Z)V
if-ltz p3, :cond_11
const/4 v2, 0x1
goto :goto_12
:cond_11
const/4 v2, 0x0
.line 63
:goto_12
invoke-static {v2}, Lcom/google/android/exoplayer2/util/Assertions;->checkArgument(Z)V
.line 64
iput-boolean p1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->trimOnReset:Z
.line 65
iput p2, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->individualAllocationSize:I
.line 66
iput p3, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
add-int/lit8 p1, p3, 0x64
.line 67
new-array p1, p1, [Lcom/google/android/exoplayer2/upstream/Allocation;
iput-object p1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
if-lez p3, :cond_3b
mul-int p1, p3, p2
.line 69
new-array p1, p1, [B
iput-object p1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->initialAllocationBlock:[B
:goto_29
if-ge v0, p3, :cond_3e
mul-int p1, v0, p2
.line 72
iget-object v2, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
new-instance v3, Lcom/google/android/exoplayer2/upstream/Allocation;
iget-object v4, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->initialAllocationBlock:[B
invoke-direct {v3, v4, p1}, Lcom/google/android/exoplayer2/upstream/Allocation;-><init>([BI)V
aput-object v3, v2, v0
add-int/lit8 v0, v0, 0x1
goto :goto_29
:cond_3b
const/4 p1, 0x0
.line 75
iput-object p1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->initialAllocationBlock:[B
:cond_3e
new-array p1, v1, [Lcom/google/android/exoplayer2/upstream/Allocation;
.line 77
iput-object p1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->singleAllocationReleaseHolder:[Lcom/google/android/exoplayer2/upstream/Allocation;
return-void
.end method
# virtual methods
.method public declared-synchronized allocate()Lcom/google/android/exoplayer2/upstream/Allocation;
.registers 5
monitor-enter p0
.line 96
:try_start_1
iget v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->allocatedCount:I
add-int/lit8 v0, v0, 0x1
iput v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->allocatedCount:I
.line 98
iget v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
if-lez v0, :cond_1b
.line 99
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
iget v1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
add-int/lit8 v1, v1, -0x1
iput v1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
aget-object v0, v0, v1
.line 100
iget-object v2, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
const/4 v3, 0x0
aput-object v3, v2, v1
goto :goto_25
.line 102
:cond_1b
new-instance v0, Lcom/google/android/exoplayer2/upstream/Allocation;
iget v1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->individualAllocationSize:I
new-array v1, v1, [B
const/4 v2, 0x0
invoke-direct {v0, v1, v2}, Lcom/google/android/exoplayer2/upstream/Allocation;-><init>([BI)V
:try_end_25
.catchall {:try_start_1 .. :try_end_25} :catchall_27
.line 104
:goto_25
monitor-exit p0
return-object v0
:catchall_27
move-exception v0
monitor-exit p0
throw v0
.end method
.method public getIndividualAllocationLength()I
.registers 2
.line 179
iget v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->individualAllocationSize:I
return v0
.end method
.method public declared-synchronized getTotalBytesAllocated()I
.registers 3
monitor-enter p0
.line 174
:try_start_1
iget v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->allocatedCount:I
iget v1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->individualAllocationSize:I
:try_end_5
.catchall {:try_start_1 .. :try_end_5} :catchall_9
mul-int v0, v0, v1
monitor-exit p0
return v0
:catchall_9
move-exception v0
monitor-exit p0
throw v0
.end method
.method public declared-synchronized release(Lcom/google/android/exoplayer2/upstream/Allocation;)V
.registers 4
monitor-enter p0
.line 109
:try_start_1
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->singleAllocationReleaseHolder:[Lcom/google/android/exoplayer2/upstream/Allocation;
const/4 v1, 0x0
aput-object p1, v0, v1
.line 110
iget-object p1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->singleAllocationReleaseHolder:[Lcom/google/android/exoplayer2/upstream/Allocation;
invoke-virtual {p0, p1}, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->release([Lcom/google/android/exoplayer2/upstream/Allocation;)V
:try_end_b
.catchall {:try_start_1 .. :try_end_b} :catchall_d
.line 111
monitor-exit p0
return-void
:catchall_d
move-exception p1
monitor-exit p0
throw p1
.end method
.method public declared-synchronized release([Lcom/google/android/exoplayer2/upstream/Allocation;)V
.registers 9
monitor-enter p0
.line 115
:try_start_1
iget v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
array-length v1, p1
add-int/2addr v0, v1
iget-object v1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
array-length v1, v1
if-lt v0, v1, :cond_21
.line 116
iget-object v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
iget-object v1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
array-length v1, v1
mul-int/lit8 v1, v1, 0x2
iget v2, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
array-length v3, p1
add-int/2addr v2, v3
.line 117
invoke-static {v1, v2}, Ljava/lang/Math;->max(II)I
move-result v1
.line 116
invoke-static {v0, v1}, Ljava/util/Arrays;->copyOf([Ljava/lang/Object;I)[Ljava/lang/Object;
move-result-object v0
check-cast v0, [Lcom/google/android/exoplayer2/upstream/Allocation;
iput-object v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
.line 119
:cond_21
array-length v0, p1
const/4 v1, 0x0
const/4 v2, 0x0
:goto_24
if-ge v2, v0, :cond_49
aget-object v3, p1, v2
.line 121
iget-object v4, v3, Lcom/google/android/exoplayer2/upstream/Allocation;->data:[B
iget-object v5, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->initialAllocationBlock:[B
if-eq v4, v5, :cond_38
iget-object v4, v3, Lcom/google/android/exoplayer2/upstream/Allocation;->data:[B
array-length v4, v4
iget v5, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->individualAllocationSize:I
if-ne v4, v5, :cond_36
goto :goto_38
:cond_36
const/4 v4, 0x0
goto :goto_39
:cond_38
:goto_38
const/4 v4, 0x1
:goto_39
invoke-static {v4}, Lcom/google/android/exoplayer2/util/Assertions;->checkArgument(Z)V
.line 123
iget-object v4, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
iget v5, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
add-int/lit8 v6, v5, 0x1
iput v6, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
aput-object v3, v4, v5
add-int/lit8 v2, v2, 0x1
goto :goto_24
.line 125
:cond_49
iget v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->allocatedCount:I
array-length p1, p1
sub-int/2addr v0, p1
iput v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->allocatedCount:I
.line 127
invoke-virtual {p0}, Ljava/lang/Object;->notifyAll()V
:try_end_52
.catchall {:try_start_1 .. :try_end_52} :catchall_54
.line 128
monitor-exit p0
return-void
:catchall_54
move-exception p1
monitor-exit p0
throw p1
.end method
.method public declared-synchronized reset()V
.registers 2
monitor-enter p0
.line 81
:try_start_1
iget-boolean v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->trimOnReset:Z
if-eqz v0, :cond_9
const/4 v0, 0x0
.line 82
invoke-virtual {p0, v0}, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->setTargetBufferSize(I)V
:try_end_9
.catchall {:try_start_1 .. :try_end_9} :catchall_b
.line 84
:cond_9
monitor-exit p0
return-void
:catchall_b
move-exception v0
monitor-exit p0
throw v0
.end method
.method public declared-synchronized setTargetBufferSize(I)V
.registers 3
monitor-enter p0
.line 87
:try_start_1
iget v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->targetBufferSize:I
if-ge p1, v0, :cond_7
const/4 v0, 0x1
goto :goto_8
:cond_7
const/4 v0, 0x0
.line 88
:goto_8
iput p1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->targetBufferSize:I
if-eqz v0, :cond_f
.line 90
invoke-virtual {p0}, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->trim()V
:try_end_f
.catchall {:try_start_1 .. :try_end_f} :catchall_11
.line 92
:cond_f
monitor-exit p0
return-void
:catchall_11
move-exception p1
monitor-exit p0
throw p1
.end method
.method public declared-synchronized trim()V
.registers 8
monitor-enter p0
.line 132
:try_start_1
iget v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->targetBufferSize:I
iget v1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->individualAllocationSize:I
invoke-static {v0, v1}, Lcom/google/android/exoplayer2/util/Util;->ceilDivide(II)I
move-result v0
.line 133
iget v1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->allocatedCount:I
sub-int/2addr v0, v1
const/4 v1, 0x0
invoke-static {v1, v0}, Ljava/lang/Math;->max(II)I
move-result v0
.line 134
iget v2, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
:try_end_13
.catchall {:try_start_1 .. :try_end_13} :catchall_60
if-lt v0, v2, :cond_17
.line 136
monitor-exit p0
return-void
.line 139
:cond_17
:try_start_17
iget-object v2, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->initialAllocationBlock:[B
if-eqz v2, :cond_54
.line 144
iget v2, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
add-int/lit8 v2, v2, -0x1
:goto_1f
if-gt v1, v2, :cond_4a
.line 146
iget-object v3, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
aget-object v3, v3, v1
.line 147
iget-object v4, v3, Lcom/google/android/exoplayer2/upstream/Allocation;->data:[B
iget-object v5, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->initialAllocationBlock:[B
if-ne v4, v5, :cond_2e
add-int/lit8 v1, v1, 0x1
goto :goto_1f
.line 150
:cond_2e
iget-object v4, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
aget-object v4, v4, v2
.line 151
iget-object v5, v4, Lcom/google/android/exoplayer2/upstream/Allocation;->data:[B
iget-object v6, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->initialAllocationBlock:[B
if-eq v5, v6, :cond_3b
add-int/lit8 v2, v2, -0x1
goto :goto_1f
.line 154
:cond_3b
iget-object v5, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
add-int/lit8 v6, v1, 0x1
aput-object v4, v5, v1
.line 155
iget-object v1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
add-int/lit8 v4, v2, -0x1
aput-object v3, v1, v2
move v2, v4
move v1, v6
goto :goto_1f
.line 160
:cond_4a
invoke-static {v0, v1}, Ljava/lang/Math;->max(II)I
move-result v0
.line 161
iget v1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
:try_end_50
.catchall {:try_start_17 .. :try_end_50} :catchall_60
if-lt v0, v1, :cond_54
.line 163
monitor-exit p0
return-void
.line 168
:cond_54
:try_start_54
iget-object v1, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableAllocations:[Lcom/google/android/exoplayer2/upstream/Allocation;
iget v2, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
const/4 v3, 0x0
invoke-static {v1, v0, v2, v3}, Ljava/util/Arrays;->fill([Ljava/lang/Object;IILjava/lang/Object;)V
.line 169
iput v0, p0, Lcom/google/android/exoplayer2/upstream/DefaultAllocator;->availableCount:I
:try_end_5e
.catchall {:try_start_54 .. :try_end_5e} :catchall_60
.line 170
monitor-exit p0
return-void
:catchall_60
move-exception v0
monitor-exit p0
throw v0
.end method