Rename rotation detection method name

The old name checkRotationChanged() did not suggest that the flag was
reset.
This commit is contained in:
Romain Vimont 2018-03-01 17:14:54 +01:00
parent 38b56f552e
commit a7979e4e74

View file

@ -49,7 +49,7 @@ public class ScreenEncoder implements Device.RotationListener {
rotationChanged.set(true); rotationChanged.set(true);
} }
public boolean checkRotationChanged() { public boolean consumeRotationChange() {
return rotationChanged.getAndSet(false); return rotationChanged.getAndSet(false);
} }
@ -87,11 +87,11 @@ public class ScreenEncoder implements Device.RotationListener {
byte[] buf = new byte[bitRate / 8]; // may contain up to 1 second of video byte[] buf = new byte[bitRate / 8]; // may contain up to 1 second of video
boolean eof = false; boolean eof = false;
MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo(); MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
while (!checkRotationChanged() && !eof) { while (!consumeRotationChange() && !eof) {
int outputBufferId = codec.dequeueOutputBuffer(bufferInfo, -1); int outputBufferId = codec.dequeueOutputBuffer(bufferInfo, -1);
eof = (bufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0; eof = (bufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0;
try { try {
if (checkRotationChanged()) { if (consumeRotationChange()) {
// must restart encoding with new size // must restart encoding with new size
break; break;
} }