330 lines
10 KiB
Smali
330 lines
10 KiB
Smali
.class public Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;
|
|
.super Ljava/lang/Thread;
|
|
.source "WebRtcAudioTrack.java"
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/EnclosingClass;
|
|
value = Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
.end annotation
|
|
|
|
.annotation system Ldalvik/annotation/InnerClass;
|
|
accessFlags = 0x1
|
|
name = "AudioTrackThread"
|
|
.end annotation
|
|
|
|
|
|
# instance fields
|
|
.field public volatile keepAlive:Z
|
|
|
|
.field public final synthetic this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Lorg/webrtc/audio/WebRtcAudioTrack;Ljava/lang/String;)V
|
|
.locals 0
|
|
|
|
iput-object p1, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-direct {p0, p2}, Ljava/lang/Thread;-><init>(Ljava/lang/String;)V
|
|
|
|
const/4 p1, 0x1
|
|
|
|
iput-boolean p1, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->keepAlive:Z
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private writeBytes(Landroid/media/AudioTrack;Ljava/nio/ByteBuffer;I)I
|
|
.locals 1
|
|
|
|
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
|
|
|
|
const/4 v0, 0x0
|
|
|
|
invoke-virtual {p1, p2, p3, v0}, Landroid/media/AudioTrack;->write(Ljava/nio/ByteBuffer;II)I
|
|
|
|
move-result p1
|
|
|
|
return p1
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public run()V
|
|
.locals 7
|
|
|
|
const/16 v0, -0x13
|
|
|
|
invoke-static {v0}, Landroid/os/Process;->setThreadPriority(I)V
|
|
|
|
new-instance v0, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v1, "AudioTrackThread"
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-static {}, Lorg/webrtc/audio/WebRtcAudioUtils;->getThreadInfo()Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "WebRtcAudioTrackExternal"
|
|
|
|
invoke-static {v1, v0}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
iget-object v0, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v0}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$000(Lorg/webrtc/audio/WebRtcAudioTrack;)Landroid/media/AudioTrack;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Landroid/media/AudioTrack;->getPlayState()I
|
|
|
|
move-result v0
|
|
|
|
const/4 v2, 0x0
|
|
|
|
const/4 v3, 0x3
|
|
|
|
if-ne v0, v3, :cond_0
|
|
|
|
const/4 v0, 0x1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
const/4 v0, 0x0
|
|
|
|
:goto_0
|
|
invoke-static {v0}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$100(Z)V
|
|
|
|
iget-object v0, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v0}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$200(Lorg/webrtc/audio/WebRtcAudioTrack;)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Ljava/nio/ByteBuffer;->capacity()I
|
|
|
|
move-result v0
|
|
|
|
:goto_1
|
|
iget-boolean v3, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->keepAlive:Z
|
|
|
|
if-eqz v3, :cond_4
|
|
|
|
iget-object v3, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v3}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$300(Lorg/webrtc/audio/WebRtcAudioTrack;)J
|
|
|
|
move-result-wide v3
|
|
|
|
invoke-static {v3, v4, v0}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$400(JI)V
|
|
|
|
iget-object v3, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v3}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$200(Lorg/webrtc/audio/WebRtcAudioTrack;)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-virtual {v3}, Ljava/nio/ByteBuffer;->remaining()I
|
|
|
|
move-result v3
|
|
|
|
if-gt v0, v3, :cond_1
|
|
|
|
const/4 v3, 0x1
|
|
|
|
goto :goto_2
|
|
|
|
:cond_1
|
|
const/4 v3, 0x0
|
|
|
|
:goto_2
|
|
invoke-static {v3}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$100(Z)V
|
|
|
|
iget-object v3, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v3}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$500(Lorg/webrtc/audio/WebRtcAudioTrack;)Z
|
|
|
|
move-result v3
|
|
|
|
if-eqz v3, :cond_2
|
|
|
|
iget-object v3, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v3}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$200(Lorg/webrtc/audio/WebRtcAudioTrack;)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-virtual {v3}, Ljava/nio/ByteBuffer;->clear()Ljava/nio/Buffer;
|
|
|
|
iget-object v3, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v3}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$200(Lorg/webrtc/audio/WebRtcAudioTrack;)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object v3
|
|
|
|
iget-object v4, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v4}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$600(Lorg/webrtc/audio/WebRtcAudioTrack;)[B
|
|
|
|
move-result-object v4
|
|
|
|
invoke-virtual {v3, v4}, Ljava/nio/ByteBuffer;->put([B)Ljava/nio/ByteBuffer;
|
|
|
|
iget-object v3, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v3}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$200(Lorg/webrtc/audio/WebRtcAudioTrack;)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-virtual {v3, v2}, Ljava/nio/ByteBuffer;->position(I)Ljava/nio/Buffer;
|
|
|
|
:cond_2
|
|
iget-object v3, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v3}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$000(Lorg/webrtc/audio/WebRtcAudioTrack;)Landroid/media/AudioTrack;
|
|
|
|
move-result-object v3
|
|
|
|
iget-object v4, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v4}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$200(Lorg/webrtc/audio/WebRtcAudioTrack;)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object v4
|
|
|
|
invoke-direct {p0, v3, v4, v0}, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->writeBytes(Landroid/media/AudioTrack;Ljava/nio/ByteBuffer;I)I
|
|
|
|
move-result v3
|
|
|
|
if-eq v3, v0, :cond_3
|
|
|
|
new-instance v4, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v5, "AudioTrack.write played invalid number of bytes: "
|
|
|
|
invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v4, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v4
|
|
|
|
invoke-static {v1, v4}, Lorg/webrtc/Logging;->e(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
if-gez v3, :cond_3
|
|
|
|
iput-boolean v2, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->keepAlive:Z
|
|
|
|
iget-object v4, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
new-instance v5, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v6, "AudioTrack.write failed: "
|
|
|
|
invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v5, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-static {v4, v3}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$700(Lorg/webrtc/audio/WebRtcAudioTrack;Ljava/lang/String;)V
|
|
|
|
:cond_3
|
|
iget-object v3, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v3}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$200(Lorg/webrtc/audio/WebRtcAudioTrack;)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-virtual {v3}, Ljava/nio/ByteBuffer;->rewind()Ljava/nio/Buffer;
|
|
|
|
goto/16 :goto_1
|
|
|
|
:cond_4
|
|
iget-object v0, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v0}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$000(Lorg/webrtc/audio/WebRtcAudioTrack;)Landroid/media/AudioTrack;
|
|
|
|
move-result-object v0
|
|
|
|
if-eqz v0, :cond_5
|
|
|
|
const-string v0, "Calling AudioTrack.stop..."
|
|
|
|
invoke-static {v1, v0}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
:try_start_0
|
|
iget-object v0, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->this$0:Lorg/webrtc/audio/WebRtcAudioTrack;
|
|
|
|
invoke-static {v0}, Lorg/webrtc/audio/WebRtcAudioTrack;->access$000(Lorg/webrtc/audio/WebRtcAudioTrack;)Landroid/media/AudioTrack;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Landroid/media/AudioTrack;->stop()V
|
|
|
|
const-string v0, "AudioTrack.stop is done."
|
|
|
|
invoke-static {v1, v0}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
:try_end_0
|
|
.catch Ljava/lang/IllegalStateException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
goto :goto_3
|
|
|
|
:catch_0
|
|
move-exception v0
|
|
|
|
const-string v2, "AudioTrack.stop failed: "
|
|
|
|
invoke-static {v2}, Lf/e/b/a/a;->a(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
move-result-object v2
|
|
|
|
invoke-virtual {v0}, Ljava/lang/IllegalStateException;->getMessage()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-static {v1, v0}, Lorg/webrtc/Logging;->e(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
:cond_5
|
|
:goto_3
|
|
return-void
|
|
.end method
|
|
|
|
.method public stopThread()V
|
|
.locals 2
|
|
|
|
const-string v0, "WebRtcAudioTrackExternal"
|
|
|
|
const-string v1, "stopThread"
|
|
|
|
invoke-static {v0, v1}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
const/4 v0, 0x0
|
|
|
|
iput-boolean v0, p0, Lorg/webrtc/audio/WebRtcAudioTrack$AudioTrackThread;->keepAlive:Z
|
|
|
|
return-void
|
|
.end method
|