aacdecoder-android-0.8读取时发生异常

时间:2018-08-24 00:03:25

标签: android audio-streaming aac

我在使用Android 8的设备上使用aacdecoder库时遇到问题。在屏幕锁定后几分钟(大约4或5分钟的播放停止)后,它可以正常工作。

Android Studio控制台引发的错误如下: E / BufferReader:读取时发生异常:java.net.SocketException:软件导致连接中止

据我所见,问题出在这部分代码的BufferReader.class文件中:

public void run() {
    Log.d(LOG, "run() started....");
    int cap = this.capacity;
    boolean var2 = false;

    while(!this.stopped) {
        BufferReader.Buffer buffer = this.buffers[this.indexMine];
        int total = 0;
        if (cap != buffer.data.length) {
            Log.d(LOG, "run() capacity changed: " + buffer.data.length + " -> " + cap);
            buffer = null;
            this.buffers[this.indexMine] = null;
            this.buffers[this.indexMine] = buffer = new BufferReader.Buffer(cap);
        }

        while(!this.stopped && total < cap) {
            try {
                int n = this.is.read(buffer.data, total, cap - total);
                if (n == -1) {
                    this.stopped = true;
                } else {
                    total += n;
                }
            } catch (IOException var8) {
                Log.e(LOG, "Exception when reading: " + var8);
                this.stopped = true;
            }
        }

        buffer.size = total;
        synchronized(this) {
            this.notify();
            int indexNew = (this.indexMine + 1) % this.buffers.length;

            while(!this.stopped && indexNew == this.indexBlocked) {
                try {
                    this.wait();
                } catch (InterruptedException var9) {
                    ;
                }
            }

            this.indexMine = indexNew;
            cap = this.capacity;
        }
    }

    Log.d(LOG, "run() stopped.");
}

到目前为止,我还无法找到解决方案,感谢您的帮助,感谢您的宝贵时间!

0 个答案:

没有答案