Skip to content

Commit 8e26ad6

Browse files
committed
fix streamblockingqueue
1 parent 913e4a7 commit 8e26ad6

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

common/src/main/java/com/pedro/common/StreamBlockingQueue.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import java.util.concurrent.PriorityBlockingQueue
55
import java.util.concurrent.atomic.AtomicBoolean
66
import kotlin.math.max
77

8-
class StreamBlockingQueue(var size: Int) {
8+
class StreamBlockingQueue(var capacity: Int) {
99

10-
private val queue = PriorityBlockingQueue<MediaFrame>(size) { p0, p1 ->
10+
private val queue = PriorityBlockingQueue<MediaFrame>(capacity) { p0, p1 ->
1111
p0.info.timestamp.compare(p1.info.timestamp)
1212
}
1313
private var cacheQueue = PriorityBlockingQueue<MediaFrame>(200) { p0, p1 ->
@@ -18,7 +18,7 @@ class StreamBlockingQueue(var size: Int) {
1818
private var startTs = 0L
1919

2020
fun trySend(item: MediaFrame): Boolean {
21-
if (queue.size >= size) return false
21+
if (queue.size >= capacity) return false
2222
if (cacheTime > 0 && !cacheTimeFilled.get()) {
2323
if (startTs == 0L) startTs = TimeUtils.getCurrentTimeMillis()
2424
val t = TimeUtils.getCurrentTimeMillis() - startTs
@@ -39,7 +39,7 @@ class StreamBlockingQueue(var size: Int) {
3939
return queue.take()
4040
}
4141

42-
fun remainingCapacity(): Int = max(0, size - queue.size)
42+
fun remainingCapacity(): Int = max(0, capacity - queue.size)
4343

4444
fun drainTo(destiny: StreamBlockingQueue) {
4545
queue.drainTo(destiny.queue)

common/src/main/java/com/pedro/common/base/BaseSender.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ abstract class BaseSender(
103103
if (newSize < queue.getSize() - queue.remainingCapacity()) {
104104
throw RuntimeException("Can't fit current cache inside new cache size")
105105
}
106-
queue.size = newSize
106+
queue.capacity = newSize
107107
}
108108

109109
fun getCacheSize(): Int = cacheSize

0 commit comments

Comments
 (0)