Skip to content

Commit

Permalink
Backed out 2 changesets (bug 1552607) for causing checkstyle failures…
Browse files Browse the repository at this point in the history
…. CLOSED TREE

Backed out changeset 53a39e402451 (bug 1552607)
Backed out changeset 6385b8616d54 (bug 1552607)
  • Loading branch information
Mihai Alexandru Michis committed Jul 2, 2019
1 parent 1cdfbb2 commit 4c80736
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 38 deletions.
14 changes: 5 additions & 9 deletions dom/media/platforms/android/RemoteDataDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,16 +437,15 @@ class RemoteAudioDecoder : public RemoteDataDecoder {
return mFirstDemuxedSampleTime->ToMicroseconds() > aTime;
}

bool ShouldDiscardSample(int64_t aSession) const {
bool ShouldDiscardSample() const {
AssertOnTaskQueue();
// HandleOutput() runs on Android binder thread pool and could be preempted
// by RemoteDateDecoder task queue. That means ProcessOutput() could be
// scheduled after ProcessShutdown() or ProcessFlush(). We won't need the
// sample which is returned after calling Shutdown() and Flush(). We can
// check mFirstDemuxedSampleTime to know whether the Flush() has been
// called, becasue it would be reset in Flush().
return GetState() == State::SHUTDOWN || !mFirstDemuxedSampleTime ||
mSession != aSession;
return GetState() == State::SHUTDOWN || !mFirstDemuxedSampleTime;
}

// Param and LocalRef are only valid for the duration of a JNI method call.
Expand All @@ -467,7 +466,7 @@ class RemoteAudioDecoder : public RemoteDataDecoder {

AssertOnTaskQueue();

if (ShouldDiscardSample(aSample->Session()) || !aBuffer->IsValid()) {
if (ShouldDiscardSample() || !aBuffer->IsValid()) {
aSample->Dispose();
return;
}
Expand Down Expand Up @@ -591,7 +590,6 @@ RemoteDataDecoder::RemoteDataDecoder(MediaData::Type aType,
mFormat(aFormat),
mDrmStubId(aDrmStubId),
mTaskQueue(aTaskQueue),
mSession(0),
mNumPendingInputs(0) {}

RefPtr<MediaDataDecoder::FlushPromise> RemoteDataDecoder::Flush() {
Expand All @@ -608,7 +606,6 @@ RefPtr<MediaDataDecoder::FlushPromise> RemoteDataDecoder::ProcessFlush() {
mDecodePromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
mDrainPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
SetState(State::DRAINED);
mSession++;
mJavaDecoder->Flush();
return FlushPromise::CreateAndResolve(true, __func__);
}
Expand Down Expand Up @@ -636,7 +633,7 @@ RefPtr<MediaDataDecoder::DecodePromise> RemoteDataDecoder::Drain() {
SetState(State::DRAINING);
self->mInputBufferInfo->Set(0, 0, -1,
MediaCodec::BUFFER_FLAG_END_OF_STREAM);
mJavaDecoder->Input(nullptr, self->mInputBufferInfo, nullptr, mSession);
mJavaDecoder->Input(nullptr, self->mInputBufferInfo, nullptr);
return p;
});
}
Expand Down Expand Up @@ -743,7 +740,7 @@ RefPtr<MediaDataDecoder::DecodePromise> RemoteDataDecoder::ProcessDecode(
SetState(State::DRAINABLE);
mInputBufferInfo->Set(0, aSample->Size(), aSample->mTime.ToMicroseconds(), 0);
return mJavaDecoder->Input(bytes, mInputBufferInfo,
GetCryptoInfoFromSample(aSample), mSession)
GetCryptoInfoFromSample(aSample))
? mDecodePromise.Ensure(__func__)
: DecodePromise::CreateAndReject(
MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__), __func__);
Expand Down Expand Up @@ -831,7 +828,6 @@ void RemoteDataDecoder::DrainComplete() {
}
SetState(State::DRAINED);
ReturnDecodedData();
mSession++;
// Make decoder accept input again.
mJavaDecoder->Flush();
}
Expand Down
4 changes: 0 additions & 4 deletions dom/media/platforms/android/RemoteDataDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ class RemoteDataDecoder : public MediaDataDecoder,
// information. Contents must be changed only on mTaskQueue.
java::sdk::BufferInfo::GlobalRef mInputBufferInfo;

// Session ID attached to samples. It's increased every time
// CodecProxy::Flush() is called. Accessed on mTaskqueue only.
int64_t mSession;

private:
enum class PendingOp { INCREASE, DECREASE, CLEAR };
void UpdatePendingInputStatus(PendingOp aOp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ int32_t WebrtcMediaCodecVP8VideoRemoteEncoder::Encode(
bufferInfo->Set(0, size, inputImage.render_time_ms() * PR_USEC_PER_MSEC, 0);
}

mJavaEncoder->Input(bytes, bufferInfo, nullptr, 0);
mJavaEncoder->Input(bytes, bufferInfo, nullptr);

return WEBRTC_VIDEO_CODEC_OK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ private final class InputProcessor {
private Queue<Sample> mDequeuedSamples = new LinkedList<>();
private Queue<Input> mInputSamples = new LinkedList<>();
private boolean mStopped;
private long mSession;

private synchronized Sample onAllocate(final int size) {
Sample sample = mSamplePool.obtainInput(size);
Expand All @@ -90,12 +89,10 @@ private synchronized void onSample(final Sample sample) {
return;
}

if (sample.session >= mSession) {
Sample dequeued = mDequeuedSamples.remove();
dequeued.setBufferInfo(sample.info);
dequeued.setCryptoInfo(sample.cryptoInfo);
queueSample(dequeued);
}
Sample dequeued = mDequeuedSamples.remove();
dequeued.setBufferInfo(sample.info);
dequeued.setCryptoInfo(sample.cryptoInfo);
queueSample(dequeued);

sample.dispose();
}
Expand Down Expand Up @@ -148,9 +145,6 @@ private boolean isValidBuffer(final int index) {
private void feedSampleToBuffer() {
while (!mAvailableInputBuffers.isEmpty() && !mInputSamples.isEmpty()) {
int index = mAvailableInputBuffers.poll();
if (!isValidBuffer(index)) {
continue;
}
int len = 0;
final Sample sample = mInputSamples.poll().sample;
long pts = sample.info.presentationTimeUs;
Expand Down Expand Up @@ -213,7 +207,6 @@ private synchronized void reset() {
mDequeuedSamples.clear();

mAvailableInputBuffers.clear();
mSession++;
}

private synchronized void start() {
Expand Down Expand Up @@ -247,7 +240,6 @@ private class OutputProcessor {
private boolean mHasOutputCapacitySet;
private Queue<Output> mSentOutputs = new LinkedList<>();
private boolean mStopped;
private long mSession;

private OutputProcessor(final boolean renderToSurface) {
mRenderToSurface = renderToSurface;
Expand All @@ -261,7 +253,6 @@ private synchronized void onBuffer(final int index, final MediaCodec.BufferInfo
try {
Sample output = obtainOutputSample(index, info);
mSentOutputs.add(new Output(output, index));
output.session = mSession;
mCallbacks.onOutput(output);
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -341,7 +332,6 @@ private synchronized void reset() {
mSamplePool.recycleOutput(o.sample);
}
mSentOutputs.clear();
mSession++;
}

private synchronized void start() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public synchronized boolean isTunneledPlaybackSupported() {

@WrapForJNI
public synchronized boolean input(final ByteBuffer bytes, final BufferInfo info,
final CryptoInfo cryptoInfo, final long session) {
final CryptoInfo cryptoInfo) {
if (mRemote == null) {
Log.e(LOGTAG, "cannot send input to an ended codec");
return false;
Expand All @@ -239,7 +239,7 @@ public synchronized boolean input(final ByteBuffer bytes, final BufferInfo info,
try {
Sample s = mRemote.dequeueInput(info.size);
fillInputBuffer(s.bufferId, bytes, info.offset, info.size);
return sendInput(s.set(info, cryptoInfo, session));
return sendInput(s.set(info, cryptoInfo));
} catch (RemoteException | NullPointerException e) {
Log.e(LOGTAG, "fail to dequeue input buffer", e);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public final class Sample implements Parcelable {
EOS = new Sample();
EOS.info.set(0, 0, Long.MIN_VALUE, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
}
@WrapForJNI
public long session;

public static final int NO_BUFFER = -1;

Expand Down Expand Up @@ -73,10 +71,9 @@ private void readCrypto(final Parcel in) {
mode);
}

public Sample set(final BufferInfo info, final CryptoInfo cryptoInfo, long session) {
public Sample set(final BufferInfo info, final CryptoInfo cryptoInfo) {
setBufferInfo(info);
setCryptoInfo(cryptoInfo);
this.session = session;
return this;
}

Expand Down Expand Up @@ -147,7 +144,6 @@ private synchronized Sample obtainSample(final Parcel in) {
} else {
s = new Sample();
}
s.session = in.readLong();
s.bufferId = in.readInt();
s.readInfo(in);
s.readCrypto(in);
Expand All @@ -162,7 +158,6 @@ public int describeContents() {

@Override
public void writeToParcel(final Parcel dest, final int parcelableFlags) {
dest.writeLong(session);
dest.writeInt(bufferId);
writeInfo(dest);
writeCrypto(dest);
Expand Down Expand Up @@ -211,8 +206,7 @@ public String toString() {
}

StringBuilder str = new StringBuilder();
str.append("{ session#:").append(session).
append(", buffer#").append(bufferId).
str.append("{ buffer#").append(bufferId).
append(", info=").
append("{ offset=").append(info.offset).
append(", size=").append(info.size).
Expand Down

0 comments on commit 4c80736

Please sign in to comment.